Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372
  1. 'use strict';
  2. var fs$6 = require('fs');
  3. var path$4 = require('path');
  4. var os$2 = require('os');
  5. var tty$2 = require('tty');
  6. var assert$2 = require('assert');
  7. var util$6 = require('util');
  8. var stream_1 = require('stream');
  9. var events_1 = require('events');
  10. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  11. var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$6);
  12. var path__default = /*#__PURE__*/_interopDefaultLegacy(path$4);
  13. var os__default = /*#__PURE__*/_interopDefaultLegacy(os$2);
  14. var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty$2);
  15. var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$2);
  16. var util__default = /*#__PURE__*/_interopDefaultLegacy(util$6);
  17. var stream_1__default = /*#__PURE__*/_interopDefaultLegacy(stream_1);
  18. var events_1__default = /*#__PURE__*/_interopDefaultLegacy(events_1);
  19. var require$$0$9 = require("./package.json");
  20. function getDefaultExportFromNamespaceIfPresent (n) {
  21. return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
  22. }
  23. function createCommonjsModule(fn) {
  24. var module = { exports: {} };
  25. return fn(module, module.exports), module.exports;
  26. }
  27. /*istanbul ignore start*/
  28. var base$1 = createCommonjsModule(function (module, exports) {
  29. Object.defineProperty(exports, "__esModule", {
  30. value: true
  31. });
  32. exports["default"] = Diff;
  33. /*istanbul ignore end*/
  34. function Diff() {}
  35. Diff.prototype = {
  36. /*istanbul ignore start*/
  37. /*istanbul ignore end*/
  38. diff: function diff(oldString, newString) {
  39. /*istanbul ignore start*/
  40. var
  41. /*istanbul ignore end*/
  42. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  43. var callback = options.callback;
  44. if (typeof options === 'function') {
  45. callback = options;
  46. options = {};
  47. }
  48. this.options = options;
  49. var self = this;
  50. function done(value) {
  51. if (callback) {
  52. setTimeout(function () {
  53. callback(undefined, value);
  54. }, 0);
  55. return true;
  56. } else {
  57. return value;
  58. }
  59. } // Allow subclasses to massage the input prior to running
  60. oldString = this.castInput(oldString);
  61. newString = this.castInput(newString);
  62. oldString = this.removeEmpty(this.tokenize(oldString));
  63. newString = this.removeEmpty(this.tokenize(newString));
  64. var newLen = newString.length,
  65. oldLen = oldString.length;
  66. var editLength = 1;
  67. var maxEditLength = newLen + oldLen;
  68. var bestPath = [{
  69. newPos: -1,
  70. components: []
  71. }]; // Seed editLength = 0, i.e. the content starts with the same values
  72. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  73. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  74. // Identity per the equality and tokenizer
  75. return done([{
  76. value: this.join(newString),
  77. count: newString.length
  78. }]);
  79. } // Main worker method. checks all permutations of a given edit length for acceptance.
  80. function execEditLength() {
  81. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  82. var basePath =
  83. /*istanbul ignore start*/
  84. void 0
  85. /*istanbul ignore end*/
  86. ;
  87. var addPath = bestPath[diagonalPath - 1],
  88. removePath = bestPath[diagonalPath + 1],
  89. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  90. if (addPath) {
  91. // No one else is going to attempt to use this value, clear it
  92. bestPath[diagonalPath - 1] = undefined;
  93. }
  94. var canAdd = addPath && addPath.newPos + 1 < newLen,
  95. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  96. if (!canAdd && !canRemove) {
  97. // If this path is a terminal then prune
  98. bestPath[diagonalPath] = undefined;
  99. continue;
  100. } // Select the diagonal that we want to branch from. We select the prior
  101. // path whose position in the new string is the farthest from the origin
  102. // and does not pass the bounds of the diff graph
  103. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  104. basePath = clonePath(removePath);
  105. self.pushComponent(basePath.components, undefined, true);
  106. } else {
  107. basePath = addPath; // No need to clone, we've pulled it from the list
  108. basePath.newPos++;
  109. self.pushComponent(basePath.components, true, undefined);
  110. }
  111. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  112. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  113. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  114. } else {
  115. // Otherwise track this path as a potential candidate and continue.
  116. bestPath[diagonalPath] = basePath;
  117. }
  118. }
  119. editLength++;
  120. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  121. // sync and async mode which is never fun. Loops over execEditLength until a value
  122. // is produced.
  123. if (callback) {
  124. (function exec() {
  125. setTimeout(function () {
  126. // This should not happen, but we want to be safe.
  127. /* istanbul ignore next */
  128. if (editLength > maxEditLength) {
  129. return callback();
  130. }
  131. if (!execEditLength()) {
  132. exec();
  133. }
  134. }, 0);
  135. })();
  136. } else {
  137. while (editLength <= maxEditLength) {
  138. var ret = execEditLength();
  139. if (ret) {
  140. return ret;
  141. }
  142. }
  143. }
  144. },
  145. /*istanbul ignore start*/
  146. /*istanbul ignore end*/
  147. pushComponent: function pushComponent(components, added, removed) {
  148. var last = components[components.length - 1];
  149. if (last && last.added === added && last.removed === removed) {
  150. // We need to clone here as the component clone operation is just
  151. // as shallow array clone
  152. components[components.length - 1] = {
  153. count: last.count + 1,
  154. added: added,
  155. removed: removed
  156. };
  157. } else {
  158. components.push({
  159. count: 1,
  160. added: added,
  161. removed: removed
  162. });
  163. }
  164. },
  165. /*istanbul ignore start*/
  166. /*istanbul ignore end*/
  167. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  168. var newLen = newString.length,
  169. oldLen = oldString.length,
  170. newPos = basePath.newPos,
  171. oldPos = newPos - diagonalPath,
  172. commonCount = 0;
  173. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  174. newPos++;
  175. oldPos++;
  176. commonCount++;
  177. }
  178. if (commonCount) {
  179. basePath.components.push({
  180. count: commonCount
  181. });
  182. }
  183. basePath.newPos = newPos;
  184. return oldPos;
  185. },
  186. /*istanbul ignore start*/
  187. /*istanbul ignore end*/
  188. equals: function equals(left, right) {
  189. if (this.options.comparator) {
  190. return this.options.comparator(left, right);
  191. } else {
  192. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  193. }
  194. },
  195. /*istanbul ignore start*/
  196. /*istanbul ignore end*/
  197. removeEmpty: function removeEmpty(array) {
  198. var ret = [];
  199. for (var i = 0; i < array.length; i++) {
  200. if (array[i]) {
  201. ret.push(array[i]);
  202. }
  203. }
  204. return ret;
  205. },
  206. /*istanbul ignore start*/
  207. /*istanbul ignore end*/
  208. castInput: function castInput(value) {
  209. return value;
  210. },
  211. /*istanbul ignore start*/
  212. /*istanbul ignore end*/
  213. tokenize: function tokenize(value) {
  214. return value.split('');
  215. },
  216. /*istanbul ignore start*/
  217. /*istanbul ignore end*/
  218. join: function join(chars) {
  219. return chars.join('');
  220. }
  221. };
  222. function buildValues(diff, components, newString, oldString, useLongestToken) {
  223. var componentPos = 0,
  224. componentLen = components.length,
  225. newPos = 0,
  226. oldPos = 0;
  227. for (; componentPos < componentLen; componentPos++) {
  228. var component = components[componentPos];
  229. if (!component.removed) {
  230. if (!component.added && useLongestToken) {
  231. var value = newString.slice(newPos, newPos + component.count);
  232. value = value.map(function (value, i) {
  233. var oldValue = oldString[oldPos + i];
  234. return oldValue.length > value.length ? oldValue : value;
  235. });
  236. component.value = diff.join(value);
  237. } else {
  238. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  239. }
  240. newPos += component.count; // Common case
  241. if (!component.added) {
  242. oldPos += component.count;
  243. }
  244. } else {
  245. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  246. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  247. // The diffing algorithm is tied to add then remove output and this is the simplest
  248. // route to get the desired output with minimal overhead.
  249. if (componentPos && components[componentPos - 1].added) {
  250. var tmp = components[componentPos - 1];
  251. components[componentPos - 1] = components[componentPos];
  252. components[componentPos] = tmp;
  253. }
  254. }
  255. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  256. // For this case we merge the terminal into the prior string and drop the change.
  257. // This is only available for string mode.
  258. var lastComponent = components[componentLen - 1];
  259. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  260. components[componentLen - 2].value += lastComponent.value;
  261. components.pop();
  262. }
  263. return components;
  264. }
  265. function clonePath(path) {
  266. return {
  267. newPos: path.newPos,
  268. components: path.components.slice(0)
  269. };
  270. }
  271. });
  272. /*istanbul ignore start*/
  273. var character = createCommonjsModule(function (module, exports) {
  274. Object.defineProperty(exports, "__esModule", {
  275. value: true
  276. });
  277. exports.diffChars = diffChars;
  278. exports.characterDiff = void 0;
  279. /*istanbul ignore end*/
  280. var
  281. /*istanbul ignore start*/
  282. _base = _interopRequireDefault(base$1)
  283. /*istanbul ignore end*/
  284. ;
  285. /*istanbul ignore start*/
  286. function _interopRequireDefault(obj) {
  287. return obj && obj.__esModule ? obj : {
  288. "default": obj
  289. };
  290. }
  291. /*istanbul ignore end*/
  292. var characterDiff = new
  293. /*istanbul ignore start*/
  294. _base
  295. /*istanbul ignore end*/
  296. [
  297. /*istanbul ignore start*/
  298. "default"
  299. /*istanbul ignore end*/
  300. ]();
  301. /*istanbul ignore start*/
  302. exports.characterDiff = characterDiff;
  303. /*istanbul ignore end*/
  304. function diffChars(oldStr, newStr, options) {
  305. return characterDiff.diff(oldStr, newStr, options);
  306. }
  307. });
  308. /*istanbul ignore start*/
  309. var generateOptions_1 = generateOptions;
  310. /*istanbul ignore end*/
  311. function generateOptions(options, defaults) {
  312. if (typeof options === 'function') {
  313. defaults.callback = options;
  314. } else if (options) {
  315. for (var name in options) {
  316. /* istanbul ignore else */
  317. if (options.hasOwnProperty(name)) {
  318. defaults[name] = options[name];
  319. }
  320. }
  321. }
  322. return defaults;
  323. }
  324. var params = /*#__PURE__*/Object.defineProperty({
  325. generateOptions: generateOptions_1
  326. }, '__esModule', {
  327. value: true
  328. });
  329. /*istanbul ignore start*/
  330. var word = createCommonjsModule(function (module, exports) {
  331. Object.defineProperty(exports, "__esModule", {
  332. value: true
  333. });
  334. exports.diffWords = diffWords;
  335. exports.diffWordsWithSpace = diffWordsWithSpace;
  336. exports.wordDiff = void 0;
  337. /*istanbul ignore end*/
  338. var
  339. /*istanbul ignore start*/
  340. _base = _interopRequireDefault(base$1)
  341. /*istanbul ignore end*/
  342. ;
  343. /*istanbul ignore start*/
  344. function _interopRequireDefault(obj) {
  345. return obj && obj.__esModule ? obj : {
  346. "default": obj
  347. };
  348. }
  349. /*istanbul ignore end*/
  350. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  351. //
  352. // Ranges and exceptions:
  353. // Latin-1 Supplement, 0080–00FF
  354. // - U+00D7 × Multiplication sign
  355. // - U+00F7 ÷ Division sign
  356. // Latin Extended-A, 0100–017F
  357. // Latin Extended-B, 0180–024F
  358. // IPA Extensions, 0250–02AF
  359. // Spacing Modifier Letters, 02B0–02FF
  360. // - U+02C7 ˇ &#711; Caron
  361. // - U+02D8 ˘ &#728; Breve
  362. // - U+02D9 ˙ &#729; Dot Above
  363. // - U+02DA ˚ &#730; Ring Above
  364. // - U+02DB ˛ &#731; Ogonek
  365. // - U+02DC ˜ &#732; Small Tilde
  366. // - U+02DD ˝ &#733; Double Acute Accent
  367. // Latin Extended Additional, 1E00–1EFF
  368. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  369. var reWhitespace = /\S/;
  370. var wordDiff = new
  371. /*istanbul ignore start*/
  372. _base
  373. /*istanbul ignore end*/
  374. [
  375. /*istanbul ignore start*/
  376. "default"
  377. /*istanbul ignore end*/
  378. ]();
  379. /*istanbul ignore start*/
  380. exports.wordDiff = wordDiff;
  381. /*istanbul ignore end*/
  382. wordDiff.equals = function (left, right) {
  383. if (this.options.ignoreCase) {
  384. left = left.toLowerCase();
  385. right = right.toLowerCase();
  386. }
  387. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  388. };
  389. wordDiff.tokenize = function (value) {
  390. // All whitespace symbols except newline group into one token, each newline - in separate token
  391. var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  392. for (var i = 0; i < tokens.length - 1; i++) {
  393. // If we have an empty string in the next field and we have only word chars before and after, merge
  394. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  395. tokens[i] += tokens[i + 2];
  396. tokens.splice(i + 1, 2);
  397. i--;
  398. }
  399. }
  400. return tokens;
  401. };
  402. function diffWords(oldStr, newStr, options) {
  403. options =
  404. /*istanbul ignore start*/
  405. (/*istanbul ignore end*/
  406. /*istanbul ignore start*/
  407. 0, params
  408. /*istanbul ignore end*/
  409. .
  410. /*istanbul ignore start*/
  411. generateOptions
  412. /*istanbul ignore end*/
  413. )(options, {
  414. ignoreWhitespace: true
  415. });
  416. return wordDiff.diff(oldStr, newStr, options);
  417. }
  418. function diffWordsWithSpace(oldStr, newStr, options) {
  419. return wordDiff.diff(oldStr, newStr, options);
  420. }
  421. });
  422. /*istanbul ignore start*/
  423. var line$B = createCommonjsModule(function (module, exports) {
  424. Object.defineProperty(exports, "__esModule", {
  425. value: true
  426. });
  427. exports.diffLines = diffLines;
  428. exports.diffTrimmedLines = diffTrimmedLines;
  429. exports.lineDiff = void 0;
  430. /*istanbul ignore end*/
  431. var
  432. /*istanbul ignore start*/
  433. _base = _interopRequireDefault(base$1)
  434. /*istanbul ignore end*/
  435. ;
  436. /*istanbul ignore start*/
  437. function _interopRequireDefault(obj) {
  438. return obj && obj.__esModule ? obj : {
  439. "default": obj
  440. };
  441. }
  442. /*istanbul ignore end*/
  443. var lineDiff = new
  444. /*istanbul ignore start*/
  445. _base
  446. /*istanbul ignore end*/
  447. [
  448. /*istanbul ignore start*/
  449. "default"
  450. /*istanbul ignore end*/
  451. ]();
  452. /*istanbul ignore start*/
  453. exports.lineDiff = lineDiff;
  454. /*istanbul ignore end*/
  455. lineDiff.tokenize = function (value) {
  456. var retLines = [],
  457. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  458. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  459. linesAndNewlines.pop();
  460. } // Merge the content and line separators into single tokens
  461. for (var i = 0; i < linesAndNewlines.length; i++) {
  462. var line = linesAndNewlines[i];
  463. if (i % 2 && !this.options.newlineIsToken) {
  464. retLines[retLines.length - 1] += line;
  465. } else {
  466. if (this.options.ignoreWhitespace) {
  467. line = line.trim();
  468. }
  469. retLines.push(line);
  470. }
  471. }
  472. return retLines;
  473. };
  474. function diffLines(oldStr, newStr, callback) {
  475. return lineDiff.diff(oldStr, newStr, callback);
  476. }
  477. function diffTrimmedLines(oldStr, newStr, callback) {
  478. var options =
  479. /*istanbul ignore start*/
  480. (/*istanbul ignore end*/
  481. /*istanbul ignore start*/
  482. 0, params
  483. /*istanbul ignore end*/
  484. .
  485. /*istanbul ignore start*/
  486. generateOptions
  487. /*istanbul ignore end*/
  488. )(callback, {
  489. ignoreWhitespace: true
  490. });
  491. return lineDiff.diff(oldStr, newStr, options);
  492. }
  493. });
  494. /*istanbul ignore start*/
  495. var sentence = createCommonjsModule(function (module, exports) {
  496. Object.defineProperty(exports, "__esModule", {
  497. value: true
  498. });
  499. exports.diffSentences = diffSentences;
  500. exports.sentenceDiff = void 0;
  501. /*istanbul ignore end*/
  502. var
  503. /*istanbul ignore start*/
  504. _base = _interopRequireDefault(base$1)
  505. /*istanbul ignore end*/
  506. ;
  507. /*istanbul ignore start*/
  508. function _interopRequireDefault(obj) {
  509. return obj && obj.__esModule ? obj : {
  510. "default": obj
  511. };
  512. }
  513. /*istanbul ignore end*/
  514. var sentenceDiff = new
  515. /*istanbul ignore start*/
  516. _base
  517. /*istanbul ignore end*/
  518. [
  519. /*istanbul ignore start*/
  520. "default"
  521. /*istanbul ignore end*/
  522. ]();
  523. /*istanbul ignore start*/
  524. exports.sentenceDiff = sentenceDiff;
  525. /*istanbul ignore end*/
  526. sentenceDiff.tokenize = function (value) {
  527. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  528. };
  529. function diffSentences(oldStr, newStr, callback) {
  530. return sentenceDiff.diff(oldStr, newStr, callback);
  531. }
  532. });
  533. /*istanbul ignore start*/
  534. var css$1 = createCommonjsModule(function (module, exports) {
  535. Object.defineProperty(exports, "__esModule", {
  536. value: true
  537. });
  538. exports.diffCss = diffCss;
  539. exports.cssDiff = void 0;
  540. /*istanbul ignore end*/
  541. var
  542. /*istanbul ignore start*/
  543. _base = _interopRequireDefault(base$1)
  544. /*istanbul ignore end*/
  545. ;
  546. /*istanbul ignore start*/
  547. function _interopRequireDefault(obj) {
  548. return obj && obj.__esModule ? obj : {
  549. "default": obj
  550. };
  551. }
  552. /*istanbul ignore end*/
  553. var cssDiff = new
  554. /*istanbul ignore start*/
  555. _base
  556. /*istanbul ignore end*/
  557. [
  558. /*istanbul ignore start*/
  559. "default"
  560. /*istanbul ignore end*/
  561. ]();
  562. /*istanbul ignore start*/
  563. exports.cssDiff = cssDiff;
  564. /*istanbul ignore end*/
  565. cssDiff.tokenize = function (value) {
  566. return value.split(/([{}:;,]|\s+)/);
  567. };
  568. function diffCss(oldStr, newStr, callback) {
  569. return cssDiff.diff(oldStr, newStr, callback);
  570. }
  571. });
  572. var check = function (it) {
  573. return it && it.Math == Math && it;
  574. };
  575. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  576. var global$2 =
  577. // eslint-disable-next-line es/no-global-this -- safe
  578. check(typeof globalThis == 'object' && globalThis) ||
  579. check(typeof window == 'object' && window) ||
  580. // eslint-disable-next-line no-restricted-globals -- safe
  581. check(typeof self == 'object' && self) ||
  582. check(typeof global$2 == 'object' && global$2) ||
  583. // eslint-disable-next-line no-new-func -- fallback
  584. (function () { return this; })() || Function('return this')();
  585. var fails = function (exec) {
  586. try {
  587. return !!exec();
  588. } catch (error) {
  589. return true;
  590. }
  591. };
  592. // Detect IE8's incomplete defineProperty implementation
  593. var descriptors$1 = !fails(function () {
  594. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  595. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  596. });
  597. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  598. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  599. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  600. // Nashorn ~ JDK8 bug
  601. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  602. // `Object.prototype.propertyIsEnumerable` method implementation
  603. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  604. var f$4 = NASHORN_BUG ? function propertyIsEnumerable(V) {
  605. var descriptor = getOwnPropertyDescriptor$1(this, V);
  606. return !!descriptor && descriptor.enumerable;
  607. } : $propertyIsEnumerable;
  608. var objectPropertyIsEnumerable = {
  609. f: f$4
  610. };
  611. var createPropertyDescriptor = function (bitmap, value) {
  612. return {
  613. enumerable: !(bitmap & 1),
  614. configurable: !(bitmap & 2),
  615. writable: !(bitmap & 4),
  616. value: value
  617. };
  618. };
  619. var toString$2 = {}.toString;
  620. var classofRaw = function (it) {
  621. return toString$2.call(it).slice(8, -1);
  622. };
  623. var split = ''.split;
  624. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  625. var indexedObject = fails(function () {
  626. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  627. // eslint-disable-next-line no-prototype-builtins -- safe
  628. return !Object('z').propertyIsEnumerable(0);
  629. }) ? function (it) {
  630. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  631. } : Object;
  632. // `RequireObjectCoercible` abstract operation
  633. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  634. var requireObjectCoercible = function (it) {
  635. if (it == undefined) throw TypeError("Can't call method on " + it);
  636. return it;
  637. };
  638. // toObject with fallback for non-array-like ES3 strings
  639. var toIndexedObject = function (it) {
  640. return indexedObject(requireObjectCoercible(it));
  641. };
  642. var isObject$3 = function (it) {
  643. return typeof it === 'object' ? it !== null : typeof it === 'function';
  644. };
  645. var aFunction$1 = function (variable) {
  646. return typeof variable == 'function' ? variable : undefined;
  647. };
  648. var getBuiltIn = function (namespace, method) {
  649. return arguments.length < 2 ? aFunction$1(global$2[namespace]) : global$2[namespace] && global$2[namespace][method];
  650. };
  651. var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
  652. var process$3 = global$2.process;
  653. var Deno = global$2.Deno;
  654. var versions = process$3 && process$3.versions || Deno && Deno.version;
  655. var v8$2 = versions && versions.v8;
  656. var match$1, version$2;
  657. if (v8$2) {
  658. match$1 = v8$2.split('.');
  659. version$2 = match$1[0] < 4 ? 1 : match$1[0] + match$1[1];
  660. } else if (engineUserAgent) {
  661. match$1 = engineUserAgent.match(/Edge\/(\d+)/);
  662. if (!match$1 || match$1[1] >= 74) {
  663. match$1 = engineUserAgent.match(/Chrome\/(\d+)/);
  664. if (match$1) version$2 = match$1[1];
  665. }
  666. }
  667. var engineV8Version = version$2 && +version$2;
  668. /* eslint-disable es/no-symbol -- required for testing */
  669. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  670. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
  671. var symbol = Symbol();
  672. // Chrome 38 Symbol has incorrect toString conversion
  673. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  674. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  675. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  676. !Symbol.sham && engineV8Version && engineV8Version < 41;
  677. });
  678. /* eslint-disable es/no-symbol -- required for testing */
  679. var useSymbolAsUid = nativeSymbol
  680. && !Symbol.sham
  681. && typeof Symbol.iterator == 'symbol';
  682. var isSymbol$1 = useSymbolAsUid ? function (it) {
  683. return typeof it == 'symbol';
  684. } : function (it) {
  685. var $Symbol = getBuiltIn('Symbol');
  686. return typeof $Symbol == 'function' && Object(it) instanceof $Symbol;
  687. };
  688. // `OrdinaryToPrimitive` abstract operation
  689. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  690. var ordinaryToPrimitive = function (input, pref) {
  691. var fn, val;
  692. if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject$3(val = fn.call(input))) return val;
  693. if (typeof (fn = input.valueOf) == 'function' && !isObject$3(val = fn.call(input))) return val;
  694. if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject$3(val = fn.call(input))) return val;
  695. throw TypeError("Can't convert object to primitive value");
  696. };
  697. var setGlobal = function (key, value) {
  698. try {
  699. // eslint-disable-next-line es/no-object-defineproperty -- safe
  700. Object.defineProperty(global$2, key, { value: value, configurable: true, writable: true });
  701. } catch (error) {
  702. global$2[key] = value;
  703. } return value;
  704. };
  705. var SHARED = '__core-js_shared__';
  706. var store$1 = global$2[SHARED] || setGlobal(SHARED, {});
  707. var sharedStore = store$1;
  708. var shared = createCommonjsModule(function (module) {
  709. (module.exports = function (key, value) {
  710. return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
  711. })('versions', []).push({
  712. version: '3.17.3',
  713. mode: 'global',
  714. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  715. });
  716. });
  717. // `ToObject` abstract operation
  718. // https://tc39.es/ecma262/#sec-toobject
  719. var toObject = function (argument) {
  720. return Object(requireObjectCoercible(argument));
  721. };
  722. var hasOwnProperty$b = {}.hasOwnProperty;
  723. var has$1 = Object.hasOwn || function hasOwn(it, key) {
  724. return hasOwnProperty$b.call(toObject(it), key);
  725. };
  726. var id = 0;
  727. var postfix = Math.random();
  728. var uid$1 = function (key) {
  729. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  730. };
  731. var WellKnownSymbolsStore = shared('wks');
  732. var Symbol$2 = global$2.Symbol;
  733. var createWellKnownSymbol = useSymbolAsUid ? Symbol$2 : Symbol$2 && Symbol$2.withoutSetter || uid$1;
  734. var wellKnownSymbol = function (name) {
  735. if (!has$1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
  736. if (nativeSymbol && has$1(Symbol$2, name)) {
  737. WellKnownSymbolsStore[name] = Symbol$2[name];
  738. } else {
  739. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  740. }
  741. } return WellKnownSymbolsStore[name];
  742. };
  743. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  744. // `ToPrimitive` abstract operation
  745. // https://tc39.es/ecma262/#sec-toprimitive
  746. var toPrimitive = function (input, pref) {
  747. if (!isObject$3(input) || isSymbol$1(input)) return input;
  748. var exoticToPrim = input[TO_PRIMITIVE];
  749. var result;
  750. if (exoticToPrim !== undefined) {
  751. if (pref === undefined) pref = 'default';
  752. result = exoticToPrim.call(input, pref);
  753. if (!isObject$3(result) || isSymbol$1(result)) return result;
  754. throw TypeError("Can't convert object to primitive value");
  755. }
  756. if (pref === undefined) pref = 'number';
  757. return ordinaryToPrimitive(input, pref);
  758. };
  759. // `ToPropertyKey` abstract operation
  760. // https://tc39.es/ecma262/#sec-topropertykey
  761. var toPropertyKey = function (argument) {
  762. var key = toPrimitive(argument, 'string');
  763. return isSymbol$1(key) ? key : String(key);
  764. };
  765. var document = global$2.document;
  766. // typeof document.createElement is 'object' in old IE
  767. var EXISTS = isObject$3(document) && isObject$3(document.createElement);
  768. var documentCreateElement = function (it) {
  769. return EXISTS ? document.createElement(it) : {};
  770. };
  771. // Thank's IE8 for his funny defineProperty
  772. var ie8DomDefine = !descriptors$1 && !fails(function () {
  773. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  774. return Object.defineProperty(documentCreateElement('div'), 'a', {
  775. get: function () { return 7; }
  776. }).a != 7;
  777. });
  778. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  779. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  780. // `Object.getOwnPropertyDescriptor` method
  781. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  782. var f$3 = descriptors$1 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  783. O = toIndexedObject(O);
  784. P = toPropertyKey(P);
  785. if (ie8DomDefine) try {
  786. return $getOwnPropertyDescriptor(O, P);
  787. } catch (error) { /* empty */ }
  788. if (has$1(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  789. };
  790. var objectGetOwnPropertyDescriptor = {
  791. f: f$3
  792. };
  793. var anObject = function (it) {
  794. if (!isObject$3(it)) {
  795. throw TypeError(String(it) + ' is not an object');
  796. } return it;
  797. };
  798. // eslint-disable-next-line es/no-object-defineproperty -- safe
  799. var $defineProperty = Object.defineProperty;
  800. // `Object.defineProperty` method
  801. // https://tc39.es/ecma262/#sec-object.defineproperty
  802. var f$2 = descriptors$1 ? $defineProperty : function defineProperty(O, P, Attributes) {
  803. anObject(O);
  804. P = toPropertyKey(P);
  805. anObject(Attributes);
  806. if (ie8DomDefine) try {
  807. return $defineProperty(O, P, Attributes);
  808. } catch (error) { /* empty */ }
  809. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  810. if ('value' in Attributes) O[P] = Attributes.value;
  811. return O;
  812. };
  813. var objectDefineProperty = {
  814. f: f$2
  815. };
  816. var createNonEnumerableProperty = descriptors$1 ? function (object, key, value) {
  817. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  818. } : function (object, key, value) {
  819. object[key] = value;
  820. return object;
  821. };
  822. var functionToString = Function.toString;
  823. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  824. if (typeof sharedStore.inspectSource != 'function') {
  825. sharedStore.inspectSource = function (it) {
  826. return functionToString.call(it);
  827. };
  828. }
  829. var inspectSource = sharedStore.inspectSource;
  830. var WeakMap$3 = global$2.WeakMap;
  831. var nativeWeakMap = typeof WeakMap$3 === 'function' && /native code/.test(inspectSource(WeakMap$3));
  832. var keys$1 = shared('keys');
  833. var sharedKey = function (key) {
  834. return keys$1[key] || (keys$1[key] = uid$1(key));
  835. };
  836. var hiddenKeys$1 = {};
  837. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  838. var WeakMap$2 = global$2.WeakMap;
  839. var set$1, get$2, has;
  840. var enforce = function (it) {
  841. return has(it) ? get$2(it) : set$1(it, {});
  842. };
  843. var getterFor = function (TYPE) {
  844. return function (it) {
  845. var state;
  846. if (!isObject$3(it) || (state = get$2(it)).type !== TYPE) {
  847. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  848. } return state;
  849. };
  850. };
  851. if (nativeWeakMap || sharedStore.state) {
  852. var store = sharedStore.state || (sharedStore.state = new WeakMap$2());
  853. var wmget = store.get;
  854. var wmhas = store.has;
  855. var wmset = store.set;
  856. set$1 = function (it, metadata) {
  857. if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  858. metadata.facade = it;
  859. wmset.call(store, it, metadata);
  860. return metadata;
  861. };
  862. get$2 = function (it) {
  863. return wmget.call(store, it) || {};
  864. };
  865. has = function (it) {
  866. return wmhas.call(store, it);
  867. };
  868. } else {
  869. var STATE = sharedKey('state');
  870. hiddenKeys$1[STATE] = true;
  871. set$1 = function (it, metadata) {
  872. if (has$1(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  873. metadata.facade = it;
  874. createNonEnumerableProperty(it, STATE, metadata);
  875. return metadata;
  876. };
  877. get$2 = function (it) {
  878. return has$1(it, STATE) ? it[STATE] : {};
  879. };
  880. has = function (it) {
  881. return has$1(it, STATE);
  882. };
  883. }
  884. var internalState = {
  885. set: set$1,
  886. get: get$2,
  887. has: has,
  888. enforce: enforce,
  889. getterFor: getterFor
  890. };
  891. var redefine = createCommonjsModule(function (module) {
  892. var getInternalState = internalState.get;
  893. var enforceInternalState = internalState.enforce;
  894. var TEMPLATE = String(String).split('String');
  895. (module.exports = function (O, key, value, options) {
  896. var unsafe = options ? !!options.unsafe : false;
  897. var simple = options ? !!options.enumerable : false;
  898. var noTargetGet = options ? !!options.noTargetGet : false;
  899. var state;
  900. if (typeof value == 'function') {
  901. if (typeof key == 'string' && !has$1(value, 'name')) {
  902. createNonEnumerableProperty(value, 'name', key);
  903. }
  904. state = enforceInternalState(value);
  905. if (!state.source) {
  906. state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
  907. }
  908. }
  909. if (O === global$2) {
  910. if (simple) O[key] = value;
  911. else setGlobal(key, value);
  912. return;
  913. } else if (!unsafe) {
  914. delete O[key];
  915. } else if (!noTargetGet && O[key]) {
  916. simple = true;
  917. }
  918. if (simple) O[key] = value;
  919. else createNonEnumerableProperty(O, key, value);
  920. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  921. })(Function.prototype, 'toString', function toString() {
  922. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  923. });
  924. });
  925. var ceil = Math.ceil;
  926. var floor$1 = Math.floor;
  927. // `ToInteger` abstract operation
  928. // https://tc39.es/ecma262/#sec-tointeger
  929. var toInteger = function (argument) {
  930. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$1 : ceil)(argument);
  931. };
  932. var min$1 = Math.min;
  933. // `ToLength` abstract operation
  934. // https://tc39.es/ecma262/#sec-tolength
  935. var toLength = function (argument) {
  936. return argument > 0 ? min$1(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  937. };
  938. var max = Math.max;
  939. var min = Math.min;
  940. // Helper for a popular repeating case of the spec:
  941. // Let integer be ? ToInteger(index).
  942. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  943. var toAbsoluteIndex = function (index, length) {
  944. var integer = toInteger(index);
  945. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  946. };
  947. // `Array.prototype.{ indexOf, includes }` methods implementation
  948. var createMethod = function (IS_INCLUDES) {
  949. return function ($this, el, fromIndex) {
  950. var O = toIndexedObject($this);
  951. var length = toLength(O.length);
  952. var index = toAbsoluteIndex(fromIndex, length);
  953. var value;
  954. // Array#includes uses SameValueZero equality algorithm
  955. // eslint-disable-next-line no-self-compare -- NaN check
  956. if (IS_INCLUDES && el != el) while (length > index) {
  957. value = O[index++];
  958. // eslint-disable-next-line no-self-compare -- NaN check
  959. if (value != value) return true;
  960. // Array#indexOf ignores holes, Array#includes - not
  961. } else for (;length > index; index++) {
  962. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  963. } return !IS_INCLUDES && -1;
  964. };
  965. };
  966. var arrayIncludes$1 = {
  967. // `Array.prototype.includes` method
  968. // https://tc39.es/ecma262/#sec-array.prototype.includes
  969. includes: createMethod(true),
  970. // `Array.prototype.indexOf` method
  971. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  972. indexOf: createMethod(false)
  973. };
  974. var indexOf = arrayIncludes$1.indexOf;
  975. var objectKeysInternal = function (object, names) {
  976. var O = toIndexedObject(object);
  977. var i = 0;
  978. var result = [];
  979. var key;
  980. for (key in O) !has$1(hiddenKeys$1, key) && has$1(O, key) && result.push(key);
  981. // Don't enum bug & hidden keys
  982. while (names.length > i) if (has$1(O, key = names[i++])) {
  983. ~indexOf(result, key) || result.push(key);
  984. }
  985. return result;
  986. };
  987. // IE8- don't enum bug keys
  988. var enumBugKeys = [
  989. 'constructor',
  990. 'hasOwnProperty',
  991. 'isPrototypeOf',
  992. 'propertyIsEnumerable',
  993. 'toLocaleString',
  994. 'toString',
  995. 'valueOf'
  996. ];
  997. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  998. // `Object.getOwnPropertyNames` method
  999. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  1000. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  1001. var f$1 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1002. return objectKeysInternal(O, hiddenKeys);
  1003. };
  1004. var objectGetOwnPropertyNames = {
  1005. f: f$1
  1006. };
  1007. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  1008. var f = Object.getOwnPropertySymbols;
  1009. var objectGetOwnPropertySymbols = {
  1010. f: f
  1011. };
  1012. // all object keys, includes non-enumerable and symbols
  1013. var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1014. var keys = objectGetOwnPropertyNames.f(anObject(it));
  1015. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  1016. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  1017. };
  1018. var copyConstructorProperties = function (target, source) {
  1019. var keys = ownKeys(source);
  1020. var defineProperty = objectDefineProperty.f;
  1021. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  1022. for (var i = 0; i < keys.length; i++) {
  1023. var key = keys[i];
  1024. if (!has$1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1025. }
  1026. };
  1027. var replacement = /#|\.prototype\./;
  1028. var isForced = function (feature, detection) {
  1029. var value = data$3[normalize$3(feature)];
  1030. return value == POLYFILL ? true
  1031. : value == NATIVE ? false
  1032. : typeof detection == 'function' ? fails(detection)
  1033. : !!detection;
  1034. };
  1035. var normalize$3 = isForced.normalize = function (string) {
  1036. return String(string).replace(replacement, '.').toLowerCase();
  1037. };
  1038. var data$3 = isForced.data = {};
  1039. var NATIVE = isForced.NATIVE = 'N';
  1040. var POLYFILL = isForced.POLYFILL = 'P';
  1041. var isForced_1 = isForced;
  1042. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  1043. /*
  1044. options.target - name of the target object
  1045. options.global - target is the global object
  1046. options.stat - export as static methods of target
  1047. options.proto - export as prototype methods of target
  1048. options.real - real prototype method for the `pure` version
  1049. options.forced - export even if the native feature is available
  1050. options.bind - bind methods to the target, required for the `pure` version
  1051. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  1052. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  1053. options.sham - add a flag to not completely full polyfills
  1054. options.enumerable - export as enumerable property
  1055. options.noTargetGet - prevent calling a getter on target
  1056. */
  1057. var _export = function (options, source) {
  1058. var TARGET = options.target;
  1059. var GLOBAL = options.global;
  1060. var STATIC = options.stat;
  1061. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  1062. if (GLOBAL) {
  1063. target = global$2;
  1064. } else if (STATIC) {
  1065. target = global$2[TARGET] || setGlobal(TARGET, {});
  1066. } else {
  1067. target = (global$2[TARGET] || {}).prototype;
  1068. }
  1069. if (target) for (key in source) {
  1070. sourceProperty = source[key];
  1071. if (options.noTargetGet) {
  1072. descriptor = getOwnPropertyDescriptor(target, key);
  1073. targetProperty = descriptor && descriptor.value;
  1074. } else targetProperty = target[key];
  1075. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  1076. // contained in target
  1077. if (!FORCED && targetProperty !== undefined) {
  1078. if (typeof sourceProperty === typeof targetProperty) continue;
  1079. copyConstructorProperties(sourceProperty, targetProperty);
  1080. }
  1081. // add a flag to not completely full polyfills
  1082. if (options.sham || (targetProperty && targetProperty.sham)) {
  1083. createNonEnumerableProperty(sourceProperty, 'sham', true);
  1084. }
  1085. // extend global
  1086. redefine(target, key, sourceProperty, options);
  1087. }
  1088. };
  1089. var aFunction = function (it) {
  1090. if (typeof it != 'function') {
  1091. throw TypeError(String(it) + ' is not a function');
  1092. } return it;
  1093. };
  1094. var toString$1 = function (argument) {
  1095. if (isSymbol$1(argument)) throw TypeError('Cannot convert a Symbol value to a string');
  1096. return String(argument);
  1097. };
  1098. // TODO: use something more complex like timsort?
  1099. var floor = Math.floor;
  1100. var mergeSort = function (array, comparefn) {
  1101. var length = array.length;
  1102. var middle = floor(length / 2);
  1103. return length < 8 ? insertionSort(array, comparefn) : merge$1(
  1104. mergeSort(array.slice(0, middle), comparefn),
  1105. mergeSort(array.slice(middle), comparefn),
  1106. comparefn
  1107. );
  1108. };
  1109. var insertionSort = function (array, comparefn) {
  1110. var length = array.length;
  1111. var i = 1;
  1112. var element, j;
  1113. while (i < length) {
  1114. j = i;
  1115. element = array[i];
  1116. while (j && comparefn(array[j - 1], element) > 0) {
  1117. array[j] = array[--j];
  1118. }
  1119. if (j !== i++) array[j] = element;
  1120. } return array;
  1121. };
  1122. var merge$1 = function (left, right, comparefn) {
  1123. var llength = left.length;
  1124. var rlength = right.length;
  1125. var lindex = 0;
  1126. var rindex = 0;
  1127. var result = [];
  1128. while (lindex < llength || rindex < rlength) {
  1129. if (lindex < llength && rindex < rlength) {
  1130. result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]);
  1131. } else {
  1132. result.push(lindex < llength ? left[lindex++] : right[rindex++]);
  1133. }
  1134. } return result;
  1135. };
  1136. var arraySort = mergeSort;
  1137. var arrayMethodIsStrict = function (METHOD_NAME, argument) {
  1138. var method = [][METHOD_NAME];
  1139. return !!method && fails(function () {
  1140. // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
  1141. method.call(null, argument || function () { throw 1; }, 1);
  1142. });
  1143. };
  1144. var firefox = engineUserAgent.match(/firefox\/(\d+)/i);
  1145. var engineFfVersion = !!firefox && +firefox[1];
  1146. var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent);
  1147. var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./);
  1148. var engineWebkitVersion = !!webkit && +webkit[1];
  1149. var test$1 = [];
  1150. var nativeSort = test$1.sort;
  1151. // IE8-
  1152. var FAILS_ON_UNDEFINED = fails(function () {
  1153. test$1.sort(undefined);
  1154. });
  1155. // V8 bug
  1156. var FAILS_ON_NULL = fails(function () {
  1157. test$1.sort(null);
  1158. });
  1159. // Old WebKit
  1160. var STRICT_METHOD = arrayMethodIsStrict('sort');
  1161. var STABLE_SORT = !fails(function () {
  1162. // feature detection can be too slow, so check engines versions
  1163. if (engineV8Version) return engineV8Version < 70;
  1164. if (engineFfVersion && engineFfVersion > 3) return;
  1165. if (engineIsIeOrEdge) return true;
  1166. if (engineWebkitVersion) return engineWebkitVersion < 603;
  1167. var result = '';
  1168. var code, chr, value, index;
  1169. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  1170. for (code = 65; code < 76; code++) {
  1171. chr = String.fromCharCode(code);
  1172. switch (code) {
  1173. case 66: case 69: case 70: case 72: value = 3; break;
  1174. case 68: case 71: value = 4; break;
  1175. default: value = 2;
  1176. }
  1177. for (index = 0; index < 47; index++) {
  1178. test$1.push({ k: chr + index, v: value });
  1179. }
  1180. }
  1181. test$1.sort(function (a, b) { return b.v - a.v; });
  1182. for (index = 0; index < test$1.length; index++) {
  1183. chr = test$1[index].k.charAt(0);
  1184. if (result.charAt(result.length - 1) !== chr) result += chr;
  1185. }
  1186. return result !== 'DGBEFHACIJK';
  1187. });
  1188. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  1189. var getSortCompare = function (comparefn) {
  1190. return function (x, y) {
  1191. if (y === undefined) return -1;
  1192. if (x === undefined) return 1;
  1193. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  1194. return toString$1(x) > toString$1(y) ? 1 : -1;
  1195. };
  1196. };
  1197. // `Array.prototype.sort` method
  1198. // https://tc39.es/ecma262/#sec-array.prototype.sort
  1199. _export({ target: 'Array', proto: true, forced: FORCED }, {
  1200. sort: function sort(comparefn) {
  1201. if (comparefn !== undefined) aFunction(comparefn);
  1202. var array = toObject(this);
  1203. if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn);
  1204. var items = [];
  1205. var arrayLength = toLength(array.length);
  1206. var itemsLength, index;
  1207. for (index = 0; index < arrayLength; index++) {
  1208. if (index in array) items.push(array[index]);
  1209. }
  1210. items = arraySort(items, getSortCompare(comparefn));
  1211. itemsLength = items.length;
  1212. index = 0;
  1213. while (index < itemsLength) array[index] = items[index++];
  1214. while (index < arrayLength) delete array[index++];
  1215. return array;
  1216. }
  1217. });
  1218. var json = createCommonjsModule(function (module, exports) {
  1219. Object.defineProperty(exports, "__esModule", {
  1220. value: true
  1221. });
  1222. exports.diffJson = diffJson;
  1223. exports.canonicalize = canonicalize;
  1224. exports.jsonDiff = void 0;
  1225. /*istanbul ignore end*/
  1226. var
  1227. /*istanbul ignore start*/
  1228. _base = _interopRequireDefault(base$1)
  1229. /*istanbul ignore end*/
  1230. ;
  1231. /*istanbul ignore start*/
  1232. function _interopRequireDefault(obj) {
  1233. return obj && obj.__esModule ? obj : {
  1234. "default": obj
  1235. };
  1236. }
  1237. function _typeof(obj) {
  1238. "@babel/helpers - typeof";
  1239. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1240. _typeof = function _typeof(obj) {
  1241. return typeof obj;
  1242. };
  1243. } else {
  1244. _typeof = function _typeof(obj) {
  1245. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1246. };
  1247. }
  1248. return _typeof(obj);
  1249. }
  1250. /*istanbul ignore end*/
  1251. var objectPrototypeToString = Object.prototype.toString;
  1252. var jsonDiff = new
  1253. /*istanbul ignore start*/
  1254. _base
  1255. /*istanbul ignore end*/
  1256. [
  1257. /*istanbul ignore start*/
  1258. "default"
  1259. /*istanbul ignore end*/
  1260. ](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  1261. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  1262. /*istanbul ignore start*/
  1263. exports.jsonDiff = jsonDiff;
  1264. /*istanbul ignore end*/
  1265. jsonDiff.useLongestToken = true;
  1266. jsonDiff.tokenize =
  1267. /*istanbul ignore start*/
  1268. line$B
  1269. /*istanbul ignore end*/
  1270. .
  1271. /*istanbul ignore start*/
  1272. lineDiff
  1273. /*istanbul ignore end*/
  1274. .tokenize;
  1275. jsonDiff.castInput = function (value) {
  1276. /*istanbul ignore start*/
  1277. var _this$options =
  1278. /*istanbul ignore end*/
  1279. this.options,
  1280. undefinedReplacement = _this$options.undefinedReplacement,
  1281. _this$options$stringi = _this$options.stringifyReplacer,
  1282. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v)
  1283. /*istanbul ignore start*/
  1284. {
  1285. return (
  1286. /*istanbul ignore end*/
  1287. typeof v === 'undefined' ? undefinedReplacement : v
  1288. );
  1289. } : _this$options$stringi;
  1290. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  1291. };
  1292. jsonDiff.equals = function (left, right) {
  1293. return (
  1294. /*istanbul ignore start*/
  1295. _base
  1296. /*istanbul ignore end*/
  1297. [
  1298. /*istanbul ignore start*/
  1299. "default"
  1300. /*istanbul ignore end*/
  1301. ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  1302. );
  1303. };
  1304. function diffJson(oldObj, newObj, options) {
  1305. return jsonDiff.diff(oldObj, newObj, options);
  1306. } // This function handles the presence of circular references by bailing out when encountering an
  1307. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  1308. function canonicalize(obj, stack, replacementStack, replacer, key) {
  1309. stack = stack || [];
  1310. replacementStack = replacementStack || [];
  1311. if (replacer) {
  1312. obj = replacer(key, obj);
  1313. }
  1314. var i;
  1315. for (i = 0; i < stack.length; i += 1) {
  1316. if (stack[i] === obj) {
  1317. return replacementStack[i];
  1318. }
  1319. }
  1320. var canonicalizedObj;
  1321. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  1322. stack.push(obj);
  1323. canonicalizedObj = new Array(obj.length);
  1324. replacementStack.push(canonicalizedObj);
  1325. for (i = 0; i < obj.length; i += 1) {
  1326. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  1327. }
  1328. stack.pop();
  1329. replacementStack.pop();
  1330. return canonicalizedObj;
  1331. }
  1332. if (obj && obj.toJSON) {
  1333. obj = obj.toJSON();
  1334. }
  1335. if (
  1336. /*istanbul ignore start*/
  1337. _typeof(
  1338. /*istanbul ignore end*/
  1339. obj) === 'object' && obj !== null) {
  1340. stack.push(obj);
  1341. canonicalizedObj = {};
  1342. replacementStack.push(canonicalizedObj);
  1343. var sortedKeys = [],
  1344. _key;
  1345. for (_key in obj) {
  1346. /* istanbul ignore else */
  1347. if (obj.hasOwnProperty(_key)) {
  1348. sortedKeys.push(_key);
  1349. }
  1350. }
  1351. sortedKeys.sort();
  1352. for (i = 0; i < sortedKeys.length; i += 1) {
  1353. _key = sortedKeys[i];
  1354. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  1355. }
  1356. stack.pop();
  1357. replacementStack.pop();
  1358. } else {
  1359. canonicalizedObj = obj;
  1360. }
  1361. return canonicalizedObj;
  1362. }
  1363. });
  1364. /*istanbul ignore start*/
  1365. var array$5 = createCommonjsModule(function (module, exports) {
  1366. Object.defineProperty(exports, "__esModule", {
  1367. value: true
  1368. });
  1369. exports.diffArrays = diffArrays;
  1370. exports.arrayDiff = void 0;
  1371. /*istanbul ignore end*/
  1372. var
  1373. /*istanbul ignore start*/
  1374. _base = _interopRequireDefault(base$1)
  1375. /*istanbul ignore end*/
  1376. ;
  1377. /*istanbul ignore start*/
  1378. function _interopRequireDefault(obj) {
  1379. return obj && obj.__esModule ? obj : {
  1380. "default": obj
  1381. };
  1382. }
  1383. /*istanbul ignore end*/
  1384. var arrayDiff = new
  1385. /*istanbul ignore start*/
  1386. _base
  1387. /*istanbul ignore end*/
  1388. [
  1389. /*istanbul ignore start*/
  1390. "default"
  1391. /*istanbul ignore end*/
  1392. ]();
  1393. /*istanbul ignore start*/
  1394. exports.arrayDiff = arrayDiff;
  1395. /*istanbul ignore end*/
  1396. arrayDiff.tokenize = function (value) {
  1397. return value.slice();
  1398. };
  1399. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  1400. return value;
  1401. };
  1402. function diffArrays(oldArr, newArr, callback) {
  1403. return arrayDiff.diff(oldArr, newArr, callback);
  1404. }
  1405. });
  1406. /*istanbul ignore start*/
  1407. var parsePatch_1 = parsePatch;
  1408. /*istanbul ignore end*/
  1409. function parsePatch(uniDiff) {
  1410. /*istanbul ignore start*/
  1411. var
  1412. /*istanbul ignore end*/
  1413. options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1414. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  1415. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1416. list = [],
  1417. i = 0;
  1418. function parseIndex() {
  1419. var index = {};
  1420. list.push(index); // Parse diff metadata
  1421. while (i < diffstr.length) {
  1422. var line = diffstr[i]; // File header found, end parsing diff metadata
  1423. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  1424. break;
  1425. } // Diff index
  1426. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  1427. if (header) {
  1428. index.index = header[1];
  1429. }
  1430. i++;
  1431. } // Parse file headers if they are defined. Unified diff requires them, but
  1432. // there's no technical issues to have an isolated hunk without file header
  1433. parseFileHeader(index);
  1434. parseFileHeader(index); // Parse hunks
  1435. index.hunks = [];
  1436. while (i < diffstr.length) {
  1437. var _line = diffstr[i];
  1438. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  1439. break;
  1440. } else if (/^@@/.test(_line)) {
  1441. index.hunks.push(parseHunk());
  1442. } else if (_line && options.strict) {
  1443. // Ignore unexpected content unless in strict mode
  1444. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1445. } else {
  1446. i++;
  1447. }
  1448. }
  1449. } // Parses the --- and +++ headers, if none are found, no lines
  1450. // are consumed.
  1451. function parseFileHeader(index) {
  1452. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  1453. if (fileHeader) {
  1454. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1455. var data = fileHeader[2].split('\t', 2);
  1456. var fileName = data[0].replace(/\\\\/g, '\\');
  1457. if (/^".*"$/.test(fileName)) {
  1458. fileName = fileName.substr(1, fileName.length - 2);
  1459. }
  1460. index[keyPrefix + 'FileName'] = fileName;
  1461. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  1462. i++;
  1463. }
  1464. } // Parses a hunk
  1465. // This assumes that we are at the start of a hunk.
  1466. function parseHunk() {
  1467. var chunkHeaderIndex = i,
  1468. chunkHeaderLine = diffstr[i++],
  1469. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1470. var hunk = {
  1471. oldStart: +chunkHeader[1],
  1472. oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
  1473. newStart: +chunkHeader[3],
  1474. newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
  1475. lines: [],
  1476. linedelimiters: []
  1477. }; // Unified Diff Format quirk: If the chunk size is 0,
  1478. // the first number is one lower than one would expect.
  1479. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  1480. if (hunk.oldLines === 0) {
  1481. hunk.oldStart += 1;
  1482. }
  1483. if (hunk.newLines === 0) {
  1484. hunk.newStart += 1;
  1485. }
  1486. var addCount = 0,
  1487. removeCount = 0;
  1488. for (; i < diffstr.length; i++) {
  1489. // Lines starting with '---' could be mistaken for the "remove line" operation
  1490. // But they could be the header for the next file. Therefore prune such cases out.
  1491. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1492. break;
  1493. }
  1494. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  1495. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1496. hunk.lines.push(diffstr[i]);
  1497. hunk.linedelimiters.push(delimiters[i] || '\n');
  1498. if (operation === '+') {
  1499. addCount++;
  1500. } else if (operation === '-') {
  1501. removeCount++;
  1502. } else if (operation === ' ') {
  1503. addCount++;
  1504. removeCount++;
  1505. }
  1506. } else {
  1507. break;
  1508. }
  1509. } // Handle the empty block count case
  1510. if (!addCount && hunk.newLines === 1) {
  1511. hunk.newLines = 0;
  1512. }
  1513. if (!removeCount && hunk.oldLines === 1) {
  1514. hunk.oldLines = 0;
  1515. } // Perform optional sanity checking
  1516. if (options.strict) {
  1517. if (addCount !== hunk.newLines) {
  1518. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1519. }
  1520. if (removeCount !== hunk.oldLines) {
  1521. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1522. }
  1523. }
  1524. return hunk;
  1525. }
  1526. while (i < diffstr.length) {
  1527. parseIndex();
  1528. }
  1529. return list;
  1530. }
  1531. var parse$b = /*#__PURE__*/Object.defineProperty({
  1532. parsePatch: parsePatch_1
  1533. }, '__esModule', {
  1534. value: true
  1535. });
  1536. /*istanbul ignore start*/
  1537. var distanceIterator = createCommonjsModule(function (module, exports) {
  1538. Object.defineProperty(exports, "__esModule", {
  1539. value: true
  1540. });
  1541. exports["default"] = _default;
  1542. /*istanbul ignore end*/
  1543. // Iterator that traverses in the range of [min, max], stepping
  1544. // by distance from a given start position. I.e. for [0, 4], with
  1545. // start of 2, this will iterate 2, 3, 1, 4, 0.
  1546. function
  1547. /*istanbul ignore start*/
  1548. _default
  1549. /*istanbul ignore end*/
  1550. (start, minLine, maxLine) {
  1551. var wantForward = true,
  1552. backwardExhausted = false,
  1553. forwardExhausted = false,
  1554. localOffset = 1;
  1555. return function iterator() {
  1556. if (wantForward && !forwardExhausted) {
  1557. if (backwardExhausted) {
  1558. localOffset++;
  1559. } else {
  1560. wantForward = false;
  1561. } // Check if trying to fit beyond text length, and if not, check it fits
  1562. // after offset location (or desired location on first iteration)
  1563. if (start + localOffset <= maxLine) {
  1564. return localOffset;
  1565. }
  1566. forwardExhausted = true;
  1567. }
  1568. if (!backwardExhausted) {
  1569. if (!forwardExhausted) {
  1570. wantForward = true;
  1571. } // Check if trying to fit before text beginning, and if not, check it fits
  1572. // before offset location
  1573. if (minLine <= start - localOffset) {
  1574. return -localOffset++;
  1575. }
  1576. backwardExhausted = true;
  1577. return iterator();
  1578. } // We tried to fit hunk before text beginning and beyond text length, then
  1579. // hunk can't fit on the text. Return undefined
  1580. };
  1581. }
  1582. });
  1583. /*istanbul ignore start*/
  1584. var applyPatch_1 = applyPatch;
  1585. var applyPatches_1 = applyPatches;
  1586. /*istanbul ignore end*/
  1587. var
  1588. /*istanbul ignore start*/
  1589. _distanceIterator = _interopRequireDefault$1(distanceIterator)
  1590. /*istanbul ignore end*/
  1591. ;
  1592. /*istanbul ignore start*/
  1593. function _interopRequireDefault$1(obj) {
  1594. return obj && obj.__esModule ? obj : {
  1595. "default": obj
  1596. };
  1597. }
  1598. /*istanbul ignore end*/
  1599. function applyPatch(source, uniDiff) {
  1600. /*istanbul ignore start*/
  1601. var
  1602. /*istanbul ignore end*/
  1603. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1604. if (typeof uniDiff === 'string') {
  1605. uniDiff =
  1606. /*istanbul ignore start*/
  1607. (/*istanbul ignore end*/
  1608. /*istanbul ignore start*/
  1609. 0, parse$b
  1610. /*istanbul ignore end*/
  1611. .
  1612. /*istanbul ignore start*/
  1613. parsePatch
  1614. /*istanbul ignore end*/
  1615. )(uniDiff);
  1616. }
  1617. if (Array.isArray(uniDiff)) {
  1618. if (uniDiff.length > 1) {
  1619. throw new Error('applyPatch only works with a single input.');
  1620. }
  1621. uniDiff = uniDiff[0];
  1622. } // Apply the diff to the input
  1623. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1624. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1625. hunks = uniDiff.hunks,
  1626. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1627. /*istanbul ignore start*/
  1628. {
  1629. return (
  1630. /*istanbul ignore end*/
  1631. line === patchContent
  1632. );
  1633. },
  1634. errorCount = 0,
  1635. fuzzFactor = options.fuzzFactor || 0,
  1636. minLine = 0,
  1637. offset = 0,
  1638. removeEOFNL,
  1639. addEOFNL;
  1640. /**
  1641. * Checks if the hunk exactly fits on the provided location
  1642. */
  1643. function hunkFits(hunk, toPos) {
  1644. for (var j = 0; j < hunk.lines.length; j++) {
  1645. var line = hunk.lines[j],
  1646. operation = line.length > 0 ? line[0] : ' ',
  1647. content = line.length > 0 ? line.substr(1) : line;
  1648. if (operation === ' ' || operation === '-') {
  1649. // Context sanity check
  1650. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1651. errorCount++;
  1652. if (errorCount > fuzzFactor) {
  1653. return false;
  1654. }
  1655. }
  1656. toPos++;
  1657. }
  1658. }
  1659. return true;
  1660. } // Search best fit offsets for each hunk based on the previous ones
  1661. for (var i = 0; i < hunks.length; i++) {
  1662. var hunk = hunks[i],
  1663. maxLine = lines.length - hunk.oldLines,
  1664. localOffset = 0,
  1665. toPos = offset + hunk.oldStart - 1;
  1666. var iterator =
  1667. /*istanbul ignore start*/
  1668. (/*istanbul ignore end*/
  1669. /*istanbul ignore start*/
  1670. 0, _distanceIterator
  1671. /*istanbul ignore end*/
  1672. [
  1673. /*istanbul ignore start*/
  1674. "default"
  1675. /*istanbul ignore end*/
  1676. ])(toPos, minLine, maxLine);
  1677. for (; localOffset !== undefined; localOffset = iterator()) {
  1678. if (hunkFits(hunk, toPos + localOffset)) {
  1679. hunk.offset = offset += localOffset;
  1680. break;
  1681. }
  1682. }
  1683. if (localOffset === undefined) {
  1684. return false;
  1685. } // Set lower text limit to end of the current hunk, so next ones don't try
  1686. // to fit over already patched text
  1687. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1688. } // Apply patch hunks
  1689. var diffOffset = 0;
  1690. for (var _i = 0; _i < hunks.length; _i++) {
  1691. var _hunk = hunks[_i],
  1692. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  1693. diffOffset += _hunk.newLines - _hunk.oldLines;
  1694. for (var j = 0; j < _hunk.lines.length; j++) {
  1695. var line = _hunk.lines[j],
  1696. operation = line.length > 0 ? line[0] : ' ',
  1697. content = line.length > 0 ? line.substr(1) : line,
  1698. delimiter = _hunk.linedelimiters[j];
  1699. if (operation === ' ') {
  1700. _toPos++;
  1701. } else if (operation === '-') {
  1702. lines.splice(_toPos, 1);
  1703. delimiters.splice(_toPos, 1);
  1704. /* istanbul ignore else */
  1705. } else if (operation === '+') {
  1706. lines.splice(_toPos, 0, content);
  1707. delimiters.splice(_toPos, 0, delimiter);
  1708. _toPos++;
  1709. } else if (operation === '\\') {
  1710. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1711. if (previousOperation === '+') {
  1712. removeEOFNL = true;
  1713. } else if (previousOperation === '-') {
  1714. addEOFNL = true;
  1715. }
  1716. }
  1717. }
  1718. } // Handle EOFNL insertion/removal
  1719. if (removeEOFNL) {
  1720. while (!lines[lines.length - 1]) {
  1721. lines.pop();
  1722. delimiters.pop();
  1723. }
  1724. } else if (addEOFNL) {
  1725. lines.push('');
  1726. delimiters.push('\n');
  1727. }
  1728. for (var _k = 0; _k < lines.length - 1; _k++) {
  1729. lines[_k] = lines[_k] + delimiters[_k];
  1730. }
  1731. return lines.join('');
  1732. } // Wrapper that supports multiple file patches via callbacks.
  1733. function applyPatches(uniDiff, options) {
  1734. if (typeof uniDiff === 'string') {
  1735. uniDiff =
  1736. /*istanbul ignore start*/
  1737. (/*istanbul ignore end*/
  1738. /*istanbul ignore start*/
  1739. 0, parse$b
  1740. /*istanbul ignore end*/
  1741. .
  1742. /*istanbul ignore start*/
  1743. parsePatch
  1744. /*istanbul ignore end*/
  1745. )(uniDiff);
  1746. }
  1747. var currentIndex = 0;
  1748. function processIndex() {
  1749. var index = uniDiff[currentIndex++];
  1750. if (!index) {
  1751. return options.complete();
  1752. }
  1753. options.loadFile(index, function (err, data) {
  1754. if (err) {
  1755. return options.complete(err);
  1756. }
  1757. var updatedContent = applyPatch(data, index, options);
  1758. options.patched(index, updatedContent, function (err) {
  1759. if (err) {
  1760. return options.complete(err);
  1761. }
  1762. processIndex();
  1763. });
  1764. });
  1765. }
  1766. processIndex();
  1767. }
  1768. var apply = /*#__PURE__*/Object.defineProperty({
  1769. applyPatch: applyPatch_1,
  1770. applyPatches: applyPatches_1
  1771. }, '__esModule', {
  1772. value: true
  1773. });
  1774. /*istanbul ignore start*/
  1775. var structuredPatch_1 = structuredPatch;
  1776. var formatPatch_1 = formatPatch;
  1777. var createTwoFilesPatch_1 = createTwoFilesPatch;
  1778. var createPatch_1 = createPatch;
  1779. /*istanbul ignore end*/
  1780. /*istanbul ignore start*/
  1781. function _toConsumableArray$1(arr) {
  1782. return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
  1783. }
  1784. function _nonIterableSpread$1() {
  1785. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1786. }
  1787. function _unsupportedIterableToArray$1(o, minLen) {
  1788. if (!o) return;
  1789. if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
  1790. var n = Object.prototype.toString.call(o).slice(8, -1);
  1791. if (n === "Object" && o.constructor) n = o.constructor.name;
  1792. if (n === "Map" || n === "Set") return Array.from(o);
  1793. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
  1794. }
  1795. function _iterableToArray$1(iter) {
  1796. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  1797. }
  1798. function _arrayWithoutHoles$1(arr) {
  1799. if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
  1800. }
  1801. function _arrayLikeToArray$1(arr, len) {
  1802. if (len == null || len > arr.length) len = arr.length;
  1803. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1804. arr2[i] = arr[i];
  1805. }
  1806. return arr2;
  1807. }
  1808. /*istanbul ignore end*/
  1809. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1810. if (!options) {
  1811. options = {};
  1812. }
  1813. if (typeof options.context === 'undefined') {
  1814. options.context = 4;
  1815. }
  1816. var diff =
  1817. /*istanbul ignore start*/
  1818. (/*istanbul ignore end*/
  1819. /*istanbul ignore start*/
  1820. 0, line$B
  1821. /*istanbul ignore end*/
  1822. .
  1823. /*istanbul ignore start*/
  1824. diffLines
  1825. /*istanbul ignore end*/
  1826. )(oldStr, newStr, options);
  1827. diff.push({
  1828. value: '',
  1829. lines: []
  1830. }); // Append an empty value to make cleanup easier
  1831. function contextLines(lines) {
  1832. return lines.map(function (entry) {
  1833. return ' ' + entry;
  1834. });
  1835. }
  1836. var hunks = [];
  1837. var oldRangeStart = 0,
  1838. newRangeStart = 0,
  1839. curRange = [],
  1840. oldLine = 1,
  1841. newLine = 1;
  1842. /*istanbul ignore start*/
  1843. var _loop = function _loop(
  1844. /*istanbul ignore end*/
  1845. i) {
  1846. var current = diff[i],
  1847. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1848. current.lines = lines;
  1849. if (current.added || current.removed) {
  1850. /*istanbul ignore start*/
  1851. var _curRange;
  1852. /*istanbul ignore end*/
  1853. // If we have previous context, start with that
  1854. if (!oldRangeStart) {
  1855. var prev = diff[i - 1];
  1856. oldRangeStart = oldLine;
  1857. newRangeStart = newLine;
  1858. if (prev) {
  1859. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1860. oldRangeStart -= curRange.length;
  1861. newRangeStart -= curRange.length;
  1862. }
  1863. } // Output our changes
  1864. /*istanbul ignore start*/
  1865. /*istanbul ignore end*/
  1866. /*istanbul ignore start*/
  1867. (_curRange =
  1868. /*istanbul ignore end*/
  1869. curRange).push.apply(
  1870. /*istanbul ignore start*/
  1871. _curRange
  1872. /*istanbul ignore end*/
  1873. ,
  1874. /*istanbul ignore start*/
  1875. _toConsumableArray$1(
  1876. /*istanbul ignore end*/
  1877. lines.map(function (entry) {
  1878. return (current.added ? '+' : '-') + entry;
  1879. }))); // Track the updated file position
  1880. if (current.added) {
  1881. newLine += lines.length;
  1882. } else {
  1883. oldLine += lines.length;
  1884. }
  1885. } else {
  1886. // Identical context lines. Track line changes
  1887. if (oldRangeStart) {
  1888. // Close out any changes that have been output (or join overlapping)
  1889. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1890. /*istanbul ignore start*/
  1891. var _curRange2;
  1892. /*istanbul ignore end*/
  1893. // Overlapping
  1894. /*istanbul ignore start*/
  1895. /*istanbul ignore end*/
  1896. /*istanbul ignore start*/
  1897. (_curRange2 =
  1898. /*istanbul ignore end*/
  1899. curRange).push.apply(
  1900. /*istanbul ignore start*/
  1901. _curRange2
  1902. /*istanbul ignore end*/
  1903. ,
  1904. /*istanbul ignore start*/
  1905. _toConsumableArray$1(
  1906. /*istanbul ignore end*/
  1907. contextLines(lines)));
  1908. } else {
  1909. /*istanbul ignore start*/
  1910. var _curRange3;
  1911. /*istanbul ignore end*/
  1912. // end the range and output
  1913. var contextSize = Math.min(lines.length, options.context);
  1914. /*istanbul ignore start*/
  1915. /*istanbul ignore end*/
  1916. /*istanbul ignore start*/
  1917. (_curRange3 =
  1918. /*istanbul ignore end*/
  1919. curRange).push.apply(
  1920. /*istanbul ignore start*/
  1921. _curRange3
  1922. /*istanbul ignore end*/
  1923. ,
  1924. /*istanbul ignore start*/
  1925. _toConsumableArray$1(
  1926. /*istanbul ignore end*/
  1927. contextLines(lines.slice(0, contextSize))));
  1928. var hunk = {
  1929. oldStart: oldRangeStart,
  1930. oldLines: oldLine - oldRangeStart + contextSize,
  1931. newStart: newRangeStart,
  1932. newLines: newLine - newRangeStart + contextSize,
  1933. lines: curRange
  1934. };
  1935. if (i >= diff.length - 2 && lines.length <= options.context) {
  1936. // EOF is inside this hunk
  1937. var oldEOFNewline = /\n$/.test(oldStr);
  1938. var newEOFNewline = /\n$/.test(newStr);
  1939. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  1940. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  1941. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1942. // however, if the old file is empty, do not output the no-nl line
  1943. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1944. }
  1945. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  1946. curRange.push('\\ No newline at end of file');
  1947. }
  1948. }
  1949. hunks.push(hunk);
  1950. oldRangeStart = 0;
  1951. newRangeStart = 0;
  1952. curRange = [];
  1953. }
  1954. }
  1955. oldLine += lines.length;
  1956. newLine += lines.length;
  1957. }
  1958. };
  1959. for (var i = 0; i < diff.length; i++) {
  1960. /*istanbul ignore start*/
  1961. _loop(
  1962. /*istanbul ignore end*/
  1963. i);
  1964. }
  1965. return {
  1966. oldFileName: oldFileName,
  1967. newFileName: newFileName,
  1968. oldHeader: oldHeader,
  1969. newHeader: newHeader,
  1970. hunks: hunks
  1971. };
  1972. }
  1973. function formatPatch(diff) {
  1974. var ret = [];
  1975. if (diff.oldFileName == diff.newFileName) {
  1976. ret.push('Index: ' + diff.oldFileName);
  1977. }
  1978. ret.push('===================================================================');
  1979. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1980. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1981. for (var i = 0; i < diff.hunks.length; i++) {
  1982. var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
  1983. // the first number is one lower than one would expect.
  1984. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  1985. if (hunk.oldLines === 0) {
  1986. hunk.oldStart -= 1;
  1987. }
  1988. if (hunk.newLines === 0) {
  1989. hunk.newStart -= 1;
  1990. }
  1991. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1992. ret.push.apply(ret, hunk.lines);
  1993. }
  1994. return ret.join('\n') + '\n';
  1995. }
  1996. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1997. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  1998. }
  1999. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  2000. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  2001. }
  2002. var create = /*#__PURE__*/Object.defineProperty({
  2003. structuredPatch: structuredPatch_1,
  2004. formatPatch: formatPatch_1,
  2005. createTwoFilesPatch: createTwoFilesPatch_1,
  2006. createPatch: createPatch_1
  2007. }, '__esModule', {
  2008. value: true
  2009. });
  2010. /*istanbul ignore start*/
  2011. var arrayEqual_1 = arrayEqual;
  2012. var arrayStartsWith_1 = arrayStartsWith;
  2013. /*istanbul ignore end*/
  2014. function arrayEqual(a, b) {
  2015. if (a.length !== b.length) {
  2016. return false;
  2017. }
  2018. return arrayStartsWith(a, b);
  2019. }
  2020. function arrayStartsWith(array, start) {
  2021. if (start.length > array.length) {
  2022. return false;
  2023. }
  2024. for (var i = 0; i < start.length; i++) {
  2025. if (start[i] !== array[i]) {
  2026. return false;
  2027. }
  2028. }
  2029. return true;
  2030. }
  2031. var array$4 = /*#__PURE__*/Object.defineProperty({
  2032. arrayEqual: arrayEqual_1,
  2033. arrayStartsWith: arrayStartsWith_1
  2034. }, '__esModule', {
  2035. value: true
  2036. });
  2037. /*istanbul ignore start*/
  2038. var calcLineCount_1 = calcLineCount;
  2039. var merge_2 = merge;
  2040. /*istanbul ignore end*/
  2041. /*istanbul ignore start*/
  2042. function _toConsumableArray(arr) {
  2043. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  2044. }
  2045. function _nonIterableSpread() {
  2046. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2047. }
  2048. function _unsupportedIterableToArray(o, minLen) {
  2049. if (!o) return;
  2050. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2051. var n = Object.prototype.toString.call(o).slice(8, -1);
  2052. if (n === "Object" && o.constructor) n = o.constructor.name;
  2053. if (n === "Map" || n === "Set") return Array.from(o);
  2054. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2055. }
  2056. function _iterableToArray(iter) {
  2057. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  2058. }
  2059. function _arrayWithoutHoles(arr) {
  2060. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  2061. }
  2062. function _arrayLikeToArray(arr, len) {
  2063. if (len == null || len > arr.length) len = arr.length;
  2064. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2065. arr2[i] = arr[i];
  2066. }
  2067. return arr2;
  2068. }
  2069. /*istanbul ignore end*/
  2070. function calcLineCount(hunk) {
  2071. /*istanbul ignore start*/
  2072. var _calcOldNewLineCount =
  2073. /*istanbul ignore end*/
  2074. calcOldNewLineCount(hunk.lines),
  2075. oldLines = _calcOldNewLineCount.oldLines,
  2076. newLines = _calcOldNewLineCount.newLines;
  2077. if (oldLines !== undefined) {
  2078. hunk.oldLines = oldLines;
  2079. } else {
  2080. delete hunk.oldLines;
  2081. }
  2082. if (newLines !== undefined) {
  2083. hunk.newLines = newLines;
  2084. } else {
  2085. delete hunk.newLines;
  2086. }
  2087. }
  2088. function merge(mine, theirs, base) {
  2089. mine = loadPatch(mine, base);
  2090. theirs = loadPatch(theirs, base);
  2091. var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
  2092. // Leaving sanity checks on this to the API consumer that may know more about the
  2093. // meaning in their own context.
  2094. if (mine.index || theirs.index) {
  2095. ret.index = mine.index || theirs.index;
  2096. }
  2097. if (mine.newFileName || theirs.newFileName) {
  2098. if (!fileNameChanged(mine)) {
  2099. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  2100. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  2101. ret.newFileName = theirs.newFileName || mine.newFileName;
  2102. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  2103. ret.newHeader = theirs.newHeader || mine.newHeader;
  2104. } else if (!fileNameChanged(theirs)) {
  2105. // No header or no change in theirs, use ours
  2106. ret.oldFileName = mine.oldFileName;
  2107. ret.newFileName = mine.newFileName;
  2108. ret.oldHeader = mine.oldHeader;
  2109. ret.newHeader = mine.newHeader;
  2110. } else {
  2111. // Both changed... figure it out
  2112. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  2113. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  2114. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  2115. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  2116. }
  2117. }
  2118. ret.hunks = [];
  2119. var mineIndex = 0,
  2120. theirsIndex = 0,
  2121. mineOffset = 0,
  2122. theirsOffset = 0;
  2123. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  2124. var mineCurrent = mine.hunks[mineIndex] || {
  2125. oldStart: Infinity
  2126. },
  2127. theirsCurrent = theirs.hunks[theirsIndex] || {
  2128. oldStart: Infinity
  2129. };
  2130. if (hunkBefore(mineCurrent, theirsCurrent)) {
  2131. // This patch does not overlap with any of the others, yay.
  2132. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  2133. mineIndex++;
  2134. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  2135. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  2136. // This patch does not overlap with any of the others, yay.
  2137. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  2138. theirsIndex++;
  2139. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  2140. } else {
  2141. // Overlap, merge as best we can
  2142. var mergedHunk = {
  2143. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  2144. oldLines: 0,
  2145. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  2146. newLines: 0,
  2147. lines: []
  2148. };
  2149. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  2150. theirsIndex++;
  2151. mineIndex++;
  2152. ret.hunks.push(mergedHunk);
  2153. }
  2154. }
  2155. return ret;
  2156. }
  2157. function loadPatch(param, base) {
  2158. if (typeof param === 'string') {
  2159. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  2160. return (
  2161. /*istanbul ignore start*/
  2162. (/*istanbul ignore end*/
  2163. /*istanbul ignore start*/
  2164. 0, parse$b
  2165. /*istanbul ignore end*/
  2166. .
  2167. /*istanbul ignore start*/
  2168. parsePatch
  2169. /*istanbul ignore end*/
  2170. )(param)[0]
  2171. );
  2172. }
  2173. if (!base) {
  2174. throw new Error('Must provide a base reference or pass in a patch');
  2175. }
  2176. return (
  2177. /*istanbul ignore start*/
  2178. (/*istanbul ignore end*/
  2179. /*istanbul ignore start*/
  2180. 0, create
  2181. /*istanbul ignore end*/
  2182. .
  2183. /*istanbul ignore start*/
  2184. structuredPatch
  2185. /*istanbul ignore end*/
  2186. )(undefined, undefined, base, param)
  2187. );
  2188. }
  2189. return param;
  2190. }
  2191. function fileNameChanged(patch) {
  2192. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  2193. }
  2194. function selectField(index, mine, theirs) {
  2195. if (mine === theirs) {
  2196. return mine;
  2197. } else {
  2198. index.conflict = true;
  2199. return {
  2200. mine: mine,
  2201. theirs: theirs
  2202. };
  2203. }
  2204. }
  2205. function hunkBefore(test, check) {
  2206. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  2207. }
  2208. function cloneHunk(hunk, offset) {
  2209. return {
  2210. oldStart: hunk.oldStart,
  2211. oldLines: hunk.oldLines,
  2212. newStart: hunk.newStart + offset,
  2213. newLines: hunk.newLines,
  2214. lines: hunk.lines
  2215. };
  2216. }
  2217. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  2218. // This will generally result in a conflicted hunk, but there are cases where the context
  2219. // is the only overlap where we can successfully merge the content here.
  2220. var mine = {
  2221. offset: mineOffset,
  2222. lines: mineLines,
  2223. index: 0
  2224. },
  2225. their = {
  2226. offset: theirOffset,
  2227. lines: theirLines,
  2228. index: 0
  2229. }; // Handle any leading content
  2230. insertLeading(hunk, mine, their);
  2231. insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
  2232. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  2233. var mineCurrent = mine.lines[mine.index],
  2234. theirCurrent = their.lines[their.index];
  2235. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  2236. // Both modified ...
  2237. mutualChange(hunk, mine, their);
  2238. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  2239. /*istanbul ignore start*/
  2240. var _hunk$lines;
  2241. /*istanbul ignore end*/
  2242. // Mine inserted
  2243. /*istanbul ignore start*/
  2244. /*istanbul ignore end*/
  2245. /*istanbul ignore start*/
  2246. (_hunk$lines =
  2247. /*istanbul ignore end*/
  2248. hunk.lines).push.apply(
  2249. /*istanbul ignore start*/
  2250. _hunk$lines
  2251. /*istanbul ignore end*/
  2252. ,
  2253. /*istanbul ignore start*/
  2254. _toConsumableArray(
  2255. /*istanbul ignore end*/
  2256. collectChange(mine)));
  2257. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  2258. /*istanbul ignore start*/
  2259. var _hunk$lines2;
  2260. /*istanbul ignore end*/
  2261. // Theirs inserted
  2262. /*istanbul ignore start*/
  2263. /*istanbul ignore end*/
  2264. /*istanbul ignore start*/
  2265. (_hunk$lines2 =
  2266. /*istanbul ignore end*/
  2267. hunk.lines).push.apply(
  2268. /*istanbul ignore start*/
  2269. _hunk$lines2
  2270. /*istanbul ignore end*/
  2271. ,
  2272. /*istanbul ignore start*/
  2273. _toConsumableArray(
  2274. /*istanbul ignore end*/
  2275. collectChange(their)));
  2276. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  2277. // Mine removed or edited
  2278. removal(hunk, mine, their);
  2279. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  2280. // Their removed or edited
  2281. removal(hunk, their, mine, true);
  2282. } else if (mineCurrent === theirCurrent) {
  2283. // Context identity
  2284. hunk.lines.push(mineCurrent);
  2285. mine.index++;
  2286. their.index++;
  2287. } else {
  2288. // Context mismatch
  2289. conflict(hunk, collectChange(mine), collectChange(their));
  2290. }
  2291. } // Now push anything that may be remaining
  2292. insertTrailing(hunk, mine);
  2293. insertTrailing(hunk, their);
  2294. calcLineCount(hunk);
  2295. }
  2296. function mutualChange(hunk, mine, their) {
  2297. var myChanges = collectChange(mine),
  2298. theirChanges = collectChange(their);
  2299. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  2300. // Special case for remove changes that are supersets of one another
  2301. if (
  2302. /*istanbul ignore start*/
  2303. (/*istanbul ignore end*/
  2304. /*istanbul ignore start*/
  2305. 0, array$4
  2306. /*istanbul ignore end*/
  2307. .
  2308. /*istanbul ignore start*/
  2309. arrayStartsWith
  2310. /*istanbul ignore end*/
  2311. )(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  2312. /*istanbul ignore start*/
  2313. var _hunk$lines3;
  2314. /*istanbul ignore end*/
  2315. /*istanbul ignore start*/
  2316. /*istanbul ignore end*/
  2317. /*istanbul ignore start*/
  2318. (_hunk$lines3 =
  2319. /*istanbul ignore end*/
  2320. hunk.lines).push.apply(
  2321. /*istanbul ignore start*/
  2322. _hunk$lines3
  2323. /*istanbul ignore end*/
  2324. ,
  2325. /*istanbul ignore start*/
  2326. _toConsumableArray(
  2327. /*istanbul ignore end*/
  2328. myChanges));
  2329. return;
  2330. } else if (
  2331. /*istanbul ignore start*/
  2332. (/*istanbul ignore end*/
  2333. /*istanbul ignore start*/
  2334. 0, array$4
  2335. /*istanbul ignore end*/
  2336. .
  2337. /*istanbul ignore start*/
  2338. arrayStartsWith
  2339. /*istanbul ignore end*/
  2340. )(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  2341. /*istanbul ignore start*/
  2342. var _hunk$lines4;
  2343. /*istanbul ignore end*/
  2344. /*istanbul ignore start*/
  2345. /*istanbul ignore end*/
  2346. /*istanbul ignore start*/
  2347. (_hunk$lines4 =
  2348. /*istanbul ignore end*/
  2349. hunk.lines).push.apply(
  2350. /*istanbul ignore start*/
  2351. _hunk$lines4
  2352. /*istanbul ignore end*/
  2353. ,
  2354. /*istanbul ignore start*/
  2355. _toConsumableArray(
  2356. /*istanbul ignore end*/
  2357. theirChanges));
  2358. return;
  2359. }
  2360. } else if (
  2361. /*istanbul ignore start*/
  2362. (/*istanbul ignore end*/
  2363. /*istanbul ignore start*/
  2364. 0, array$4
  2365. /*istanbul ignore end*/
  2366. .
  2367. /*istanbul ignore start*/
  2368. arrayEqual
  2369. /*istanbul ignore end*/
  2370. )(myChanges, theirChanges)) {
  2371. /*istanbul ignore start*/
  2372. var _hunk$lines5;
  2373. /*istanbul ignore end*/
  2374. /*istanbul ignore start*/
  2375. /*istanbul ignore end*/
  2376. /*istanbul ignore start*/
  2377. (_hunk$lines5 =
  2378. /*istanbul ignore end*/
  2379. hunk.lines).push.apply(
  2380. /*istanbul ignore start*/
  2381. _hunk$lines5
  2382. /*istanbul ignore end*/
  2383. ,
  2384. /*istanbul ignore start*/
  2385. _toConsumableArray(
  2386. /*istanbul ignore end*/
  2387. myChanges));
  2388. return;
  2389. }
  2390. conflict(hunk, myChanges, theirChanges);
  2391. }
  2392. function removal(hunk, mine, their, swap) {
  2393. var myChanges = collectChange(mine),
  2394. theirChanges = collectContext(their, myChanges);
  2395. if (theirChanges.merged) {
  2396. /*istanbul ignore start*/
  2397. var _hunk$lines6;
  2398. /*istanbul ignore end*/
  2399. /*istanbul ignore start*/
  2400. /*istanbul ignore end*/
  2401. /*istanbul ignore start*/
  2402. (_hunk$lines6 =
  2403. /*istanbul ignore end*/
  2404. hunk.lines).push.apply(
  2405. /*istanbul ignore start*/
  2406. _hunk$lines6
  2407. /*istanbul ignore end*/
  2408. ,
  2409. /*istanbul ignore start*/
  2410. _toConsumableArray(
  2411. /*istanbul ignore end*/
  2412. theirChanges.merged));
  2413. } else {
  2414. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  2415. }
  2416. }
  2417. function conflict(hunk, mine, their) {
  2418. hunk.conflict = true;
  2419. hunk.lines.push({
  2420. conflict: true,
  2421. mine: mine,
  2422. theirs: their
  2423. });
  2424. }
  2425. function insertLeading(hunk, insert, their) {
  2426. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  2427. var line = insert.lines[insert.index++];
  2428. hunk.lines.push(line);
  2429. insert.offset++;
  2430. }
  2431. }
  2432. function insertTrailing(hunk, insert) {
  2433. while (insert.index < insert.lines.length) {
  2434. var line = insert.lines[insert.index++];
  2435. hunk.lines.push(line);
  2436. }
  2437. }
  2438. function collectChange(state) {
  2439. var ret = [],
  2440. operation = state.lines[state.index][0];
  2441. while (state.index < state.lines.length) {
  2442. var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  2443. if (operation === '-' && line[0] === '+') {
  2444. operation = '+';
  2445. }
  2446. if (operation === line[0]) {
  2447. ret.push(line);
  2448. state.index++;
  2449. } else {
  2450. break;
  2451. }
  2452. }
  2453. return ret;
  2454. }
  2455. function collectContext(state, matchChanges) {
  2456. var changes = [],
  2457. merged = [],
  2458. matchIndex = 0,
  2459. contextChanges = false,
  2460. conflicted = false;
  2461. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  2462. var change = state.lines[state.index],
  2463. match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
  2464. if (match[0] === '+') {
  2465. break;
  2466. }
  2467. contextChanges = contextChanges || change[0] !== ' ';
  2468. merged.push(match);
  2469. matchIndex++; // Consume any additions in the other block as a conflict to attempt
  2470. // to pull in the remaining context after this
  2471. if (change[0] === '+') {
  2472. conflicted = true;
  2473. while (change[0] === '+') {
  2474. changes.push(change);
  2475. change = state.lines[++state.index];
  2476. }
  2477. }
  2478. if (match.substr(1) === change.substr(1)) {
  2479. changes.push(change);
  2480. state.index++;
  2481. } else {
  2482. conflicted = true;
  2483. }
  2484. }
  2485. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  2486. conflicted = true;
  2487. }
  2488. if (conflicted) {
  2489. return changes;
  2490. }
  2491. while (matchIndex < matchChanges.length) {
  2492. merged.push(matchChanges[matchIndex++]);
  2493. }
  2494. return {
  2495. merged: merged,
  2496. changes: changes
  2497. };
  2498. }
  2499. function allRemoves(changes) {
  2500. return changes.reduce(function (prev, change) {
  2501. return prev && change[0] === '-';
  2502. }, true);
  2503. }
  2504. function skipRemoveSuperset(state, removeChanges, delta) {
  2505. for (var i = 0; i < delta; i++) {
  2506. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  2507. if (state.lines[state.index + i] !== ' ' + changeContent) {
  2508. return false;
  2509. }
  2510. }
  2511. state.index += delta;
  2512. return true;
  2513. }
  2514. function calcOldNewLineCount(lines) {
  2515. var oldLines = 0;
  2516. var newLines = 0;
  2517. lines.forEach(function (line) {
  2518. if (typeof line !== 'string') {
  2519. var myCount = calcOldNewLineCount(line.mine);
  2520. var theirCount = calcOldNewLineCount(line.theirs);
  2521. if (oldLines !== undefined) {
  2522. if (myCount.oldLines === theirCount.oldLines) {
  2523. oldLines += myCount.oldLines;
  2524. } else {
  2525. oldLines = undefined;
  2526. }
  2527. }
  2528. if (newLines !== undefined) {
  2529. if (myCount.newLines === theirCount.newLines) {
  2530. newLines += myCount.newLines;
  2531. } else {
  2532. newLines = undefined;
  2533. }
  2534. }
  2535. } else {
  2536. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  2537. newLines++;
  2538. }
  2539. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  2540. oldLines++;
  2541. }
  2542. }
  2543. });
  2544. return {
  2545. oldLines: oldLines,
  2546. newLines: newLines
  2547. };
  2548. }
  2549. var merge_1 = /*#__PURE__*/Object.defineProperty({
  2550. calcLineCount: calcLineCount_1,
  2551. merge: merge_2
  2552. }, '__esModule', {
  2553. value: true
  2554. });
  2555. /*istanbul ignore start*/
  2556. var convertChangesToDMP_1 = convertChangesToDMP;
  2557. /*istanbul ignore end*/
  2558. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  2559. function convertChangesToDMP(changes) {
  2560. var ret = [],
  2561. change,
  2562. operation;
  2563. for (var i = 0; i < changes.length; i++) {
  2564. change = changes[i];
  2565. if (change.added) {
  2566. operation = 1;
  2567. } else if (change.removed) {
  2568. operation = -1;
  2569. } else {
  2570. operation = 0;
  2571. }
  2572. ret.push([operation, change.value]);
  2573. }
  2574. return ret;
  2575. }
  2576. var dmp = /*#__PURE__*/Object.defineProperty({
  2577. convertChangesToDMP: convertChangesToDMP_1
  2578. }, '__esModule', {
  2579. value: true
  2580. });
  2581. /*istanbul ignore start*/
  2582. var convertChangesToXML_1 = convertChangesToXML;
  2583. /*istanbul ignore end*/
  2584. function convertChangesToXML(changes) {
  2585. var ret = [];
  2586. for (var i = 0; i < changes.length; i++) {
  2587. var change = changes[i];
  2588. if (change.added) {
  2589. ret.push('<ins>');
  2590. } else if (change.removed) {
  2591. ret.push('<del>');
  2592. }
  2593. ret.push(escapeHTML(change.value));
  2594. if (change.added) {
  2595. ret.push('</ins>');
  2596. } else if (change.removed) {
  2597. ret.push('</del>');
  2598. }
  2599. }
  2600. return ret.join('');
  2601. }
  2602. function escapeHTML(s) {
  2603. var n = s;
  2604. n = n.replace(/&/g, '&amp;');
  2605. n = n.replace(/</g, '&lt;');
  2606. n = n.replace(/>/g, '&gt;');
  2607. n = n.replace(/"/g, '&quot;');
  2608. return n;
  2609. }
  2610. var xml = /*#__PURE__*/Object.defineProperty({
  2611. convertChangesToXML: convertChangesToXML_1
  2612. }, '__esModule', {
  2613. value: true
  2614. });
  2615. /*istanbul ignore start*/
  2616. var lib$6 = createCommonjsModule(function (module, exports) {
  2617. Object.defineProperty(exports, "__esModule", {
  2618. value: true
  2619. });
  2620. Object.defineProperty(exports, "Diff", {
  2621. enumerable: true,
  2622. get: function get() {
  2623. return _base["default"];
  2624. }
  2625. });
  2626. Object.defineProperty(exports, "diffChars", {
  2627. enumerable: true,
  2628. get: function get() {
  2629. return character.diffChars;
  2630. }
  2631. });
  2632. Object.defineProperty(exports, "diffWords", {
  2633. enumerable: true,
  2634. get: function get() {
  2635. return word.diffWords;
  2636. }
  2637. });
  2638. Object.defineProperty(exports, "diffWordsWithSpace", {
  2639. enumerable: true,
  2640. get: function get() {
  2641. return word.diffWordsWithSpace;
  2642. }
  2643. });
  2644. Object.defineProperty(exports, "diffLines", {
  2645. enumerable: true,
  2646. get: function get() {
  2647. return line$B.diffLines;
  2648. }
  2649. });
  2650. Object.defineProperty(exports, "diffTrimmedLines", {
  2651. enumerable: true,
  2652. get: function get() {
  2653. return line$B.diffTrimmedLines;
  2654. }
  2655. });
  2656. Object.defineProperty(exports, "diffSentences", {
  2657. enumerable: true,
  2658. get: function get() {
  2659. return sentence.diffSentences;
  2660. }
  2661. });
  2662. Object.defineProperty(exports, "diffCss", {
  2663. enumerable: true,
  2664. get: function get() {
  2665. return css$1.diffCss;
  2666. }
  2667. });
  2668. Object.defineProperty(exports, "diffJson", {
  2669. enumerable: true,
  2670. get: function get() {
  2671. return json.diffJson;
  2672. }
  2673. });
  2674. Object.defineProperty(exports, "canonicalize", {
  2675. enumerable: true,
  2676. get: function get() {
  2677. return json.canonicalize;
  2678. }
  2679. });
  2680. Object.defineProperty(exports, "diffArrays", {
  2681. enumerable: true,
  2682. get: function get() {
  2683. return array$5.diffArrays;
  2684. }
  2685. });
  2686. Object.defineProperty(exports, "applyPatch", {
  2687. enumerable: true,
  2688. get: function get() {
  2689. return apply.applyPatch;
  2690. }
  2691. });
  2692. Object.defineProperty(exports, "applyPatches", {
  2693. enumerable: true,
  2694. get: function get() {
  2695. return apply.applyPatches;
  2696. }
  2697. });
  2698. Object.defineProperty(exports, "parsePatch", {
  2699. enumerable: true,
  2700. get: function get() {
  2701. return parse$b.parsePatch;
  2702. }
  2703. });
  2704. Object.defineProperty(exports, "merge", {
  2705. enumerable: true,
  2706. get: function get() {
  2707. return merge_1.merge;
  2708. }
  2709. });
  2710. Object.defineProperty(exports, "structuredPatch", {
  2711. enumerable: true,
  2712. get: function get() {
  2713. return create.structuredPatch;
  2714. }
  2715. });
  2716. Object.defineProperty(exports, "createTwoFilesPatch", {
  2717. enumerable: true,
  2718. get: function get() {
  2719. return create.createTwoFilesPatch;
  2720. }
  2721. });
  2722. Object.defineProperty(exports, "createPatch", {
  2723. enumerable: true,
  2724. get: function get() {
  2725. return create.createPatch;
  2726. }
  2727. });
  2728. Object.defineProperty(exports, "convertChangesToDMP", {
  2729. enumerable: true,
  2730. get: function get() {
  2731. return dmp.convertChangesToDMP;
  2732. }
  2733. });
  2734. Object.defineProperty(exports, "convertChangesToXML", {
  2735. enumerable: true,
  2736. get: function get() {
  2737. return xml.convertChangesToXML;
  2738. }
  2739. });
  2740. /*istanbul ignore end*/
  2741. var
  2742. /*istanbul ignore start*/
  2743. _base = _interopRequireDefault(base$1)
  2744. /*istanbul ignore end*/
  2745. ;
  2746. /*istanbul ignore start*/
  2747. function _interopRequireDefault(obj) {
  2748. return obj && obj.__esModule ? obj : {
  2749. "default": obj
  2750. };
  2751. }
  2752. /*istanbul ignore end*/
  2753. });
  2754. var doc = require("./doc.js");
  2755. var ansiRegex = ({
  2756. onlyFirst = false
  2757. } = {}) => {
  2758. const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  2759. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  2760. };
  2761. var stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
  2762. /* eslint-disable yoda */
  2763. const isFullwidthCodePoint = codePoint => {
  2764. if (Number.isNaN(codePoint)) {
  2765. return false;
  2766. } // Code points are derived from:
  2767. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  2768. if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
  2769. codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  2770. codePoint === 0x232A || 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || 0x3250 <= codePoint && codePoint <= 0x4DBF || 0x4E00 <= codePoint && codePoint <= 0xA4C6 || 0xA960 <= codePoint && codePoint <= 0xA97C || 0xAC00 <= codePoint && codePoint <= 0xD7A3 || 0xF900 <= codePoint && codePoint <= 0xFAFF || 0xFE10 <= codePoint && codePoint <= 0xFE19 || 0xFE30 <= codePoint && codePoint <= 0xFE6B || 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || 0x1B000 <= codePoint && codePoint <= 0x1B001 || 0x1F200 <= codePoint && codePoint <= 0x1F251 || 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
  2771. return true;
  2772. }
  2773. return false;
  2774. };
  2775. var isFullwidthCodePoint_1 = isFullwidthCodePoint;
  2776. var _default$r = isFullwidthCodePoint;
  2777. isFullwidthCodePoint_1.default = _default$r;
  2778. var emojiRegex = function () {
  2779. // https://mths.be/emoji
  2780. return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
  2781. };
  2782. const stringWidth = string => {
  2783. if (typeof string !== 'string' || string.length === 0) {
  2784. return 0;
  2785. }
  2786. string = stripAnsi(string);
  2787. if (string.length === 0) {
  2788. return 0;
  2789. }
  2790. string = string.replace(emojiRegex(), ' ');
  2791. let width = 0;
  2792. for (let i = 0; i < string.length; i++) {
  2793. const code = string.codePointAt(i); // Ignore control characters
  2794. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  2795. continue;
  2796. } // Ignore combining characters
  2797. if (code >= 0x300 && code <= 0x36F) {
  2798. continue;
  2799. } // Surrogates
  2800. if (code > 0xFFFF) {
  2801. i++;
  2802. }
  2803. width += isFullwidthCodePoint_1(code) ? 2 : 1;
  2804. }
  2805. return width;
  2806. };
  2807. var stringWidth_1 = stringWidth; // TODO: remove this in the next major version
  2808. var _default$q = stringWidth;
  2809. stringWidth_1.default = _default$q;
  2810. var escapeStringRegexp$2 = string => {
  2811. if (typeof string !== 'string') {
  2812. throw new TypeError('Expected a string');
  2813. } // Escape characters with special meaning either inside or outside character sets.
  2814. // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
  2815. return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
  2816. };
  2817. const getLast$e = arr => arr[arr.length - 1];
  2818. var getLast_1 = getLast$e;
  2819. function _objectWithoutPropertiesLoose(source, excluded) {
  2820. if (source == null) return {};
  2821. var target = {};
  2822. var sourceKeys = Object.keys(source);
  2823. var key, i;
  2824. for (i = 0; i < sourceKeys.length; i++) {
  2825. key = sourceKeys[i];
  2826. if (excluded.indexOf(key) >= 0) continue;
  2827. target[key] = source[key];
  2828. }
  2829. return target;
  2830. }
  2831. function _objectWithoutProperties(source, excluded) {
  2832. if (source == null) return {};
  2833. var target = _objectWithoutPropertiesLoose(source, excluded);
  2834. var key, i;
  2835. if (Object.getOwnPropertySymbols) {
  2836. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  2837. for (i = 0; i < sourceSymbolKeys.length; i++) {
  2838. key = sourceSymbolKeys[i];
  2839. if (excluded.indexOf(key) >= 0) continue;
  2840. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  2841. target[key] = source[key];
  2842. }
  2843. }
  2844. return target;
  2845. }
  2846. // `IsArray` abstract operation
  2847. // https://tc39.es/ecma262/#sec-isarray
  2848. // eslint-disable-next-line es/no-array-isarray -- safe
  2849. var isArray$3 = Array.isArray || function isArray(arg) {
  2850. return classofRaw(arg) == 'Array';
  2851. };
  2852. // optional / simple context binding
  2853. var functionBindContext = function (fn, that, length) {
  2854. aFunction(fn);
  2855. if (that === undefined) return fn;
  2856. switch (length) {
  2857. case 0: return function () {
  2858. return fn.call(that);
  2859. };
  2860. case 1: return function (a) {
  2861. return fn.call(that, a);
  2862. };
  2863. case 2: return function (a, b) {
  2864. return fn.call(that, a, b);
  2865. };
  2866. case 3: return function (a, b, c) {
  2867. return fn.call(that, a, b, c);
  2868. };
  2869. }
  2870. return function (/* ...args */) {
  2871. return fn.apply(that, arguments);
  2872. };
  2873. };
  2874. // `FlattenIntoArray` abstract operation
  2875. // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
  2876. var flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
  2877. var targetIndex = start;
  2878. var sourceIndex = 0;
  2879. var mapFn = mapper ? functionBindContext(mapper, thisArg, 3) : false;
  2880. var element;
  2881. while (sourceIndex < sourceLen) {
  2882. if (sourceIndex in source) {
  2883. element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
  2884. if (depth > 0 && isArray$3(element)) {
  2885. targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
  2886. } else {
  2887. if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');
  2888. target[targetIndex] = element;
  2889. }
  2890. targetIndex++;
  2891. }
  2892. sourceIndex++;
  2893. }
  2894. return targetIndex;
  2895. };
  2896. var flattenIntoArray_1 = flattenIntoArray;
  2897. var SPECIES = wellKnownSymbol('species');
  2898. // a part of `ArraySpeciesCreate` abstract operation
  2899. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  2900. var arraySpeciesConstructor = function (originalArray) {
  2901. var C;
  2902. if (isArray$3(originalArray)) {
  2903. C = originalArray.constructor;
  2904. // cross-realm fallback
  2905. if (typeof C == 'function' && (C === Array || isArray$3(C.prototype))) C = undefined;
  2906. else if (isObject$3(C)) {
  2907. C = C[SPECIES];
  2908. if (C === null) C = undefined;
  2909. }
  2910. } return C === undefined ? Array : C;
  2911. };
  2912. // `ArraySpeciesCreate` abstract operation
  2913. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  2914. var arraySpeciesCreate = function (originalArray, length) {
  2915. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  2916. };
  2917. // `Array.prototype.flatMap` method
  2918. // https://tc39.es/ecma262/#sec-array.prototype.flatmap
  2919. _export({ target: 'Array', proto: true }, {
  2920. flatMap: function flatMap(callbackfn /* , thisArg */) {
  2921. var O = toObject(this);
  2922. var sourceLen = toLength(O.length);
  2923. var A;
  2924. aFunction(callbackfn);
  2925. A = arraySpeciesCreate(O, 0);
  2926. A.length = flattenIntoArray_1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2927. return A;
  2928. }
  2929. });
  2930. var iterators = {};
  2931. var ITERATOR$1 = wellKnownSymbol('iterator');
  2932. var ArrayPrototype = Array.prototype;
  2933. // check on default Array iterator
  2934. var isArrayIteratorMethod = function (it) {
  2935. return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$1] === it);
  2936. };
  2937. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  2938. var test = {};
  2939. test[TO_STRING_TAG$1] = 'z';
  2940. var toStringTagSupport = String(test) === '[object z]';
  2941. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2942. // ES3 wrong here
  2943. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  2944. // fallback for IE11 Script Access Denied error
  2945. var tryGet = function (it, key) {
  2946. try {
  2947. return it[key];
  2948. } catch (error) { /* empty */ }
  2949. };
  2950. // getting tag from ES6+ `Object.prototype.toString`
  2951. var classof = toStringTagSupport ? classofRaw : function (it) {
  2952. var O, tag, result;
  2953. return it === undefined ? 'Undefined' : it === null ? 'Null'
  2954. // @@toStringTag case
  2955. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  2956. // builtinTag case
  2957. : CORRECT_ARGUMENTS ? classofRaw(O)
  2958. // ES3 arguments fallback
  2959. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  2960. };
  2961. var ITERATOR = wellKnownSymbol('iterator');
  2962. var getIteratorMethod = function (it) {
  2963. if (it != undefined) return it[ITERATOR]
  2964. || it['@@iterator']
  2965. || iterators[classof(it)];
  2966. };
  2967. var getIterator = function (it, usingIterator) {
  2968. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(it) : usingIterator;
  2969. if (typeof iteratorMethod != 'function') {
  2970. throw TypeError(String(it) + ' is not iterable');
  2971. } return anObject(iteratorMethod.call(it));
  2972. };
  2973. var iteratorClose = function (iterator, kind, value) {
  2974. var innerResult, innerError;
  2975. anObject(iterator);
  2976. try {
  2977. innerResult = iterator['return'];
  2978. if (innerResult === undefined) {
  2979. if (kind === 'throw') throw value;
  2980. return value;
  2981. }
  2982. innerResult = innerResult.call(iterator);
  2983. } catch (error) {
  2984. innerError = true;
  2985. innerResult = error;
  2986. }
  2987. if (kind === 'throw') throw value;
  2988. if (innerError) throw innerResult;
  2989. anObject(innerResult);
  2990. return value;
  2991. };
  2992. var Result = function (stopped, result) {
  2993. this.stopped = stopped;
  2994. this.result = result;
  2995. };
  2996. var iterate = function (iterable, unboundFunction, options) {
  2997. var that = options && options.that;
  2998. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  2999. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  3000. var INTERRUPTED = !!(options && options.INTERRUPTED);
  3001. var fn = functionBindContext(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
  3002. var iterator, iterFn, index, length, result, next, step;
  3003. var stop = function (condition) {
  3004. if (iterator) iteratorClose(iterator, 'normal', condition);
  3005. return new Result(true, condition);
  3006. };
  3007. var callFn = function (value) {
  3008. if (AS_ENTRIES) {
  3009. anObject(value);
  3010. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  3011. } return INTERRUPTED ? fn(value, stop) : fn(value);
  3012. };
  3013. if (IS_ITERATOR) {
  3014. iterator = iterable;
  3015. } else {
  3016. iterFn = getIteratorMethod(iterable);
  3017. if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
  3018. // optimisation for array iterators
  3019. if (isArrayIteratorMethod(iterFn)) {
  3020. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  3021. result = callFn(iterable[index]);
  3022. if (result && result instanceof Result) return result;
  3023. } return new Result(false);
  3024. }
  3025. iterator = getIterator(iterable, iterFn);
  3026. }
  3027. next = iterator.next;
  3028. while (!(step = next.call(iterator)).done) {
  3029. try {
  3030. result = callFn(step.value);
  3031. } catch (error) {
  3032. iteratorClose(iterator, 'throw', error);
  3033. }
  3034. if (typeof result == 'object' && result && result instanceof Result) return result;
  3035. } return new Result(false);
  3036. };
  3037. var createProperty = function (object, key, value) {
  3038. var propertyKey = toPropertyKey(key);
  3039. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  3040. else object[propertyKey] = value;
  3041. };
  3042. // `Object.fromEntries` method
  3043. // https://github.com/tc39/proposal-object-from-entries
  3044. _export({ target: 'Object', stat: true }, {
  3045. fromEntries: function fromEntries(iterable) {
  3046. var obj = {};
  3047. iterate(iterable, function (k, v) {
  3048. createProperty(obj, k, v);
  3049. }, { AS_ENTRIES: true });
  3050. return obj;
  3051. }
  3052. });
  3053. const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
  3054. var debug_1 = debug;
  3055. // Note: this is the semver.org version of the spec that it implements
  3056. // Not necessarily the package version of this code.
  3057. const SEMVER_SPEC_VERSION = '2.0.0';
  3058. const MAX_LENGTH$3 = 256;
  3059. const MAX_SAFE_INTEGER$3 = Number.MAX_SAFE_INTEGER ||
  3060. /* istanbul ignore next */
  3061. 9007199254740991; // Max safe segment length for coercion.
  3062. const MAX_SAFE_COMPONENT_LENGTH = 16;
  3063. var constants$5 = {
  3064. SEMVER_SPEC_VERSION,
  3065. MAX_LENGTH: MAX_LENGTH$3,
  3066. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$3,
  3067. MAX_SAFE_COMPONENT_LENGTH
  3068. };
  3069. var re_1 = createCommonjsModule(function (module, exports) {
  3070. const {
  3071. MAX_SAFE_COMPONENT_LENGTH
  3072. } = constants$5;
  3073. exports = module.exports = {}; // The actual regexps go on exports.re
  3074. const re = exports.re = [];
  3075. const src = exports.src = [];
  3076. const t = exports.t = {};
  3077. let R = 0;
  3078. const createToken = (name, value, isGlobal) => {
  3079. const index = R++;
  3080. debug_1(index, value);
  3081. t[name] = index;
  3082. src[index] = value;
  3083. re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
  3084. }; // The following Regular Expressions can be used for tokenizing,
  3085. // validating, and parsing SemVer version strings.
  3086. // ## Numeric Identifier
  3087. // A single `0`, or a non-zero digit followed by zero or more digits.
  3088. createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
  3089. createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
  3090. // Zero or more digits, followed by a letter or hyphen, and then zero or
  3091. // more letters, digits, or hyphens.
  3092. createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
  3093. // Three dot-separated numeric identifiers.
  3094. createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
  3095. createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
  3096. // A numeric identifier, or a non-numeric identifier.
  3097. createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
  3098. createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
  3099. // Hyphen, followed by one or more dot-separated pre-release version
  3100. // identifiers.
  3101. createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
  3102. createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
  3103. // Any combination of digits, letters, or hyphens.
  3104. createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
  3105. // Plus sign, followed by one or more period-separated build metadata
  3106. // identifiers.
  3107. createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
  3108. // A main version, followed optionally by a pre-release version and
  3109. // build metadata.
  3110. // Note that the only major, minor, patch, and pre-release sections of
  3111. // the version string are capturing groups. The build metadata is not a
  3112. // capturing group, because it should not ever be used in version
  3113. // comparison.
  3114. createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
  3115. createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  3116. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  3117. // common in the npm registry.
  3118. createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
  3119. createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
  3120. createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
  3121. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  3122. // Only the first item is strictly required.
  3123. createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
  3124. createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
  3125. createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
  3126. createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
  3127. createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
  3128. createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
  3129. // Extract anything that could conceivably be a part of a valid semver
  3130. createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
  3131. createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
  3132. // Meaning is "reasonably at or greater than"
  3133. createToken('LONETILDE', '(?:~>?)');
  3134. createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
  3135. exports.tildeTrimReplace = '$1~';
  3136. createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
  3137. createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
  3138. // Meaning is "at least and backwards compatible with"
  3139. createToken('LONECARET', '(?:\\^)');
  3140. createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
  3141. exports.caretTrimReplace = '$1^';
  3142. createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
  3143. createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
  3144. createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
  3145. createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
  3146. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  3147. createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
  3148. exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  3149. // Note that these all use the loose form, because they'll be
  3150. // checked against either the strict or loose comparator form
  3151. // later.
  3152. createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
  3153. createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
  3154. createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
  3155. createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
  3156. createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
  3157. });
  3158. // parse out just the options we care about so we always get a consistent
  3159. // obj with keys in a consistent order.
  3160. const opts$1 = ['includePrerelease', 'loose', 'rtl'];
  3161. const parseOptions = options => !options ? {} : typeof options !== 'object' ? {
  3162. loose: true
  3163. } : opts$1.filter(k => options[k]).reduce((options, k) => {
  3164. options[k] = true;
  3165. return options;
  3166. }, {});
  3167. var parseOptions_1 = parseOptions;
  3168. const numeric$1 = /^[0-9]+$/;
  3169. const compareIdentifiers$1 = (a, b) => {
  3170. const anum = numeric$1.test(a);
  3171. const bnum = numeric$1.test(b);
  3172. if (anum && bnum) {
  3173. a = +a;
  3174. b = +b;
  3175. }
  3176. return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
  3177. };
  3178. const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
  3179. var identifiers = {
  3180. compareIdentifiers: compareIdentifiers$1,
  3181. rcompareIdentifiers
  3182. };
  3183. const {
  3184. MAX_LENGTH: MAX_LENGTH$2,
  3185. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$2
  3186. } = constants$5;
  3187. const {
  3188. re,
  3189. t
  3190. } = re_1;
  3191. const {
  3192. compareIdentifiers
  3193. } = identifiers;
  3194. class SemVer {
  3195. constructor(version, options) {
  3196. options = parseOptions_1(options);
  3197. if (version instanceof SemVer) {
  3198. if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
  3199. return version;
  3200. } else {
  3201. version = version.version;
  3202. }
  3203. } else if (typeof version !== 'string') {
  3204. throw new TypeError(`Invalid Version: ${version}`);
  3205. }
  3206. if (version.length > MAX_LENGTH$2) {
  3207. throw new TypeError(`version is longer than ${MAX_LENGTH$2} characters`);
  3208. }
  3209. debug_1('SemVer', version, options);
  3210. this.options = options;
  3211. this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
  3212. // don't run into trouble passing this.options around.
  3213. this.includePrerelease = !!options.includePrerelease;
  3214. const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  3215. if (!m) {
  3216. throw new TypeError(`Invalid Version: ${version}`);
  3217. }
  3218. this.raw = version; // these are actually numbers
  3219. this.major = +m[1];
  3220. this.minor = +m[2];
  3221. this.patch = +m[3];
  3222. if (this.major > MAX_SAFE_INTEGER$2 || this.major < 0) {
  3223. throw new TypeError('Invalid major version');
  3224. }
  3225. if (this.minor > MAX_SAFE_INTEGER$2 || this.minor < 0) {
  3226. throw new TypeError('Invalid minor version');
  3227. }
  3228. if (this.patch > MAX_SAFE_INTEGER$2 || this.patch < 0) {
  3229. throw new TypeError('Invalid patch version');
  3230. } // numberify any prerelease numeric ids
  3231. if (!m[4]) {
  3232. this.prerelease = [];
  3233. } else {
  3234. this.prerelease = m[4].split('.').map(id => {
  3235. if (/^[0-9]+$/.test(id)) {
  3236. const num = +id;
  3237. if (num >= 0 && num < MAX_SAFE_INTEGER$2) {
  3238. return num;
  3239. }
  3240. }
  3241. return id;
  3242. });
  3243. }
  3244. this.build = m[5] ? m[5].split('.') : [];
  3245. this.format();
  3246. }
  3247. format() {
  3248. this.version = `${this.major}.${this.minor}.${this.patch}`;
  3249. if (this.prerelease.length) {
  3250. this.version += `-${this.prerelease.join('.')}`;
  3251. }
  3252. return this.version;
  3253. }
  3254. toString() {
  3255. return this.version;
  3256. }
  3257. compare(other) {
  3258. debug_1('SemVer.compare', this.version, this.options, other);
  3259. if (!(other instanceof SemVer)) {
  3260. if (typeof other === 'string' && other === this.version) {
  3261. return 0;
  3262. }
  3263. other = new SemVer(other, this.options);
  3264. }
  3265. if (other.version === this.version) {
  3266. return 0;
  3267. }
  3268. return this.compareMain(other) || this.comparePre(other);
  3269. }
  3270. compareMain(other) {
  3271. if (!(other instanceof SemVer)) {
  3272. other = new SemVer(other, this.options);
  3273. }
  3274. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  3275. }
  3276. comparePre(other) {
  3277. if (!(other instanceof SemVer)) {
  3278. other = new SemVer(other, this.options);
  3279. } // NOT having a prerelease is > having one
  3280. if (this.prerelease.length && !other.prerelease.length) {
  3281. return -1;
  3282. } else if (!this.prerelease.length && other.prerelease.length) {
  3283. return 1;
  3284. } else if (!this.prerelease.length && !other.prerelease.length) {
  3285. return 0;
  3286. }
  3287. let i = 0;
  3288. do {
  3289. const a = this.prerelease[i];
  3290. const b = other.prerelease[i];
  3291. debug_1('prerelease compare', i, a, b);
  3292. if (a === undefined && b === undefined) {
  3293. return 0;
  3294. } else if (b === undefined) {
  3295. return 1;
  3296. } else if (a === undefined) {
  3297. return -1;
  3298. } else if (a === b) {
  3299. continue;
  3300. } else {
  3301. return compareIdentifiers(a, b);
  3302. }
  3303. } while (++i);
  3304. }
  3305. compareBuild(other) {
  3306. if (!(other instanceof SemVer)) {
  3307. other = new SemVer(other, this.options);
  3308. }
  3309. let i = 0;
  3310. do {
  3311. const a = this.build[i];
  3312. const b = other.build[i];
  3313. debug_1('prerelease compare', i, a, b);
  3314. if (a === undefined && b === undefined) {
  3315. return 0;
  3316. } else if (b === undefined) {
  3317. return 1;
  3318. } else if (a === undefined) {
  3319. return -1;
  3320. } else if (a === b) {
  3321. continue;
  3322. } else {
  3323. return compareIdentifiers(a, b);
  3324. }
  3325. } while (++i);
  3326. } // preminor will bump the version up to the next minor release, and immediately
  3327. // down to pre-release. premajor and prepatch work the same way.
  3328. inc(release, identifier) {
  3329. switch (release) {
  3330. case 'premajor':
  3331. this.prerelease.length = 0;
  3332. this.patch = 0;
  3333. this.minor = 0;
  3334. this.major++;
  3335. this.inc('pre', identifier);
  3336. break;
  3337. case 'preminor':
  3338. this.prerelease.length = 0;
  3339. this.patch = 0;
  3340. this.minor++;
  3341. this.inc('pre', identifier);
  3342. break;
  3343. case 'prepatch':
  3344. // If this is already a prerelease, it will bump to the next version
  3345. // drop any prereleases that might already exist, since they are not
  3346. // relevant at this point.
  3347. this.prerelease.length = 0;
  3348. this.inc('patch', identifier);
  3349. this.inc('pre', identifier);
  3350. break;
  3351. // If the input is a non-prerelease version, this acts the same as
  3352. // prepatch.
  3353. case 'prerelease':
  3354. if (this.prerelease.length === 0) {
  3355. this.inc('patch', identifier);
  3356. }
  3357. this.inc('pre', identifier);
  3358. break;
  3359. case 'major':
  3360. // If this is a pre-major version, bump up to the same major version.
  3361. // Otherwise increment major.
  3362. // 1.0.0-5 bumps to 1.0.0
  3363. // 1.1.0 bumps to 2.0.0
  3364. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
  3365. this.major++;
  3366. }
  3367. this.minor = 0;
  3368. this.patch = 0;
  3369. this.prerelease = [];
  3370. break;
  3371. case 'minor':
  3372. // If this is a pre-minor version, bump up to the same minor version.
  3373. // Otherwise increment minor.
  3374. // 1.2.0-5 bumps to 1.2.0
  3375. // 1.2.1 bumps to 1.3.0
  3376. if (this.patch !== 0 || this.prerelease.length === 0) {
  3377. this.minor++;
  3378. }
  3379. this.patch = 0;
  3380. this.prerelease = [];
  3381. break;
  3382. case 'patch':
  3383. // If this is not a pre-release version, it will increment the patch.
  3384. // If it is a pre-release it will bump up to the same patch version.
  3385. // 1.2.0-5 patches to 1.2.0
  3386. // 1.2.0 patches to 1.2.1
  3387. if (this.prerelease.length === 0) {
  3388. this.patch++;
  3389. }
  3390. this.prerelease = [];
  3391. break;
  3392. // This probably shouldn't be used publicly.
  3393. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
  3394. case 'pre':
  3395. if (this.prerelease.length === 0) {
  3396. this.prerelease = [0];
  3397. } else {
  3398. let i = this.prerelease.length;
  3399. while (--i >= 0) {
  3400. if (typeof this.prerelease[i] === 'number') {
  3401. this.prerelease[i]++;
  3402. i = -2;
  3403. }
  3404. }
  3405. if (i === -1) {
  3406. // didn't increment anything
  3407. this.prerelease.push(0);
  3408. }
  3409. }
  3410. if (identifier) {
  3411. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  3412. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  3413. if (this.prerelease[0] === identifier) {
  3414. if (isNaN(this.prerelease[1])) {
  3415. this.prerelease = [identifier, 0];
  3416. }
  3417. } else {
  3418. this.prerelease = [identifier, 0];
  3419. }
  3420. }
  3421. break;
  3422. default:
  3423. throw new Error(`invalid increment argument: ${release}`);
  3424. }
  3425. this.format();
  3426. this.raw = this.version;
  3427. return this;
  3428. }
  3429. }
  3430. var semver$3 = SemVer;
  3431. const compare$1 = (a, b, loose) => new semver$3(a, loose).compare(new semver$3(b, loose));
  3432. var compare_1 = compare$1;
  3433. const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
  3434. var lt_1 = lt;
  3435. const gte$1 = (a, b, loose) => compare_1(a, b, loose) >= 0;
  3436. var gte_1 = gte$1;
  3437. var arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
  3438. [keyName]: key
  3439. }, value));
  3440. var lib$5 = createCommonjsModule(function (module, exports) {
  3441. Object.defineProperty(exports, "__esModule", {
  3442. value: true
  3443. });
  3444. exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
  3445. function noop() {
  3446. var args = [];
  3447. for (var _i = 0; _i < arguments.length; _i++) {
  3448. args[_i] = arguments[_i];
  3449. }
  3450. }
  3451. function createWeakMap() {
  3452. if (typeof WeakMap !== "undefined") {
  3453. return new WeakMap();
  3454. } else {
  3455. return fakeSetOrMap();
  3456. }
  3457. }
  3458. /**
  3459. * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
  3460. */
  3461. function fakeSetOrMap() {
  3462. return {
  3463. add: noop,
  3464. delete: noop,
  3465. get: noop,
  3466. set: noop,
  3467. has: function (k) {
  3468. return false;
  3469. }
  3470. };
  3471. } // Safe hasOwnProperty
  3472. var hop = Object.prototype.hasOwnProperty;
  3473. var has = function (obj, prop) {
  3474. return hop.call(obj, prop);
  3475. }; // Copy all own enumerable properties from source to target
  3476. function extend(target, source) {
  3477. for (var prop in source) {
  3478. if (has(source, prop)) {
  3479. target[prop] = source[prop];
  3480. }
  3481. }
  3482. return target;
  3483. }
  3484. var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
  3485. var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
  3486. var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
  3487. var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
  3488. var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
  3489. function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
  3490. // If first interpolated value is a reference to outdent,
  3491. // determine indentation level from the indentation of the interpolated value.
  3492. var indentationLevel = 0;
  3493. var match = strings[0].match(reDetectIndentation);
  3494. if (match) {
  3495. indentationLevel = match[1].length;
  3496. }
  3497. var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
  3498. var reMatchIndent = new RegExp(reSource, "g");
  3499. if (firstInterpolatedValueSetsIndentationLevel) {
  3500. strings = strings.slice(1);
  3501. }
  3502. var newline = options.newline,
  3503. trimLeadingNewline = options.trimLeadingNewline,
  3504. trimTrailingNewline = options.trimTrailingNewline;
  3505. var normalizeNewlines = typeof newline === "string";
  3506. var l = strings.length;
  3507. var outdentedStrings = strings.map(function (v, i) {
  3508. // Remove leading indentation from all lines
  3509. v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
  3510. if (i === 0 && trimLeadingNewline) {
  3511. v = v.replace(reLeadingNewline, "");
  3512. } // Trim a trailing newline from the last string
  3513. if (i === l - 1 && trimTrailingNewline) {
  3514. v = v.replace(reTrailingNewline, "");
  3515. } // Normalize newlines
  3516. if (normalizeNewlines) {
  3517. v = v.replace(/\r\n|\n|\r/g, function (_) {
  3518. return newline;
  3519. });
  3520. }
  3521. return v;
  3522. });
  3523. return outdentedStrings;
  3524. }
  3525. function concatStringsAndValues(strings, values) {
  3526. var ret = "";
  3527. for (var i = 0, l = strings.length; i < l; i++) {
  3528. ret += strings[i];
  3529. if (i < l - 1) {
  3530. ret += values[i];
  3531. }
  3532. }
  3533. return ret;
  3534. }
  3535. function isTemplateStringsArray(v) {
  3536. return has(v, "raw") && has(v, "length");
  3537. }
  3538. /**
  3539. * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
  3540. * makeInstance
  3541. * @param options
  3542. * @return {outdent}
  3543. */
  3544. function createInstance(options) {
  3545. /** Cache of pre-processed template literal arrays */
  3546. var arrayAutoIndentCache = createWeakMap();
  3547. /**
  3548. * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
  3549. * before interpolated values are injected.
  3550. */
  3551. var arrayFirstInterpSetsIndentCache = createWeakMap();
  3552. function outdent(stringsOrOptions) {
  3553. var values = [];
  3554. for (var _i = 1; _i < arguments.length; _i++) {
  3555. values[_i - 1] = arguments[_i];
  3556. }
  3557. /* tslint:enable:no-shadowed-variable */
  3558. if (isTemplateStringsArray(stringsOrOptions)) {
  3559. var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
  3560. var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
  3561. var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
  3562. var renderedArray = cache.get(strings);
  3563. if (!renderedArray) {
  3564. renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
  3565. cache.set(strings, renderedArray);
  3566. }
  3567. /** If no interpolated values, skip concatenation step */
  3568. if (values.length === 0) {
  3569. return renderedArray[0];
  3570. }
  3571. /** Concatenate string literals with interpolated values */
  3572. var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
  3573. return rendered;
  3574. } else {
  3575. // Create and return a new instance of outdent with the given options
  3576. return createInstance(extend(extend({}, options), stringsOrOptions || {}));
  3577. }
  3578. }
  3579. var fullOutdent = extend(outdent, {
  3580. string: function (str) {
  3581. return _outdentArray([str], false, options)[0];
  3582. }
  3583. });
  3584. return fullOutdent;
  3585. }
  3586. var defaultOutdent = createInstance({
  3587. trimLeadingNewline: true,
  3588. trimTrailingNewline: true
  3589. });
  3590. exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
  3591. // import outdent from 'outdent';
  3592. exports.default = defaultOutdent;
  3593. {
  3594. // In webpack harmony-modules environments, module.exports is read-only,
  3595. // so we fail gracefully.
  3596. try {
  3597. module.exports = defaultOutdent;
  3598. Object.defineProperty(defaultOutdent, "__esModule", {
  3599. value: true
  3600. });
  3601. defaultOutdent.default = defaultOutdent;
  3602. defaultOutdent.outdent = defaultOutdent;
  3603. } catch (e) {}
  3604. }
  3605. });
  3606. const {
  3607. outdent
  3608. } = lib$5;
  3609. const CATEGORY_CONFIG = "Config";
  3610. const CATEGORY_EDITOR = "Editor";
  3611. const CATEGORY_FORMAT = "Format";
  3612. const CATEGORY_OTHER = "Other";
  3613. const CATEGORY_OUTPUT = "Output";
  3614. const CATEGORY_GLOBAL = "Global";
  3615. const CATEGORY_SPECIAL = "Special";
  3616. /**
  3617. * @typedef {Object} OptionInfo
  3618. * @property {string} [since] - available since version
  3619. * @property {string} category
  3620. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  3621. * @property {boolean} [array] - indicate it's an array of the specified type
  3622. * @property {OptionValueInfo} [default]
  3623. * @property {OptionRangeInfo} [range] - for type int
  3624. * @property {string} description
  3625. * @property {string} [deprecated] - deprecated since version
  3626. * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
  3627. * @property {(value: any) => boolean} [exception]
  3628. * @property {OptionChoiceInfo[]} [choices] - for type choice
  3629. * @property {string} [cliName]
  3630. * @property {string} [cliCategory]
  3631. * @property {string} [cliDescription]
  3632. *
  3633. * @typedef {number | boolean | string} OptionValue
  3634. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  3635. *
  3636. * @typedef {Object} OptionRedirectInfo
  3637. * @property {string} option
  3638. * @property {OptionValue} value
  3639. *
  3640. * @typedef {Object} OptionRangeInfo
  3641. * @property {number} start - recommended range start
  3642. * @property {number} end - recommended range end
  3643. * @property {number} step - recommended range step
  3644. *
  3645. * @typedef {Object} OptionChoiceInfo
  3646. * @property {boolean | string} value - boolean for the option that is originally boolean type
  3647. * @property {string} description
  3648. * @property {string} [since] - undefined if available since the first version of the option
  3649. * @property {string} [deprecated] - deprecated since version
  3650. * @property {OptionValueInfo} [redirect] - redirect deprecated value
  3651. */
  3652. /** @type {{ [name: string]: OptionInfo }} */
  3653. const options$7 = {
  3654. cursorOffset: {
  3655. since: "1.4.0",
  3656. category: CATEGORY_SPECIAL,
  3657. type: "int",
  3658. default: -1,
  3659. range: {
  3660. start: -1,
  3661. end: Number.POSITIVE_INFINITY,
  3662. step: 1
  3663. },
  3664. description: outdent`
  3665. Print (to stderr) where a cursor at the given position would move to after formatting.
  3666. This option cannot be used with --range-start and --range-end.
  3667. `,
  3668. cliCategory: CATEGORY_EDITOR
  3669. },
  3670. endOfLine: {
  3671. since: "1.15.0",
  3672. category: CATEGORY_GLOBAL,
  3673. type: "choice",
  3674. default: [{
  3675. since: "1.15.0",
  3676. value: "auto"
  3677. }, {
  3678. since: "2.0.0",
  3679. value: "lf"
  3680. }],
  3681. description: "Which end of line characters to apply.",
  3682. choices: [{
  3683. value: "lf",
  3684. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  3685. }, {
  3686. value: "crlf",
  3687. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  3688. }, {
  3689. value: "cr",
  3690. description: "Carriage Return character only (\\r), used very rarely"
  3691. }, {
  3692. value: "auto",
  3693. description: outdent`
  3694. Maintain existing
  3695. (mixed values within one file are normalised by looking at what's used after the first line)
  3696. `
  3697. }]
  3698. },
  3699. filepath: {
  3700. since: "1.4.0",
  3701. category: CATEGORY_SPECIAL,
  3702. type: "path",
  3703. description: "Specify the input filepath. This will be used to do parser inference.",
  3704. cliName: "stdin-filepath",
  3705. cliCategory: CATEGORY_OTHER,
  3706. cliDescription: "Path to the file to pretend that stdin comes from."
  3707. },
  3708. insertPragma: {
  3709. since: "1.8.0",
  3710. category: CATEGORY_SPECIAL,
  3711. type: "boolean",
  3712. default: false,
  3713. description: "Insert @format pragma into file's first docblock comment.",
  3714. cliCategory: CATEGORY_OTHER
  3715. },
  3716. parser: {
  3717. since: "0.0.10",
  3718. category: CATEGORY_GLOBAL,
  3719. type: "choice",
  3720. default: [{
  3721. since: "0.0.10",
  3722. value: "babylon"
  3723. }, {
  3724. since: "1.13.0",
  3725. value: undefined
  3726. }],
  3727. description: "Which parser to use.",
  3728. exception: value => typeof value === "string" || typeof value === "function",
  3729. choices: [{
  3730. value: "flow",
  3731. description: "Flow"
  3732. }, {
  3733. value: "babel",
  3734. since: "1.16.0",
  3735. description: "JavaScript"
  3736. }, {
  3737. value: "babel-flow",
  3738. since: "1.16.0",
  3739. description: "Flow"
  3740. }, {
  3741. value: "babel-ts",
  3742. since: "2.0.0",
  3743. description: "TypeScript"
  3744. }, {
  3745. value: "typescript",
  3746. since: "1.4.0",
  3747. description: "TypeScript"
  3748. }, {
  3749. value: "espree",
  3750. since: "2.2.0",
  3751. description: "JavaScript"
  3752. }, {
  3753. value: "meriyah",
  3754. since: "2.2.0",
  3755. description: "JavaScript"
  3756. }, {
  3757. value: "css",
  3758. since: "1.7.1",
  3759. description: "CSS"
  3760. }, {
  3761. value: "less",
  3762. since: "1.7.1",
  3763. description: "Less"
  3764. }, {
  3765. value: "scss",
  3766. since: "1.7.1",
  3767. description: "SCSS"
  3768. }, {
  3769. value: "json",
  3770. since: "1.5.0",
  3771. description: "JSON"
  3772. }, {
  3773. value: "json5",
  3774. since: "1.13.0",
  3775. description: "JSON5"
  3776. }, {
  3777. value: "json-stringify",
  3778. since: "1.13.0",
  3779. description: "JSON.stringify"
  3780. }, {
  3781. value: "graphql",
  3782. since: "1.5.0",
  3783. description: "GraphQL"
  3784. }, {
  3785. value: "markdown",
  3786. since: "1.8.0",
  3787. description: "Markdown"
  3788. }, {
  3789. value: "mdx",
  3790. since: "1.15.0",
  3791. description: "MDX"
  3792. }, {
  3793. value: "vue",
  3794. since: "1.10.0",
  3795. description: "Vue"
  3796. }, {
  3797. value: "yaml",
  3798. since: "1.14.0",
  3799. description: "YAML"
  3800. }, {
  3801. value: "glimmer",
  3802. since: "2.3.0",
  3803. description: "Ember / Handlebars"
  3804. }, {
  3805. value: "html",
  3806. since: "1.15.0",
  3807. description: "HTML"
  3808. }, {
  3809. value: "angular",
  3810. since: "1.15.0",
  3811. description: "Angular"
  3812. }, {
  3813. value: "lwc",
  3814. since: "1.17.0",
  3815. description: "Lightning Web Components"
  3816. }]
  3817. },
  3818. plugins: {
  3819. since: "1.10.0",
  3820. type: "path",
  3821. array: true,
  3822. default: [{
  3823. value: []
  3824. }],
  3825. category: CATEGORY_GLOBAL,
  3826. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  3827. exception: value => typeof value === "string" || typeof value === "object",
  3828. cliName: "plugin",
  3829. cliCategory: CATEGORY_CONFIG
  3830. },
  3831. pluginSearchDirs: {
  3832. since: "1.13.0",
  3833. type: "path",
  3834. array: true,
  3835. default: [{
  3836. value: []
  3837. }],
  3838. category: CATEGORY_GLOBAL,
  3839. description: outdent`
  3840. Custom directory that contains prettier plugins in node_modules subdirectory.
  3841. Overrides default behavior when plugins are searched relatively to the location of Prettier.
  3842. Multiple values are accepted.
  3843. `,
  3844. exception: value => typeof value === "string" || typeof value === "object",
  3845. cliName: "plugin-search-dir",
  3846. cliCategory: CATEGORY_CONFIG
  3847. },
  3848. printWidth: {
  3849. since: "0.0.0",
  3850. category: CATEGORY_GLOBAL,
  3851. type: "int",
  3852. default: 80,
  3853. description: "The line length where Prettier will try wrap.",
  3854. range: {
  3855. start: 0,
  3856. end: Number.POSITIVE_INFINITY,
  3857. step: 1
  3858. }
  3859. },
  3860. rangeEnd: {
  3861. since: "1.4.0",
  3862. category: CATEGORY_SPECIAL,
  3863. type: "int",
  3864. default: Number.POSITIVE_INFINITY,
  3865. range: {
  3866. start: 0,
  3867. end: Number.POSITIVE_INFINITY,
  3868. step: 1
  3869. },
  3870. description: outdent`
  3871. Format code ending at a given character offset (exclusive).
  3872. The range will extend forwards to the end of the selected statement.
  3873. This option cannot be used with --cursor-offset.
  3874. `,
  3875. cliCategory: CATEGORY_EDITOR
  3876. },
  3877. rangeStart: {
  3878. since: "1.4.0",
  3879. category: CATEGORY_SPECIAL,
  3880. type: "int",
  3881. default: 0,
  3882. range: {
  3883. start: 0,
  3884. end: Number.POSITIVE_INFINITY,
  3885. step: 1
  3886. },
  3887. description: outdent`
  3888. Format code starting at a given character offset.
  3889. The range will extend backwards to the start of the first line containing the selected statement.
  3890. This option cannot be used with --cursor-offset.
  3891. `,
  3892. cliCategory: CATEGORY_EDITOR
  3893. },
  3894. requirePragma: {
  3895. since: "1.7.0",
  3896. category: CATEGORY_SPECIAL,
  3897. type: "boolean",
  3898. default: false,
  3899. description: outdent`
  3900. Require either '@prettier' or '@format' to be present in the file's first docblock comment
  3901. in order for it to be formatted.
  3902. `,
  3903. cliCategory: CATEGORY_OTHER
  3904. },
  3905. tabWidth: {
  3906. type: "int",
  3907. category: CATEGORY_GLOBAL,
  3908. default: 2,
  3909. description: "Number of spaces per indentation level.",
  3910. range: {
  3911. start: 0,
  3912. end: Number.POSITIVE_INFINITY,
  3913. step: 1
  3914. }
  3915. },
  3916. useTabs: {
  3917. since: "1.0.0",
  3918. category: CATEGORY_GLOBAL,
  3919. type: "boolean",
  3920. default: false,
  3921. description: "Indent with tabs instead of spaces."
  3922. },
  3923. embeddedLanguageFormatting: {
  3924. since: "2.1.0",
  3925. category: CATEGORY_GLOBAL,
  3926. type: "choice",
  3927. default: [{
  3928. since: "2.1.0",
  3929. value: "auto"
  3930. }],
  3931. description: "Control how Prettier formats quoted code embedded in the file.",
  3932. choices: [{
  3933. value: "auto",
  3934. description: "Format embedded code if Prettier can automatically identify it."
  3935. }, {
  3936. value: "off",
  3937. description: "Never automatically format embedded code."
  3938. }]
  3939. }
  3940. };
  3941. var coreOptions$1 = {
  3942. CATEGORY_CONFIG,
  3943. CATEGORY_EDITOR,
  3944. CATEGORY_FORMAT,
  3945. CATEGORY_OTHER,
  3946. CATEGORY_OUTPUT,
  3947. CATEGORY_GLOBAL,
  3948. CATEGORY_SPECIAL,
  3949. options: options$7
  3950. };
  3951. const _excluded$3 = ["cliName", "cliCategory", "cliDescription"];
  3952. const semver$2 = {
  3953. compare: compare_1,
  3954. lt: lt_1,
  3955. gte: gte_1
  3956. };
  3957. const currentVersion = require$$0$9.version;
  3958. const coreOptions = coreOptions$1.options;
  3959. /**
  3960. * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
  3961. * of this function created by `withPlugins`. Don't pass them here directly.
  3962. * @param {object} param0
  3963. * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
  3964. * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
  3965. * @param {boolean=} param0.showUnreleased
  3966. * @param {boolean=} param0.showDeprecated
  3967. * @param {boolean=} param0.showInternal
  3968. */
  3969. function getSupportInfo$3({
  3970. plugins = [],
  3971. showUnreleased = false,
  3972. showDeprecated = false,
  3973. showInternal = false
  3974. } = {}) {
  3975. // pre-release version is smaller than the normal version in semver,
  3976. // we need to treat it as the normal one so as to test new features.
  3977. const version = currentVersion.split("-", 1)[0];
  3978. const languages = plugins.flatMap(plugin => plugin.languages || []).filter(filterSince);
  3979. const options = arrayify(Object.assign({}, ...plugins.map(({
  3980. options
  3981. }) => options), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
  3982. option = Object.assign({}, option);
  3983. if (Array.isArray(option.default)) {
  3984. option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$2.compare(info2.since, info1.since))[0].value;
  3985. }
  3986. if (Array.isArray(option.choices)) {
  3987. option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
  3988. if (option.name === "parser") {
  3989. collectParsersFromLanguages(option, languages, plugins);
  3990. }
  3991. }
  3992. const pluginDefaults = Object.fromEntries(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
  3993. return Object.assign(Object.assign({}, option), {}, {
  3994. pluginDefaults
  3995. });
  3996. });
  3997. return {
  3998. languages,
  3999. options
  4000. };
  4001. function filterSince(object) {
  4002. return showUnreleased || !("since" in object) || object.since && semver$2.gte(version, object.since);
  4003. }
  4004. function filterDeprecated(object) {
  4005. return showDeprecated || !("deprecated" in object) || object.deprecated && semver$2.lt(version, object.deprecated);
  4006. }
  4007. function mapInternal(object) {
  4008. if (showInternal) {
  4009. return object;
  4010. }
  4011. const newObject = _objectWithoutProperties(object, _excluded$3);
  4012. return newObject;
  4013. }
  4014. }
  4015. function collectParsersFromLanguages(option, languages, plugins) {
  4016. const existingValues = new Set(option.choices.map(choice => choice.value));
  4017. for (const language of languages) {
  4018. if (language.parsers) {
  4019. for (const value of language.parsers) {
  4020. if (!existingValues.has(value)) {
  4021. existingValues.add(value);
  4022. const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
  4023. let description = language.name;
  4024. if (plugin && plugin.name) {
  4025. description += ` (plugin: ${plugin.name})`;
  4026. }
  4027. option.choices.push({
  4028. value,
  4029. description
  4030. });
  4031. }
  4032. }
  4033. }
  4034. }
  4035. }
  4036. var support = {
  4037. getSupportInfo: getSupportInfo$3
  4038. };
  4039. const {
  4040. getSupportInfo: getSupportInfo$2
  4041. } = support;
  4042. const notAsciiRegex = /[^\x20-\x7F]/;
  4043. const getPenultimate$1 = arr => arr[arr.length - 2];
  4044. /**
  4045. * @typedef {{backwards?: boolean}} SkipOptions
  4046. */
  4047. /**
  4048. * @param {string | RegExp} chars
  4049. * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4050. */
  4051. function skip$1(chars) {
  4052. return (text, index, opts) => {
  4053. const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  4054. // to check for failures (did someone say monads?).
  4055. /* istanbul ignore next */
  4056. if (index === false) {
  4057. return false;
  4058. }
  4059. const {
  4060. length
  4061. } = text;
  4062. let cursor = index;
  4063. while (cursor >= 0 && cursor < length) {
  4064. const c = text.charAt(cursor);
  4065. if (chars instanceof RegExp) {
  4066. if (!chars.test(c)) {
  4067. return cursor;
  4068. }
  4069. } else if (!chars.includes(c)) {
  4070. return cursor;
  4071. }
  4072. backwards ? cursor-- : cursor++;
  4073. }
  4074. if (cursor === -1 || cursor === length) {
  4075. // If we reached the beginning or end of the file, return the
  4076. // out-of-bounds cursor. It's up to the caller to handle this
  4077. // correctly. We don't want to indicate `false` though if it
  4078. // actually skipped valid characters.
  4079. return cursor;
  4080. }
  4081. return false;
  4082. };
  4083. }
  4084. /**
  4085. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4086. */
  4087. const skipWhitespace$2 = skip$1(/\s/);
  4088. /**
  4089. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4090. */
  4091. const skipSpaces$2 = skip$1(" \t");
  4092. /**
  4093. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4094. */
  4095. const skipToLineEnd$1 = skip$1(",; \t");
  4096. /**
  4097. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4098. */
  4099. const skipEverythingButNewLine$2 = skip$1(/[^\n\r]/);
  4100. /**
  4101. * @param {string} text
  4102. * @param {number | false} index
  4103. * @returns {number | false}
  4104. */
  4105. function skipInlineComment$1(text, index) {
  4106. /* istanbul ignore next */
  4107. if (index === false) {
  4108. return false;
  4109. }
  4110. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  4111. for (let i = index + 2; i < text.length; ++i) {
  4112. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  4113. return i + 2;
  4114. }
  4115. }
  4116. }
  4117. return index;
  4118. }
  4119. /**
  4120. * @param {string} text
  4121. * @param {number | false} index
  4122. * @returns {number | false}
  4123. */
  4124. function skipTrailingComment$1(text, index) {
  4125. /* istanbul ignore next */
  4126. if (index === false) {
  4127. return false;
  4128. }
  4129. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  4130. return skipEverythingButNewLine$2(text, index);
  4131. }
  4132. return index;
  4133. } // This one doesn't use the above helper function because it wants to
  4134. // test \r\n in order and `skip` doesn't support ordering and we only
  4135. // want to skip one newline. It's simple to implement.
  4136. /**
  4137. * @param {string} text
  4138. * @param {number | false} index
  4139. * @param {SkipOptions=} opts
  4140. * @returns {number | false}
  4141. */
  4142. function skipNewline$2(text, index, opts) {
  4143. const backwards = opts && opts.backwards;
  4144. if (index === false) {
  4145. return false;
  4146. }
  4147. const atIndex = text.charAt(index);
  4148. if (backwards) {
  4149. // We already replace `\r\n` with `\n` before parsing
  4150. /* istanbul ignore next */
  4151. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  4152. return index - 2;
  4153. }
  4154. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  4155. return index - 1;
  4156. }
  4157. } else {
  4158. // We already replace `\r\n` with `\n` before parsing
  4159. /* istanbul ignore next */
  4160. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  4161. return index + 2;
  4162. }
  4163. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  4164. return index + 1;
  4165. }
  4166. }
  4167. return index;
  4168. }
  4169. /**
  4170. * @param {string} text
  4171. * @param {number} index
  4172. * @param {SkipOptions=} opts
  4173. * @returns {boolean}
  4174. */
  4175. function hasNewline$a(text, index, opts = {}) {
  4176. const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
  4177. const idx2 = skipNewline$2(text, idx, opts);
  4178. return idx !== idx2;
  4179. }
  4180. /**
  4181. * @param {string} text
  4182. * @param {number} start
  4183. * @param {number} end
  4184. * @returns {boolean}
  4185. */
  4186. function hasNewlineInRange$5(text, start, end) {
  4187. for (let i = start; i < end; ++i) {
  4188. if (text.charAt(i) === "\n") {
  4189. return true;
  4190. }
  4191. }
  4192. return false;
  4193. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  4194. /**
  4195. * @template N
  4196. * @param {string} text
  4197. * @param {N} node
  4198. * @param {(node: N) => number} locStart
  4199. */
  4200. function isPreviousLineEmpty$3(text, node, locStart) {
  4201. /** @type {number | false} */
  4202. let idx = locStart(node) - 1;
  4203. idx = skipSpaces$2(text, idx, {
  4204. backwards: true
  4205. });
  4206. idx = skipNewline$2(text, idx, {
  4207. backwards: true
  4208. });
  4209. idx = skipSpaces$2(text, idx, {
  4210. backwards: true
  4211. });
  4212. const idx2 = skipNewline$2(text, idx, {
  4213. backwards: true
  4214. });
  4215. return idx !== idx2;
  4216. }
  4217. /**
  4218. * @param {string} text
  4219. * @param {number} index
  4220. * @returns {boolean}
  4221. */
  4222. function isNextLineEmptyAfterIndex$3(text, index) {
  4223. /** @type {number | false} */
  4224. let oldIdx = null;
  4225. /** @type {number | false} */
  4226. let idx = index;
  4227. while (idx !== oldIdx) {
  4228. // We need to skip all the potential trailing inline comments
  4229. oldIdx = idx;
  4230. idx = skipToLineEnd$1(text, idx);
  4231. idx = skipInlineComment$1(text, idx);
  4232. idx = skipSpaces$2(text, idx);
  4233. }
  4234. idx = skipTrailingComment$1(text, idx);
  4235. idx = skipNewline$2(text, idx);
  4236. return idx !== false && hasNewline$a(text, idx);
  4237. }
  4238. /**
  4239. * @template N
  4240. * @param {string} text
  4241. * @param {N} node
  4242. * @param {(node: N) => number} locEnd
  4243. * @returns {boolean}
  4244. */
  4245. function isNextLineEmpty$e(text, node, locEnd) {
  4246. return isNextLineEmptyAfterIndex$3(text, locEnd(node));
  4247. }
  4248. /**
  4249. * @param {string} text
  4250. * @param {number} idx
  4251. * @returns {number | false}
  4252. */
  4253. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, idx) {
  4254. /** @type {number | false} */
  4255. let oldIdx = null;
  4256. /** @type {number | false} */
  4257. let nextIdx = idx;
  4258. while (nextIdx !== oldIdx) {
  4259. oldIdx = nextIdx;
  4260. nextIdx = skipSpaces$2(text, nextIdx);
  4261. nextIdx = skipInlineComment$1(text, nextIdx);
  4262. nextIdx = skipTrailingComment$1(text, nextIdx);
  4263. nextIdx = skipNewline$2(text, nextIdx);
  4264. }
  4265. return nextIdx;
  4266. }
  4267. /**
  4268. * @template N
  4269. * @param {string} text
  4270. * @param {N} node
  4271. * @param {(node: N) => number} locEnd
  4272. * @returns {number | false}
  4273. */
  4274. function getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd) {
  4275. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, locEnd(node));
  4276. }
  4277. /**
  4278. * @template N
  4279. * @param {string} text
  4280. * @param {N} node
  4281. * @param {(node: N) => number} locEnd
  4282. * @returns {string}
  4283. */
  4284. function getNextNonSpaceNonCommentCharacter$2(text, node, locEnd) {
  4285. return text.charAt( // @ts-expect-error => TBD: can return false, should we define a fallback?
  4286. getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd));
  4287. } // Not using, but it's public utils
  4288. /* istanbul ignore next */
  4289. /**
  4290. * @param {string} text
  4291. * @param {number} index
  4292. * @param {SkipOptions=} opts
  4293. * @returns {boolean}
  4294. */
  4295. function hasSpaces$1(text, index, opts = {}) {
  4296. const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
  4297. return idx !== index;
  4298. }
  4299. /**
  4300. * @param {string} value
  4301. * @param {number} tabWidth
  4302. * @param {number=} startIndex
  4303. * @returns {number}
  4304. */
  4305. function getAlignmentSize$2(value, tabWidth, startIndex = 0) {
  4306. let size = 0;
  4307. for (let i = startIndex; i < value.length; ++i) {
  4308. if (value[i] === "\t") {
  4309. // Tabs behave in a way that they are aligned to the nearest
  4310. // multiple of tabWidth:
  4311. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  4312. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  4313. size = size + tabWidth - size % tabWidth;
  4314. } else {
  4315. size++;
  4316. }
  4317. }
  4318. return size;
  4319. }
  4320. /**
  4321. * @param {string} value
  4322. * @param {number} tabWidth
  4323. * @returns {number}
  4324. */
  4325. function getIndentSize$2(value, tabWidth) {
  4326. const lastNewlineIndex = value.lastIndexOf("\n");
  4327. if (lastNewlineIndex === -1) {
  4328. return 0;
  4329. }
  4330. return getAlignmentSize$2( // All the leading whitespaces
  4331. value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
  4332. }
  4333. /**
  4334. * @typedef {'"' | "'"} Quote
  4335. */
  4336. /**
  4337. *
  4338. * @param {string} raw
  4339. * @param {Quote} preferredQuote
  4340. * @returns {Quote}
  4341. */
  4342. function getPreferredQuote$1(raw, preferredQuote) {
  4343. // `rawContent` is the string exactly like it appeared in the input source
  4344. // code, without its enclosing quotes.
  4345. const rawContent = raw.slice(1, -1);
  4346. /** @type {{ quote: '"', regex: RegExp }} */
  4347. const double = {
  4348. quote: '"',
  4349. regex: /"/g
  4350. };
  4351. /** @type {{ quote: "'", regex: RegExp }} */
  4352. const single = {
  4353. quote: "'",
  4354. regex: /'/g
  4355. };
  4356. const preferred = preferredQuote === "'" ? single : double;
  4357. const alternate = preferred === single ? double : single;
  4358. let result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
  4359. // the string, we might want to enclose with the alternate quote instead, to
  4360. // minimize the number of escaped quotes.
  4361. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  4362. const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  4363. const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  4364. result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
  4365. }
  4366. return result;
  4367. }
  4368. function printString$4(raw, options) {
  4369. // `rawContent` is the string exactly like it appeared in the input source
  4370. // code, without its enclosing quotes.
  4371. const rawContent = raw.slice(1, -1);
  4372. /** @type {Quote} */
  4373. const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote$1(raw, options.singleQuote ? "'" : '"'); // It might sound unnecessary to use `makeString` even if the string already
  4374. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  4375. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  4376. // sure that we consistently output the minimum amount of escaped quotes.
  4377. return makeString$1(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
  4378. }
  4379. /**
  4380. * @param {string} rawContent
  4381. * @param {Quote} enclosingQuote
  4382. * @param {boolean=} unescapeUnnecessaryEscapes
  4383. * @returns {string}
  4384. */
  4385. function makeString$1(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  4386. const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  4387. const regex = /\\(.)|(["'])/gs; // Escape and unescape single and double quotes as needed to be able to
  4388. // enclose `rawContent` with `enclosingQuote`.
  4389. const newContent = rawContent.replace(regex, (match, escaped, quote) => {
  4390. // If we matched an escape, and the escaped character is a quote of the
  4391. // other type than we intend to enclose the string with, there's no need for
  4392. // it to be escaped, so return it _without_ the backslash.
  4393. if (escaped === otherQuote) {
  4394. return escaped;
  4395. } // If we matched an unescaped quote and it is of the _same_ type as we
  4396. // intend to enclose the string with, it must be escaped, so return it with
  4397. // a backslash.
  4398. if (quote === enclosingQuote) {
  4399. return "\\" + quote;
  4400. }
  4401. if (quote) {
  4402. return quote;
  4403. } // Unescape any unnecessarily escaped character.
  4404. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  4405. return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
  4406. });
  4407. return enclosingQuote + newContent + enclosingQuote;
  4408. }
  4409. function printNumber$4(rawNumber) {
  4410. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  4411. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  4412. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  4413. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  4414. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  4415. .replace(/\.(?=e|$)/, "");
  4416. }
  4417. /**
  4418. * @param {string} str
  4419. * @param {string} target
  4420. * @returns {number}
  4421. */
  4422. function getMaxContinuousCount$3(str, target) {
  4423. const results = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
  4424. if (results === null) {
  4425. return 0;
  4426. }
  4427. return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
  4428. }
  4429. function getMinNotPresentContinuousCount$1(str, target) {
  4430. const matches = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
  4431. if (matches === null) {
  4432. return 0;
  4433. }
  4434. const countPresent = new Map();
  4435. let max = 0;
  4436. for (const match of matches) {
  4437. const count = match.length / target.length;
  4438. countPresent.set(count, true);
  4439. if (count > max) {
  4440. max = count;
  4441. }
  4442. }
  4443. for (let i = 1; i < max; i++) {
  4444. if (!countPresent.get(i)) {
  4445. return i;
  4446. }
  4447. }
  4448. return max + 1;
  4449. }
  4450. /**
  4451. * @param {string} text
  4452. * @returns {number}
  4453. */
  4454. function getStringWidth$5(text) {
  4455. if (!text) {
  4456. return 0;
  4457. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  4458. if (!notAsciiRegex.test(text)) {
  4459. return text.length;
  4460. }
  4461. return stringWidth_1(text);
  4462. }
  4463. function addCommentHelper(node, comment) {
  4464. const comments = node.comments || (node.comments = []);
  4465. comments.push(comment);
  4466. comment.printed = false;
  4467. comment.nodeDescription = describeNodeForDebugging(node);
  4468. }
  4469. function addLeadingComment$3(node, comment) {
  4470. comment.leading = true;
  4471. comment.trailing = false;
  4472. addCommentHelper(node, comment);
  4473. }
  4474. function addDanglingComment$3(node, comment, marker) {
  4475. comment.leading = false;
  4476. comment.trailing = false;
  4477. if (marker) {
  4478. comment.marker = marker;
  4479. }
  4480. addCommentHelper(node, comment);
  4481. }
  4482. function addTrailingComment$3(node, comment) {
  4483. comment.leading = false;
  4484. comment.trailing = true;
  4485. addCommentHelper(node, comment);
  4486. }
  4487. function inferParserByLanguage$2(language, options) {
  4488. const {
  4489. languages
  4490. } = getSupportInfo$2({
  4491. plugins: options.plugins
  4492. });
  4493. const matched = languages.find(({
  4494. name
  4495. }) => name.toLowerCase() === language) || languages.find(({
  4496. aliases
  4497. }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
  4498. extensions
  4499. }) => Array.isArray(extensions) && extensions.includes(`.${language}`));
  4500. return matched && matched.parsers[0];
  4501. }
  4502. function isFrontMatterNode$5(node) {
  4503. return node && node.type === "front-matter";
  4504. }
  4505. function getShebang$1(text) {
  4506. if (!text.startsWith("#!")) {
  4507. return "";
  4508. }
  4509. const index = text.indexOf("\n");
  4510. if (index === -1) {
  4511. return text;
  4512. }
  4513. return text.slice(0, index);
  4514. }
  4515. /**
  4516. * @param {any} object
  4517. * @returns {object is Array<any>}
  4518. */
  4519. function isNonEmptyArray$j(object) {
  4520. return Array.isArray(object) && object.length > 0;
  4521. }
  4522. /**
  4523. * @param {string} description
  4524. * @returns {(node: any) => symbol}
  4525. */
  4526. function createGroupIdMapper$2(description) {
  4527. const groupIds = new WeakMap();
  4528. return function (node) {
  4529. if (!groupIds.has(node)) {
  4530. groupIds.set(node, Symbol(description));
  4531. }
  4532. return groupIds.get(node);
  4533. };
  4534. }
  4535. function describeNodeForDebugging(node) {
  4536. const nodeType = node.type || node.kind || "(unknown type)";
  4537. let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
  4538. if (nodeName.length > 20) {
  4539. nodeName = nodeName.slice(0, 19) + "…";
  4540. }
  4541. return nodeType + (nodeName ? " " + nodeName : "");
  4542. }
  4543. var util$5 = {
  4544. inferParserByLanguage: inferParserByLanguage$2,
  4545. getStringWidth: getStringWidth$5,
  4546. getMaxContinuousCount: getMaxContinuousCount$3,
  4547. getMinNotPresentContinuousCount: getMinNotPresentContinuousCount$1,
  4548. getPenultimate: getPenultimate$1,
  4549. getLast: getLast_1,
  4550. getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1,
  4551. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$4,
  4552. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$2,
  4553. skip: skip$1,
  4554. skipWhitespace: skipWhitespace$2,
  4555. skipSpaces: skipSpaces$2,
  4556. skipToLineEnd: skipToLineEnd$1,
  4557. skipEverythingButNewLine: skipEverythingButNewLine$2,
  4558. skipInlineComment: skipInlineComment$1,
  4559. skipTrailingComment: skipTrailingComment$1,
  4560. skipNewline: skipNewline$2,
  4561. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$3,
  4562. isNextLineEmpty: isNextLineEmpty$e,
  4563. isPreviousLineEmpty: isPreviousLineEmpty$3,
  4564. hasNewline: hasNewline$a,
  4565. hasNewlineInRange: hasNewlineInRange$5,
  4566. hasSpaces: hasSpaces$1,
  4567. getAlignmentSize: getAlignmentSize$2,
  4568. getIndentSize: getIndentSize$2,
  4569. getPreferredQuote: getPreferredQuote$1,
  4570. printString: printString$4,
  4571. printNumber: printNumber$4,
  4572. makeString: makeString$1,
  4573. addLeadingComment: addLeadingComment$3,
  4574. addDanglingComment: addDanglingComment$3,
  4575. addTrailingComment: addTrailingComment$3,
  4576. isFrontMatterNode: isFrontMatterNode$5,
  4577. getShebang: getShebang$1,
  4578. isNonEmptyArray: isNonEmptyArray$j,
  4579. createGroupIdMapper: createGroupIdMapper$2
  4580. };
  4581. function guessEndOfLine$1(text) {
  4582. const index = text.indexOf("\r");
  4583. if (index >= 0) {
  4584. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  4585. }
  4586. return "lf";
  4587. }
  4588. function convertEndOfLineToChars$1(value) {
  4589. switch (value) {
  4590. case "cr":
  4591. return "\r";
  4592. case "crlf":
  4593. return "\r\n";
  4594. default:
  4595. return "\n";
  4596. }
  4597. }
  4598. function countEndOfLineChars$1(text, eol) {
  4599. let regex;
  4600. /* istanbul ignore else */
  4601. if (eol === "\n") {
  4602. regex = /\n/g;
  4603. } else if (eol === "\r") {
  4604. regex = /\r/g;
  4605. } else if (eol === "\r\n") {
  4606. regex = /\r\n/g;
  4607. } else {
  4608. throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
  4609. }
  4610. const endOfLines = text.match(regex);
  4611. return endOfLines ? endOfLines.length : 0;
  4612. }
  4613. function normalizeEndOfLine$2(text) {
  4614. return text.replace(/\r\n?/g, "\n");
  4615. }
  4616. var endOfLine = {
  4617. guessEndOfLine: guessEndOfLine$1,
  4618. convertEndOfLineToChars: convertEndOfLineToChars$1,
  4619. countEndOfLineChars: countEndOfLineChars$1,
  4620. normalizeEndOfLine: normalizeEndOfLine$2
  4621. };
  4622. /**
  4623. * @class
  4624. */
  4625. class LineByLine {
  4626. constructor(file, options) {
  4627. options = options || {};
  4628. if (!options.readChunk) options.readChunk = 1024;
  4629. if (!options.newLineCharacter) {
  4630. options.newLineCharacter = 0x0a; //linux line ending
  4631. } else {
  4632. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  4633. }
  4634. if (typeof file === 'number') {
  4635. this.fd = file;
  4636. } else {
  4637. this.fd = fs__default['default'].openSync(file, 'r');
  4638. }
  4639. this.options = options;
  4640. this.newLineCharacter = options.newLineCharacter;
  4641. this.reset();
  4642. }
  4643. _searchInBuffer(buffer, hexNeedle) {
  4644. let found = -1;
  4645. for (let i = 0; i <= buffer.length; i++) {
  4646. let b_byte = buffer[i];
  4647. if (b_byte === hexNeedle) {
  4648. found = i;
  4649. break;
  4650. }
  4651. }
  4652. return found;
  4653. }
  4654. reset() {
  4655. this.eofReached = false;
  4656. this.linesCache = [];
  4657. this.fdPosition = 0;
  4658. }
  4659. close() {
  4660. fs__default['default'].closeSync(this.fd);
  4661. this.fd = null;
  4662. }
  4663. _extractLines(buffer) {
  4664. let line;
  4665. const lines = [];
  4666. let bufferPosition = 0;
  4667. let lastNewLineBufferPosition = 0;
  4668. while (true) {
  4669. let bufferPositionValue = buffer[bufferPosition++];
  4670. if (bufferPositionValue === this.newLineCharacter) {
  4671. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  4672. lines.push(line);
  4673. lastNewLineBufferPosition = bufferPosition;
  4674. } else if (bufferPositionValue === undefined) {
  4675. break;
  4676. }
  4677. }
  4678. let leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  4679. if (leftovers.length) {
  4680. lines.push(leftovers);
  4681. }
  4682. return lines;
  4683. }
  4684. _readChunk(lineLeftovers) {
  4685. let totalBytesRead = 0;
  4686. let bytesRead;
  4687. const buffers = [];
  4688. do {
  4689. const readBuffer = new Buffer(this.options.readChunk);
  4690. bytesRead = fs__default['default'].readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  4691. totalBytesRead = totalBytesRead + bytesRead;
  4692. this.fdPosition = this.fdPosition + bytesRead;
  4693. buffers.push(readBuffer);
  4694. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  4695. let bufferData = Buffer.concat(buffers);
  4696. if (bytesRead < this.options.readChunk) {
  4697. this.eofReached = true;
  4698. bufferData = bufferData.slice(0, totalBytesRead);
  4699. }
  4700. if (totalBytesRead) {
  4701. this.linesCache = this._extractLines(bufferData);
  4702. if (lineLeftovers) {
  4703. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  4704. }
  4705. }
  4706. return totalBytesRead;
  4707. }
  4708. next() {
  4709. if (!this.fd) return false;
  4710. let line = false;
  4711. if (this.eofReached && this.linesCache.length === 0) {
  4712. return line;
  4713. }
  4714. let bytesRead;
  4715. if (!this.linesCache.length) {
  4716. bytesRead = this._readChunk();
  4717. }
  4718. if (this.linesCache.length) {
  4719. line = this.linesCache.shift();
  4720. const lastLineCharacter = line[line.length - 1];
  4721. if (lastLineCharacter !== this.newLineCharacter) {
  4722. bytesRead = this._readChunk(line);
  4723. if (bytesRead) {
  4724. line = this.linesCache.shift();
  4725. }
  4726. }
  4727. }
  4728. if (this.eofReached && this.linesCache.length === 0) {
  4729. this.close();
  4730. }
  4731. if (line && line[line.length - 1] === this.newLineCharacter) {
  4732. line = line.slice(0, line.length - 1);
  4733. }
  4734. return line;
  4735. }
  4736. }
  4737. var readlines = LineByLine;
  4738. class ConfigError$1 extends Error {}
  4739. class DebugError extends Error {}
  4740. class UndefinedParserError$1 extends Error {}
  4741. class ArgExpansionBailout$3 extends Error {}
  4742. var errors = {
  4743. ConfigError: ConfigError$1,
  4744. DebugError,
  4745. UndefinedParserError: UndefinedParserError$1,
  4746. ArgExpansionBailout: ArgExpansionBailout$3
  4747. };
  4748. /*! *****************************************************************************
  4749. Copyright (c) Microsoft Corporation.
  4750. Permission to use, copy, modify, and/or distribute this software for any
  4751. purpose with or without fee is hereby granted.
  4752. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  4753. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  4754. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  4755. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  4756. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  4757. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  4758. PERFORMANCE OF THIS SOFTWARE.
  4759. ***************************************************************************** */
  4760. /* global Reflect, Promise */
  4761. var extendStatics = function (d, b) {
  4762. extendStatics = Object.setPrototypeOf || {
  4763. __proto__: []
  4764. } instanceof Array && function (d, b) {
  4765. d.__proto__ = b;
  4766. } || function (d, b) {
  4767. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4768. };
  4769. return extendStatics(d, b);
  4770. };
  4771. function __extends(d, b) {
  4772. extendStatics(d, b);
  4773. function __() {
  4774. this.constructor = d;
  4775. }
  4776. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4777. }
  4778. var __assign = function () {
  4779. __assign = Object.assign || function __assign(t) {
  4780. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4781. s = arguments[i];
  4782. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4783. }
  4784. return t;
  4785. };
  4786. return __assign.apply(this, arguments);
  4787. };
  4788. function __rest(s, e) {
  4789. var t = {};
  4790. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  4791. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4792. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  4793. }
  4794. return t;
  4795. }
  4796. function __decorate(decorators, target, key, desc) {
  4797. var c = arguments.length,
  4798. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  4799. d;
  4800. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  4801. return c > 3 && r && Object.defineProperty(target, key, r), r;
  4802. }
  4803. function __param(paramIndex, decorator) {
  4804. return function (target, key) {
  4805. decorator(target, key, paramIndex);
  4806. };
  4807. }
  4808. function __metadata(metadataKey, metadataValue) {
  4809. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  4810. }
  4811. function __awaiter$2(thisArg, _arguments, P, generator) {
  4812. function adopt(value) {
  4813. return value instanceof P ? value : new P(function (resolve) {
  4814. resolve(value);
  4815. });
  4816. }
  4817. return new (P || (P = Promise))(function (resolve, reject) {
  4818. function fulfilled(value) {
  4819. try {
  4820. step(generator.next(value));
  4821. } catch (e) {
  4822. reject(e);
  4823. }
  4824. }
  4825. function rejected(value) {
  4826. try {
  4827. step(generator["throw"](value));
  4828. } catch (e) {
  4829. reject(e);
  4830. }
  4831. }
  4832. function step(result) {
  4833. result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
  4834. }
  4835. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4836. });
  4837. }
  4838. function __generator$2(thisArg, body) {
  4839. var _ = {
  4840. label: 0,
  4841. sent: function () {
  4842. if (t[0] & 1) throw t[1];
  4843. return t[1];
  4844. },
  4845. trys: [],
  4846. ops: []
  4847. },
  4848. f,
  4849. y,
  4850. t,
  4851. g;
  4852. return g = {
  4853. next: verb(0),
  4854. "throw": verb(1),
  4855. "return": verb(2)
  4856. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  4857. return this;
  4858. }), g;
  4859. function verb(n) {
  4860. return function (v) {
  4861. return step([n, v]);
  4862. };
  4863. }
  4864. function step(op) {
  4865. if (f) throw new TypeError("Generator is already executing.");
  4866. while (_) try {
  4867. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4868. if (y = 0, t) op = [op[0] & 2, t.value];
  4869. switch (op[0]) {
  4870. case 0:
  4871. case 1:
  4872. t = op;
  4873. break;
  4874. case 4:
  4875. _.label++;
  4876. return {
  4877. value: op[1],
  4878. done: false
  4879. };
  4880. case 5:
  4881. _.label++;
  4882. y = op[1];
  4883. op = [0];
  4884. continue;
  4885. case 7:
  4886. op = _.ops.pop();
  4887. _.trys.pop();
  4888. continue;
  4889. default:
  4890. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  4891. _ = 0;
  4892. continue;
  4893. }
  4894. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  4895. _.label = op[1];
  4896. break;
  4897. }
  4898. if (op[0] === 6 && _.label < t[1]) {
  4899. _.label = t[1];
  4900. t = op;
  4901. break;
  4902. }
  4903. if (t && _.label < t[2]) {
  4904. _.label = t[2];
  4905. _.ops.push(op);
  4906. break;
  4907. }
  4908. if (t[2]) _.ops.pop();
  4909. _.trys.pop();
  4910. continue;
  4911. }
  4912. op = body.call(thisArg, _);
  4913. } catch (e) {
  4914. op = [6, e];
  4915. y = 0;
  4916. } finally {
  4917. f = t = 0;
  4918. }
  4919. if (op[0] & 5) throw op[1];
  4920. return {
  4921. value: op[0] ? op[1] : void 0,
  4922. done: true
  4923. };
  4924. }
  4925. }
  4926. function __createBinding(o, m, k, k2) {
  4927. if (k2 === undefined) k2 = k;
  4928. o[k2] = m[k];
  4929. }
  4930. function __exportStar(m, exports) {
  4931. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
  4932. }
  4933. function __values(o) {
  4934. var s = typeof Symbol === "function" && Symbol.iterator,
  4935. m = s && o[s],
  4936. i = 0;
  4937. if (m) return m.call(o);
  4938. if (o && typeof o.length === "number") return {
  4939. next: function () {
  4940. if (o && i >= o.length) o = void 0;
  4941. return {
  4942. value: o && o[i++],
  4943. done: !o
  4944. };
  4945. }
  4946. };
  4947. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  4948. }
  4949. function __read(o, n) {
  4950. var m = typeof Symbol === "function" && o[Symbol.iterator];
  4951. if (!m) return o;
  4952. var i = m.call(o),
  4953. r,
  4954. ar = [],
  4955. e;
  4956. try {
  4957. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  4958. } catch (error) {
  4959. e = {
  4960. error: error
  4961. };
  4962. } finally {
  4963. try {
  4964. if (r && !r.done && (m = i["return"])) m.call(i);
  4965. } finally {
  4966. if (e) throw e.error;
  4967. }
  4968. }
  4969. return ar;
  4970. }
  4971. function __spread() {
  4972. for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
  4973. return ar;
  4974. }
  4975. function __spreadArrays() {
  4976. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  4977. for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
  4978. return r;
  4979. }
  4980. function __await(v) {
  4981. return this instanceof __await ? (this.v = v, this) : new __await(v);
  4982. }
  4983. function __asyncGenerator(thisArg, _arguments, generator) {
  4984. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  4985. var g = generator.apply(thisArg, _arguments || []),
  4986. i,
  4987. q = [];
  4988. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  4989. return this;
  4990. }, i;
  4991. function verb(n) {
  4992. if (g[n]) i[n] = function (v) {
  4993. return new Promise(function (a, b) {
  4994. q.push([n, v, a, b]) > 1 || resume(n, v);
  4995. });
  4996. };
  4997. }
  4998. function resume(n, v) {
  4999. try {
  5000. step(g[n](v));
  5001. } catch (e) {
  5002. settle(q[0][3], e);
  5003. }
  5004. }
  5005. function step(r) {
  5006. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  5007. }
  5008. function fulfill(value) {
  5009. resume("next", value);
  5010. }
  5011. function reject(value) {
  5012. resume("throw", value);
  5013. }
  5014. function settle(f, v) {
  5015. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  5016. }
  5017. }
  5018. function __asyncDelegator(o) {
  5019. var i, p;
  5020. return i = {}, verb("next"), verb("throw", function (e) {
  5021. throw e;
  5022. }), verb("return"), i[Symbol.iterator] = function () {
  5023. return this;
  5024. }, i;
  5025. function verb(n, f) {
  5026. i[n] = o[n] ? function (v) {
  5027. return (p = !p) ? {
  5028. value: __await(o[n](v)),
  5029. done: n === "return"
  5030. } : f ? f(v) : v;
  5031. } : f;
  5032. }
  5033. }
  5034. function __asyncValues(o) {
  5035. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5036. var m = o[Symbol.asyncIterator],
  5037. i;
  5038. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  5039. return this;
  5040. }, i);
  5041. function verb(n) {
  5042. i[n] = o[n] && function (v) {
  5043. return new Promise(function (resolve, reject) {
  5044. v = o[n](v), settle(resolve, reject, v.done, v.value);
  5045. });
  5046. };
  5047. }
  5048. function settle(resolve, reject, d, v) {
  5049. Promise.resolve(v).then(function (v) {
  5050. resolve({
  5051. value: v,
  5052. done: d
  5053. });
  5054. }, reject);
  5055. }
  5056. }
  5057. function __makeTemplateObject(cooked, raw) {
  5058. if (Object.defineProperty) {
  5059. Object.defineProperty(cooked, "raw", {
  5060. value: raw
  5061. });
  5062. } else {
  5063. cooked.raw = raw;
  5064. }
  5065. return cooked;
  5066. }
  5067. function __importStar$2(mod) {
  5068. if (mod && mod.__esModule) return mod;
  5069. var result = {};
  5070. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5071. result.default = mod;
  5072. return result;
  5073. }
  5074. function __importDefault$1(mod) {
  5075. return mod && mod.__esModule ? mod : {
  5076. default: mod
  5077. };
  5078. }
  5079. function __classPrivateFieldGet(receiver, privateMap) {
  5080. if (!privateMap.has(receiver)) {
  5081. throw new TypeError("attempted to get private field on non-instance");
  5082. }
  5083. return privateMap.get(receiver);
  5084. }
  5085. function __classPrivateFieldSet(receiver, privateMap, value) {
  5086. if (!privateMap.has(receiver)) {
  5087. throw new TypeError("attempted to set private field on non-instance");
  5088. }
  5089. privateMap.set(receiver, value);
  5090. return value;
  5091. }
  5092. var tslib_es6 = /*#__PURE__*/Object.freeze({
  5093. __proto__: null,
  5094. __extends: __extends,
  5095. get __assign () { return __assign; },
  5096. __rest: __rest,
  5097. __decorate: __decorate,
  5098. __param: __param,
  5099. __metadata: __metadata,
  5100. __awaiter: __awaiter$2,
  5101. __generator: __generator$2,
  5102. __createBinding: __createBinding,
  5103. __exportStar: __exportStar,
  5104. __values: __values,
  5105. __read: __read,
  5106. __spread: __spread,
  5107. __spreadArrays: __spreadArrays,
  5108. __await: __await,
  5109. __asyncGenerator: __asyncGenerator,
  5110. __asyncDelegator: __asyncDelegator,
  5111. __asyncValues: __asyncValues,
  5112. __makeTemplateObject: __makeTemplateObject,
  5113. __importStar: __importStar$2,
  5114. __importDefault: __importDefault$1,
  5115. __classPrivateFieldGet: __classPrivateFieldGet,
  5116. __classPrivateFieldSet: __classPrivateFieldSet
  5117. });
  5118. var api = createCommonjsModule(function (module, exports) {
  5119. Object.defineProperty(exports, "__esModule", {
  5120. value: true
  5121. });
  5122. exports.apiDescriptor = {
  5123. key: key => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key),
  5124. value(value) {
  5125. if (value === null || typeof value !== 'object') {
  5126. return JSON.stringify(value);
  5127. }
  5128. if (Array.isArray(value)) {
  5129. return `[${value.map(subValue => exports.apiDescriptor.value(subValue)).join(', ')}]`;
  5130. }
  5131. const keys = Object.keys(value);
  5132. return keys.length === 0 ? '{}' : `{ ${keys.map(key => `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`).join(', ')} }`;
  5133. },
  5134. pair: ({
  5135. key,
  5136. value
  5137. }) => exports.apiDescriptor.value({
  5138. [key]: value
  5139. })
  5140. };
  5141. });
  5142. var descriptors = createCommonjsModule(function (module, exports) {
  5143. Object.defineProperty(exports, "__esModule", {
  5144. value: true
  5145. });
  5146. tslib_es6.__exportStar(api, exports);
  5147. });
  5148. var matchOperatorsRe$1 = /[|\\{}()[\]^$+*?.]/g;
  5149. var escapeStringRegexp$1 = function (str) {
  5150. if (typeof str !== 'string') {
  5151. throw new TypeError('Expected a string');
  5152. }
  5153. return str.replace(matchOperatorsRe$1, '\\$&');
  5154. };
  5155. var colorName$1 = {
  5156. "aliceblue": [240, 248, 255],
  5157. "antiquewhite": [250, 235, 215],
  5158. "aqua": [0, 255, 255],
  5159. "aquamarine": [127, 255, 212],
  5160. "azure": [240, 255, 255],
  5161. "beige": [245, 245, 220],
  5162. "bisque": [255, 228, 196],
  5163. "black": [0, 0, 0],
  5164. "blanchedalmond": [255, 235, 205],
  5165. "blue": [0, 0, 255],
  5166. "blueviolet": [138, 43, 226],
  5167. "brown": [165, 42, 42],
  5168. "burlywood": [222, 184, 135],
  5169. "cadetblue": [95, 158, 160],
  5170. "chartreuse": [127, 255, 0],
  5171. "chocolate": [210, 105, 30],
  5172. "coral": [255, 127, 80],
  5173. "cornflowerblue": [100, 149, 237],
  5174. "cornsilk": [255, 248, 220],
  5175. "crimson": [220, 20, 60],
  5176. "cyan": [0, 255, 255],
  5177. "darkblue": [0, 0, 139],
  5178. "darkcyan": [0, 139, 139],
  5179. "darkgoldenrod": [184, 134, 11],
  5180. "darkgray": [169, 169, 169],
  5181. "darkgreen": [0, 100, 0],
  5182. "darkgrey": [169, 169, 169],
  5183. "darkkhaki": [189, 183, 107],
  5184. "darkmagenta": [139, 0, 139],
  5185. "darkolivegreen": [85, 107, 47],
  5186. "darkorange": [255, 140, 0],
  5187. "darkorchid": [153, 50, 204],
  5188. "darkred": [139, 0, 0],
  5189. "darksalmon": [233, 150, 122],
  5190. "darkseagreen": [143, 188, 143],
  5191. "darkslateblue": [72, 61, 139],
  5192. "darkslategray": [47, 79, 79],
  5193. "darkslategrey": [47, 79, 79],
  5194. "darkturquoise": [0, 206, 209],
  5195. "darkviolet": [148, 0, 211],
  5196. "deeppink": [255, 20, 147],
  5197. "deepskyblue": [0, 191, 255],
  5198. "dimgray": [105, 105, 105],
  5199. "dimgrey": [105, 105, 105],
  5200. "dodgerblue": [30, 144, 255],
  5201. "firebrick": [178, 34, 34],
  5202. "floralwhite": [255, 250, 240],
  5203. "forestgreen": [34, 139, 34],
  5204. "fuchsia": [255, 0, 255],
  5205. "gainsboro": [220, 220, 220],
  5206. "ghostwhite": [248, 248, 255],
  5207. "gold": [255, 215, 0],
  5208. "goldenrod": [218, 165, 32],
  5209. "gray": [128, 128, 128],
  5210. "green": [0, 128, 0],
  5211. "greenyellow": [173, 255, 47],
  5212. "grey": [128, 128, 128],
  5213. "honeydew": [240, 255, 240],
  5214. "hotpink": [255, 105, 180],
  5215. "indianred": [205, 92, 92],
  5216. "indigo": [75, 0, 130],
  5217. "ivory": [255, 255, 240],
  5218. "khaki": [240, 230, 140],
  5219. "lavender": [230, 230, 250],
  5220. "lavenderblush": [255, 240, 245],
  5221. "lawngreen": [124, 252, 0],
  5222. "lemonchiffon": [255, 250, 205],
  5223. "lightblue": [173, 216, 230],
  5224. "lightcoral": [240, 128, 128],
  5225. "lightcyan": [224, 255, 255],
  5226. "lightgoldenrodyellow": [250, 250, 210],
  5227. "lightgray": [211, 211, 211],
  5228. "lightgreen": [144, 238, 144],
  5229. "lightgrey": [211, 211, 211],
  5230. "lightpink": [255, 182, 193],
  5231. "lightsalmon": [255, 160, 122],
  5232. "lightseagreen": [32, 178, 170],
  5233. "lightskyblue": [135, 206, 250],
  5234. "lightslategray": [119, 136, 153],
  5235. "lightslategrey": [119, 136, 153],
  5236. "lightsteelblue": [176, 196, 222],
  5237. "lightyellow": [255, 255, 224],
  5238. "lime": [0, 255, 0],
  5239. "limegreen": [50, 205, 50],
  5240. "linen": [250, 240, 230],
  5241. "magenta": [255, 0, 255],
  5242. "maroon": [128, 0, 0],
  5243. "mediumaquamarine": [102, 205, 170],
  5244. "mediumblue": [0, 0, 205],
  5245. "mediumorchid": [186, 85, 211],
  5246. "mediumpurple": [147, 112, 219],
  5247. "mediumseagreen": [60, 179, 113],
  5248. "mediumslateblue": [123, 104, 238],
  5249. "mediumspringgreen": [0, 250, 154],
  5250. "mediumturquoise": [72, 209, 204],
  5251. "mediumvioletred": [199, 21, 133],
  5252. "midnightblue": [25, 25, 112],
  5253. "mintcream": [245, 255, 250],
  5254. "mistyrose": [255, 228, 225],
  5255. "moccasin": [255, 228, 181],
  5256. "navajowhite": [255, 222, 173],
  5257. "navy": [0, 0, 128],
  5258. "oldlace": [253, 245, 230],
  5259. "olive": [128, 128, 0],
  5260. "olivedrab": [107, 142, 35],
  5261. "orange": [255, 165, 0],
  5262. "orangered": [255, 69, 0],
  5263. "orchid": [218, 112, 214],
  5264. "palegoldenrod": [238, 232, 170],
  5265. "palegreen": [152, 251, 152],
  5266. "paleturquoise": [175, 238, 238],
  5267. "palevioletred": [219, 112, 147],
  5268. "papayawhip": [255, 239, 213],
  5269. "peachpuff": [255, 218, 185],
  5270. "peru": [205, 133, 63],
  5271. "pink": [255, 192, 203],
  5272. "plum": [221, 160, 221],
  5273. "powderblue": [176, 224, 230],
  5274. "purple": [128, 0, 128],
  5275. "rebeccapurple": [102, 51, 153],
  5276. "red": [255, 0, 0],
  5277. "rosybrown": [188, 143, 143],
  5278. "royalblue": [65, 105, 225],
  5279. "saddlebrown": [139, 69, 19],
  5280. "salmon": [250, 128, 114],
  5281. "sandybrown": [244, 164, 96],
  5282. "seagreen": [46, 139, 87],
  5283. "seashell": [255, 245, 238],
  5284. "sienna": [160, 82, 45],
  5285. "silver": [192, 192, 192],
  5286. "skyblue": [135, 206, 235],
  5287. "slateblue": [106, 90, 205],
  5288. "slategray": [112, 128, 144],
  5289. "slategrey": [112, 128, 144],
  5290. "snow": [255, 250, 250],
  5291. "springgreen": [0, 255, 127],
  5292. "steelblue": [70, 130, 180],
  5293. "tan": [210, 180, 140],
  5294. "teal": [0, 128, 128],
  5295. "thistle": [216, 191, 216],
  5296. "tomato": [255, 99, 71],
  5297. "turquoise": [64, 224, 208],
  5298. "violet": [238, 130, 238],
  5299. "wheat": [245, 222, 179],
  5300. "white": [255, 255, 255],
  5301. "whitesmoke": [245, 245, 245],
  5302. "yellow": [255, 255, 0],
  5303. "yellowgreen": [154, 205, 50]
  5304. };
  5305. /* MIT license */
  5306. var conversions$1 = createCommonjsModule(function (module) {
  5307. // NOTE: conversions should only return primitive values (i.e. arrays, or
  5308. // values that give correct `typeof` results).
  5309. // do not use box values types (i.e. Number(), String(), etc.)
  5310. var reverseKeywords = {};
  5311. for (var key in colorName$1) {
  5312. if (colorName$1.hasOwnProperty(key)) {
  5313. reverseKeywords[colorName$1[key]] = key;
  5314. }
  5315. }
  5316. var convert = module.exports = {
  5317. rgb: {
  5318. channels: 3,
  5319. labels: 'rgb'
  5320. },
  5321. hsl: {
  5322. channels: 3,
  5323. labels: 'hsl'
  5324. },
  5325. hsv: {
  5326. channels: 3,
  5327. labels: 'hsv'
  5328. },
  5329. hwb: {
  5330. channels: 3,
  5331. labels: 'hwb'
  5332. },
  5333. cmyk: {
  5334. channels: 4,
  5335. labels: 'cmyk'
  5336. },
  5337. xyz: {
  5338. channels: 3,
  5339. labels: 'xyz'
  5340. },
  5341. lab: {
  5342. channels: 3,
  5343. labels: 'lab'
  5344. },
  5345. lch: {
  5346. channels: 3,
  5347. labels: 'lch'
  5348. },
  5349. hex: {
  5350. channels: 1,
  5351. labels: ['hex']
  5352. },
  5353. keyword: {
  5354. channels: 1,
  5355. labels: ['keyword']
  5356. },
  5357. ansi16: {
  5358. channels: 1,
  5359. labels: ['ansi16']
  5360. },
  5361. ansi256: {
  5362. channels: 1,
  5363. labels: ['ansi256']
  5364. },
  5365. hcg: {
  5366. channels: 3,
  5367. labels: ['h', 'c', 'g']
  5368. },
  5369. apple: {
  5370. channels: 3,
  5371. labels: ['r16', 'g16', 'b16']
  5372. },
  5373. gray: {
  5374. channels: 1,
  5375. labels: ['gray']
  5376. }
  5377. }; // hide .channels and .labels properties
  5378. for (var model in convert) {
  5379. if (convert.hasOwnProperty(model)) {
  5380. if (!('channels' in convert[model])) {
  5381. throw new Error('missing channels property: ' + model);
  5382. }
  5383. if (!('labels' in convert[model])) {
  5384. throw new Error('missing channel labels property: ' + model);
  5385. }
  5386. if (convert[model].labels.length !== convert[model].channels) {
  5387. throw new Error('channel and label counts mismatch: ' + model);
  5388. }
  5389. var channels = convert[model].channels;
  5390. var labels = convert[model].labels;
  5391. delete convert[model].channels;
  5392. delete convert[model].labels;
  5393. Object.defineProperty(convert[model], 'channels', {
  5394. value: channels
  5395. });
  5396. Object.defineProperty(convert[model], 'labels', {
  5397. value: labels
  5398. });
  5399. }
  5400. }
  5401. convert.rgb.hsl = function (rgb) {
  5402. var r = rgb[0] / 255;
  5403. var g = rgb[1] / 255;
  5404. var b = rgb[2] / 255;
  5405. var min = Math.min(r, g, b);
  5406. var max = Math.max(r, g, b);
  5407. var delta = max - min;
  5408. var h;
  5409. var s;
  5410. var l;
  5411. if (max === min) {
  5412. h = 0;
  5413. } else if (r === max) {
  5414. h = (g - b) / delta;
  5415. } else if (g === max) {
  5416. h = 2 + (b - r) / delta;
  5417. } else if (b === max) {
  5418. h = 4 + (r - g) / delta;
  5419. }
  5420. h = Math.min(h * 60, 360);
  5421. if (h < 0) {
  5422. h += 360;
  5423. }
  5424. l = (min + max) / 2;
  5425. if (max === min) {
  5426. s = 0;
  5427. } else if (l <= 0.5) {
  5428. s = delta / (max + min);
  5429. } else {
  5430. s = delta / (2 - max - min);
  5431. }
  5432. return [h, s * 100, l * 100];
  5433. };
  5434. convert.rgb.hsv = function (rgb) {
  5435. var rdif;
  5436. var gdif;
  5437. var bdif;
  5438. var h;
  5439. var s;
  5440. var r = rgb[0] / 255;
  5441. var g = rgb[1] / 255;
  5442. var b = rgb[2] / 255;
  5443. var v = Math.max(r, g, b);
  5444. var diff = v - Math.min(r, g, b);
  5445. var diffc = function (c) {
  5446. return (v - c) / 6 / diff + 1 / 2;
  5447. };
  5448. if (diff === 0) {
  5449. h = s = 0;
  5450. } else {
  5451. s = diff / v;
  5452. rdif = diffc(r);
  5453. gdif = diffc(g);
  5454. bdif = diffc(b);
  5455. if (r === v) {
  5456. h = bdif - gdif;
  5457. } else if (g === v) {
  5458. h = 1 / 3 + rdif - bdif;
  5459. } else if (b === v) {
  5460. h = 2 / 3 + gdif - rdif;
  5461. }
  5462. if (h < 0) {
  5463. h += 1;
  5464. } else if (h > 1) {
  5465. h -= 1;
  5466. }
  5467. }
  5468. return [h * 360, s * 100, v * 100];
  5469. };
  5470. convert.rgb.hwb = function (rgb) {
  5471. var r = rgb[0];
  5472. var g = rgb[1];
  5473. var b = rgb[2];
  5474. var h = convert.rgb.hsl(rgb)[0];
  5475. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  5476. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  5477. return [h, w * 100, b * 100];
  5478. };
  5479. convert.rgb.cmyk = function (rgb) {
  5480. var r = rgb[0] / 255;
  5481. var g = rgb[1] / 255;
  5482. var b = rgb[2] / 255;
  5483. var c;
  5484. var m;
  5485. var y;
  5486. var k;
  5487. k = Math.min(1 - r, 1 - g, 1 - b);
  5488. c = (1 - r - k) / (1 - k) || 0;
  5489. m = (1 - g - k) / (1 - k) || 0;
  5490. y = (1 - b - k) / (1 - k) || 0;
  5491. return [c * 100, m * 100, y * 100, k * 100];
  5492. };
  5493. /**
  5494. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  5495. * */
  5496. function comparativeDistance(x, y) {
  5497. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  5498. }
  5499. convert.rgb.keyword = function (rgb) {
  5500. var reversed = reverseKeywords[rgb];
  5501. if (reversed) {
  5502. return reversed;
  5503. }
  5504. var currentClosestDistance = Infinity;
  5505. var currentClosestKeyword;
  5506. for (var keyword in colorName$1) {
  5507. if (colorName$1.hasOwnProperty(keyword)) {
  5508. var value = colorName$1[keyword]; // Compute comparative distance
  5509. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  5510. if (distance < currentClosestDistance) {
  5511. currentClosestDistance = distance;
  5512. currentClosestKeyword = keyword;
  5513. }
  5514. }
  5515. }
  5516. return currentClosestKeyword;
  5517. };
  5518. convert.keyword.rgb = function (keyword) {
  5519. return colorName$1[keyword];
  5520. };
  5521. convert.rgb.xyz = function (rgb) {
  5522. var r = rgb[0] / 255;
  5523. var g = rgb[1] / 255;
  5524. var b = rgb[2] / 255; // assume sRGB
  5525. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  5526. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  5527. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  5528. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  5529. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  5530. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  5531. return [x * 100, y * 100, z * 100];
  5532. };
  5533. convert.rgb.lab = function (rgb) {
  5534. var xyz = convert.rgb.xyz(rgb);
  5535. var x = xyz[0];
  5536. var y = xyz[1];
  5537. var z = xyz[2];
  5538. var l;
  5539. var a;
  5540. var b;
  5541. x /= 95.047;
  5542. y /= 100;
  5543. z /= 108.883;
  5544. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  5545. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  5546. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  5547. l = 116 * y - 16;
  5548. a = 500 * (x - y);
  5549. b = 200 * (y - z);
  5550. return [l, a, b];
  5551. };
  5552. convert.hsl.rgb = function (hsl) {
  5553. var h = hsl[0] / 360;
  5554. var s = hsl[1] / 100;
  5555. var l = hsl[2] / 100;
  5556. var t1;
  5557. var t2;
  5558. var t3;
  5559. var rgb;
  5560. var val;
  5561. if (s === 0) {
  5562. val = l * 255;
  5563. return [val, val, val];
  5564. }
  5565. if (l < 0.5) {
  5566. t2 = l * (1 + s);
  5567. } else {
  5568. t2 = l + s - l * s;
  5569. }
  5570. t1 = 2 * l - t2;
  5571. rgb = [0, 0, 0];
  5572. for (var i = 0; i < 3; i++) {
  5573. t3 = h + 1 / 3 * -(i - 1);
  5574. if (t3 < 0) {
  5575. t3++;
  5576. }
  5577. if (t3 > 1) {
  5578. t3--;
  5579. }
  5580. if (6 * t3 < 1) {
  5581. val = t1 + (t2 - t1) * 6 * t3;
  5582. } else if (2 * t3 < 1) {
  5583. val = t2;
  5584. } else if (3 * t3 < 2) {
  5585. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  5586. } else {
  5587. val = t1;
  5588. }
  5589. rgb[i] = val * 255;
  5590. }
  5591. return rgb;
  5592. };
  5593. convert.hsl.hsv = function (hsl) {
  5594. var h = hsl[0];
  5595. var s = hsl[1] / 100;
  5596. var l = hsl[2] / 100;
  5597. var smin = s;
  5598. var lmin = Math.max(l, 0.01);
  5599. var sv;
  5600. var v;
  5601. l *= 2;
  5602. s *= l <= 1 ? l : 2 - l;
  5603. smin *= lmin <= 1 ? lmin : 2 - lmin;
  5604. v = (l + s) / 2;
  5605. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  5606. return [h, sv * 100, v * 100];
  5607. };
  5608. convert.hsv.rgb = function (hsv) {
  5609. var h = hsv[0] / 60;
  5610. var s = hsv[1] / 100;
  5611. var v = hsv[2] / 100;
  5612. var hi = Math.floor(h) % 6;
  5613. var f = h - Math.floor(h);
  5614. var p = 255 * v * (1 - s);
  5615. var q = 255 * v * (1 - s * f);
  5616. var t = 255 * v * (1 - s * (1 - f));
  5617. v *= 255;
  5618. switch (hi) {
  5619. case 0:
  5620. return [v, t, p];
  5621. case 1:
  5622. return [q, v, p];
  5623. case 2:
  5624. return [p, v, t];
  5625. case 3:
  5626. return [p, q, v];
  5627. case 4:
  5628. return [t, p, v];
  5629. case 5:
  5630. return [v, p, q];
  5631. }
  5632. };
  5633. convert.hsv.hsl = function (hsv) {
  5634. var h = hsv[0];
  5635. var s = hsv[1] / 100;
  5636. var v = hsv[2] / 100;
  5637. var vmin = Math.max(v, 0.01);
  5638. var lmin;
  5639. var sl;
  5640. var l;
  5641. l = (2 - s) * v;
  5642. lmin = (2 - s) * vmin;
  5643. sl = s * vmin;
  5644. sl /= lmin <= 1 ? lmin : 2 - lmin;
  5645. sl = sl || 0;
  5646. l /= 2;
  5647. return [h, sl * 100, l * 100];
  5648. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  5649. convert.hwb.rgb = function (hwb) {
  5650. var h = hwb[0] / 360;
  5651. var wh = hwb[1] / 100;
  5652. var bl = hwb[2] / 100;
  5653. var ratio = wh + bl;
  5654. var i;
  5655. var v;
  5656. var f;
  5657. var n; // wh + bl cant be > 1
  5658. if (ratio > 1) {
  5659. wh /= ratio;
  5660. bl /= ratio;
  5661. }
  5662. i = Math.floor(6 * h);
  5663. v = 1 - bl;
  5664. f = 6 * h - i;
  5665. if ((i & 0x01) !== 0) {
  5666. f = 1 - f;
  5667. }
  5668. n = wh + f * (v - wh); // linear interpolation
  5669. var r;
  5670. var g;
  5671. var b;
  5672. switch (i) {
  5673. default:
  5674. case 6:
  5675. case 0:
  5676. r = v;
  5677. g = n;
  5678. b = wh;
  5679. break;
  5680. case 1:
  5681. r = n;
  5682. g = v;
  5683. b = wh;
  5684. break;
  5685. case 2:
  5686. r = wh;
  5687. g = v;
  5688. b = n;
  5689. break;
  5690. case 3:
  5691. r = wh;
  5692. g = n;
  5693. b = v;
  5694. break;
  5695. case 4:
  5696. r = n;
  5697. g = wh;
  5698. b = v;
  5699. break;
  5700. case 5:
  5701. r = v;
  5702. g = wh;
  5703. b = n;
  5704. break;
  5705. }
  5706. return [r * 255, g * 255, b * 255];
  5707. };
  5708. convert.cmyk.rgb = function (cmyk) {
  5709. var c = cmyk[0] / 100;
  5710. var m = cmyk[1] / 100;
  5711. var y = cmyk[2] / 100;
  5712. var k = cmyk[3] / 100;
  5713. var r;
  5714. var g;
  5715. var b;
  5716. r = 1 - Math.min(1, c * (1 - k) + k);
  5717. g = 1 - Math.min(1, m * (1 - k) + k);
  5718. b = 1 - Math.min(1, y * (1 - k) + k);
  5719. return [r * 255, g * 255, b * 255];
  5720. };
  5721. convert.xyz.rgb = function (xyz) {
  5722. var x = xyz[0] / 100;
  5723. var y = xyz[1] / 100;
  5724. var z = xyz[2] / 100;
  5725. var r;
  5726. var g;
  5727. var b;
  5728. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  5729. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  5730. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  5731. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  5732. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  5733. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  5734. r = Math.min(Math.max(0, r), 1);
  5735. g = Math.min(Math.max(0, g), 1);
  5736. b = Math.min(Math.max(0, b), 1);
  5737. return [r * 255, g * 255, b * 255];
  5738. };
  5739. convert.xyz.lab = function (xyz) {
  5740. var x = xyz[0];
  5741. var y = xyz[1];
  5742. var z = xyz[2];
  5743. var l;
  5744. var a;
  5745. var b;
  5746. x /= 95.047;
  5747. y /= 100;
  5748. z /= 108.883;
  5749. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  5750. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  5751. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  5752. l = 116 * y - 16;
  5753. a = 500 * (x - y);
  5754. b = 200 * (y - z);
  5755. return [l, a, b];
  5756. };
  5757. convert.lab.xyz = function (lab) {
  5758. var l = lab[0];
  5759. var a = lab[1];
  5760. var b = lab[2];
  5761. var x;
  5762. var y;
  5763. var z;
  5764. y = (l + 16) / 116;
  5765. x = a / 500 + y;
  5766. z = y - b / 200;
  5767. var y2 = Math.pow(y, 3);
  5768. var x2 = Math.pow(x, 3);
  5769. var z2 = Math.pow(z, 3);
  5770. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  5771. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  5772. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  5773. x *= 95.047;
  5774. y *= 100;
  5775. z *= 108.883;
  5776. return [x, y, z];
  5777. };
  5778. convert.lab.lch = function (lab) {
  5779. var l = lab[0];
  5780. var a = lab[1];
  5781. var b = lab[2];
  5782. var hr;
  5783. var h;
  5784. var c;
  5785. hr = Math.atan2(b, a);
  5786. h = hr * 360 / 2 / Math.PI;
  5787. if (h < 0) {
  5788. h += 360;
  5789. }
  5790. c = Math.sqrt(a * a + b * b);
  5791. return [l, c, h];
  5792. };
  5793. convert.lch.lab = function (lch) {
  5794. var l = lch[0];
  5795. var c = lch[1];
  5796. var h = lch[2];
  5797. var a;
  5798. var b;
  5799. var hr;
  5800. hr = h / 360 * 2 * Math.PI;
  5801. a = c * Math.cos(hr);
  5802. b = c * Math.sin(hr);
  5803. return [l, a, b];
  5804. };
  5805. convert.rgb.ansi16 = function (args) {
  5806. var r = args[0];
  5807. var g = args[1];
  5808. var b = args[2];
  5809. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  5810. value = Math.round(value / 50);
  5811. if (value === 0) {
  5812. return 30;
  5813. }
  5814. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  5815. if (value === 2) {
  5816. ansi += 60;
  5817. }
  5818. return ansi;
  5819. };
  5820. convert.hsv.ansi16 = function (args) {
  5821. // optimization here; we already know the value and don't need to get
  5822. // it converted for us.
  5823. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  5824. };
  5825. convert.rgb.ansi256 = function (args) {
  5826. var r = args[0];
  5827. var g = args[1];
  5828. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  5829. // black and white. normal palette only has 4 greyscale shades.
  5830. if (r === g && g === b) {
  5831. if (r < 8) {
  5832. return 16;
  5833. }
  5834. if (r > 248) {
  5835. return 231;
  5836. }
  5837. return Math.round((r - 8) / 247 * 24) + 232;
  5838. }
  5839. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  5840. return ansi;
  5841. };
  5842. convert.ansi16.rgb = function (args) {
  5843. var color = args % 10; // handle greyscale
  5844. if (color === 0 || color === 7) {
  5845. if (args > 50) {
  5846. color += 3.5;
  5847. }
  5848. color = color / 10.5 * 255;
  5849. return [color, color, color];
  5850. }
  5851. var mult = (~~(args > 50) + 1) * 0.5;
  5852. var r = (color & 1) * mult * 255;
  5853. var g = (color >> 1 & 1) * mult * 255;
  5854. var b = (color >> 2 & 1) * mult * 255;
  5855. return [r, g, b];
  5856. };
  5857. convert.ansi256.rgb = function (args) {
  5858. // handle greyscale
  5859. if (args >= 232) {
  5860. var c = (args - 232) * 10 + 8;
  5861. return [c, c, c];
  5862. }
  5863. args -= 16;
  5864. var rem;
  5865. var r = Math.floor(args / 36) / 5 * 255;
  5866. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  5867. var b = rem % 6 / 5 * 255;
  5868. return [r, g, b];
  5869. };
  5870. convert.rgb.hex = function (args) {
  5871. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  5872. var string = integer.toString(16).toUpperCase();
  5873. return '000000'.substring(string.length) + string;
  5874. };
  5875. convert.hex.rgb = function (args) {
  5876. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  5877. if (!match) {
  5878. return [0, 0, 0];
  5879. }
  5880. var colorString = match[0];
  5881. if (match[0].length === 3) {
  5882. colorString = colorString.split('').map(function (char) {
  5883. return char + char;
  5884. }).join('');
  5885. }
  5886. var integer = parseInt(colorString, 16);
  5887. var r = integer >> 16 & 0xFF;
  5888. var g = integer >> 8 & 0xFF;
  5889. var b = integer & 0xFF;
  5890. return [r, g, b];
  5891. };
  5892. convert.rgb.hcg = function (rgb) {
  5893. var r = rgb[0] / 255;
  5894. var g = rgb[1] / 255;
  5895. var b = rgb[2] / 255;
  5896. var max = Math.max(Math.max(r, g), b);
  5897. var min = Math.min(Math.min(r, g), b);
  5898. var chroma = max - min;
  5899. var grayscale;
  5900. var hue;
  5901. if (chroma < 1) {
  5902. grayscale = min / (1 - chroma);
  5903. } else {
  5904. grayscale = 0;
  5905. }
  5906. if (chroma <= 0) {
  5907. hue = 0;
  5908. } else if (max === r) {
  5909. hue = (g - b) / chroma % 6;
  5910. } else if (max === g) {
  5911. hue = 2 + (b - r) / chroma;
  5912. } else {
  5913. hue = 4 + (r - g) / chroma + 4;
  5914. }
  5915. hue /= 6;
  5916. hue %= 1;
  5917. return [hue * 360, chroma * 100, grayscale * 100];
  5918. };
  5919. convert.hsl.hcg = function (hsl) {
  5920. var s = hsl[1] / 100;
  5921. var l = hsl[2] / 100;
  5922. var c = 1;
  5923. var f = 0;
  5924. if (l < 0.5) {
  5925. c = 2.0 * s * l;
  5926. } else {
  5927. c = 2.0 * s * (1.0 - l);
  5928. }
  5929. if (c < 1.0) {
  5930. f = (l - 0.5 * c) / (1.0 - c);
  5931. }
  5932. return [hsl[0], c * 100, f * 100];
  5933. };
  5934. convert.hsv.hcg = function (hsv) {
  5935. var s = hsv[1] / 100;
  5936. var v = hsv[2] / 100;
  5937. var c = s * v;
  5938. var f = 0;
  5939. if (c < 1.0) {
  5940. f = (v - c) / (1 - c);
  5941. }
  5942. return [hsv[0], c * 100, f * 100];
  5943. };
  5944. convert.hcg.rgb = function (hcg) {
  5945. var h = hcg[0] / 360;
  5946. var c = hcg[1] / 100;
  5947. var g = hcg[2] / 100;
  5948. if (c === 0.0) {
  5949. return [g * 255, g * 255, g * 255];
  5950. }
  5951. var pure = [0, 0, 0];
  5952. var hi = h % 1 * 6;
  5953. var v = hi % 1;
  5954. var w = 1 - v;
  5955. var mg = 0;
  5956. switch (Math.floor(hi)) {
  5957. case 0:
  5958. pure[0] = 1;
  5959. pure[1] = v;
  5960. pure[2] = 0;
  5961. break;
  5962. case 1:
  5963. pure[0] = w;
  5964. pure[1] = 1;
  5965. pure[2] = 0;
  5966. break;
  5967. case 2:
  5968. pure[0] = 0;
  5969. pure[1] = 1;
  5970. pure[2] = v;
  5971. break;
  5972. case 3:
  5973. pure[0] = 0;
  5974. pure[1] = w;
  5975. pure[2] = 1;
  5976. break;
  5977. case 4:
  5978. pure[0] = v;
  5979. pure[1] = 0;
  5980. pure[2] = 1;
  5981. break;
  5982. default:
  5983. pure[0] = 1;
  5984. pure[1] = 0;
  5985. pure[2] = w;
  5986. }
  5987. mg = (1.0 - c) * g;
  5988. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  5989. };
  5990. convert.hcg.hsv = function (hcg) {
  5991. var c = hcg[1] / 100;
  5992. var g = hcg[2] / 100;
  5993. var v = c + g * (1.0 - c);
  5994. var f = 0;
  5995. if (v > 0.0) {
  5996. f = c / v;
  5997. }
  5998. return [hcg[0], f * 100, v * 100];
  5999. };
  6000. convert.hcg.hsl = function (hcg) {
  6001. var c = hcg[1] / 100;
  6002. var g = hcg[2] / 100;
  6003. var l = g * (1.0 - c) + 0.5 * c;
  6004. var s = 0;
  6005. if (l > 0.0 && l < 0.5) {
  6006. s = c / (2 * l);
  6007. } else if (l >= 0.5 && l < 1.0) {
  6008. s = c / (2 * (1 - l));
  6009. }
  6010. return [hcg[0], s * 100, l * 100];
  6011. };
  6012. convert.hcg.hwb = function (hcg) {
  6013. var c = hcg[1] / 100;
  6014. var g = hcg[2] / 100;
  6015. var v = c + g * (1.0 - c);
  6016. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  6017. };
  6018. convert.hwb.hcg = function (hwb) {
  6019. var w = hwb[1] / 100;
  6020. var b = hwb[2] / 100;
  6021. var v = 1 - b;
  6022. var c = v - w;
  6023. var g = 0;
  6024. if (c < 1) {
  6025. g = (v - c) / (1 - c);
  6026. }
  6027. return [hwb[0], c * 100, g * 100];
  6028. };
  6029. convert.apple.rgb = function (apple) {
  6030. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  6031. };
  6032. convert.rgb.apple = function (rgb) {
  6033. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  6034. };
  6035. convert.gray.rgb = function (args) {
  6036. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  6037. };
  6038. convert.gray.hsl = convert.gray.hsv = function (args) {
  6039. return [0, 0, args[0]];
  6040. };
  6041. convert.gray.hwb = function (gray) {
  6042. return [0, 100, gray[0]];
  6043. };
  6044. convert.gray.cmyk = function (gray) {
  6045. return [0, 0, 0, gray[0]];
  6046. };
  6047. convert.gray.lab = function (gray) {
  6048. return [gray[0], 0, 0];
  6049. };
  6050. convert.gray.hex = function (gray) {
  6051. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  6052. var integer = (val << 16) + (val << 8) + val;
  6053. var string = integer.toString(16).toUpperCase();
  6054. return '000000'.substring(string.length) + string;
  6055. };
  6056. convert.rgb.gray = function (rgb) {
  6057. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  6058. return [val / 255 * 100];
  6059. };
  6060. });
  6061. /*
  6062. this function routes a model to all other models.
  6063. all functions that are routed have a property `.conversion` attached
  6064. to the returned synthetic function. This property is an array
  6065. of strings, each with the steps in between the 'from' and 'to'
  6066. color models (inclusive).
  6067. conversions that are not possible simply are not included.
  6068. */
  6069. function buildGraph$1() {
  6070. var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  6071. var models = Object.keys(conversions$1);
  6072. for (var len = models.length, i = 0; i < len; i++) {
  6073. graph[models[i]] = {
  6074. // http://jsperf.com/1-vs-infinity
  6075. // micro-opt, but this is simple.
  6076. distance: -1,
  6077. parent: null
  6078. };
  6079. }
  6080. return graph;
  6081. } // https://en.wikipedia.org/wiki/Breadth-first_search
  6082. function deriveBFS$1(fromModel) {
  6083. var graph = buildGraph$1();
  6084. var queue = [fromModel]; // unshift -> queue -> pop
  6085. graph[fromModel].distance = 0;
  6086. while (queue.length) {
  6087. var current = queue.pop();
  6088. var adjacents = Object.keys(conversions$1[current]);
  6089. for (var len = adjacents.length, i = 0; i < len; i++) {
  6090. var adjacent = adjacents[i];
  6091. var node = graph[adjacent];
  6092. if (node.distance === -1) {
  6093. node.distance = graph[current].distance + 1;
  6094. node.parent = current;
  6095. queue.unshift(adjacent);
  6096. }
  6097. }
  6098. }
  6099. return graph;
  6100. }
  6101. function link$2(from, to) {
  6102. return function (args) {
  6103. return to(from(args));
  6104. };
  6105. }
  6106. function wrapConversion$1(toModel, graph) {
  6107. var path = [graph[toModel].parent, toModel];
  6108. var fn = conversions$1[graph[toModel].parent][toModel];
  6109. var cur = graph[toModel].parent;
  6110. while (graph[cur].parent) {
  6111. path.unshift(graph[cur].parent);
  6112. fn = link$2(conversions$1[graph[cur].parent][cur], fn);
  6113. cur = graph[cur].parent;
  6114. }
  6115. fn.conversion = path;
  6116. return fn;
  6117. }
  6118. var route$1 = function (fromModel) {
  6119. var graph = deriveBFS$1(fromModel);
  6120. var conversion = {};
  6121. var models = Object.keys(graph);
  6122. for (var len = models.length, i = 0; i < len; i++) {
  6123. var toModel = models[i];
  6124. var node = graph[toModel];
  6125. if (node.parent === null) {
  6126. // no possible conversion, or this node is the source model.
  6127. continue;
  6128. }
  6129. conversion[toModel] = wrapConversion$1(toModel, graph);
  6130. }
  6131. return conversion;
  6132. };
  6133. var convert$2 = {};
  6134. var models$1 = Object.keys(conversions$1);
  6135. function wrapRaw$1(fn) {
  6136. var wrappedFn = function (args) {
  6137. if (args === undefined || args === null) {
  6138. return args;
  6139. }
  6140. if (arguments.length > 1) {
  6141. args = Array.prototype.slice.call(arguments);
  6142. }
  6143. return fn(args);
  6144. }; // preserve .conversion property if there is one
  6145. if ('conversion' in fn) {
  6146. wrappedFn.conversion = fn.conversion;
  6147. }
  6148. return wrappedFn;
  6149. }
  6150. function wrapRounded$1(fn) {
  6151. var wrappedFn = function (args) {
  6152. if (args === undefined || args === null) {
  6153. return args;
  6154. }
  6155. if (arguments.length > 1) {
  6156. args = Array.prototype.slice.call(arguments);
  6157. }
  6158. var result = fn(args); // we're assuming the result is an array here.
  6159. // see notice in conversions.js; don't use box types
  6160. // in conversion functions.
  6161. if (typeof result === 'object') {
  6162. for (var len = result.length, i = 0; i < len; i++) {
  6163. result[i] = Math.round(result[i]);
  6164. }
  6165. }
  6166. return result;
  6167. }; // preserve .conversion property if there is one
  6168. if ('conversion' in fn) {
  6169. wrappedFn.conversion = fn.conversion;
  6170. }
  6171. return wrappedFn;
  6172. }
  6173. models$1.forEach(function (fromModel) {
  6174. convert$2[fromModel] = {};
  6175. Object.defineProperty(convert$2[fromModel], 'channels', {
  6176. value: conversions$1[fromModel].channels
  6177. });
  6178. Object.defineProperty(convert$2[fromModel], 'labels', {
  6179. value: conversions$1[fromModel].labels
  6180. });
  6181. var routes = route$1(fromModel);
  6182. var routeModels = Object.keys(routes);
  6183. routeModels.forEach(function (toModel) {
  6184. var fn = routes[toModel];
  6185. convert$2[fromModel][toModel] = wrapRounded$1(fn);
  6186. convert$2[fromModel][toModel].raw = wrapRaw$1(fn);
  6187. });
  6188. });
  6189. var colorConvert$1 = convert$2;
  6190. var ansiStyles$2 = createCommonjsModule(function (module) {
  6191. const wrapAnsi16 = (fn, offset) => function () {
  6192. const code = fn.apply(colorConvert$1, arguments);
  6193. return `\u001B[${code + offset}m`;
  6194. };
  6195. const wrapAnsi256 = (fn, offset) => function () {
  6196. const code = fn.apply(colorConvert$1, arguments);
  6197. return `\u001B[${38 + offset};5;${code}m`;
  6198. };
  6199. const wrapAnsi16m = (fn, offset) => function () {
  6200. const rgb = fn.apply(colorConvert$1, arguments);
  6201. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  6202. };
  6203. function assembleStyles() {
  6204. const codes = new Map();
  6205. const styles = {
  6206. modifier: {
  6207. reset: [0, 0],
  6208. // 21 isn't widely supported and 22 does the same thing
  6209. bold: [1, 22],
  6210. dim: [2, 22],
  6211. italic: [3, 23],
  6212. underline: [4, 24],
  6213. inverse: [7, 27],
  6214. hidden: [8, 28],
  6215. strikethrough: [9, 29]
  6216. },
  6217. color: {
  6218. black: [30, 39],
  6219. red: [31, 39],
  6220. green: [32, 39],
  6221. yellow: [33, 39],
  6222. blue: [34, 39],
  6223. magenta: [35, 39],
  6224. cyan: [36, 39],
  6225. white: [37, 39],
  6226. gray: [90, 39],
  6227. // Bright color
  6228. redBright: [91, 39],
  6229. greenBright: [92, 39],
  6230. yellowBright: [93, 39],
  6231. blueBright: [94, 39],
  6232. magentaBright: [95, 39],
  6233. cyanBright: [96, 39],
  6234. whiteBright: [97, 39]
  6235. },
  6236. bgColor: {
  6237. bgBlack: [40, 49],
  6238. bgRed: [41, 49],
  6239. bgGreen: [42, 49],
  6240. bgYellow: [43, 49],
  6241. bgBlue: [44, 49],
  6242. bgMagenta: [45, 49],
  6243. bgCyan: [46, 49],
  6244. bgWhite: [47, 49],
  6245. // Bright color
  6246. bgBlackBright: [100, 49],
  6247. bgRedBright: [101, 49],
  6248. bgGreenBright: [102, 49],
  6249. bgYellowBright: [103, 49],
  6250. bgBlueBright: [104, 49],
  6251. bgMagentaBright: [105, 49],
  6252. bgCyanBright: [106, 49],
  6253. bgWhiteBright: [107, 49]
  6254. }
  6255. }; // Fix humans
  6256. styles.color.grey = styles.color.gray;
  6257. for (const groupName of Object.keys(styles)) {
  6258. const group = styles[groupName];
  6259. for (const styleName of Object.keys(group)) {
  6260. const style = group[styleName];
  6261. styles[styleName] = {
  6262. open: `\u001B[${style[0]}m`,
  6263. close: `\u001B[${style[1]}m`
  6264. };
  6265. group[styleName] = styles[styleName];
  6266. codes.set(style[0], style[1]);
  6267. }
  6268. Object.defineProperty(styles, groupName, {
  6269. value: group,
  6270. enumerable: false
  6271. });
  6272. Object.defineProperty(styles, 'codes', {
  6273. value: codes,
  6274. enumerable: false
  6275. });
  6276. }
  6277. const ansi2ansi = n => n;
  6278. const rgb2rgb = (r, g, b) => [r, g, b];
  6279. styles.color.close = '\u001B[39m';
  6280. styles.bgColor.close = '\u001B[49m';
  6281. styles.color.ansi = {
  6282. ansi: wrapAnsi16(ansi2ansi, 0)
  6283. };
  6284. styles.color.ansi256 = {
  6285. ansi256: wrapAnsi256(ansi2ansi, 0)
  6286. };
  6287. styles.color.ansi16m = {
  6288. rgb: wrapAnsi16m(rgb2rgb, 0)
  6289. };
  6290. styles.bgColor.ansi = {
  6291. ansi: wrapAnsi16(ansi2ansi, 10)
  6292. };
  6293. styles.bgColor.ansi256 = {
  6294. ansi256: wrapAnsi256(ansi2ansi, 10)
  6295. };
  6296. styles.bgColor.ansi16m = {
  6297. rgb: wrapAnsi16m(rgb2rgb, 10)
  6298. };
  6299. for (let key of Object.keys(colorConvert$1)) {
  6300. if (typeof colorConvert$1[key] !== 'object') {
  6301. continue;
  6302. }
  6303. const suite = colorConvert$1[key];
  6304. if (key === 'ansi16') {
  6305. key = 'ansi';
  6306. }
  6307. if ('ansi16' in suite) {
  6308. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  6309. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  6310. }
  6311. if ('ansi256' in suite) {
  6312. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  6313. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  6314. }
  6315. if ('rgb' in suite) {
  6316. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  6317. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  6318. }
  6319. }
  6320. return styles;
  6321. } // Make the export immutable
  6322. Object.defineProperty(module, 'exports', {
  6323. enumerable: true,
  6324. get: assembleStyles
  6325. });
  6326. });
  6327. var hasFlag$2 = (flag, argv) => {
  6328. argv = argv || process.argv;
  6329. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  6330. const pos = argv.indexOf(prefix + flag);
  6331. const terminatorPos = argv.indexOf('--');
  6332. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6333. };
  6334. const env$2 = process.env;
  6335. let forceColor$2;
  6336. if (hasFlag$2('no-color') || hasFlag$2('no-colors') || hasFlag$2('color=false')) {
  6337. forceColor$2 = false;
  6338. } else if (hasFlag$2('color') || hasFlag$2('colors') || hasFlag$2('color=true') || hasFlag$2('color=always')) {
  6339. forceColor$2 = true;
  6340. }
  6341. if ('FORCE_COLOR' in env$2) {
  6342. forceColor$2 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
  6343. }
  6344. function translateLevel$2(level) {
  6345. if (level === 0) {
  6346. return false;
  6347. }
  6348. return {
  6349. level,
  6350. hasBasic: true,
  6351. has256: level >= 2,
  6352. has16m: level >= 3
  6353. };
  6354. }
  6355. function supportsColor$2(stream) {
  6356. if (forceColor$2 === false) {
  6357. return 0;
  6358. }
  6359. if (hasFlag$2('color=16m') || hasFlag$2('color=full') || hasFlag$2('color=truecolor')) {
  6360. return 3;
  6361. }
  6362. if (hasFlag$2('color=256')) {
  6363. return 2;
  6364. }
  6365. if (stream && !stream.isTTY && forceColor$2 !== true) {
  6366. return 0;
  6367. }
  6368. const min = forceColor$2 ? 1 : 0;
  6369. if (process.platform === 'win32') {
  6370. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6371. // libuv that enables 256 color output on Windows. Anything earlier and it
  6372. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6373. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6374. // release that supports 256 colors. Windows 10 build 14931 is the first release
  6375. // that supports 16m/TrueColor.
  6376. const osRelease = os__default['default'].release().split('.');
  6377. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6378. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  6379. }
  6380. return 1;
  6381. }
  6382. if ('CI' in env$2) {
  6383. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') {
  6384. return 1;
  6385. }
  6386. return min;
  6387. }
  6388. if ('TEAMCITY_VERSION' in env$2) {
  6389. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
  6390. }
  6391. if (env$2.COLORTERM === 'truecolor') {
  6392. return 3;
  6393. }
  6394. if ('TERM_PROGRAM' in env$2) {
  6395. const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6396. switch (env$2.TERM_PROGRAM) {
  6397. case 'iTerm.app':
  6398. return version >= 3 ? 3 : 2;
  6399. case 'Apple_Terminal':
  6400. return 2;
  6401. // No default
  6402. }
  6403. }
  6404. if (/-256(color)?$/i.test(env$2.TERM)) {
  6405. return 2;
  6406. }
  6407. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
  6408. return 1;
  6409. }
  6410. if ('COLORTERM' in env$2) {
  6411. return 1;
  6412. }
  6413. if (env$2.TERM === 'dumb') {
  6414. return min;
  6415. }
  6416. return min;
  6417. }
  6418. function getSupportLevel$2(stream) {
  6419. const level = supportsColor$2(stream);
  6420. return translateLevel$2(level);
  6421. }
  6422. var supportsColor_1$2 = {
  6423. supportsColor: getSupportLevel$2,
  6424. stdout: getSupportLevel$2(process.stdout),
  6425. stderr: getSupportLevel$2(process.stderr)
  6426. };
  6427. const TEMPLATE_REGEX$2 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  6428. const STYLE_REGEX$2 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  6429. const STRING_REGEX$3 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  6430. const ESCAPE_REGEX$2 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  6431. const ESCAPES$2 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  6432. function unescape$2(c) {
  6433. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  6434. return String.fromCharCode(parseInt(c.slice(1), 16));
  6435. }
  6436. return ESCAPES$2.get(c) || c;
  6437. }
  6438. function parseArguments$2(name, args) {
  6439. const results = [];
  6440. const chunks = args.trim().split(/\s*,\s*/g);
  6441. let matches;
  6442. for (const chunk of chunks) {
  6443. if (!isNaN(chunk)) {
  6444. results.push(Number(chunk));
  6445. } else if (matches = chunk.match(STRING_REGEX$3)) {
  6446. results.push(matches[2].replace(ESCAPE_REGEX$2, (m, escape, chr) => escape ? unescape$2(escape) : chr));
  6447. } else {
  6448. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  6449. }
  6450. }
  6451. return results;
  6452. }
  6453. function parseStyle$2(style) {
  6454. STYLE_REGEX$2.lastIndex = 0;
  6455. const results = [];
  6456. let matches;
  6457. while ((matches = STYLE_REGEX$2.exec(style)) !== null) {
  6458. const name = matches[1];
  6459. if (matches[2]) {
  6460. const args = parseArguments$2(name, matches[2]);
  6461. results.push([name].concat(args));
  6462. } else {
  6463. results.push([name]);
  6464. }
  6465. }
  6466. return results;
  6467. }
  6468. function buildStyle$2(chalk, styles) {
  6469. const enabled = {};
  6470. for (const layer of styles) {
  6471. for (const style of layer.styles) {
  6472. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  6473. }
  6474. }
  6475. let current = chalk;
  6476. for (const styleName of Object.keys(enabled)) {
  6477. if (Array.isArray(enabled[styleName])) {
  6478. if (!(styleName in current)) {
  6479. throw new Error(`Unknown Chalk style: ${styleName}`);
  6480. }
  6481. if (enabled[styleName].length > 0) {
  6482. current = current[styleName].apply(current, enabled[styleName]);
  6483. } else {
  6484. current = current[styleName];
  6485. }
  6486. }
  6487. }
  6488. return current;
  6489. }
  6490. var templates$2 = (chalk, tmp) => {
  6491. const styles = [];
  6492. const chunks = [];
  6493. let chunk = []; // eslint-disable-next-line max-params
  6494. tmp.replace(TEMPLATE_REGEX$2, (m, escapeChar, inverse, style, close, chr) => {
  6495. if (escapeChar) {
  6496. chunk.push(unescape$2(escapeChar));
  6497. } else if (style) {
  6498. const str = chunk.join('');
  6499. chunk = [];
  6500. chunks.push(styles.length === 0 ? str : buildStyle$2(chalk, styles)(str));
  6501. styles.push({
  6502. inverse,
  6503. styles: parseStyle$2(style)
  6504. });
  6505. } else if (close) {
  6506. if (styles.length === 0) {
  6507. throw new Error('Found extraneous } in Chalk template literal');
  6508. }
  6509. chunks.push(buildStyle$2(chalk, styles)(chunk.join('')));
  6510. chunk = [];
  6511. styles.pop();
  6512. } else {
  6513. chunk.push(chr);
  6514. }
  6515. });
  6516. chunks.push(chunk.join(''));
  6517. if (styles.length > 0) {
  6518. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  6519. throw new Error(errMsg);
  6520. }
  6521. return chunks.join('');
  6522. };
  6523. var chalk$2 = createCommonjsModule(function (module) {
  6524. const stdoutColor = supportsColor_1$2.stdout;
  6525. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  6526. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  6527. const skipModels = new Set(['gray']);
  6528. const styles = Object.create(null);
  6529. function applyOptions(obj, options) {
  6530. options = options || {}; // Detect level if not set manually
  6531. const scLevel = stdoutColor ? stdoutColor.level : 0;
  6532. obj.level = options.level === undefined ? scLevel : options.level;
  6533. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  6534. }
  6535. function Chalk(options) {
  6536. // We check for this.template here since calling `chalk.constructor()`
  6537. // by itself will have a `this` of a previously constructed chalk object
  6538. if (!this || !(this instanceof Chalk) || this.template) {
  6539. const chalk = {};
  6540. applyOptions(chalk, options);
  6541. chalk.template = function () {
  6542. const args = [].slice.call(arguments);
  6543. return chalkTag.apply(null, [chalk.template].concat(args));
  6544. };
  6545. Object.setPrototypeOf(chalk, Chalk.prototype);
  6546. Object.setPrototypeOf(chalk.template, chalk);
  6547. chalk.template.constructor = Chalk;
  6548. return chalk.template;
  6549. }
  6550. applyOptions(this, options);
  6551. } // Use bright blue on Windows as the normal blue color is illegible
  6552. if (isSimpleWindowsTerm) {
  6553. ansiStyles$2.blue.open = '\u001B[94m';
  6554. }
  6555. for (const key of Object.keys(ansiStyles$2)) {
  6556. ansiStyles$2[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2[key].close), 'g');
  6557. styles[key] = {
  6558. get() {
  6559. const codes = ansiStyles$2[key];
  6560. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  6561. }
  6562. };
  6563. }
  6564. styles.visible = {
  6565. get() {
  6566. return build.call(this, this._styles || [], true, 'visible');
  6567. }
  6568. };
  6569. ansiStyles$2.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2.color.close), 'g');
  6570. for (const model of Object.keys(ansiStyles$2.color.ansi)) {
  6571. if (skipModels.has(model)) {
  6572. continue;
  6573. }
  6574. styles[model] = {
  6575. get() {
  6576. const level = this.level;
  6577. return function () {
  6578. const open = ansiStyles$2.color[levelMapping[level]][model].apply(null, arguments);
  6579. const codes = {
  6580. open,
  6581. close: ansiStyles$2.color.close,
  6582. closeRe: ansiStyles$2.color.closeRe
  6583. };
  6584. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  6585. };
  6586. }
  6587. };
  6588. }
  6589. ansiStyles$2.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2.bgColor.close), 'g');
  6590. for (const model of Object.keys(ansiStyles$2.bgColor.ansi)) {
  6591. if (skipModels.has(model)) {
  6592. continue;
  6593. }
  6594. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  6595. styles[bgModel] = {
  6596. get() {
  6597. const level = this.level;
  6598. return function () {
  6599. const open = ansiStyles$2.bgColor[levelMapping[level]][model].apply(null, arguments);
  6600. const codes = {
  6601. open,
  6602. close: ansiStyles$2.bgColor.close,
  6603. closeRe: ansiStyles$2.bgColor.closeRe
  6604. };
  6605. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  6606. };
  6607. }
  6608. };
  6609. }
  6610. const proto = Object.defineProperties(() => {}, styles);
  6611. function build(_styles, _empty, key) {
  6612. const builder = function () {
  6613. return applyStyle.apply(builder, arguments);
  6614. };
  6615. builder._styles = _styles;
  6616. builder._empty = _empty;
  6617. const self = this;
  6618. Object.defineProperty(builder, 'level', {
  6619. enumerable: true,
  6620. get() {
  6621. return self.level;
  6622. },
  6623. set(level) {
  6624. self.level = level;
  6625. }
  6626. });
  6627. Object.defineProperty(builder, 'enabled', {
  6628. enumerable: true,
  6629. get() {
  6630. return self.enabled;
  6631. },
  6632. set(enabled) {
  6633. self.enabled = enabled;
  6634. }
  6635. }); // See below for fix regarding invisible grey/dim combination on Windows
  6636. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  6637. // no way to create a function with a different prototype
  6638. builder.__proto__ = proto; // eslint-disable-line no-proto
  6639. return builder;
  6640. }
  6641. function applyStyle() {
  6642. // Support varags, but simply cast to string in case there's only one arg
  6643. const args = arguments;
  6644. const argsLen = args.length;
  6645. let str = String(arguments[0]);
  6646. if (argsLen === 0) {
  6647. return '';
  6648. }
  6649. if (argsLen > 1) {
  6650. // Don't slice `arguments`, it prevents V8 optimizations
  6651. for (let a = 1; a < argsLen; a++) {
  6652. str += ' ' + args[a];
  6653. }
  6654. }
  6655. if (!this.enabled || this.level <= 0 || !str) {
  6656. return this._empty ? '' : str;
  6657. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  6658. // see https://github.com/chalk/chalk/issues/58
  6659. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  6660. const originalDim = ansiStyles$2.dim.open;
  6661. if (isSimpleWindowsTerm && this.hasGrey) {
  6662. ansiStyles$2.dim.open = '';
  6663. }
  6664. for (const code of this._styles.slice().reverse()) {
  6665. // Replace any instances already present with a re-opening code
  6666. // otherwise only the part of the string until said closing code
  6667. // will be colored, and the rest will simply be 'plain'.
  6668. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  6669. // after next line to fix a bleed issue on macOS
  6670. // https://github.com/chalk/chalk/pull/92
  6671. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  6672. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  6673. ansiStyles$2.dim.open = originalDim;
  6674. return str;
  6675. }
  6676. function chalkTag(chalk, strings) {
  6677. if (!Array.isArray(strings)) {
  6678. // If chalk() was called by itself or with a string,
  6679. // return the string itself as a string.
  6680. return [].slice.call(arguments, 1).join(' ');
  6681. }
  6682. const args = [].slice.call(arguments, 2);
  6683. const parts = [strings.raw[0]];
  6684. for (let i = 1; i < strings.length; i++) {
  6685. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  6686. parts.push(String(strings.raw[i]));
  6687. }
  6688. return templates$2(chalk, parts.join(''));
  6689. }
  6690. Object.defineProperties(Chalk.prototype, styles);
  6691. module.exports = Chalk(); // eslint-disable-line new-cap
  6692. module.exports.supportsColor = stdoutColor;
  6693. module.exports.default = module.exports; // For TypeScript
  6694. });
  6695. var commonDeprecatedHandler = (keyOrPair, redirectTo, {
  6696. descriptor
  6697. }) => {
  6698. const messages = [`${chalk$2.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
  6699. if (redirectTo) {
  6700. messages.push(`we now treat it as ${chalk$2.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
  6701. }
  6702. return messages.join('; ') + '.';
  6703. };
  6704. var common$3 = /*#__PURE__*/Object.defineProperty({
  6705. commonDeprecatedHandler: commonDeprecatedHandler
  6706. }, '__esModule', {
  6707. value: true
  6708. });
  6709. var deprecated = createCommonjsModule(function (module, exports) {
  6710. Object.defineProperty(exports, "__esModule", {
  6711. value: true
  6712. });
  6713. tslib_es6.__exportStar(common$3, exports);
  6714. });
  6715. var commonInvalidHandler = (key, value, utils) => [`Invalid ${chalk$2.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk$2.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk$2.default.red(utils.descriptor.value(value))}.`].join(' ');
  6716. var common$2 = /*#__PURE__*/Object.defineProperty({
  6717. commonInvalidHandler: commonInvalidHandler
  6718. }, '__esModule', {
  6719. value: true
  6720. });
  6721. var invalid = createCommonjsModule(function (module, exports) {
  6722. Object.defineProperty(exports, "__esModule", {
  6723. value: true
  6724. });
  6725. tslib_es6.__exportStar(common$2, exports);
  6726. });
  6727. /* eslint-disable no-nested-ternary */
  6728. var arr = [];
  6729. var charCodeCache$1 = [];
  6730. var leven$1 = function (a, b) {
  6731. if (a === b) {
  6732. return 0;
  6733. }
  6734. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  6735. // shortest & which one is the longest
  6736. if (a.length > b.length) {
  6737. a = b;
  6738. b = swap;
  6739. }
  6740. var aLen = a.length;
  6741. var bLen = b.length;
  6742. if (aLen === 0) {
  6743. return bLen;
  6744. }
  6745. if (bLen === 0) {
  6746. return aLen;
  6747. } // Performing suffix trimming:
  6748. // We can linearly drop suffix common to both strings since they
  6749. // don't increase distance at all
  6750. // Note: `~-` is the bitwise way to perform a `- 1` operation
  6751. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  6752. aLen--;
  6753. bLen--;
  6754. }
  6755. if (aLen === 0) {
  6756. return bLen;
  6757. } // Performing prefix trimming
  6758. // We can linearly drop prefix common to both strings since they
  6759. // don't increase distance at all
  6760. var start = 0;
  6761. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  6762. start++;
  6763. }
  6764. aLen -= start;
  6765. bLen -= start;
  6766. if (aLen === 0) {
  6767. return bLen;
  6768. }
  6769. var bCharCode;
  6770. var ret;
  6771. var tmp;
  6772. var tmp2;
  6773. var i = 0;
  6774. var j = 0;
  6775. while (i < aLen) {
  6776. charCodeCache$1[start + i] = a.charCodeAt(start + i);
  6777. arr[i] = ++i;
  6778. }
  6779. while (j < bLen) {
  6780. bCharCode = b.charCodeAt(start + j);
  6781. tmp = j++;
  6782. ret = j;
  6783. for (i = 0; i < aLen; i++) {
  6784. tmp2 = bCharCode === charCodeCache$1[start + i] ? tmp : tmp + 1;
  6785. tmp = arr[i];
  6786. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  6787. }
  6788. }
  6789. return ret;
  6790. };
  6791. var levenUnknownHandler = (key, value, {
  6792. descriptor,
  6793. logger,
  6794. schemas
  6795. }) => {
  6796. const messages = [`Ignored unknown option ${chalk$2.default.yellow(descriptor.pair({
  6797. key,
  6798. value
  6799. }))}.`];
  6800. const suggestion = Object.keys(schemas).sort().find(knownKey => leven$1(key, knownKey) < 3);
  6801. if (suggestion) {
  6802. messages.push(`Did you mean ${chalk$2.default.blue(descriptor.key(suggestion))}?`);
  6803. }
  6804. logger.warn(messages.join(' '));
  6805. };
  6806. var leven_1$1 = /*#__PURE__*/Object.defineProperty({
  6807. levenUnknownHandler: levenUnknownHandler
  6808. }, '__esModule', {
  6809. value: true
  6810. });
  6811. var unknown = createCommonjsModule(function (module, exports) {
  6812. Object.defineProperty(exports, "__esModule", {
  6813. value: true
  6814. });
  6815. tslib_es6.__exportStar(leven_1$1, exports);
  6816. });
  6817. var handlers = createCommonjsModule(function (module, exports) {
  6818. Object.defineProperty(exports, "__esModule", {
  6819. value: true
  6820. });
  6821. tslib_es6.__exportStar(deprecated, exports);
  6822. tslib_es6.__exportStar(invalid, exports);
  6823. tslib_es6.__exportStar(unknown, exports);
  6824. });
  6825. const HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  6826. function createSchema(SchemaConstructor, parameters) {
  6827. const schema = new SchemaConstructor(parameters);
  6828. const subSchema = Object.create(schema);
  6829. for (const handlerKey of HANDLER_KEYS) {
  6830. if (handlerKey in parameters) {
  6831. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  6832. }
  6833. }
  6834. return subSchema;
  6835. }
  6836. var createSchema_1 = createSchema;
  6837. class Schema {
  6838. constructor(parameters) {
  6839. this.name = parameters.name;
  6840. }
  6841. static create(parameters) {
  6842. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  6843. return createSchema(this, parameters);
  6844. }
  6845. default(_utils) {
  6846. return undefined;
  6847. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  6848. expected(_utils) {
  6849. return 'nothing';
  6850. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  6851. validate(_value, _utils) {
  6852. return false;
  6853. }
  6854. deprecated(_value, _utils) {
  6855. return false;
  6856. }
  6857. forward(_value, _utils) {
  6858. return undefined;
  6859. }
  6860. redirect(_value, _utils) {
  6861. return undefined;
  6862. }
  6863. overlap(currentValue, _newValue, _utils) {
  6864. return currentValue;
  6865. }
  6866. preprocess(value, _utils) {
  6867. return value;
  6868. }
  6869. postprocess(value, _utils) {
  6870. return value;
  6871. }
  6872. }
  6873. var Schema_1 = Schema;
  6874. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  6875. return typeof handler === 'function' ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler;
  6876. }
  6877. var schema = /*#__PURE__*/Object.defineProperty({
  6878. createSchema: createSchema_1,
  6879. Schema: Schema_1
  6880. }, '__esModule', {
  6881. value: true
  6882. });
  6883. class AliasSchema extends schema.Schema {
  6884. constructor(parameters) {
  6885. super(parameters);
  6886. this._sourceName = parameters.sourceName;
  6887. }
  6888. expected(utils) {
  6889. return utils.schemas[this._sourceName].expected(utils);
  6890. }
  6891. validate(value, utils) {
  6892. return utils.schemas[this._sourceName].validate(value, utils);
  6893. }
  6894. redirect(_value, _utils) {
  6895. return this._sourceName;
  6896. }
  6897. }
  6898. var AliasSchema_1 = AliasSchema;
  6899. var alias = /*#__PURE__*/Object.defineProperty({
  6900. AliasSchema: AliasSchema_1
  6901. }, '__esModule', {
  6902. value: true
  6903. });
  6904. class AnySchema extends schema.Schema {
  6905. expected() {
  6906. return 'anything';
  6907. }
  6908. validate() {
  6909. return true;
  6910. }
  6911. }
  6912. var AnySchema_1 = AnySchema;
  6913. var any = /*#__PURE__*/Object.defineProperty({
  6914. AnySchema: AnySchema_1
  6915. }, '__esModule', {
  6916. value: true
  6917. });
  6918. class ArraySchema extends schema.Schema {
  6919. constructor(_a) {
  6920. var {
  6921. valueSchema,
  6922. name = valueSchema.name
  6923. } = _a,
  6924. handlers = tslib_es6.__rest(_a, ["valueSchema", "name"]);
  6925. super(Object.assign({}, handlers, {
  6926. name
  6927. }));
  6928. this._valueSchema = valueSchema;
  6929. }
  6930. expected(utils) {
  6931. return `an array of ${this._valueSchema.expected(utils)}`;
  6932. }
  6933. validate(value, utils) {
  6934. if (!Array.isArray(value)) {
  6935. return false;
  6936. }
  6937. const invalidValues = [];
  6938. for (const subValue of value) {
  6939. const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  6940. if (subValidateResult !== true) {
  6941. invalidValues.push(subValidateResult.value);
  6942. }
  6943. }
  6944. return invalidValues.length === 0 ? true : {
  6945. value: invalidValues
  6946. };
  6947. }
  6948. deprecated(value, utils) {
  6949. const deprecatedResult = [];
  6950. for (const subValue of value) {
  6951. const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  6952. if (subDeprecatedResult !== false) {
  6953. deprecatedResult.push(...subDeprecatedResult.map(({
  6954. value: deprecatedValue
  6955. }) => ({
  6956. value: [deprecatedValue]
  6957. })));
  6958. }
  6959. }
  6960. return deprecatedResult;
  6961. }
  6962. forward(value, utils) {
  6963. const forwardResult = [];
  6964. for (const subValue of value) {
  6965. const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  6966. forwardResult.push(...subForwardResult.map(wrapTransferResult));
  6967. }
  6968. return forwardResult;
  6969. }
  6970. redirect(value, utils) {
  6971. const remain = [];
  6972. const redirect = [];
  6973. for (const subValue of value) {
  6974. const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  6975. if ('remain' in subRedirectResult) {
  6976. remain.push(subRedirectResult.remain);
  6977. }
  6978. redirect.push(...subRedirectResult.redirect.map(wrapTransferResult));
  6979. }
  6980. return remain.length === 0 ? {
  6981. redirect
  6982. } : {
  6983. redirect,
  6984. remain
  6985. };
  6986. }
  6987. overlap(currentValue, newValue) {
  6988. return currentValue.concat(newValue);
  6989. }
  6990. }
  6991. var ArraySchema_1 = ArraySchema;
  6992. function wrapTransferResult({
  6993. from,
  6994. to
  6995. }) {
  6996. return {
  6997. from: [from],
  6998. to
  6999. };
  7000. }
  7001. var array$3 = /*#__PURE__*/Object.defineProperty({
  7002. ArraySchema: ArraySchema_1
  7003. }, '__esModule', {
  7004. value: true
  7005. });
  7006. class BooleanSchema extends schema.Schema {
  7007. expected() {
  7008. return 'true or false';
  7009. }
  7010. validate(value) {
  7011. return typeof value === 'boolean';
  7012. }
  7013. }
  7014. var BooleanSchema_1 = BooleanSchema;
  7015. var boolean = /*#__PURE__*/Object.defineProperty({
  7016. BooleanSchema: BooleanSchema_1
  7017. }, '__esModule', {
  7018. value: true
  7019. });
  7020. function recordFromArray(array, mainKey) {
  7021. const record = Object.create(null);
  7022. for (const value of array) {
  7023. const key = value[mainKey]; // istanbul ignore next
  7024. if (record[key]) {
  7025. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  7026. } // @ts-ignore
  7027. record[key] = value;
  7028. }
  7029. return record;
  7030. }
  7031. var recordFromArray_1 = recordFromArray;
  7032. function mapFromArray(array, mainKey) {
  7033. const map = new Map();
  7034. for (const value of array) {
  7035. const key = value[mainKey]; // istanbul ignore next
  7036. if (map.has(key)) {
  7037. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  7038. }
  7039. map.set(key, value);
  7040. }
  7041. return map;
  7042. }
  7043. var mapFromArray_1 = mapFromArray;
  7044. function createAutoChecklist() {
  7045. const map = Object.create(null);
  7046. return id => {
  7047. const idString = JSON.stringify(id);
  7048. if (map[idString]) {
  7049. return true;
  7050. }
  7051. map[idString] = true;
  7052. return false;
  7053. };
  7054. }
  7055. var createAutoChecklist_1 = createAutoChecklist;
  7056. function partition$1(array, predicate) {
  7057. const trueArray = [];
  7058. const falseArray = [];
  7059. for (const value of array) {
  7060. if (predicate(value)) {
  7061. trueArray.push(value);
  7062. } else {
  7063. falseArray.push(value);
  7064. }
  7065. }
  7066. return [trueArray, falseArray];
  7067. }
  7068. var partition_1$1 = partition$1;
  7069. function isInt(value) {
  7070. return value === Math.floor(value);
  7071. }
  7072. var isInt_1 = isInt;
  7073. function comparePrimitive(a, b) {
  7074. if (a === b) {
  7075. return 0;
  7076. }
  7077. const typeofA = typeof a;
  7078. const typeofB = typeof b;
  7079. const orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  7080. if (typeofA !== typeofB) {
  7081. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  7082. }
  7083. if (typeofA !== 'string') {
  7084. return Number(a) - Number(b);
  7085. }
  7086. return a.localeCompare(b);
  7087. }
  7088. var comparePrimitive_1 = comparePrimitive;
  7089. function normalizeDefaultResult(result) {
  7090. return result === undefined ? {} : result;
  7091. }
  7092. var normalizeDefaultResult_1 = normalizeDefaultResult;
  7093. function normalizeValidateResult(result, value) {
  7094. return result === true ? true : result === false ? {
  7095. value
  7096. } : result;
  7097. }
  7098. var normalizeValidateResult_1 = normalizeValidateResult;
  7099. function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) {
  7100. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  7101. value
  7102. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  7103. }
  7104. var normalizeDeprecatedResult_1 = normalizeDeprecatedResult;
  7105. function normalizeTransferResult(result, value) {
  7106. return typeof result === 'string' || 'key' in result ? {
  7107. from: value,
  7108. to: result
  7109. } : 'from' in result ? {
  7110. from: result.from,
  7111. to: result.to
  7112. } : {
  7113. from: value,
  7114. to: result.to
  7115. };
  7116. }
  7117. var normalizeTransferResult_1 = normalizeTransferResult;
  7118. function normalizeForwardResult(result, value) {
  7119. return result === undefined ? [] : Array.isArray(result) ? result.map(transferResult => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)];
  7120. }
  7121. var normalizeForwardResult_1 = normalizeForwardResult;
  7122. function normalizeRedirectResult(result, value) {
  7123. const redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
  7124. return redirect.length === 0 ? {
  7125. remain: value,
  7126. redirect
  7127. } : typeof result === 'object' && 'remain' in result ? {
  7128. remain: result.remain,
  7129. redirect
  7130. } : {
  7131. redirect
  7132. };
  7133. }
  7134. var normalizeRedirectResult_1 = normalizeRedirectResult;
  7135. var utils$b = /*#__PURE__*/Object.defineProperty({
  7136. recordFromArray: recordFromArray_1,
  7137. mapFromArray: mapFromArray_1,
  7138. createAutoChecklist: createAutoChecklist_1,
  7139. partition: partition_1$1,
  7140. isInt: isInt_1,
  7141. comparePrimitive: comparePrimitive_1,
  7142. normalizeDefaultResult: normalizeDefaultResult_1,
  7143. normalizeValidateResult: normalizeValidateResult_1,
  7144. normalizeDeprecatedResult: normalizeDeprecatedResult_1,
  7145. normalizeTransferResult: normalizeTransferResult_1,
  7146. normalizeForwardResult: normalizeForwardResult_1,
  7147. normalizeRedirectResult: normalizeRedirectResult_1
  7148. }, '__esModule', {
  7149. value: true
  7150. });
  7151. class ChoiceSchema extends schema.Schema {
  7152. constructor(parameters) {
  7153. super(parameters);
  7154. this._choices = utils$b.mapFromArray(parameters.choices.map(choice => choice && typeof choice === 'object' ? choice : {
  7155. value: choice
  7156. }), 'value');
  7157. }
  7158. expected({
  7159. descriptor
  7160. }) {
  7161. const choiceValues = Array.from(this._choices.keys()).map(value => this._choices.get(value)).filter(choiceInfo => !choiceInfo.deprecated).map(choiceInfo => choiceInfo.value).sort(utils$b.comparePrimitive).map(descriptor.value);
  7162. const head = choiceValues.slice(0, -2);
  7163. const tail = choiceValues.slice(-2);
  7164. return head.concat(tail.join(' or ')).join(', ');
  7165. }
  7166. validate(value) {
  7167. return this._choices.has(value);
  7168. }
  7169. deprecated(value) {
  7170. const choiceInfo = this._choices.get(value);
  7171. return choiceInfo && choiceInfo.deprecated ? {
  7172. value
  7173. } : false;
  7174. }
  7175. forward(value) {
  7176. const choiceInfo = this._choices.get(value);
  7177. return choiceInfo ? choiceInfo.forward : undefined;
  7178. }
  7179. redirect(value) {
  7180. const choiceInfo = this._choices.get(value);
  7181. return choiceInfo ? choiceInfo.redirect : undefined;
  7182. }
  7183. }
  7184. var ChoiceSchema_1 = ChoiceSchema;
  7185. var choice = /*#__PURE__*/Object.defineProperty({
  7186. ChoiceSchema: ChoiceSchema_1
  7187. }, '__esModule', {
  7188. value: true
  7189. });
  7190. class NumberSchema extends schema.Schema {
  7191. expected() {
  7192. return 'a number';
  7193. }
  7194. validate(value, _utils) {
  7195. return typeof value === 'number';
  7196. }
  7197. }
  7198. var NumberSchema_1 = NumberSchema;
  7199. var number = /*#__PURE__*/Object.defineProperty({
  7200. NumberSchema: NumberSchema_1
  7201. }, '__esModule', {
  7202. value: true
  7203. });
  7204. class IntegerSchema extends number.NumberSchema {
  7205. expected() {
  7206. return 'an integer';
  7207. }
  7208. validate(value, utils) {
  7209. return utils.normalizeValidateResult(super.validate(value, utils), value) === true && utils$b.isInt(value);
  7210. }
  7211. }
  7212. var IntegerSchema_1 = IntegerSchema;
  7213. var integer = /*#__PURE__*/Object.defineProperty({
  7214. IntegerSchema: IntegerSchema_1
  7215. }, '__esModule', {
  7216. value: true
  7217. });
  7218. class StringSchema extends schema.Schema {
  7219. expected() {
  7220. return 'a string';
  7221. }
  7222. validate(value) {
  7223. return typeof value === 'string';
  7224. }
  7225. }
  7226. var StringSchema_1 = StringSchema;
  7227. var string$1 = /*#__PURE__*/Object.defineProperty({
  7228. StringSchema: StringSchema_1
  7229. }, '__esModule', {
  7230. value: true
  7231. });
  7232. var schemas = createCommonjsModule(function (module, exports) {
  7233. Object.defineProperty(exports, "__esModule", {
  7234. value: true
  7235. });
  7236. tslib_es6.__exportStar(alias, exports);
  7237. tslib_es6.__exportStar(any, exports);
  7238. tslib_es6.__exportStar(array$3, exports);
  7239. tslib_es6.__exportStar(boolean, exports);
  7240. tslib_es6.__exportStar(choice, exports);
  7241. tslib_es6.__exportStar(integer, exports);
  7242. tslib_es6.__exportStar(number, exports);
  7243. tslib_es6.__exportStar(string$1, exports);
  7244. });
  7245. var defaultDescriptor = api.apiDescriptor;
  7246. var defaultUnknownHandler = leven_1$1.levenUnknownHandler;
  7247. var defaultInvalidHandler = invalid.commonInvalidHandler;
  7248. var defaultDeprecatedHandler = common$3.commonDeprecatedHandler;
  7249. var defaults = /*#__PURE__*/Object.defineProperty({
  7250. defaultDescriptor: defaultDescriptor,
  7251. defaultUnknownHandler: defaultUnknownHandler,
  7252. defaultInvalidHandler: defaultInvalidHandler,
  7253. defaultDeprecatedHandler: defaultDeprecatedHandler
  7254. }, '__esModule', {
  7255. value: true
  7256. });
  7257. var normalize_1 = (options, schemas, opts) => new Normalizer(schemas, opts).normalize(options);
  7258. class Normalizer {
  7259. constructor(schemas, opts) {
  7260. // istanbul ignore next
  7261. const {
  7262. logger = console,
  7263. descriptor = defaults.defaultDescriptor,
  7264. unknown = defaults.defaultUnknownHandler,
  7265. invalid = defaults.defaultInvalidHandler,
  7266. deprecated = defaults.defaultDeprecatedHandler
  7267. } = opts || {};
  7268. this._utils = {
  7269. descriptor,
  7270. logger:
  7271. /* istanbul ignore next */
  7272. logger || {
  7273. warn: () => {}
  7274. },
  7275. schemas: utils$b.recordFromArray(schemas, 'name'),
  7276. normalizeDefaultResult: utils$b.normalizeDefaultResult,
  7277. normalizeDeprecatedResult: utils$b.normalizeDeprecatedResult,
  7278. normalizeForwardResult: utils$b.normalizeForwardResult,
  7279. normalizeRedirectResult: utils$b.normalizeRedirectResult,
  7280. normalizeValidateResult: utils$b.normalizeValidateResult
  7281. };
  7282. this._unknownHandler = unknown;
  7283. this._invalidHandler = invalid;
  7284. this._deprecatedHandler = deprecated;
  7285. this.cleanHistory();
  7286. }
  7287. cleanHistory() {
  7288. this._hasDeprecationWarned = utils$b.createAutoChecklist();
  7289. }
  7290. normalize(options) {
  7291. const normalized = {};
  7292. const restOptionsArray = [options];
  7293. const applyNormalization = () => {
  7294. while (restOptionsArray.length !== 0) {
  7295. const currentOptions = restOptionsArray.shift();
  7296. const transferredOptionsArray = this._applyNormalization(currentOptions, normalized);
  7297. restOptionsArray.push(...transferredOptionsArray);
  7298. }
  7299. };
  7300. applyNormalization();
  7301. for (const key of Object.keys(this._utils.schemas)) {
  7302. const schema = this._utils.schemas[key];
  7303. if (!(key in normalized)) {
  7304. const defaultResult = utils$b.normalizeDefaultResult(schema.default(this._utils));
  7305. if ('value' in defaultResult) {
  7306. restOptionsArray.push({
  7307. [key]: defaultResult.value
  7308. });
  7309. }
  7310. }
  7311. }
  7312. applyNormalization();
  7313. for (const key of Object.keys(this._utils.schemas)) {
  7314. const schema = this._utils.schemas[key];
  7315. if (key in normalized) {
  7316. normalized[key] = schema.postprocess(normalized[key], this._utils);
  7317. }
  7318. }
  7319. return normalized;
  7320. }
  7321. _applyNormalization(options, normalized) {
  7322. const transferredOptionsArray = [];
  7323. const [knownOptionNames, unknownOptionNames] = utils$b.partition(Object.keys(options), key => key in this._utils.schemas);
  7324. for (const key of knownOptionNames) {
  7325. const schema = this._utils.schemas[key];
  7326. const value = schema.preprocess(options[key], this._utils);
  7327. const validateResult = utils$b.normalizeValidateResult(schema.validate(value, this._utils), value);
  7328. if (validateResult !== true) {
  7329. const {
  7330. value: invalidValue
  7331. } = validateResult;
  7332. const errorMessageOrError = this._invalidHandler(key, invalidValue, this._utils);
  7333. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  7334. /* istanbul ignore next*/
  7335. errorMessageOrError;
  7336. }
  7337. const appendTransferredOptions = ({
  7338. from,
  7339. to
  7340. }) => {
  7341. transferredOptionsArray.push(typeof to === 'string' ? {
  7342. [to]: from
  7343. } : {
  7344. [to.key]: to.value
  7345. });
  7346. };
  7347. const warnDeprecated = ({
  7348. value: currentValue,
  7349. redirectTo
  7350. }) => {
  7351. const deprecatedResult = utils$b.normalizeDeprecatedResult(schema.deprecated(currentValue, this._utils), value,
  7352. /* doNotNormalizeTrue */
  7353. true);
  7354. if (deprecatedResult === false) {
  7355. return;
  7356. }
  7357. if (deprecatedResult === true) {
  7358. if (!this._hasDeprecationWarned(key)) {
  7359. this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils));
  7360. }
  7361. } else {
  7362. for (const {
  7363. value: deprecatedValue
  7364. } of deprecatedResult) {
  7365. const pair = {
  7366. key,
  7367. value: deprecatedValue
  7368. };
  7369. if (!this._hasDeprecationWarned(pair)) {
  7370. const redirectToPair = typeof redirectTo === 'string' ? {
  7371. key: redirectTo,
  7372. value: deprecatedValue
  7373. } : redirectTo;
  7374. this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils));
  7375. }
  7376. }
  7377. }
  7378. };
  7379. const forwardResult = utils$b.normalizeForwardResult(schema.forward(value, this._utils), value);
  7380. forwardResult.forEach(appendTransferredOptions);
  7381. const redirectResult = utils$b.normalizeRedirectResult(schema.redirect(value, this._utils), value);
  7382. redirectResult.redirect.forEach(appendTransferredOptions);
  7383. if ('remain' in redirectResult) {
  7384. const remainingValue = redirectResult.remain;
  7385. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, this._utils) : remainingValue;
  7386. warnDeprecated({
  7387. value: remainingValue
  7388. });
  7389. }
  7390. for (const {
  7391. from,
  7392. to
  7393. } of redirectResult.redirect) {
  7394. warnDeprecated({
  7395. value: from,
  7396. redirectTo: to
  7397. });
  7398. }
  7399. }
  7400. for (const key of unknownOptionNames) {
  7401. const value = options[key];
  7402. const unknownResult = this._unknownHandler(key, value, this._utils);
  7403. if (unknownResult) {
  7404. for (const unknownKey of Object.keys(unknownResult)) {
  7405. const unknownOption = {
  7406. [unknownKey]: unknownResult[unknownKey]
  7407. };
  7408. if (unknownKey in this._utils.schemas) {
  7409. transferredOptionsArray.push(unknownOption);
  7410. } else {
  7411. Object.assign(normalized, unknownOption);
  7412. }
  7413. }
  7414. }
  7415. }
  7416. return transferredOptionsArray;
  7417. }
  7418. }
  7419. var Normalizer_1 = Normalizer;
  7420. var normalize$2 = /*#__PURE__*/Object.defineProperty({
  7421. normalize: normalize_1,
  7422. Normalizer: Normalizer_1
  7423. }, '__esModule', {
  7424. value: true
  7425. });
  7426. var lib$4 = createCommonjsModule(function (module, exports) {
  7427. Object.defineProperty(exports, "__esModule", {
  7428. value: true
  7429. });
  7430. tslib_es6.__exportStar(descriptors, exports);
  7431. tslib_es6.__exportStar(handlers, exports);
  7432. tslib_es6.__exportStar(schemas, exports);
  7433. tslib_es6.__exportStar(normalize$2, exports);
  7434. tslib_es6.__exportStar(schema, exports);
  7435. });
  7436. const array$2 = [];
  7437. const charCodeCache = [];
  7438. const leven = (left, right) => {
  7439. if (left === right) {
  7440. return 0;
  7441. }
  7442. const swap = left; // Swapping the strings if `a` is longer than `b` so we know which one is the
  7443. // shortest & which one is the longest
  7444. if (left.length > right.length) {
  7445. left = right;
  7446. right = swap;
  7447. }
  7448. let leftLength = left.length;
  7449. let rightLength = right.length; // Performing suffix trimming:
  7450. // We can linearly drop suffix common to both strings since they
  7451. // don't increase distance at all
  7452. // Note: `~-` is the bitwise way to perform a `- 1` operation
  7453. while (leftLength > 0 && left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength)) {
  7454. leftLength--;
  7455. rightLength--;
  7456. } // Performing prefix trimming
  7457. // We can linearly drop prefix common to both strings since they
  7458. // don't increase distance at all
  7459. let start = 0;
  7460. while (start < leftLength && left.charCodeAt(start) === right.charCodeAt(start)) {
  7461. start++;
  7462. }
  7463. leftLength -= start;
  7464. rightLength -= start;
  7465. if (leftLength === 0) {
  7466. return rightLength;
  7467. }
  7468. let bCharCode;
  7469. let result;
  7470. let temp;
  7471. let temp2;
  7472. let i = 0;
  7473. let j = 0;
  7474. while (i < leftLength) {
  7475. charCodeCache[i] = left.charCodeAt(start + i);
  7476. array$2[i] = ++i;
  7477. }
  7478. while (j < rightLength) {
  7479. bCharCode = right.charCodeAt(start + j);
  7480. temp = j++;
  7481. result = j;
  7482. for (i = 0; i < leftLength; i++) {
  7483. temp2 = bCharCode === charCodeCache[i] ? temp : temp + 1;
  7484. temp = array$2[i]; // eslint-disable-next-line no-multi-assign
  7485. result = array$2[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2;
  7486. }
  7487. }
  7488. return result;
  7489. };
  7490. var leven_1 = leven; // TODO: Remove this for the next major release
  7491. var _default$p = leven;
  7492. leven_1.default = _default$p;
  7493. var colorName = {
  7494. "aliceblue": [240, 248, 255],
  7495. "antiquewhite": [250, 235, 215],
  7496. "aqua": [0, 255, 255],
  7497. "aquamarine": [127, 255, 212],
  7498. "azure": [240, 255, 255],
  7499. "beige": [245, 245, 220],
  7500. "bisque": [255, 228, 196],
  7501. "black": [0, 0, 0],
  7502. "blanchedalmond": [255, 235, 205],
  7503. "blue": [0, 0, 255],
  7504. "blueviolet": [138, 43, 226],
  7505. "brown": [165, 42, 42],
  7506. "burlywood": [222, 184, 135],
  7507. "cadetblue": [95, 158, 160],
  7508. "chartreuse": [127, 255, 0],
  7509. "chocolate": [210, 105, 30],
  7510. "coral": [255, 127, 80],
  7511. "cornflowerblue": [100, 149, 237],
  7512. "cornsilk": [255, 248, 220],
  7513. "crimson": [220, 20, 60],
  7514. "cyan": [0, 255, 255],
  7515. "darkblue": [0, 0, 139],
  7516. "darkcyan": [0, 139, 139],
  7517. "darkgoldenrod": [184, 134, 11],
  7518. "darkgray": [169, 169, 169],
  7519. "darkgreen": [0, 100, 0],
  7520. "darkgrey": [169, 169, 169],
  7521. "darkkhaki": [189, 183, 107],
  7522. "darkmagenta": [139, 0, 139],
  7523. "darkolivegreen": [85, 107, 47],
  7524. "darkorange": [255, 140, 0],
  7525. "darkorchid": [153, 50, 204],
  7526. "darkred": [139, 0, 0],
  7527. "darksalmon": [233, 150, 122],
  7528. "darkseagreen": [143, 188, 143],
  7529. "darkslateblue": [72, 61, 139],
  7530. "darkslategray": [47, 79, 79],
  7531. "darkslategrey": [47, 79, 79],
  7532. "darkturquoise": [0, 206, 209],
  7533. "darkviolet": [148, 0, 211],
  7534. "deeppink": [255, 20, 147],
  7535. "deepskyblue": [0, 191, 255],
  7536. "dimgray": [105, 105, 105],
  7537. "dimgrey": [105, 105, 105],
  7538. "dodgerblue": [30, 144, 255],
  7539. "firebrick": [178, 34, 34],
  7540. "floralwhite": [255, 250, 240],
  7541. "forestgreen": [34, 139, 34],
  7542. "fuchsia": [255, 0, 255],
  7543. "gainsboro": [220, 220, 220],
  7544. "ghostwhite": [248, 248, 255],
  7545. "gold": [255, 215, 0],
  7546. "goldenrod": [218, 165, 32],
  7547. "gray": [128, 128, 128],
  7548. "green": [0, 128, 0],
  7549. "greenyellow": [173, 255, 47],
  7550. "grey": [128, 128, 128],
  7551. "honeydew": [240, 255, 240],
  7552. "hotpink": [255, 105, 180],
  7553. "indianred": [205, 92, 92],
  7554. "indigo": [75, 0, 130],
  7555. "ivory": [255, 255, 240],
  7556. "khaki": [240, 230, 140],
  7557. "lavender": [230, 230, 250],
  7558. "lavenderblush": [255, 240, 245],
  7559. "lawngreen": [124, 252, 0],
  7560. "lemonchiffon": [255, 250, 205],
  7561. "lightblue": [173, 216, 230],
  7562. "lightcoral": [240, 128, 128],
  7563. "lightcyan": [224, 255, 255],
  7564. "lightgoldenrodyellow": [250, 250, 210],
  7565. "lightgray": [211, 211, 211],
  7566. "lightgreen": [144, 238, 144],
  7567. "lightgrey": [211, 211, 211],
  7568. "lightpink": [255, 182, 193],
  7569. "lightsalmon": [255, 160, 122],
  7570. "lightseagreen": [32, 178, 170],
  7571. "lightskyblue": [135, 206, 250],
  7572. "lightslategray": [119, 136, 153],
  7573. "lightslategrey": [119, 136, 153],
  7574. "lightsteelblue": [176, 196, 222],
  7575. "lightyellow": [255, 255, 224],
  7576. "lime": [0, 255, 0],
  7577. "limegreen": [50, 205, 50],
  7578. "linen": [250, 240, 230],
  7579. "magenta": [255, 0, 255],
  7580. "maroon": [128, 0, 0],
  7581. "mediumaquamarine": [102, 205, 170],
  7582. "mediumblue": [0, 0, 205],
  7583. "mediumorchid": [186, 85, 211],
  7584. "mediumpurple": [147, 112, 219],
  7585. "mediumseagreen": [60, 179, 113],
  7586. "mediumslateblue": [123, 104, 238],
  7587. "mediumspringgreen": [0, 250, 154],
  7588. "mediumturquoise": [72, 209, 204],
  7589. "mediumvioletred": [199, 21, 133],
  7590. "midnightblue": [25, 25, 112],
  7591. "mintcream": [245, 255, 250],
  7592. "mistyrose": [255, 228, 225],
  7593. "moccasin": [255, 228, 181],
  7594. "navajowhite": [255, 222, 173],
  7595. "navy": [0, 0, 128],
  7596. "oldlace": [253, 245, 230],
  7597. "olive": [128, 128, 0],
  7598. "olivedrab": [107, 142, 35],
  7599. "orange": [255, 165, 0],
  7600. "orangered": [255, 69, 0],
  7601. "orchid": [218, 112, 214],
  7602. "palegoldenrod": [238, 232, 170],
  7603. "palegreen": [152, 251, 152],
  7604. "paleturquoise": [175, 238, 238],
  7605. "palevioletred": [219, 112, 147],
  7606. "papayawhip": [255, 239, 213],
  7607. "peachpuff": [255, 218, 185],
  7608. "peru": [205, 133, 63],
  7609. "pink": [255, 192, 203],
  7610. "plum": [221, 160, 221],
  7611. "powderblue": [176, 224, 230],
  7612. "purple": [128, 0, 128],
  7613. "rebeccapurple": [102, 51, 153],
  7614. "red": [255, 0, 0],
  7615. "rosybrown": [188, 143, 143],
  7616. "royalblue": [65, 105, 225],
  7617. "saddlebrown": [139, 69, 19],
  7618. "salmon": [250, 128, 114],
  7619. "sandybrown": [244, 164, 96],
  7620. "seagreen": [46, 139, 87],
  7621. "seashell": [255, 245, 238],
  7622. "sienna": [160, 82, 45],
  7623. "silver": [192, 192, 192],
  7624. "skyblue": [135, 206, 235],
  7625. "slateblue": [106, 90, 205],
  7626. "slategray": [112, 128, 144],
  7627. "slategrey": [112, 128, 144],
  7628. "snow": [255, 250, 250],
  7629. "springgreen": [0, 255, 127],
  7630. "steelblue": [70, 130, 180],
  7631. "tan": [210, 180, 140],
  7632. "teal": [0, 128, 128],
  7633. "thistle": [216, 191, 216],
  7634. "tomato": [255, 99, 71],
  7635. "turquoise": [64, 224, 208],
  7636. "violet": [238, 130, 238],
  7637. "wheat": [245, 222, 179],
  7638. "white": [255, 255, 255],
  7639. "whitesmoke": [245, 245, 245],
  7640. "yellow": [255, 255, 0],
  7641. "yellowgreen": [154, 205, 50]
  7642. };
  7643. /* MIT license */
  7644. /* eslint-disable no-mixed-operators */
  7645. // NOTE: conversions should only return primitive values (i.e. arrays, or
  7646. // values that give correct `typeof` results).
  7647. // do not use box values types (i.e. Number(), String(), etc.)
  7648. const reverseKeywords = {};
  7649. for (const key of Object.keys(colorName)) {
  7650. reverseKeywords[colorName[key]] = key;
  7651. }
  7652. const convert$1 = {
  7653. rgb: {
  7654. channels: 3,
  7655. labels: 'rgb'
  7656. },
  7657. hsl: {
  7658. channels: 3,
  7659. labels: 'hsl'
  7660. },
  7661. hsv: {
  7662. channels: 3,
  7663. labels: 'hsv'
  7664. },
  7665. hwb: {
  7666. channels: 3,
  7667. labels: 'hwb'
  7668. },
  7669. cmyk: {
  7670. channels: 4,
  7671. labels: 'cmyk'
  7672. },
  7673. xyz: {
  7674. channels: 3,
  7675. labels: 'xyz'
  7676. },
  7677. lab: {
  7678. channels: 3,
  7679. labels: 'lab'
  7680. },
  7681. lch: {
  7682. channels: 3,
  7683. labels: 'lch'
  7684. },
  7685. hex: {
  7686. channels: 1,
  7687. labels: ['hex']
  7688. },
  7689. keyword: {
  7690. channels: 1,
  7691. labels: ['keyword']
  7692. },
  7693. ansi16: {
  7694. channels: 1,
  7695. labels: ['ansi16']
  7696. },
  7697. ansi256: {
  7698. channels: 1,
  7699. labels: ['ansi256']
  7700. },
  7701. hcg: {
  7702. channels: 3,
  7703. labels: ['h', 'c', 'g']
  7704. },
  7705. apple: {
  7706. channels: 3,
  7707. labels: ['r16', 'g16', 'b16']
  7708. },
  7709. gray: {
  7710. channels: 1,
  7711. labels: ['gray']
  7712. }
  7713. };
  7714. var conversions = convert$1; // Hide .channels and .labels properties
  7715. for (const model of Object.keys(convert$1)) {
  7716. if (!('channels' in convert$1[model])) {
  7717. throw new Error('missing channels property: ' + model);
  7718. }
  7719. if (!('labels' in convert$1[model])) {
  7720. throw new Error('missing channel labels property: ' + model);
  7721. }
  7722. if (convert$1[model].labels.length !== convert$1[model].channels) {
  7723. throw new Error('channel and label counts mismatch: ' + model);
  7724. }
  7725. const {
  7726. channels,
  7727. labels
  7728. } = convert$1[model];
  7729. delete convert$1[model].channels;
  7730. delete convert$1[model].labels;
  7731. Object.defineProperty(convert$1[model], 'channels', {
  7732. value: channels
  7733. });
  7734. Object.defineProperty(convert$1[model], 'labels', {
  7735. value: labels
  7736. });
  7737. }
  7738. convert$1.rgb.hsl = function (rgb) {
  7739. const r = rgb[0] / 255;
  7740. const g = rgb[1] / 255;
  7741. const b = rgb[2] / 255;
  7742. const min = Math.min(r, g, b);
  7743. const max = Math.max(r, g, b);
  7744. const delta = max - min;
  7745. let h;
  7746. let s;
  7747. if (max === min) {
  7748. h = 0;
  7749. } else if (r === max) {
  7750. h = (g - b) / delta;
  7751. } else if (g === max) {
  7752. h = 2 + (b - r) / delta;
  7753. } else if (b === max) {
  7754. h = 4 + (r - g) / delta;
  7755. }
  7756. h = Math.min(h * 60, 360);
  7757. if (h < 0) {
  7758. h += 360;
  7759. }
  7760. const l = (min + max) / 2;
  7761. if (max === min) {
  7762. s = 0;
  7763. } else if (l <= 0.5) {
  7764. s = delta / (max + min);
  7765. } else {
  7766. s = delta / (2 - max - min);
  7767. }
  7768. return [h, s * 100, l * 100];
  7769. };
  7770. convert$1.rgb.hsv = function (rgb) {
  7771. let rdif;
  7772. let gdif;
  7773. let bdif;
  7774. let h;
  7775. let s;
  7776. const r = rgb[0] / 255;
  7777. const g = rgb[1] / 255;
  7778. const b = rgb[2] / 255;
  7779. const v = Math.max(r, g, b);
  7780. const diff = v - Math.min(r, g, b);
  7781. const diffc = function (c) {
  7782. return (v - c) / 6 / diff + 1 / 2;
  7783. };
  7784. if (diff === 0) {
  7785. h = 0;
  7786. s = 0;
  7787. } else {
  7788. s = diff / v;
  7789. rdif = diffc(r);
  7790. gdif = diffc(g);
  7791. bdif = diffc(b);
  7792. if (r === v) {
  7793. h = bdif - gdif;
  7794. } else if (g === v) {
  7795. h = 1 / 3 + rdif - bdif;
  7796. } else if (b === v) {
  7797. h = 2 / 3 + gdif - rdif;
  7798. }
  7799. if (h < 0) {
  7800. h += 1;
  7801. } else if (h > 1) {
  7802. h -= 1;
  7803. }
  7804. }
  7805. return [h * 360, s * 100, v * 100];
  7806. };
  7807. convert$1.rgb.hwb = function (rgb) {
  7808. const r = rgb[0];
  7809. const g = rgb[1];
  7810. let b = rgb[2];
  7811. const h = convert$1.rgb.hsl(rgb)[0];
  7812. const w = 1 / 255 * Math.min(r, Math.min(g, b));
  7813. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  7814. return [h, w * 100, b * 100];
  7815. };
  7816. convert$1.rgb.cmyk = function (rgb) {
  7817. const r = rgb[0] / 255;
  7818. const g = rgb[1] / 255;
  7819. const b = rgb[2] / 255;
  7820. const k = Math.min(1 - r, 1 - g, 1 - b);
  7821. const c = (1 - r - k) / (1 - k) || 0;
  7822. const m = (1 - g - k) / (1 - k) || 0;
  7823. const y = (1 - b - k) / (1 - k) || 0;
  7824. return [c * 100, m * 100, y * 100, k * 100];
  7825. };
  7826. function comparativeDistance(x, y) {
  7827. /*
  7828. See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  7829. */
  7830. return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
  7831. }
  7832. convert$1.rgb.keyword = function (rgb) {
  7833. const reversed = reverseKeywords[rgb];
  7834. if (reversed) {
  7835. return reversed;
  7836. }
  7837. let currentClosestDistance = Infinity;
  7838. let currentClosestKeyword;
  7839. for (const keyword of Object.keys(colorName)) {
  7840. const value = colorName[keyword]; // Compute comparative distance
  7841. const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  7842. if (distance < currentClosestDistance) {
  7843. currentClosestDistance = distance;
  7844. currentClosestKeyword = keyword;
  7845. }
  7846. }
  7847. return currentClosestKeyword;
  7848. };
  7849. convert$1.keyword.rgb = function (keyword) {
  7850. return colorName[keyword];
  7851. };
  7852. convert$1.rgb.xyz = function (rgb) {
  7853. let r = rgb[0] / 255;
  7854. let g = rgb[1] / 255;
  7855. let b = rgb[2] / 255; // Assume sRGB
  7856. r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
  7857. g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
  7858. b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
  7859. const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  7860. const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  7861. const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  7862. return [x * 100, y * 100, z * 100];
  7863. };
  7864. convert$1.rgb.lab = function (rgb) {
  7865. const xyz = convert$1.rgb.xyz(rgb);
  7866. let x = xyz[0];
  7867. let y = xyz[1];
  7868. let z = xyz[2];
  7869. x /= 95.047;
  7870. y /= 100;
  7871. z /= 108.883;
  7872. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  7873. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  7874. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  7875. const l = 116 * y - 16;
  7876. const a = 500 * (x - y);
  7877. const b = 200 * (y - z);
  7878. return [l, a, b];
  7879. };
  7880. convert$1.hsl.rgb = function (hsl) {
  7881. const h = hsl[0] / 360;
  7882. const s = hsl[1] / 100;
  7883. const l = hsl[2] / 100;
  7884. let t2;
  7885. let t3;
  7886. let val;
  7887. if (s === 0) {
  7888. val = l * 255;
  7889. return [val, val, val];
  7890. }
  7891. if (l < 0.5) {
  7892. t2 = l * (1 + s);
  7893. } else {
  7894. t2 = l + s - l * s;
  7895. }
  7896. const t1 = 2 * l - t2;
  7897. const rgb = [0, 0, 0];
  7898. for (let i = 0; i < 3; i++) {
  7899. t3 = h + 1 / 3 * -(i - 1);
  7900. if (t3 < 0) {
  7901. t3++;
  7902. }
  7903. if (t3 > 1) {
  7904. t3--;
  7905. }
  7906. if (6 * t3 < 1) {
  7907. val = t1 + (t2 - t1) * 6 * t3;
  7908. } else if (2 * t3 < 1) {
  7909. val = t2;
  7910. } else if (3 * t3 < 2) {
  7911. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  7912. } else {
  7913. val = t1;
  7914. }
  7915. rgb[i] = val * 255;
  7916. }
  7917. return rgb;
  7918. };
  7919. convert$1.hsl.hsv = function (hsl) {
  7920. const h = hsl[0];
  7921. let s = hsl[1] / 100;
  7922. let l = hsl[2] / 100;
  7923. let smin = s;
  7924. const lmin = Math.max(l, 0.01);
  7925. l *= 2;
  7926. s *= l <= 1 ? l : 2 - l;
  7927. smin *= lmin <= 1 ? lmin : 2 - lmin;
  7928. const v = (l + s) / 2;
  7929. const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  7930. return [h, sv * 100, v * 100];
  7931. };
  7932. convert$1.hsv.rgb = function (hsv) {
  7933. const h = hsv[0] / 60;
  7934. const s = hsv[1] / 100;
  7935. let v = hsv[2] / 100;
  7936. const hi = Math.floor(h) % 6;
  7937. const f = h - Math.floor(h);
  7938. const p = 255 * v * (1 - s);
  7939. const q = 255 * v * (1 - s * f);
  7940. const t = 255 * v * (1 - s * (1 - f));
  7941. v *= 255;
  7942. switch (hi) {
  7943. case 0:
  7944. return [v, t, p];
  7945. case 1:
  7946. return [q, v, p];
  7947. case 2:
  7948. return [p, v, t];
  7949. case 3:
  7950. return [p, q, v];
  7951. case 4:
  7952. return [t, p, v];
  7953. case 5:
  7954. return [v, p, q];
  7955. }
  7956. };
  7957. convert$1.hsv.hsl = function (hsv) {
  7958. const h = hsv[0];
  7959. const s = hsv[1] / 100;
  7960. const v = hsv[2] / 100;
  7961. const vmin = Math.max(v, 0.01);
  7962. let sl;
  7963. let l;
  7964. l = (2 - s) * v;
  7965. const lmin = (2 - s) * vmin;
  7966. sl = s * vmin;
  7967. sl /= lmin <= 1 ? lmin : 2 - lmin;
  7968. sl = sl || 0;
  7969. l /= 2;
  7970. return [h, sl * 100, l * 100];
  7971. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  7972. convert$1.hwb.rgb = function (hwb) {
  7973. const h = hwb[0] / 360;
  7974. let wh = hwb[1] / 100;
  7975. let bl = hwb[2] / 100;
  7976. const ratio = wh + bl;
  7977. let f; // Wh + bl cant be > 1
  7978. if (ratio > 1) {
  7979. wh /= ratio;
  7980. bl /= ratio;
  7981. }
  7982. const i = Math.floor(6 * h);
  7983. const v = 1 - bl;
  7984. f = 6 * h - i;
  7985. if ((i & 0x01) !== 0) {
  7986. f = 1 - f;
  7987. }
  7988. const n = wh + f * (v - wh); // Linear interpolation
  7989. let r;
  7990. let g;
  7991. let b;
  7992. /* eslint-disable max-statements-per-line,no-multi-spaces */
  7993. switch (i) {
  7994. default:
  7995. case 6:
  7996. case 0:
  7997. r = v;
  7998. g = n;
  7999. b = wh;
  8000. break;
  8001. case 1:
  8002. r = n;
  8003. g = v;
  8004. b = wh;
  8005. break;
  8006. case 2:
  8007. r = wh;
  8008. g = v;
  8009. b = n;
  8010. break;
  8011. case 3:
  8012. r = wh;
  8013. g = n;
  8014. b = v;
  8015. break;
  8016. case 4:
  8017. r = n;
  8018. g = wh;
  8019. b = v;
  8020. break;
  8021. case 5:
  8022. r = v;
  8023. g = wh;
  8024. b = n;
  8025. break;
  8026. }
  8027. /* eslint-enable max-statements-per-line,no-multi-spaces */
  8028. return [r * 255, g * 255, b * 255];
  8029. };
  8030. convert$1.cmyk.rgb = function (cmyk) {
  8031. const c = cmyk[0] / 100;
  8032. const m = cmyk[1] / 100;
  8033. const y = cmyk[2] / 100;
  8034. const k = cmyk[3] / 100;
  8035. const r = 1 - Math.min(1, c * (1 - k) + k);
  8036. const g = 1 - Math.min(1, m * (1 - k) + k);
  8037. const b = 1 - Math.min(1, y * (1 - k) + k);
  8038. return [r * 255, g * 255, b * 255];
  8039. };
  8040. convert$1.xyz.rgb = function (xyz) {
  8041. const x = xyz[0] / 100;
  8042. const y = xyz[1] / 100;
  8043. const z = xyz[2] / 100;
  8044. let r;
  8045. let g;
  8046. let b;
  8047. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  8048. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  8049. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
  8050. r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
  8051. g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
  8052. b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
  8053. r = Math.min(Math.max(0, r), 1);
  8054. g = Math.min(Math.max(0, g), 1);
  8055. b = Math.min(Math.max(0, b), 1);
  8056. return [r * 255, g * 255, b * 255];
  8057. };
  8058. convert$1.xyz.lab = function (xyz) {
  8059. let x = xyz[0];
  8060. let y = xyz[1];
  8061. let z = xyz[2];
  8062. x /= 95.047;
  8063. y /= 100;
  8064. z /= 108.883;
  8065. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  8066. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  8067. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  8068. const l = 116 * y - 16;
  8069. const a = 500 * (x - y);
  8070. const b = 200 * (y - z);
  8071. return [l, a, b];
  8072. };
  8073. convert$1.lab.xyz = function (lab) {
  8074. const l = lab[0];
  8075. const a = lab[1];
  8076. const b = lab[2];
  8077. let x;
  8078. let y;
  8079. let z;
  8080. y = (l + 16) / 116;
  8081. x = a / 500 + y;
  8082. z = y - b / 200;
  8083. const y2 = y ** 3;
  8084. const x2 = x ** 3;
  8085. const z2 = z ** 3;
  8086. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  8087. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  8088. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  8089. x *= 95.047;
  8090. y *= 100;
  8091. z *= 108.883;
  8092. return [x, y, z];
  8093. };
  8094. convert$1.lab.lch = function (lab) {
  8095. const l = lab[0];
  8096. const a = lab[1];
  8097. const b = lab[2];
  8098. let h;
  8099. const hr = Math.atan2(b, a);
  8100. h = hr * 360 / 2 / Math.PI;
  8101. if (h < 0) {
  8102. h += 360;
  8103. }
  8104. const c = Math.sqrt(a * a + b * b);
  8105. return [l, c, h];
  8106. };
  8107. convert$1.lch.lab = function (lch) {
  8108. const l = lch[0];
  8109. const c = lch[1];
  8110. const h = lch[2];
  8111. const hr = h / 360 * 2 * Math.PI;
  8112. const a = c * Math.cos(hr);
  8113. const b = c * Math.sin(hr);
  8114. return [l, a, b];
  8115. };
  8116. convert$1.rgb.ansi16 = function (args, saturation = null) {
  8117. const [r, g, b] = args;
  8118. let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
  8119. value = Math.round(value / 50);
  8120. if (value === 0) {
  8121. return 30;
  8122. }
  8123. let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  8124. if (value === 2) {
  8125. ansi += 60;
  8126. }
  8127. return ansi;
  8128. };
  8129. convert$1.hsv.ansi16 = function (args) {
  8130. // Optimization here; we already know the value and don't need to get
  8131. // it converted for us.
  8132. return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
  8133. };
  8134. convert$1.rgb.ansi256 = function (args) {
  8135. const r = args[0];
  8136. const g = args[1];
  8137. const b = args[2]; // We use the extended greyscale palette here, with the exception of
  8138. // black and white. normal palette only has 4 greyscale shades.
  8139. if (r === g && g === b) {
  8140. if (r < 8) {
  8141. return 16;
  8142. }
  8143. if (r > 248) {
  8144. return 231;
  8145. }
  8146. return Math.round((r - 8) / 247 * 24) + 232;
  8147. }
  8148. const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  8149. return ansi;
  8150. };
  8151. convert$1.ansi16.rgb = function (args) {
  8152. let color = args % 10; // Handle greyscale
  8153. if (color === 0 || color === 7) {
  8154. if (args > 50) {
  8155. color += 3.5;
  8156. }
  8157. color = color / 10.5 * 255;
  8158. return [color, color, color];
  8159. }
  8160. const mult = (~~(args > 50) + 1) * 0.5;
  8161. const r = (color & 1) * mult * 255;
  8162. const g = (color >> 1 & 1) * mult * 255;
  8163. const b = (color >> 2 & 1) * mult * 255;
  8164. return [r, g, b];
  8165. };
  8166. convert$1.ansi256.rgb = function (args) {
  8167. // Handle greyscale
  8168. if (args >= 232) {
  8169. const c = (args - 232) * 10 + 8;
  8170. return [c, c, c];
  8171. }
  8172. args -= 16;
  8173. let rem;
  8174. const r = Math.floor(args / 36) / 5 * 255;
  8175. const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  8176. const b = rem % 6 / 5 * 255;
  8177. return [r, g, b];
  8178. };
  8179. convert$1.rgb.hex = function (args) {
  8180. const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  8181. const string = integer.toString(16).toUpperCase();
  8182. return '000000'.substring(string.length) + string;
  8183. };
  8184. convert$1.hex.rgb = function (args) {
  8185. const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  8186. if (!match) {
  8187. return [0, 0, 0];
  8188. }
  8189. let colorString = match[0];
  8190. if (match[0].length === 3) {
  8191. colorString = colorString.split('').map(char => {
  8192. return char + char;
  8193. }).join('');
  8194. }
  8195. const integer = parseInt(colorString, 16);
  8196. const r = integer >> 16 & 0xFF;
  8197. const g = integer >> 8 & 0xFF;
  8198. const b = integer & 0xFF;
  8199. return [r, g, b];
  8200. };
  8201. convert$1.rgb.hcg = function (rgb) {
  8202. const r = rgb[0] / 255;
  8203. const g = rgb[1] / 255;
  8204. const b = rgb[2] / 255;
  8205. const max = Math.max(Math.max(r, g), b);
  8206. const min = Math.min(Math.min(r, g), b);
  8207. const chroma = max - min;
  8208. let grayscale;
  8209. let hue;
  8210. if (chroma < 1) {
  8211. grayscale = min / (1 - chroma);
  8212. } else {
  8213. grayscale = 0;
  8214. }
  8215. if (chroma <= 0) {
  8216. hue = 0;
  8217. } else if (max === r) {
  8218. hue = (g - b) / chroma % 6;
  8219. } else if (max === g) {
  8220. hue = 2 + (b - r) / chroma;
  8221. } else {
  8222. hue = 4 + (r - g) / chroma;
  8223. }
  8224. hue /= 6;
  8225. hue %= 1;
  8226. return [hue * 360, chroma * 100, grayscale * 100];
  8227. };
  8228. convert$1.hsl.hcg = function (hsl) {
  8229. const s = hsl[1] / 100;
  8230. const l = hsl[2] / 100;
  8231. const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
  8232. let f = 0;
  8233. if (c < 1.0) {
  8234. f = (l - 0.5 * c) / (1.0 - c);
  8235. }
  8236. return [hsl[0], c * 100, f * 100];
  8237. };
  8238. convert$1.hsv.hcg = function (hsv) {
  8239. const s = hsv[1] / 100;
  8240. const v = hsv[2] / 100;
  8241. const c = s * v;
  8242. let f = 0;
  8243. if (c < 1.0) {
  8244. f = (v - c) / (1 - c);
  8245. }
  8246. return [hsv[0], c * 100, f * 100];
  8247. };
  8248. convert$1.hcg.rgb = function (hcg) {
  8249. const h = hcg[0] / 360;
  8250. const c = hcg[1] / 100;
  8251. const g = hcg[2] / 100;
  8252. if (c === 0.0) {
  8253. return [g * 255, g * 255, g * 255];
  8254. }
  8255. const pure = [0, 0, 0];
  8256. const hi = h % 1 * 6;
  8257. const v = hi % 1;
  8258. const w = 1 - v;
  8259. let mg = 0;
  8260. /* eslint-disable max-statements-per-line */
  8261. switch (Math.floor(hi)) {
  8262. case 0:
  8263. pure[0] = 1;
  8264. pure[1] = v;
  8265. pure[2] = 0;
  8266. break;
  8267. case 1:
  8268. pure[0] = w;
  8269. pure[1] = 1;
  8270. pure[2] = 0;
  8271. break;
  8272. case 2:
  8273. pure[0] = 0;
  8274. pure[1] = 1;
  8275. pure[2] = v;
  8276. break;
  8277. case 3:
  8278. pure[0] = 0;
  8279. pure[1] = w;
  8280. pure[2] = 1;
  8281. break;
  8282. case 4:
  8283. pure[0] = v;
  8284. pure[1] = 0;
  8285. pure[2] = 1;
  8286. break;
  8287. default:
  8288. pure[0] = 1;
  8289. pure[1] = 0;
  8290. pure[2] = w;
  8291. }
  8292. /* eslint-enable max-statements-per-line */
  8293. mg = (1.0 - c) * g;
  8294. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  8295. };
  8296. convert$1.hcg.hsv = function (hcg) {
  8297. const c = hcg[1] / 100;
  8298. const g = hcg[2] / 100;
  8299. const v = c + g * (1.0 - c);
  8300. let f = 0;
  8301. if (v > 0.0) {
  8302. f = c / v;
  8303. }
  8304. return [hcg[0], f * 100, v * 100];
  8305. };
  8306. convert$1.hcg.hsl = function (hcg) {
  8307. const c = hcg[1] / 100;
  8308. const g = hcg[2] / 100;
  8309. const l = g * (1.0 - c) + 0.5 * c;
  8310. let s = 0;
  8311. if (l > 0.0 && l < 0.5) {
  8312. s = c / (2 * l);
  8313. } else if (l >= 0.5 && l < 1.0) {
  8314. s = c / (2 * (1 - l));
  8315. }
  8316. return [hcg[0], s * 100, l * 100];
  8317. };
  8318. convert$1.hcg.hwb = function (hcg) {
  8319. const c = hcg[1] / 100;
  8320. const g = hcg[2] / 100;
  8321. const v = c + g * (1.0 - c);
  8322. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  8323. };
  8324. convert$1.hwb.hcg = function (hwb) {
  8325. const w = hwb[1] / 100;
  8326. const b = hwb[2] / 100;
  8327. const v = 1 - b;
  8328. const c = v - w;
  8329. let g = 0;
  8330. if (c < 1) {
  8331. g = (v - c) / (1 - c);
  8332. }
  8333. return [hwb[0], c * 100, g * 100];
  8334. };
  8335. convert$1.apple.rgb = function (apple) {
  8336. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  8337. };
  8338. convert$1.rgb.apple = function (rgb) {
  8339. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  8340. };
  8341. convert$1.gray.rgb = function (args) {
  8342. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  8343. };
  8344. convert$1.gray.hsl = function (args) {
  8345. return [0, 0, args[0]];
  8346. };
  8347. convert$1.gray.hsv = convert$1.gray.hsl;
  8348. convert$1.gray.hwb = function (gray) {
  8349. return [0, 100, gray[0]];
  8350. };
  8351. convert$1.gray.cmyk = function (gray) {
  8352. return [0, 0, 0, gray[0]];
  8353. };
  8354. convert$1.gray.lab = function (gray) {
  8355. return [gray[0], 0, 0];
  8356. };
  8357. convert$1.gray.hex = function (gray) {
  8358. const val = Math.round(gray[0] / 100 * 255) & 0xFF;
  8359. const integer = (val << 16) + (val << 8) + val;
  8360. const string = integer.toString(16).toUpperCase();
  8361. return '000000'.substring(string.length) + string;
  8362. };
  8363. convert$1.rgb.gray = function (rgb) {
  8364. const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  8365. return [val / 255 * 100];
  8366. };
  8367. /*
  8368. This function routes a model to all other models.
  8369. all functions that are routed have a property `.conversion` attached
  8370. to the returned synthetic function. This property is an array
  8371. of strings, each with the steps in between the 'from' and 'to'
  8372. color models (inclusive).
  8373. conversions that are not possible simply are not included.
  8374. */
  8375. function buildGraph() {
  8376. const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  8377. const models = Object.keys(conversions);
  8378. for (let len = models.length, i = 0; i < len; i++) {
  8379. graph[models[i]] = {
  8380. // http://jsperf.com/1-vs-infinity
  8381. // micro-opt, but this is simple.
  8382. distance: -1,
  8383. parent: null
  8384. };
  8385. }
  8386. return graph;
  8387. } // https://en.wikipedia.org/wiki/Breadth-first_search
  8388. function deriveBFS(fromModel) {
  8389. const graph = buildGraph();
  8390. const queue = [fromModel]; // Unshift -> queue -> pop
  8391. graph[fromModel].distance = 0;
  8392. while (queue.length) {
  8393. const current = queue.pop();
  8394. const adjacents = Object.keys(conversions[current]);
  8395. for (let len = adjacents.length, i = 0; i < len; i++) {
  8396. const adjacent = adjacents[i];
  8397. const node = graph[adjacent];
  8398. if (node.distance === -1) {
  8399. node.distance = graph[current].distance + 1;
  8400. node.parent = current;
  8401. queue.unshift(adjacent);
  8402. }
  8403. }
  8404. }
  8405. return graph;
  8406. }
  8407. function link$1(from, to) {
  8408. return function (args) {
  8409. return to(from(args));
  8410. };
  8411. }
  8412. function wrapConversion(toModel, graph) {
  8413. const path = [graph[toModel].parent, toModel];
  8414. let fn = conversions[graph[toModel].parent][toModel];
  8415. let cur = graph[toModel].parent;
  8416. while (graph[cur].parent) {
  8417. path.unshift(graph[cur].parent);
  8418. fn = link$1(conversions[graph[cur].parent][cur], fn);
  8419. cur = graph[cur].parent;
  8420. }
  8421. fn.conversion = path;
  8422. return fn;
  8423. }
  8424. var route = function (fromModel) {
  8425. const graph = deriveBFS(fromModel);
  8426. const conversion = {};
  8427. const models = Object.keys(graph);
  8428. for (let len = models.length, i = 0; i < len; i++) {
  8429. const toModel = models[i];
  8430. const node = graph[toModel];
  8431. if (node.parent === null) {
  8432. // No possible conversion, or this node is the source model.
  8433. continue;
  8434. }
  8435. conversion[toModel] = wrapConversion(toModel, graph);
  8436. }
  8437. return conversion;
  8438. };
  8439. const convert = {};
  8440. const models = Object.keys(conversions);
  8441. function wrapRaw(fn) {
  8442. const wrappedFn = function (...args) {
  8443. const arg0 = args[0];
  8444. if (arg0 === undefined || arg0 === null) {
  8445. return arg0;
  8446. }
  8447. if (arg0.length > 1) {
  8448. args = arg0;
  8449. }
  8450. return fn(args);
  8451. }; // Preserve .conversion property if there is one
  8452. if ('conversion' in fn) {
  8453. wrappedFn.conversion = fn.conversion;
  8454. }
  8455. return wrappedFn;
  8456. }
  8457. function wrapRounded(fn) {
  8458. const wrappedFn = function (...args) {
  8459. const arg0 = args[0];
  8460. if (arg0 === undefined || arg0 === null) {
  8461. return arg0;
  8462. }
  8463. if (arg0.length > 1) {
  8464. args = arg0;
  8465. }
  8466. const result = fn(args); // We're assuming the result is an array here.
  8467. // see notice in conversions.js; don't use box types
  8468. // in conversion functions.
  8469. if (typeof result === 'object') {
  8470. for (let len = result.length, i = 0; i < len; i++) {
  8471. result[i] = Math.round(result[i]);
  8472. }
  8473. }
  8474. return result;
  8475. }; // Preserve .conversion property if there is one
  8476. if ('conversion' in fn) {
  8477. wrappedFn.conversion = fn.conversion;
  8478. }
  8479. return wrappedFn;
  8480. }
  8481. models.forEach(fromModel => {
  8482. convert[fromModel] = {};
  8483. Object.defineProperty(convert[fromModel], 'channels', {
  8484. value: conversions[fromModel].channels
  8485. });
  8486. Object.defineProperty(convert[fromModel], 'labels', {
  8487. value: conversions[fromModel].labels
  8488. });
  8489. const routes = route(fromModel);
  8490. const routeModels = Object.keys(routes);
  8491. routeModels.forEach(toModel => {
  8492. const fn = routes[toModel];
  8493. convert[fromModel][toModel] = wrapRounded(fn);
  8494. convert[fromModel][toModel].raw = wrapRaw(fn);
  8495. });
  8496. });
  8497. var colorConvert = convert;
  8498. var ansiStyles$1 = createCommonjsModule(function (module) {
  8499. const wrapAnsi16 = (fn, offset) => (...args) => {
  8500. const code = fn(...args);
  8501. return `\u001B[${code + offset}m`;
  8502. };
  8503. const wrapAnsi256 = (fn, offset) => (...args) => {
  8504. const code = fn(...args);
  8505. return `\u001B[${38 + offset};5;${code}m`;
  8506. };
  8507. const wrapAnsi16m = (fn, offset) => (...args) => {
  8508. const rgb = fn(...args);
  8509. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  8510. };
  8511. const ansi2ansi = n => n;
  8512. const rgb2rgb = (r, g, b) => [r, g, b];
  8513. const setLazyProperty = (object, property, get) => {
  8514. Object.defineProperty(object, property, {
  8515. get: () => {
  8516. const value = get();
  8517. Object.defineProperty(object, property, {
  8518. value,
  8519. enumerable: true,
  8520. configurable: true
  8521. });
  8522. return value;
  8523. },
  8524. enumerable: true,
  8525. configurable: true
  8526. });
  8527. };
  8528. /** @type {typeof import('color-convert')} */
  8529. let colorConvert$1;
  8530. const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
  8531. if (colorConvert$1 === undefined) {
  8532. colorConvert$1 = colorConvert;
  8533. }
  8534. const offset = isBackground ? 10 : 0;
  8535. const styles = {};
  8536. for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
  8537. const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
  8538. if (sourceSpace === targetSpace) {
  8539. styles[name] = wrap(identity, offset);
  8540. } else if (typeof suite === 'object') {
  8541. styles[name] = wrap(suite[targetSpace], offset);
  8542. }
  8543. }
  8544. return styles;
  8545. };
  8546. function assembleStyles() {
  8547. const codes = new Map();
  8548. const styles = {
  8549. modifier: {
  8550. reset: [0, 0],
  8551. // 21 isn't widely supported and 22 does the same thing
  8552. bold: [1, 22],
  8553. dim: [2, 22],
  8554. italic: [3, 23],
  8555. underline: [4, 24],
  8556. inverse: [7, 27],
  8557. hidden: [8, 28],
  8558. strikethrough: [9, 29]
  8559. },
  8560. color: {
  8561. black: [30, 39],
  8562. red: [31, 39],
  8563. green: [32, 39],
  8564. yellow: [33, 39],
  8565. blue: [34, 39],
  8566. magenta: [35, 39],
  8567. cyan: [36, 39],
  8568. white: [37, 39],
  8569. // Bright color
  8570. blackBright: [90, 39],
  8571. redBright: [91, 39],
  8572. greenBright: [92, 39],
  8573. yellowBright: [93, 39],
  8574. blueBright: [94, 39],
  8575. magentaBright: [95, 39],
  8576. cyanBright: [96, 39],
  8577. whiteBright: [97, 39]
  8578. },
  8579. bgColor: {
  8580. bgBlack: [40, 49],
  8581. bgRed: [41, 49],
  8582. bgGreen: [42, 49],
  8583. bgYellow: [43, 49],
  8584. bgBlue: [44, 49],
  8585. bgMagenta: [45, 49],
  8586. bgCyan: [46, 49],
  8587. bgWhite: [47, 49],
  8588. // Bright color
  8589. bgBlackBright: [100, 49],
  8590. bgRedBright: [101, 49],
  8591. bgGreenBright: [102, 49],
  8592. bgYellowBright: [103, 49],
  8593. bgBlueBright: [104, 49],
  8594. bgMagentaBright: [105, 49],
  8595. bgCyanBright: [106, 49],
  8596. bgWhiteBright: [107, 49]
  8597. }
  8598. }; // Alias bright black as gray (and grey)
  8599. styles.color.gray = styles.color.blackBright;
  8600. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  8601. styles.color.grey = styles.color.blackBright;
  8602. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  8603. for (const [groupName, group] of Object.entries(styles)) {
  8604. for (const [styleName, style] of Object.entries(group)) {
  8605. styles[styleName] = {
  8606. open: `\u001B[${style[0]}m`,
  8607. close: `\u001B[${style[1]}m`
  8608. };
  8609. group[styleName] = styles[styleName];
  8610. codes.set(style[0], style[1]);
  8611. }
  8612. Object.defineProperty(styles, groupName, {
  8613. value: group,
  8614. enumerable: false
  8615. });
  8616. }
  8617. Object.defineProperty(styles, 'codes', {
  8618. value: codes,
  8619. enumerable: false
  8620. });
  8621. styles.color.close = '\u001B[39m';
  8622. styles.bgColor.close = '\u001B[49m';
  8623. setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
  8624. setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
  8625. setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
  8626. setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
  8627. setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
  8628. setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
  8629. return styles;
  8630. } // Make the export immutable
  8631. Object.defineProperty(module, 'exports', {
  8632. enumerable: true,
  8633. get: assembleStyles
  8634. });
  8635. });
  8636. var hasFlag$1 = (flag, argv = process.argv) => {
  8637. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  8638. const position = argv.indexOf(prefix + flag);
  8639. const terminatorPosition = argv.indexOf('--');
  8640. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  8641. };
  8642. const {
  8643. env: env$1
  8644. } = process;
  8645. let forceColor$1;
  8646. if (hasFlag$1('no-color') || hasFlag$1('no-colors') || hasFlag$1('color=false') || hasFlag$1('color=never')) {
  8647. forceColor$1 = 0;
  8648. } else if (hasFlag$1('color') || hasFlag$1('colors') || hasFlag$1('color=true') || hasFlag$1('color=always')) {
  8649. forceColor$1 = 1;
  8650. }
  8651. if ('FORCE_COLOR' in env$1) {
  8652. if (env$1.FORCE_COLOR === 'true') {
  8653. forceColor$1 = 1;
  8654. } else if (env$1.FORCE_COLOR === 'false') {
  8655. forceColor$1 = 0;
  8656. } else {
  8657. forceColor$1 = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3);
  8658. }
  8659. }
  8660. function translateLevel$1(level) {
  8661. if (level === 0) {
  8662. return false;
  8663. }
  8664. return {
  8665. level,
  8666. hasBasic: true,
  8667. has256: level >= 2,
  8668. has16m: level >= 3
  8669. };
  8670. }
  8671. function supportsColor$1(haveStream, streamIsTTY) {
  8672. if (forceColor$1 === 0) {
  8673. return 0;
  8674. }
  8675. if (hasFlag$1('color=16m') || hasFlag$1('color=full') || hasFlag$1('color=truecolor')) {
  8676. return 3;
  8677. }
  8678. if (hasFlag$1('color=256')) {
  8679. return 2;
  8680. }
  8681. if (haveStream && !streamIsTTY && forceColor$1 === undefined) {
  8682. return 0;
  8683. }
  8684. const min = forceColor$1 || 0;
  8685. if (env$1.TERM === 'dumb') {
  8686. return min;
  8687. }
  8688. if (process.platform === 'win32') {
  8689. // Windows 10 build 10586 is the first Windows release that supports 256 colors.
  8690. // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
  8691. const osRelease = os__default['default'].release().split('.');
  8692. if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  8693. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  8694. }
  8695. return 1;
  8696. }
  8697. if ('CI' in env$1) {
  8698. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
  8699. return 1;
  8700. }
  8701. return min;
  8702. }
  8703. if ('TEAMCITY_VERSION' in env$1) {
  8704. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  8705. }
  8706. if (env$1.COLORTERM === 'truecolor') {
  8707. return 3;
  8708. }
  8709. if ('TERM_PROGRAM' in env$1) {
  8710. const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  8711. switch (env$1.TERM_PROGRAM) {
  8712. case 'iTerm.app':
  8713. return version >= 3 ? 3 : 2;
  8714. case 'Apple_Terminal':
  8715. return 2;
  8716. // No default
  8717. }
  8718. }
  8719. if (/-256(color)?$/i.test(env$1.TERM)) {
  8720. return 2;
  8721. }
  8722. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  8723. return 1;
  8724. }
  8725. if ('COLORTERM' in env$1) {
  8726. return 1;
  8727. }
  8728. return min;
  8729. }
  8730. function getSupportLevel$1(stream) {
  8731. const level = supportsColor$1(stream, stream && stream.isTTY);
  8732. return translateLevel$1(level);
  8733. }
  8734. var supportsColor_1$1 = {
  8735. supportsColor: getSupportLevel$1,
  8736. stdout: translateLevel$1(supportsColor$1(true, tty__default['default'].isatty(1))),
  8737. stderr: translateLevel$1(supportsColor$1(true, tty__default['default'].isatty(2)))
  8738. };
  8739. const stringReplaceAll$1 = (string, substring, replacer) => {
  8740. let index = string.indexOf(substring);
  8741. if (index === -1) {
  8742. return string;
  8743. }
  8744. const substringLength = substring.length;
  8745. let endIndex = 0;
  8746. let returnValue = '';
  8747. do {
  8748. returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
  8749. endIndex = index + substringLength;
  8750. index = string.indexOf(substring, endIndex);
  8751. } while (index !== -1);
  8752. returnValue += string.substr(endIndex);
  8753. return returnValue;
  8754. };
  8755. const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
  8756. let endIndex = 0;
  8757. let returnValue = '';
  8758. do {
  8759. const gotCR = string[index - 1] === '\r';
  8760. returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
  8761. endIndex = index + 1;
  8762. index = string.indexOf('\n', endIndex);
  8763. } while (index !== -1);
  8764. returnValue += string.substr(endIndex);
  8765. return returnValue;
  8766. };
  8767. var util$4 = {
  8768. stringReplaceAll: stringReplaceAll$1,
  8769. stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
  8770. };
  8771. const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  8772. const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  8773. const STRING_REGEX$2 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  8774. const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
  8775. const ESCAPES$1 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  8776. function unescape$1(c) {
  8777. const u = c[0] === 'u';
  8778. const bracket = c[1] === '{';
  8779. if (u && !bracket && c.length === 5 || c[0] === 'x' && c.length === 3) {
  8780. return String.fromCharCode(parseInt(c.slice(1), 16));
  8781. }
  8782. if (u && bracket) {
  8783. return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
  8784. }
  8785. return ESCAPES$1.get(c) || c;
  8786. }
  8787. function parseArguments$1(name, arguments_) {
  8788. const results = [];
  8789. const chunks = arguments_.trim().split(/\s*,\s*/g);
  8790. let matches;
  8791. for (const chunk of chunks) {
  8792. const number = Number(chunk);
  8793. if (!Number.isNaN(number)) {
  8794. results.push(number);
  8795. } else if (matches = chunk.match(STRING_REGEX$2)) {
  8796. results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$1(escape) : character));
  8797. } else {
  8798. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  8799. }
  8800. }
  8801. return results;
  8802. }
  8803. function parseStyle$1(style) {
  8804. STYLE_REGEX$1.lastIndex = 0;
  8805. const results = [];
  8806. let matches;
  8807. while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
  8808. const name = matches[1];
  8809. if (matches[2]) {
  8810. const args = parseArguments$1(name, matches[2]);
  8811. results.push([name].concat(args));
  8812. } else {
  8813. results.push([name]);
  8814. }
  8815. }
  8816. return results;
  8817. }
  8818. function buildStyle$1(chalk, styles) {
  8819. const enabled = {};
  8820. for (const layer of styles) {
  8821. for (const style of layer.styles) {
  8822. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  8823. }
  8824. }
  8825. let current = chalk;
  8826. for (const [styleName, styles] of Object.entries(enabled)) {
  8827. if (!Array.isArray(styles)) {
  8828. continue;
  8829. }
  8830. if (!(styleName in current)) {
  8831. throw new Error(`Unknown Chalk style: ${styleName}`);
  8832. }
  8833. current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
  8834. }
  8835. return current;
  8836. }
  8837. var templates$1 = (chalk, temporary) => {
  8838. const styles = [];
  8839. const chunks = [];
  8840. let chunk = []; // eslint-disable-next-line max-params
  8841. temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => {
  8842. if (escapeCharacter) {
  8843. chunk.push(unescape$1(escapeCharacter));
  8844. } else if (style) {
  8845. const string = chunk.join('');
  8846. chunk = [];
  8847. chunks.push(styles.length === 0 ? string : buildStyle$1(chalk, styles)(string));
  8848. styles.push({
  8849. inverse,
  8850. styles: parseStyle$1(style)
  8851. });
  8852. } else if (close) {
  8853. if (styles.length === 0) {
  8854. throw new Error('Found extraneous } in Chalk template literal');
  8855. }
  8856. chunks.push(buildStyle$1(chalk, styles)(chunk.join('')));
  8857. chunk = [];
  8858. styles.pop();
  8859. } else {
  8860. chunk.push(character);
  8861. }
  8862. });
  8863. chunks.push(chunk.join(''));
  8864. if (styles.length > 0) {
  8865. const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  8866. throw new Error(errMessage);
  8867. }
  8868. return chunks.join('');
  8869. };
  8870. const {
  8871. stdout: stdoutColor,
  8872. stderr: stderrColor
  8873. } = supportsColor_1$1;
  8874. const {
  8875. stringReplaceAll,
  8876. stringEncaseCRLFWithFirstIndex
  8877. } = util$4;
  8878. const {
  8879. isArray: isArray$2
  8880. } = Array; // `supportsColor.level` → `ansiStyles.color[name]` mapping
  8881. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
  8882. const styles = Object.create(null);
  8883. const applyOptions = (object, options = {}) => {
  8884. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  8885. throw new Error('The `level` option should be an integer from 0 to 3');
  8886. } // Detect level if not set manually
  8887. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  8888. object.level = options.level === undefined ? colorLevel : options.level;
  8889. };
  8890. class ChalkClass {
  8891. constructor(options) {
  8892. // eslint-disable-next-line no-constructor-return
  8893. return chalkFactory(options);
  8894. }
  8895. }
  8896. const chalkFactory = options => {
  8897. const chalk = {};
  8898. applyOptions(chalk, options);
  8899. chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
  8900. Object.setPrototypeOf(chalk, Chalk.prototype);
  8901. Object.setPrototypeOf(chalk.template, chalk);
  8902. chalk.template.constructor = () => {
  8903. throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
  8904. };
  8905. chalk.template.Instance = ChalkClass;
  8906. return chalk.template;
  8907. };
  8908. function Chalk(options) {
  8909. return chalkFactory(options);
  8910. }
  8911. for (const [styleName, style] of Object.entries(ansiStyles$1)) {
  8912. styles[styleName] = {
  8913. get() {
  8914. const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
  8915. Object.defineProperty(this, styleName, {
  8916. value: builder
  8917. });
  8918. return builder;
  8919. }
  8920. };
  8921. }
  8922. styles.visible = {
  8923. get() {
  8924. const builder = createBuilder(this, this._styler, true);
  8925. Object.defineProperty(this, 'visible', {
  8926. value: builder
  8927. });
  8928. return builder;
  8929. }
  8930. };
  8931. const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
  8932. for (const model of usedModels) {
  8933. styles[model] = {
  8934. get() {
  8935. const {
  8936. level
  8937. } = this;
  8938. return function (...arguments_) {
  8939. const styler = createStyler(ansiStyles$1.color[levelMapping[level]][model](...arguments_), ansiStyles$1.color.close, this._styler);
  8940. return createBuilder(this, styler, this._isEmpty);
  8941. };
  8942. }
  8943. };
  8944. }
  8945. for (const model of usedModels) {
  8946. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8947. styles[bgModel] = {
  8948. get() {
  8949. const {
  8950. level
  8951. } = this;
  8952. return function (...arguments_) {
  8953. const styler = createStyler(ansiStyles$1.bgColor[levelMapping[level]][model](...arguments_), ansiStyles$1.bgColor.close, this._styler);
  8954. return createBuilder(this, styler, this._isEmpty);
  8955. };
  8956. }
  8957. };
  8958. }
  8959. const proto = Object.defineProperties(() => {}, Object.assign(Object.assign({}, styles), {}, {
  8960. level: {
  8961. enumerable: true,
  8962. get() {
  8963. return this._generator.level;
  8964. },
  8965. set(level) {
  8966. this._generator.level = level;
  8967. }
  8968. }
  8969. }));
  8970. const createStyler = (open, close, parent) => {
  8971. let openAll;
  8972. let closeAll;
  8973. if (parent === undefined) {
  8974. openAll = open;
  8975. closeAll = close;
  8976. } else {
  8977. openAll = parent.openAll + open;
  8978. closeAll = close + parent.closeAll;
  8979. }
  8980. return {
  8981. open,
  8982. close,
  8983. openAll,
  8984. closeAll,
  8985. parent
  8986. };
  8987. };
  8988. const createBuilder = (self, _styler, _isEmpty) => {
  8989. const builder = (...arguments_) => {
  8990. if (isArray$2(arguments_[0]) && isArray$2(arguments_[0].raw)) {
  8991. // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
  8992. return applyStyle(builder, chalkTag(builder, ...arguments_));
  8993. } // Single argument is hot path, implicit coercion is faster than anything
  8994. // eslint-disable-next-line no-implicit-coercion
  8995. return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
  8996. }; // We alter the prototype because we must return a function, but there is
  8997. // no way to create a function with a different prototype
  8998. Object.setPrototypeOf(builder, proto);
  8999. builder._generator = self;
  9000. builder._styler = _styler;
  9001. builder._isEmpty = _isEmpty;
  9002. return builder;
  9003. };
  9004. const applyStyle = (self, string) => {
  9005. if (self.level <= 0 || !string) {
  9006. return self._isEmpty ? '' : string;
  9007. }
  9008. let styler = self._styler;
  9009. if (styler === undefined) {
  9010. return string;
  9011. }
  9012. const {
  9013. openAll,
  9014. closeAll
  9015. } = styler;
  9016. if (string.indexOf('\u001B') !== -1) {
  9017. while (styler !== undefined) {
  9018. // Replace any instances already present with a re-opening code
  9019. // otherwise only the part of the string until said closing code
  9020. // will be colored, and the rest will simply be 'plain'.
  9021. string = stringReplaceAll(string, styler.close, styler.open);
  9022. styler = styler.parent;
  9023. }
  9024. } // We can move both next actions out of loop, because remaining actions in loop won't have
  9025. // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
  9026. // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
  9027. const lfIndex = string.indexOf('\n');
  9028. if (lfIndex !== -1) {
  9029. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  9030. }
  9031. return openAll + string + closeAll;
  9032. };
  9033. let template;
  9034. const chalkTag = (chalk, ...strings) => {
  9035. const [firstString] = strings;
  9036. if (!isArray$2(firstString) || !isArray$2(firstString.raw)) {
  9037. // If chalk() was called by itself or with a string,
  9038. // return the string itself as a string.
  9039. return strings.join(' ');
  9040. }
  9041. const arguments_ = strings.slice(1);
  9042. const parts = [firstString.raw[0]];
  9043. for (let i = 1; i < firstString.length; i++) {
  9044. parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
  9045. }
  9046. if (template === undefined) {
  9047. template = templates$1;
  9048. }
  9049. return template(chalk, parts.join(''));
  9050. };
  9051. Object.defineProperties(Chalk.prototype, styles);
  9052. const chalk$1 = Chalk(); // eslint-disable-line new-cap
  9053. chalk$1.supportsColor = stdoutColor;
  9054. chalk$1.stderr = Chalk({
  9055. level: stderrColor ? stderrColor.level : 0
  9056. }); // eslint-disable-line new-cap
  9057. chalk$1.stderr.supportsColor = stderrColor;
  9058. var source$2 = chalk$1;
  9059. const _excluded$2 = ["_"];
  9060. const cliDescriptor = {
  9061. key: key => key.length === 1 ? `-${key}` : `--${key}`,
  9062. value: value => lib$4.apiDescriptor.value(value),
  9063. pair: ({
  9064. key,
  9065. value
  9066. }) => value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`
  9067. };
  9068. class FlagSchema extends lib$4.ChoiceSchema {
  9069. constructor({
  9070. name,
  9071. flags
  9072. }) {
  9073. super({
  9074. name,
  9075. choices: flags
  9076. });
  9077. this._flags = [...flags].sort();
  9078. }
  9079. preprocess(value, utils) {
  9080. if (typeof value === "string" && value.length > 0 && !this._flags.includes(value)) {
  9081. const suggestion = this._flags.find(flag => leven_1(flag, value) < 3);
  9082. if (suggestion) {
  9083. utils.logger.warn([`Unknown flag ${source$2.yellow(utils.descriptor.value(value))},`, `did you mean ${source$2.blue(utils.descriptor.value(suggestion))}?`].join(" "));
  9084. return suggestion;
  9085. }
  9086. }
  9087. return value;
  9088. }
  9089. expected() {
  9090. return "a flag";
  9091. }
  9092. }
  9093. let hasDeprecationWarned;
  9094. function normalizeOptions$3(options, optionInfos, {
  9095. logger,
  9096. isCLI = false,
  9097. passThrough = false
  9098. } = {}) {
  9099. const unknown = !passThrough ? (key, value, options) => {
  9100. // Don't suggest `_` for unknown flags
  9101. const _options$schemas = options.schemas,
  9102. schemas = _objectWithoutProperties(_options$schemas, _excluded$2);
  9103. return lib$4.levenUnknownHandler(key, value, Object.assign(Object.assign({}, options), {}, {
  9104. schemas
  9105. }));
  9106. } : Array.isArray(passThrough) ? (key, value) => !passThrough.includes(key) ? undefined : {
  9107. [key]: value
  9108. } : (key, value) => ({
  9109. [key]: value
  9110. });
  9111. const descriptor = isCLI ? cliDescriptor : lib$4.apiDescriptor;
  9112. const schemas = optionInfosToSchemas(optionInfos, {
  9113. isCLI
  9114. });
  9115. const normalizer = new lib$4.Normalizer(schemas, {
  9116. logger,
  9117. unknown,
  9118. descriptor
  9119. });
  9120. const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  9121. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  9122. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  9123. }
  9124. const normalized = normalizer.normalize(options);
  9125. if (shouldSuppressDuplicateDeprecationWarnings) {
  9126. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  9127. }
  9128. return normalized;
  9129. }
  9130. function optionInfosToSchemas(optionInfos, {
  9131. isCLI
  9132. }) {
  9133. const schemas = [];
  9134. if (isCLI) {
  9135. schemas.push(lib$4.AnySchema.create({
  9136. name: "_"
  9137. }));
  9138. }
  9139. for (const optionInfo of optionInfos) {
  9140. schemas.push(optionInfoToSchema(optionInfo, {
  9141. isCLI,
  9142. optionInfos
  9143. }));
  9144. if (optionInfo.alias && isCLI) {
  9145. schemas.push(lib$4.AliasSchema.create({
  9146. name: optionInfo.alias,
  9147. sourceName: optionInfo.name
  9148. }));
  9149. }
  9150. }
  9151. return schemas;
  9152. }
  9153. function optionInfoToSchema(optionInfo, {
  9154. isCLI,
  9155. optionInfos
  9156. }) {
  9157. let SchemaConstructor;
  9158. const parameters = {
  9159. name: optionInfo.name
  9160. };
  9161. const handlers = {};
  9162. switch (optionInfo.type) {
  9163. case "int":
  9164. SchemaConstructor = lib$4.IntegerSchema;
  9165. if (isCLI) {
  9166. parameters.preprocess = value => Number(value);
  9167. }
  9168. break;
  9169. case "string":
  9170. SchemaConstructor = lib$4.StringSchema;
  9171. break;
  9172. case "choice":
  9173. SchemaConstructor = lib$4.ChoiceSchema;
  9174. parameters.choices = optionInfo.choices.map(choiceInfo => typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign(Object.assign({}, choiceInfo), {}, {
  9175. redirect: {
  9176. to: {
  9177. key: optionInfo.name,
  9178. value: choiceInfo.redirect
  9179. }
  9180. }
  9181. }) : choiceInfo);
  9182. break;
  9183. case "boolean":
  9184. SchemaConstructor = lib$4.BooleanSchema;
  9185. break;
  9186. case "flag":
  9187. SchemaConstructor = FlagSchema;
  9188. parameters.flags = optionInfos.flatMap(optionInfo => [optionInfo.alias, optionInfo.description && optionInfo.name, optionInfo.oppositeDescription && `no-${optionInfo.name}`].filter(Boolean));
  9189. break;
  9190. case "path":
  9191. SchemaConstructor = lib$4.StringSchema;
  9192. break;
  9193. default:
  9194. /* istanbul ignore next */
  9195. throw new Error(`Unexpected type ${optionInfo.type}`);
  9196. }
  9197. if (optionInfo.exception) {
  9198. parameters.validate = (value, schema, utils) => optionInfo.exception(value) || schema.validate(value, utils);
  9199. } else {
  9200. parameters.validate = (value, schema, utils) => value === undefined || schema.validate(value, utils);
  9201. }
  9202. /* istanbul ignore next */
  9203. if (optionInfo.redirect) {
  9204. handlers.redirect = value => !value ? undefined : {
  9205. to: {
  9206. key: optionInfo.redirect.option,
  9207. value: optionInfo.redirect.value
  9208. }
  9209. };
  9210. }
  9211. /* istanbul ignore next */
  9212. if (optionInfo.deprecated) {
  9213. handlers.deprecated = true;
  9214. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  9215. if (isCLI && !optionInfo.array) {
  9216. const originalPreprocess = parameters.preprocess || (x => x);
  9217. parameters.preprocess = (value, schema, utils) => schema.preprocess(originalPreprocess(Array.isArray(value) ? getLast_1(value) : value), utils);
  9218. }
  9219. return optionInfo.array ? lib$4.ArraySchema.create(Object.assign(Object.assign(Object.assign({}, isCLI ? {
  9220. preprocess: v => Array.isArray(v) ? v : [v]
  9221. } : {}), handlers), {}, {
  9222. valueSchema: SchemaConstructor.create(parameters)
  9223. })) : SchemaConstructor.create(Object.assign(Object.assign({}, parameters), handlers));
  9224. }
  9225. function normalizeApiOptions(options, optionInfos, opts) {
  9226. return normalizeOptions$3(options, optionInfos, opts);
  9227. }
  9228. function normalizeCliOptions(options, optionInfos, opts) {
  9229. return normalizeOptions$3(options, optionInfos, Object.assign({
  9230. isCLI: true
  9231. }, opts));
  9232. }
  9233. var optionsNormalizer = {
  9234. normalizeApiOptions,
  9235. normalizeCliOptions
  9236. };
  9237. const {
  9238. isNonEmptyArray: isNonEmptyArray$i
  9239. } = util$5;
  9240. /**
  9241. * @typedef {import("./types/estree").Node} Node
  9242. */
  9243. function locStart$s(node, opts) {
  9244. const {
  9245. ignoreDecorators
  9246. } = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  9247. if (!ignoreDecorators) {
  9248. const decorators = node.declaration && node.declaration.decorators || node.decorators;
  9249. if (isNonEmptyArray$i(decorators)) {
  9250. return locStart$s(decorators[0]);
  9251. }
  9252. }
  9253. return node.range ? node.range[0] : node.start;
  9254. }
  9255. function locEnd$r(node) {
  9256. return node.range ? node.range[1] : node.end;
  9257. }
  9258. /**
  9259. * @param {Node} nodeA
  9260. * @param {Node} nodeB
  9261. * @returns {boolean}
  9262. */
  9263. function hasSameLocStart$1(nodeA, nodeB) {
  9264. return locStart$s(nodeA) === locStart$s(nodeB);
  9265. }
  9266. /**
  9267. * @param {Node} nodeA
  9268. * @param {Node} nodeB
  9269. * @returns {boolean}
  9270. */
  9271. function hasSameLocEnd(nodeA, nodeB) {
  9272. return locEnd$r(nodeA) === locEnd$r(nodeB);
  9273. }
  9274. /**
  9275. * @param {Node} nodeA
  9276. * @param {Node} nodeB
  9277. * @returns {boolean}
  9278. */
  9279. function hasSameLoc$1(nodeA, nodeB) {
  9280. return hasSameLocStart$1(nodeA, nodeB) && hasSameLocEnd(nodeA, nodeB);
  9281. }
  9282. var loc$6 = {
  9283. locStart: locStart$s,
  9284. locEnd: locEnd$r,
  9285. hasSameLocStart: hasSameLocStart$1,
  9286. hasSameLoc: hasSameLoc$1
  9287. };
  9288. // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
  9289. // License: MIT. (See LICENSE.)
  9290. // This regex comes from regex.coffee, and is inserted here by generate-index.js
  9291. // (run `npm run build`).
  9292. var _default$o = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
  9293. var matchToToken = function (match) {
  9294. var token = {
  9295. type: "invalid",
  9296. value: match[0],
  9297. closed: undefined
  9298. };
  9299. if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
  9300. return token;
  9301. };
  9302. var jsTokens = /*#__PURE__*/Object.defineProperty({
  9303. default: _default$o,
  9304. matchToToken: matchToToken
  9305. }, '__esModule', {
  9306. value: true
  9307. });
  9308. var isIdentifierStart_1 = isIdentifierStart;
  9309. var isIdentifierChar_1 = isIdentifierChar;
  9310. var isIdentifierName_1 = isIdentifierName$1;
  9311. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  9312. let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
  9313. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  9314. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  9315. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  9316. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
  9317. const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  9318. function isInAstralSet(code, set) {
  9319. let pos = 0x10000;
  9320. for (let i = 0, length = set.length; i < length; i += 2) {
  9321. pos += set[i];
  9322. if (pos > code) return false;
  9323. pos += set[i + 1];
  9324. if (pos >= code) return true;
  9325. }
  9326. return false;
  9327. }
  9328. function isIdentifierStart(code) {
  9329. if (code < 65) return code === 36;
  9330. if (code <= 90) return true;
  9331. if (code < 97) return code === 95;
  9332. if (code <= 122) return true;
  9333. if (code <= 0xffff) {
  9334. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  9335. }
  9336. return isInAstralSet(code, astralIdentifierStartCodes);
  9337. }
  9338. function isIdentifierChar(code) {
  9339. if (code < 48) return code === 36;
  9340. if (code < 58) return true;
  9341. if (code < 65) return false;
  9342. if (code <= 90) return true;
  9343. if (code < 97) return code === 95;
  9344. if (code <= 122) return true;
  9345. if (code <= 0xffff) {
  9346. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  9347. }
  9348. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  9349. }
  9350. function isIdentifierName$1(name) {
  9351. let isFirst = true;
  9352. for (let i = 0; i < name.length; i++) {
  9353. let cp = name.charCodeAt(i);
  9354. if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
  9355. const trail = name.charCodeAt(++i);
  9356. if ((trail & 0xfc00) === 0xdc00) {
  9357. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  9358. }
  9359. }
  9360. if (isFirst) {
  9361. isFirst = false;
  9362. if (!isIdentifierStart(cp)) {
  9363. return false;
  9364. }
  9365. } else if (!isIdentifierChar(cp)) {
  9366. return false;
  9367. }
  9368. }
  9369. return !isFirst;
  9370. }
  9371. var identifier = /*#__PURE__*/Object.defineProperty({
  9372. isIdentifierStart: isIdentifierStart_1,
  9373. isIdentifierChar: isIdentifierChar_1,
  9374. isIdentifierName: isIdentifierName_1
  9375. }, '__esModule', {
  9376. value: true
  9377. });
  9378. var isReservedWord_1 = isReservedWord;
  9379. var isStrictReservedWord_1 = isStrictReservedWord;
  9380. var isStrictBindOnlyReservedWord_1 = isStrictBindOnlyReservedWord;
  9381. var isStrictBindReservedWord_1 = isStrictBindReservedWord;
  9382. var isKeyword_1 = isKeyword;
  9383. const reservedWords = {
  9384. 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"],
  9385. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  9386. strictBind: ["eval", "arguments"]
  9387. };
  9388. const keywords$1 = new Set(reservedWords.keyword);
  9389. const reservedWordsStrictSet = new Set(reservedWords.strict);
  9390. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  9391. function isReservedWord(word, inModule) {
  9392. return inModule && word === "await" || word === "enum";
  9393. }
  9394. function isStrictReservedWord(word, inModule) {
  9395. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  9396. }
  9397. function isStrictBindOnlyReservedWord(word) {
  9398. return reservedWordsStrictBindSet.has(word);
  9399. }
  9400. function isStrictBindReservedWord(word, inModule) {
  9401. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  9402. }
  9403. function isKeyword(word) {
  9404. return keywords$1.has(word);
  9405. }
  9406. var keyword$1 = /*#__PURE__*/Object.defineProperty({
  9407. isReservedWord: isReservedWord_1,
  9408. isStrictReservedWord: isStrictReservedWord_1,
  9409. isStrictBindOnlyReservedWord: isStrictBindOnlyReservedWord_1,
  9410. isStrictBindReservedWord: isStrictBindReservedWord_1,
  9411. isKeyword: isKeyword_1
  9412. }, '__esModule', {
  9413. value: true
  9414. });
  9415. var lib$3 = createCommonjsModule(function (module, exports) {
  9416. Object.defineProperty(exports, "__esModule", {
  9417. value: true
  9418. });
  9419. Object.defineProperty(exports, "isIdentifierName", {
  9420. enumerable: true,
  9421. get: function () {
  9422. return identifier.isIdentifierName;
  9423. }
  9424. });
  9425. Object.defineProperty(exports, "isIdentifierChar", {
  9426. enumerable: true,
  9427. get: function () {
  9428. return identifier.isIdentifierChar;
  9429. }
  9430. });
  9431. Object.defineProperty(exports, "isIdentifierStart", {
  9432. enumerable: true,
  9433. get: function () {
  9434. return identifier.isIdentifierStart;
  9435. }
  9436. });
  9437. Object.defineProperty(exports, "isReservedWord", {
  9438. enumerable: true,
  9439. get: function () {
  9440. return keyword$1.isReservedWord;
  9441. }
  9442. });
  9443. Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
  9444. enumerable: true,
  9445. get: function () {
  9446. return keyword$1.isStrictBindOnlyReservedWord;
  9447. }
  9448. });
  9449. Object.defineProperty(exports, "isStrictBindReservedWord", {
  9450. enumerable: true,
  9451. get: function () {
  9452. return keyword$1.isStrictBindReservedWord;
  9453. }
  9454. });
  9455. Object.defineProperty(exports, "isStrictReservedWord", {
  9456. enumerable: true,
  9457. get: function () {
  9458. return keyword$1.isStrictReservedWord;
  9459. }
  9460. });
  9461. Object.defineProperty(exports, "isKeyword", {
  9462. enumerable: true,
  9463. get: function () {
  9464. return keyword$1.isKeyword;
  9465. }
  9466. });
  9467. });
  9468. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  9469. var escapeStringRegexp = function (str) {
  9470. if (typeof str !== 'string') {
  9471. throw new TypeError('Expected a string');
  9472. }
  9473. return str.replace(matchOperatorsRe, '\\$&');
  9474. };
  9475. var ansiStyles = createCommonjsModule(function (module) {
  9476. const wrapAnsi16 = (fn, offset) => function () {
  9477. const code = fn.apply(colorConvert$1, arguments);
  9478. return `\u001B[${code + offset}m`;
  9479. };
  9480. const wrapAnsi256 = (fn, offset) => function () {
  9481. const code = fn.apply(colorConvert$1, arguments);
  9482. return `\u001B[${38 + offset};5;${code}m`;
  9483. };
  9484. const wrapAnsi16m = (fn, offset) => function () {
  9485. const rgb = fn.apply(colorConvert$1, arguments);
  9486. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  9487. };
  9488. function assembleStyles() {
  9489. const codes = new Map();
  9490. const styles = {
  9491. modifier: {
  9492. reset: [0, 0],
  9493. // 21 isn't widely supported and 22 does the same thing
  9494. bold: [1, 22],
  9495. dim: [2, 22],
  9496. italic: [3, 23],
  9497. underline: [4, 24],
  9498. inverse: [7, 27],
  9499. hidden: [8, 28],
  9500. strikethrough: [9, 29]
  9501. },
  9502. color: {
  9503. black: [30, 39],
  9504. red: [31, 39],
  9505. green: [32, 39],
  9506. yellow: [33, 39],
  9507. blue: [34, 39],
  9508. magenta: [35, 39],
  9509. cyan: [36, 39],
  9510. white: [37, 39],
  9511. gray: [90, 39],
  9512. // Bright color
  9513. redBright: [91, 39],
  9514. greenBright: [92, 39],
  9515. yellowBright: [93, 39],
  9516. blueBright: [94, 39],
  9517. magentaBright: [95, 39],
  9518. cyanBright: [96, 39],
  9519. whiteBright: [97, 39]
  9520. },
  9521. bgColor: {
  9522. bgBlack: [40, 49],
  9523. bgRed: [41, 49],
  9524. bgGreen: [42, 49],
  9525. bgYellow: [43, 49],
  9526. bgBlue: [44, 49],
  9527. bgMagenta: [45, 49],
  9528. bgCyan: [46, 49],
  9529. bgWhite: [47, 49],
  9530. // Bright color
  9531. bgBlackBright: [100, 49],
  9532. bgRedBright: [101, 49],
  9533. bgGreenBright: [102, 49],
  9534. bgYellowBright: [103, 49],
  9535. bgBlueBright: [104, 49],
  9536. bgMagentaBright: [105, 49],
  9537. bgCyanBright: [106, 49],
  9538. bgWhiteBright: [107, 49]
  9539. }
  9540. }; // Fix humans
  9541. styles.color.grey = styles.color.gray;
  9542. for (const groupName of Object.keys(styles)) {
  9543. const group = styles[groupName];
  9544. for (const styleName of Object.keys(group)) {
  9545. const style = group[styleName];
  9546. styles[styleName] = {
  9547. open: `\u001B[${style[0]}m`,
  9548. close: `\u001B[${style[1]}m`
  9549. };
  9550. group[styleName] = styles[styleName];
  9551. codes.set(style[0], style[1]);
  9552. }
  9553. Object.defineProperty(styles, groupName, {
  9554. value: group,
  9555. enumerable: false
  9556. });
  9557. Object.defineProperty(styles, 'codes', {
  9558. value: codes,
  9559. enumerable: false
  9560. });
  9561. }
  9562. const ansi2ansi = n => n;
  9563. const rgb2rgb = (r, g, b) => [r, g, b];
  9564. styles.color.close = '\u001B[39m';
  9565. styles.bgColor.close = '\u001B[49m';
  9566. styles.color.ansi = {
  9567. ansi: wrapAnsi16(ansi2ansi, 0)
  9568. };
  9569. styles.color.ansi256 = {
  9570. ansi256: wrapAnsi256(ansi2ansi, 0)
  9571. };
  9572. styles.color.ansi16m = {
  9573. rgb: wrapAnsi16m(rgb2rgb, 0)
  9574. };
  9575. styles.bgColor.ansi = {
  9576. ansi: wrapAnsi16(ansi2ansi, 10)
  9577. };
  9578. styles.bgColor.ansi256 = {
  9579. ansi256: wrapAnsi256(ansi2ansi, 10)
  9580. };
  9581. styles.bgColor.ansi16m = {
  9582. rgb: wrapAnsi16m(rgb2rgb, 10)
  9583. };
  9584. for (let key of Object.keys(colorConvert$1)) {
  9585. if (typeof colorConvert$1[key] !== 'object') {
  9586. continue;
  9587. }
  9588. const suite = colorConvert$1[key];
  9589. if (key === 'ansi16') {
  9590. key = 'ansi';
  9591. }
  9592. if ('ansi16' in suite) {
  9593. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  9594. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  9595. }
  9596. if ('ansi256' in suite) {
  9597. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  9598. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  9599. }
  9600. if ('rgb' in suite) {
  9601. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  9602. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  9603. }
  9604. }
  9605. return styles;
  9606. } // Make the export immutable
  9607. Object.defineProperty(module, 'exports', {
  9608. enumerable: true,
  9609. get: assembleStyles
  9610. });
  9611. });
  9612. var hasFlag = (flag, argv) => {
  9613. argv = argv || process.argv;
  9614. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  9615. const pos = argv.indexOf(prefix + flag);
  9616. const terminatorPos = argv.indexOf('--');
  9617. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  9618. };
  9619. const env = process.env;
  9620. let forceColor;
  9621. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  9622. forceColor = false;
  9623. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  9624. forceColor = true;
  9625. }
  9626. if ('FORCE_COLOR' in env) {
  9627. forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
  9628. }
  9629. function translateLevel(level) {
  9630. if (level === 0) {
  9631. return false;
  9632. }
  9633. return {
  9634. level,
  9635. hasBasic: true,
  9636. has256: level >= 2,
  9637. has16m: level >= 3
  9638. };
  9639. }
  9640. function supportsColor(stream) {
  9641. if (forceColor === false) {
  9642. return 0;
  9643. }
  9644. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  9645. return 3;
  9646. }
  9647. if (hasFlag('color=256')) {
  9648. return 2;
  9649. }
  9650. if (stream && !stream.isTTY && forceColor !== true) {
  9651. return 0;
  9652. }
  9653. const min = forceColor ? 1 : 0;
  9654. if (process.platform === 'win32') {
  9655. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  9656. // libuv that enables 256 color output on Windows. Anything earlier and it
  9657. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  9658. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  9659. // release that supports 256 colors. Windows 10 build 14931 is the first release
  9660. // that supports 16m/TrueColor.
  9661. const osRelease = os__default['default'].release().split('.');
  9662. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  9663. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  9664. }
  9665. return 1;
  9666. }
  9667. if ('CI' in env) {
  9668. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
  9669. return 1;
  9670. }
  9671. return min;
  9672. }
  9673. if ('TEAMCITY_VERSION' in env) {
  9674. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  9675. }
  9676. if (env.COLORTERM === 'truecolor') {
  9677. return 3;
  9678. }
  9679. if ('TERM_PROGRAM' in env) {
  9680. const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  9681. switch (env.TERM_PROGRAM) {
  9682. case 'iTerm.app':
  9683. return version >= 3 ? 3 : 2;
  9684. case 'Apple_Terminal':
  9685. return 2;
  9686. // No default
  9687. }
  9688. }
  9689. if (/-256(color)?$/i.test(env.TERM)) {
  9690. return 2;
  9691. }
  9692. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  9693. return 1;
  9694. }
  9695. if ('COLORTERM' in env) {
  9696. return 1;
  9697. }
  9698. if (env.TERM === 'dumb') {
  9699. return min;
  9700. }
  9701. return min;
  9702. }
  9703. function getSupportLevel(stream) {
  9704. const level = supportsColor(stream);
  9705. return translateLevel(level);
  9706. }
  9707. var supportsColor_1 = {
  9708. supportsColor: getSupportLevel,
  9709. stdout: getSupportLevel(process.stdout),
  9710. stderr: getSupportLevel(process.stderr)
  9711. };
  9712. const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  9713. const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  9714. const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  9715. const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  9716. const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  9717. function unescape(c) {
  9718. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  9719. return String.fromCharCode(parseInt(c.slice(1), 16));
  9720. }
  9721. return ESCAPES.get(c) || c;
  9722. }
  9723. function parseArguments(name, args) {
  9724. const results = [];
  9725. const chunks = args.trim().split(/\s*,\s*/g);
  9726. let matches;
  9727. for (const chunk of chunks) {
  9728. if (!isNaN(chunk)) {
  9729. results.push(Number(chunk));
  9730. } else if (matches = chunk.match(STRING_REGEX$1)) {
  9731. results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
  9732. } else {
  9733. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  9734. }
  9735. }
  9736. return results;
  9737. }
  9738. function parseStyle(style) {
  9739. STYLE_REGEX.lastIndex = 0;
  9740. const results = [];
  9741. let matches;
  9742. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  9743. const name = matches[1];
  9744. if (matches[2]) {
  9745. const args = parseArguments(name, matches[2]);
  9746. results.push([name].concat(args));
  9747. } else {
  9748. results.push([name]);
  9749. }
  9750. }
  9751. return results;
  9752. }
  9753. function buildStyle(chalk, styles) {
  9754. const enabled = {};
  9755. for (const layer of styles) {
  9756. for (const style of layer.styles) {
  9757. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  9758. }
  9759. }
  9760. let current = chalk;
  9761. for (const styleName of Object.keys(enabled)) {
  9762. if (Array.isArray(enabled[styleName])) {
  9763. if (!(styleName in current)) {
  9764. throw new Error(`Unknown Chalk style: ${styleName}`);
  9765. }
  9766. if (enabled[styleName].length > 0) {
  9767. current = current[styleName].apply(current, enabled[styleName]);
  9768. } else {
  9769. current = current[styleName];
  9770. }
  9771. }
  9772. }
  9773. return current;
  9774. }
  9775. var templates = (chalk, tmp) => {
  9776. const styles = [];
  9777. const chunks = [];
  9778. let chunk = []; // eslint-disable-next-line max-params
  9779. tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
  9780. if (escapeChar) {
  9781. chunk.push(unescape(escapeChar));
  9782. } else if (style) {
  9783. const str = chunk.join('');
  9784. chunk = [];
  9785. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  9786. styles.push({
  9787. inverse,
  9788. styles: parseStyle(style)
  9789. });
  9790. } else if (close) {
  9791. if (styles.length === 0) {
  9792. throw new Error('Found extraneous } in Chalk template literal');
  9793. }
  9794. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  9795. chunk = [];
  9796. styles.pop();
  9797. } else {
  9798. chunk.push(chr);
  9799. }
  9800. });
  9801. chunks.push(chunk.join(''));
  9802. if (styles.length > 0) {
  9803. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  9804. throw new Error(errMsg);
  9805. }
  9806. return chunks.join('');
  9807. };
  9808. var chalk = createCommonjsModule(function (module) {
  9809. const stdoutColor = supportsColor_1.stdout;
  9810. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  9811. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  9812. const skipModels = new Set(['gray']);
  9813. const styles = Object.create(null);
  9814. function applyOptions(obj, options) {
  9815. options = options || {}; // Detect level if not set manually
  9816. const scLevel = stdoutColor ? stdoutColor.level : 0;
  9817. obj.level = options.level === undefined ? scLevel : options.level;
  9818. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  9819. }
  9820. function Chalk(options) {
  9821. // We check for this.template here since calling `chalk.constructor()`
  9822. // by itself will have a `this` of a previously constructed chalk object
  9823. if (!this || !(this instanceof Chalk) || this.template) {
  9824. const chalk = {};
  9825. applyOptions(chalk, options);
  9826. chalk.template = function () {
  9827. const args = [].slice.call(arguments);
  9828. return chalkTag.apply(null, [chalk.template].concat(args));
  9829. };
  9830. Object.setPrototypeOf(chalk, Chalk.prototype);
  9831. Object.setPrototypeOf(chalk.template, chalk);
  9832. chalk.template.constructor = Chalk;
  9833. return chalk.template;
  9834. }
  9835. applyOptions(this, options);
  9836. } // Use bright blue on Windows as the normal blue color is illegible
  9837. if (isSimpleWindowsTerm) {
  9838. ansiStyles.blue.open = '\u001B[94m';
  9839. }
  9840. for (const key of Object.keys(ansiStyles)) {
  9841. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  9842. styles[key] = {
  9843. get() {
  9844. const codes = ansiStyles[key];
  9845. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  9846. }
  9847. };
  9848. }
  9849. styles.visible = {
  9850. get() {
  9851. return build.call(this, this._styles || [], true, 'visible');
  9852. }
  9853. };
  9854. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  9855. for (const model of Object.keys(ansiStyles.color.ansi)) {
  9856. if (skipModels.has(model)) {
  9857. continue;
  9858. }
  9859. styles[model] = {
  9860. get() {
  9861. const level = this.level;
  9862. return function () {
  9863. const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  9864. const codes = {
  9865. open,
  9866. close: ansiStyles.color.close,
  9867. closeRe: ansiStyles.color.closeRe
  9868. };
  9869. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  9870. };
  9871. }
  9872. };
  9873. }
  9874. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  9875. for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
  9876. if (skipModels.has(model)) {
  9877. continue;
  9878. }
  9879. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  9880. styles[bgModel] = {
  9881. get() {
  9882. const level = this.level;
  9883. return function () {
  9884. const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  9885. const codes = {
  9886. open,
  9887. close: ansiStyles.bgColor.close,
  9888. closeRe: ansiStyles.bgColor.closeRe
  9889. };
  9890. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  9891. };
  9892. }
  9893. };
  9894. }
  9895. const proto = Object.defineProperties(() => {}, styles);
  9896. function build(_styles, _empty, key) {
  9897. const builder = function () {
  9898. return applyStyle.apply(builder, arguments);
  9899. };
  9900. builder._styles = _styles;
  9901. builder._empty = _empty;
  9902. const self = this;
  9903. Object.defineProperty(builder, 'level', {
  9904. enumerable: true,
  9905. get() {
  9906. return self.level;
  9907. },
  9908. set(level) {
  9909. self.level = level;
  9910. }
  9911. });
  9912. Object.defineProperty(builder, 'enabled', {
  9913. enumerable: true,
  9914. get() {
  9915. return self.enabled;
  9916. },
  9917. set(enabled) {
  9918. self.enabled = enabled;
  9919. }
  9920. }); // See below for fix regarding invisible grey/dim combination on Windows
  9921. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  9922. // no way to create a function with a different prototype
  9923. builder.__proto__ = proto; // eslint-disable-line no-proto
  9924. return builder;
  9925. }
  9926. function applyStyle() {
  9927. // Support varags, but simply cast to string in case there's only one arg
  9928. const args = arguments;
  9929. const argsLen = args.length;
  9930. let str = String(arguments[0]);
  9931. if (argsLen === 0) {
  9932. return '';
  9933. }
  9934. if (argsLen > 1) {
  9935. // Don't slice `arguments`, it prevents V8 optimizations
  9936. for (let a = 1; a < argsLen; a++) {
  9937. str += ' ' + args[a];
  9938. }
  9939. }
  9940. if (!this.enabled || this.level <= 0 || !str) {
  9941. return this._empty ? '' : str;
  9942. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  9943. // see https://github.com/chalk/chalk/issues/58
  9944. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  9945. const originalDim = ansiStyles.dim.open;
  9946. if (isSimpleWindowsTerm && this.hasGrey) {
  9947. ansiStyles.dim.open = '';
  9948. }
  9949. for (const code of this._styles.slice().reverse()) {
  9950. // Replace any instances already present with a re-opening code
  9951. // otherwise only the part of the string until said closing code
  9952. // will be colored, and the rest will simply be 'plain'.
  9953. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  9954. // after next line to fix a bleed issue on macOS
  9955. // https://github.com/chalk/chalk/pull/92
  9956. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  9957. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  9958. ansiStyles.dim.open = originalDim;
  9959. return str;
  9960. }
  9961. function chalkTag(chalk, strings) {
  9962. if (!Array.isArray(strings)) {
  9963. // If chalk() was called by itself or with a string,
  9964. // return the string itself as a string.
  9965. return [].slice.call(arguments, 1).join(' ');
  9966. }
  9967. const args = [].slice.call(arguments, 2);
  9968. const parts = [strings.raw[0]];
  9969. for (let i = 1; i < strings.length; i++) {
  9970. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  9971. parts.push(String(strings.raw[i]));
  9972. }
  9973. return templates(chalk, parts.join(''));
  9974. }
  9975. Object.defineProperties(Chalk.prototype, styles);
  9976. module.exports = Chalk(); // eslint-disable-line new-cap
  9977. module.exports.supportsColor = stdoutColor;
  9978. module.exports.default = module.exports; // For TypeScript
  9979. });
  9980. var shouldHighlight_1 = shouldHighlight;
  9981. var getChalk_1 = getChalk;
  9982. var _default$n = highlight;
  9983. const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
  9984. function getDefs$1(chalk) {
  9985. return {
  9986. keyword: chalk.cyan,
  9987. capitalized: chalk.yellow,
  9988. jsxIdentifier: chalk.yellow,
  9989. punctuator: chalk.yellow,
  9990. number: chalk.magenta,
  9991. string: chalk.green,
  9992. regex: chalk.magenta,
  9993. comment: chalk.grey,
  9994. invalid: chalk.white.bgRed.bold
  9995. };
  9996. }
  9997. const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
  9998. const BRACKET = /^[()[\]{}]$/;
  9999. let tokenize;
  10000. {
  10001. const JSX_TAG = /^[a-z][\w-]*$/i;
  10002. const getTokenType = function (token, offset, text) {
  10003. if (token.type === "name") {
  10004. if ((0, lib$3.isKeyword)(token.value) || (0, lib$3.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
  10005. return "keyword";
  10006. }
  10007. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  10008. return "jsxIdentifier";
  10009. }
  10010. if (token.value[0] !== token.value[0].toLowerCase()) {
  10011. return "capitalized";
  10012. }
  10013. }
  10014. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  10015. return "bracket";
  10016. }
  10017. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  10018. return "punctuator";
  10019. }
  10020. return token.type;
  10021. };
  10022. tokenize = function* (text) {
  10023. let match;
  10024. while (match = jsTokens.default.exec(text)) {
  10025. const token = jsTokens.matchToToken(match);
  10026. yield {
  10027. type: getTokenType(token, match.index, text),
  10028. value: token.value
  10029. };
  10030. }
  10031. };
  10032. }
  10033. function highlightTokens(defs, text) {
  10034. let highlighted = "";
  10035. for (const {
  10036. type,
  10037. value
  10038. } of tokenize(text)) {
  10039. const colorize = defs[type];
  10040. if (colorize) {
  10041. highlighted += value.split(NEWLINE$1).map(str => colorize(str)).join("\n");
  10042. } else {
  10043. highlighted += value;
  10044. }
  10045. }
  10046. return highlighted;
  10047. }
  10048. function shouldHighlight(options) {
  10049. return !!chalk.supportsColor || options.forceColor;
  10050. }
  10051. function getChalk(options) {
  10052. return options.forceColor ? new chalk.constructor({
  10053. enabled: true,
  10054. level: 1
  10055. }) : chalk;
  10056. }
  10057. function highlight(code, options = {}) {
  10058. if (shouldHighlight(options)) {
  10059. const chalk = getChalk(options);
  10060. const defs = getDefs$1(chalk);
  10061. return highlightTokens(defs, code);
  10062. } else {
  10063. return code;
  10064. }
  10065. }
  10066. var lib$2 = /*#__PURE__*/Object.defineProperty({
  10067. shouldHighlight: shouldHighlight_1,
  10068. getChalk: getChalk_1,
  10069. default: _default$n
  10070. }, '__esModule', {
  10071. value: true
  10072. });
  10073. var codeFrameColumns_1 = codeFrameColumns;
  10074. var default_1 = _default$m;
  10075. let deprecationWarningShown = false;
  10076. function getDefs(chalk) {
  10077. return {
  10078. gutter: chalk.grey,
  10079. marker: chalk.red.bold,
  10080. message: chalk.red.bold
  10081. };
  10082. }
  10083. const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10084. function getMarkerLines(loc, source, opts) {
  10085. const startLoc = Object.assign({
  10086. column: 0,
  10087. line: -1
  10088. }, loc.start);
  10089. const endLoc = Object.assign({}, startLoc, loc.end);
  10090. const {
  10091. linesAbove = 2,
  10092. linesBelow = 3
  10093. } = opts || {};
  10094. const startLine = startLoc.line;
  10095. const startColumn = startLoc.column;
  10096. const endLine = endLoc.line;
  10097. const endColumn = endLoc.column;
  10098. let start = Math.max(startLine - (linesAbove + 1), 0);
  10099. let end = Math.min(source.length, endLine + linesBelow);
  10100. if (startLine === -1) {
  10101. start = 0;
  10102. }
  10103. if (endLine === -1) {
  10104. end = source.length;
  10105. }
  10106. const lineDiff = endLine - startLine;
  10107. const markerLines = {};
  10108. if (lineDiff) {
  10109. for (let i = 0; i <= lineDiff; i++) {
  10110. const lineNumber = i + startLine;
  10111. if (!startColumn) {
  10112. markerLines[lineNumber] = true;
  10113. } else if (i === 0) {
  10114. const sourceLength = source[lineNumber - 1].length;
  10115. markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
  10116. } else if (i === lineDiff) {
  10117. markerLines[lineNumber] = [0, endColumn];
  10118. } else {
  10119. const sourceLength = source[lineNumber - i].length;
  10120. markerLines[lineNumber] = [0, sourceLength];
  10121. }
  10122. }
  10123. } else {
  10124. if (startColumn === endColumn) {
  10125. if (startColumn) {
  10126. markerLines[startLine] = [startColumn, 0];
  10127. } else {
  10128. markerLines[startLine] = true;
  10129. }
  10130. } else {
  10131. markerLines[startLine] = [startColumn, endColumn - startColumn];
  10132. }
  10133. }
  10134. return {
  10135. start,
  10136. end,
  10137. markerLines
  10138. };
  10139. }
  10140. function codeFrameColumns(rawLines, loc, opts = {}) {
  10141. const highlighted = (opts.highlightCode || opts.forceColor) && (0, lib$2.shouldHighlight)(opts);
  10142. const chalk = (0, lib$2.getChalk)(opts);
  10143. const defs = getDefs(chalk);
  10144. const maybeHighlight = (chalkFn, string) => {
  10145. return highlighted ? chalkFn(string) : string;
  10146. };
  10147. const lines = rawLines.split(NEWLINE);
  10148. const {
  10149. start,
  10150. end,
  10151. markerLines
  10152. } = getMarkerLines(loc, lines, opts);
  10153. const hasColumns = loc.start && typeof loc.start.column === "number";
  10154. const numberMaxWidth = String(end).length;
  10155. const highlightedLines = highlighted ? (0, lib$2.default)(rawLines, opts) : rawLines;
  10156. let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
  10157. const number = start + 1 + index;
  10158. const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
  10159. const gutter = ` ${paddedNumber} |`;
  10160. const hasMarker = markerLines[number];
  10161. const lastMarkerLine = !markerLines[number + 1];
  10162. if (hasMarker) {
  10163. let markerLine = "";
  10164. if (Array.isArray(hasMarker)) {
  10165. const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  10166. const numberOfMarkers = hasMarker[1] || 1;
  10167. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  10168. if (lastMarkerLine && opts.message) {
  10169. markerLine += " " + maybeHighlight(defs.message, opts.message);
  10170. }
  10171. }
  10172. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
  10173. } else {
  10174. return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
  10175. }
  10176. }).join("\n");
  10177. if (opts.message && !hasColumns) {
  10178. frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
  10179. }
  10180. if (highlighted) {
  10181. return chalk.reset(frame);
  10182. } else {
  10183. return frame;
  10184. }
  10185. }
  10186. function _default$m(rawLines, lineNumber, colNumber, opts = {}) {
  10187. if (!deprecationWarningShown) {
  10188. deprecationWarningShown = true;
  10189. const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  10190. if (process.emitWarning) {
  10191. process.emitWarning(message, "DeprecationWarning");
  10192. } else {
  10193. const deprecationError = new Error(message);
  10194. deprecationError.name = "DeprecationWarning";
  10195. console.warn(new Error(message));
  10196. }
  10197. }
  10198. colNumber = Math.max(colNumber, 0);
  10199. const location = {
  10200. start: {
  10201. column: colNumber,
  10202. line: lineNumber
  10203. }
  10204. };
  10205. return codeFrameColumns(rawLines, location, opts);
  10206. }
  10207. var lib$1 = /*#__PURE__*/Object.defineProperty({
  10208. codeFrameColumns: codeFrameColumns_1,
  10209. default: default_1
  10210. }, '__esModule', {
  10211. value: true
  10212. });
  10213. const {
  10214. ConfigError
  10215. } = errors;
  10216. const {
  10217. locStart: locStart$r,
  10218. locEnd: locEnd$q
  10219. } = loc$6; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  10220. // triggering the parsers getters.
  10221. const ownNames = Object.getOwnPropertyNames;
  10222. const ownDescriptor = Object.getOwnPropertyDescriptor;
  10223. function getParsers(options) {
  10224. const parsers = {};
  10225. for (const plugin of options.plugins) {
  10226. // TODO: test this with plugins
  10227. /* istanbul ignore next */
  10228. if (!plugin.parsers) {
  10229. continue;
  10230. }
  10231. for (const name of ownNames(plugin.parsers)) {
  10232. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  10233. }
  10234. }
  10235. return parsers;
  10236. }
  10237. function resolveParser$1(opts, parsers = getParsers(opts)) {
  10238. if (typeof opts.parser === "function") {
  10239. // Custom parser API always works with JavaScript.
  10240. return {
  10241. parse: opts.parser,
  10242. astFormat: "estree",
  10243. locStart: locStart$r,
  10244. locEnd: locEnd$q
  10245. };
  10246. }
  10247. if (typeof opts.parser === "string") {
  10248. if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) {
  10249. return parsers[opts.parser];
  10250. }
  10251. try {
  10252. return {
  10253. parse: require(path__default['default'].resolve(process.cwd(), opts.parser)),
  10254. astFormat: "estree",
  10255. locStart: locStart$r,
  10256. locEnd: locEnd$q
  10257. };
  10258. } catch {
  10259. /* istanbul ignore next */
  10260. throw new ConfigError(`Couldn't resolve parser "${opts.parser}"`);
  10261. }
  10262. }
  10263. }
  10264. function parse$a(text, opts) {
  10265. const parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  10266. // the parsers getters when actually calling the parser `parse` function.
  10267. const parsersForCustomParserApi = Object.defineProperties({}, Object.fromEntries(Object.keys(parsers).map(parserName => [parserName, {
  10268. enumerable: true,
  10269. get() {
  10270. return parsers[parserName].parse;
  10271. }
  10272. }])));
  10273. const parser = resolveParser$1(opts, parsers);
  10274. try {
  10275. if (parser.preprocess) {
  10276. text = parser.preprocess(text, opts);
  10277. }
  10278. return {
  10279. text,
  10280. ast: parser.parse(text, parsersForCustomParserApi, opts)
  10281. };
  10282. } catch (error) {
  10283. const {
  10284. loc
  10285. } = error;
  10286. if (loc) {
  10287. const {
  10288. codeFrameColumns
  10289. } = lib$1;
  10290. error.codeFrame = codeFrameColumns(text, loc, {
  10291. highlightCode: true
  10292. });
  10293. error.message += "\n" + error.codeFrame;
  10294. throw error;
  10295. }
  10296. /* istanbul ignore next */
  10297. throw error.stack;
  10298. }
  10299. }
  10300. var parser$1 = {
  10301. parse: parse$a,
  10302. resolveParser: resolveParser$1
  10303. };
  10304. const {
  10305. UndefinedParserError
  10306. } = errors;
  10307. const {
  10308. getSupportInfo: getSupportInfo$1
  10309. } = support;
  10310. const {
  10311. resolveParser
  10312. } = parser$1;
  10313. const hiddenDefaults = {
  10314. astFormat: "estree",
  10315. printer: {},
  10316. originalText: undefined,
  10317. locStart: null,
  10318. locEnd: null
  10319. }; // Copy options and fill in default values.
  10320. function normalize$1(options, opts = {}) {
  10321. const rawOptions = Object.assign({}, options);
  10322. const supportOptions = getSupportInfo$1({
  10323. plugins: options.plugins,
  10324. showUnreleased: true,
  10325. showDeprecated: true
  10326. }).options;
  10327. const defaults = Object.assign(Object.assign({}, hiddenDefaults), Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.default !== undefined).map(option => [option.name, option.default])));
  10328. if (!rawOptions.parser) {
  10329. if (!rawOptions.filepath) {
  10330. const logger = opts.logger || console;
  10331. logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
  10332. rawOptions.parser = "babel";
  10333. } else {
  10334. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  10335. if (!rawOptions.parser) {
  10336. throw new UndefinedParserError(`No parser could be inferred for file: ${rawOptions.filepath}`);
  10337. }
  10338. }
  10339. }
  10340. const parser = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(x => x.name === "parser")], {
  10341. passThrough: true,
  10342. logger: false
  10343. }));
  10344. rawOptions.astFormat = parser.astFormat;
  10345. rawOptions.locEnd = parser.locEnd;
  10346. rawOptions.locStart = parser.locStart;
  10347. const plugin = getPlugin(rawOptions);
  10348. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  10349. const pluginDefaults = Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined).map(optionInfo => [optionInfo.name, optionInfo.pluginDefaults[plugin.name]]));
  10350. const mixedDefaults = Object.assign(Object.assign({}, defaults), pluginDefaults);
  10351. for (const [k, value] of Object.entries(mixedDefaults)) {
  10352. if (rawOptions[k] === null || rawOptions[k] === undefined) {
  10353. rawOptions[k] = value;
  10354. }
  10355. }
  10356. if (rawOptions.parser === "json") {
  10357. rawOptions.trailingComma = "none";
  10358. }
  10359. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  10360. passThrough: Object.keys(hiddenDefaults)
  10361. }, opts));
  10362. }
  10363. function getPlugin(options) {
  10364. const {
  10365. astFormat
  10366. } = options; // TODO: test this with plugins
  10367. /* istanbul ignore next */
  10368. if (!astFormat) {
  10369. throw new Error("getPlugin() requires astFormat to be set");
  10370. }
  10371. const printerPlugin = options.plugins.find(plugin => plugin.printers && plugin.printers[astFormat]); // TODO: test this with plugins
  10372. /* istanbul ignore next */
  10373. if (!printerPlugin) {
  10374. throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
  10375. }
  10376. return printerPlugin;
  10377. }
  10378. function getInterpreter(filepath) {
  10379. /* istanbul ignore next */
  10380. if (typeof filepath !== "string") {
  10381. return "";
  10382. }
  10383. let fd;
  10384. try {
  10385. fd = fs__default['default'].openSync(filepath, "r");
  10386. } catch {
  10387. // istanbul ignore next
  10388. return "";
  10389. }
  10390. try {
  10391. const liner = new readlines(fd);
  10392. const firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  10393. const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  10394. if (m1) {
  10395. return m1[1];
  10396. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  10397. const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  10398. if (m2) {
  10399. return m2[1];
  10400. }
  10401. return "";
  10402. } catch {
  10403. // There are some weird cases where paths are missing, causing Jest
  10404. // failures. It's unclear what these correspond to in the real world.
  10405. /* istanbul ignore next */
  10406. return "";
  10407. } finally {
  10408. try {
  10409. // There are some weird cases where paths are missing, causing Jest
  10410. // failures. It's unclear what these correspond to in the real world.
  10411. fs__default['default'].closeSync(fd);
  10412. } catch {// nop
  10413. }
  10414. }
  10415. }
  10416. function inferParser(filepath, plugins) {
  10417. const filename = path__default['default'].basename(filepath).toLowerCase();
  10418. const languages = getSupportInfo$1({
  10419. plugins
  10420. }).languages.filter(language => language.since !== null); // If the file has no extension, we can try to infer the language from the
  10421. // interpreter in the shebang line, if any; but since this requires FS access,
  10422. // do it last.
  10423. let language = languages.find(language => language.extensions && language.extensions.some(extension => filename.endsWith(extension)) || language.filenames && language.filenames.some(name => name.toLowerCase() === filename));
  10424. if (!language && !filename.includes(".")) {
  10425. const interpreter = getInterpreter(filepath);
  10426. language = languages.find(language => language.interpreters && language.interpreters.includes(interpreter));
  10427. }
  10428. return language && language.parsers[0];
  10429. }
  10430. var options$6 = {
  10431. normalize: normalize$1,
  10432. hiddenDefaults,
  10433. inferParser
  10434. };
  10435. function massageAST(ast, options, parent) {
  10436. if (Array.isArray(ast)) {
  10437. return ast.map(e => massageAST(e, options, parent)).filter(Boolean);
  10438. }
  10439. if (!ast || typeof ast !== "object") {
  10440. return ast;
  10441. }
  10442. const cleanFunction = options.printer.massageAstNode;
  10443. let ignoredProperties;
  10444. if (cleanFunction && cleanFunction.ignoredProperties) {
  10445. ignoredProperties = cleanFunction.ignoredProperties;
  10446. } else {
  10447. ignoredProperties = new Set();
  10448. }
  10449. const newObj = {};
  10450. for (const [key, value] of Object.entries(ast)) {
  10451. if (!ignoredProperties.has(key) && typeof value !== "function") {
  10452. newObj[key] = massageAST(value, options, ast);
  10453. }
  10454. }
  10455. if (cleanFunction) {
  10456. const result = cleanFunction(ast, newObj, parent);
  10457. if (result === null) {
  10458. return;
  10459. }
  10460. if (result) {
  10461. return result;
  10462. }
  10463. }
  10464. return newObj;
  10465. }
  10466. var massageAst = massageAST;
  10467. const {
  10468. builders: {
  10469. line: line$A,
  10470. hardline: hardline$C,
  10471. breakParent: breakParent$a,
  10472. indent: indent$A,
  10473. lineSuffix: lineSuffix$1,
  10474. join: join$v,
  10475. cursor
  10476. }
  10477. } = doc;
  10478. const {
  10479. hasNewline: hasNewline$9,
  10480. skipNewline: skipNewline$1,
  10481. skipSpaces: skipSpaces$1,
  10482. isPreviousLineEmpty: isPreviousLineEmpty$2,
  10483. addLeadingComment: addLeadingComment$2,
  10484. addDanglingComment: addDanglingComment$2,
  10485. addTrailingComment: addTrailingComment$2
  10486. } = util$5;
  10487. const childNodesCache = new WeakMap();
  10488. function getSortedChildNodes(node, options, resultArray) {
  10489. if (!node) {
  10490. return;
  10491. }
  10492. const {
  10493. printer,
  10494. locStart,
  10495. locEnd
  10496. } = options;
  10497. if (resultArray) {
  10498. if (printer.canAttachComment && printer.canAttachComment(node)) {
  10499. // This reverse insertion sort almost always takes constant
  10500. // time because we almost always (maybe always?) append the
  10501. // nodes in order anyway.
  10502. let i;
  10503. for (i = resultArray.length - 1; i >= 0; --i) {
  10504. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  10505. break;
  10506. }
  10507. }
  10508. resultArray.splice(i + 1, 0, node);
  10509. return;
  10510. }
  10511. } else if (childNodesCache.has(node)) {
  10512. return childNodesCache.get(node);
  10513. }
  10514. const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === "object" && Object.entries(node).filter(([key]) => key !== "enclosingNode" && key !== "precedingNode" && key !== "followingNode" && key !== "tokens" && key !== "comments").map(([, value]) => value);
  10515. if (!childNodes) {
  10516. return;
  10517. }
  10518. if (!resultArray) {
  10519. resultArray = [];
  10520. childNodesCache.set(node, resultArray);
  10521. }
  10522. for (const childNode of childNodes) {
  10523. getSortedChildNodes(childNode, options, resultArray);
  10524. }
  10525. return resultArray;
  10526. } // As efficiently as possible, decorate the comment object with
  10527. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  10528. // least one of which is guaranteed to be defined.
  10529. function decorateComment(node, comment, options, enclosingNode) {
  10530. const {
  10531. locStart,
  10532. locEnd
  10533. } = options;
  10534. const commentStart = locStart(comment);
  10535. const commentEnd = locEnd(comment);
  10536. const childNodes = getSortedChildNodes(node, options);
  10537. let precedingNode;
  10538. let followingNode; // Time to dust off the old binary search robes and wizard hat.
  10539. let left = 0;
  10540. let right = childNodes.length;
  10541. while (left < right) {
  10542. const middle = left + right >> 1;
  10543. const child = childNodes[middle];
  10544. const start = locStart(child);
  10545. const end = locEnd(child); // The comment is completely contained by this child node.
  10546. if (start <= commentStart && commentEnd <= end) {
  10547. // Abandon the binary search at this level.
  10548. return decorateComment(child, comment, options, child);
  10549. }
  10550. if (end <= commentStart) {
  10551. // This child node falls completely before the comment.
  10552. // Because we will never consider this node or any nodes
  10553. // before it again, this node must be the closest preceding
  10554. // node we have encountered so far.
  10555. precedingNode = child;
  10556. left = middle + 1;
  10557. continue;
  10558. }
  10559. if (commentEnd <= start) {
  10560. // This child node falls completely after the comment.
  10561. // Because we will never consider this node or any nodes after
  10562. // it again, this node must be the closest following node we
  10563. // have encountered so far.
  10564. followingNode = child;
  10565. right = middle;
  10566. continue;
  10567. }
  10568. /* istanbul ignore next */
  10569. throw new Error("Comment location overlaps with node location");
  10570. } // We don't want comments inside of different expressions inside of the same
  10571. // template literal to move to another expression.
  10572. if (enclosingNode && enclosingNode.type === "TemplateLiteral") {
  10573. const {
  10574. quasis
  10575. } = enclosingNode;
  10576. const commentIndex = findExpressionIndexForComment(quasis, comment, options);
  10577. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  10578. precedingNode = null;
  10579. }
  10580. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  10581. followingNode = null;
  10582. }
  10583. }
  10584. return {
  10585. enclosingNode,
  10586. precedingNode,
  10587. followingNode
  10588. };
  10589. }
  10590. const returnFalse$1 = () => false;
  10591. function attach(comments, ast, text, options) {
  10592. if (!Array.isArray(comments)) {
  10593. return;
  10594. }
  10595. const tiesToBreak = [];
  10596. const {
  10597. locStart,
  10598. locEnd,
  10599. printer: {
  10600. handleComments = {}
  10601. }
  10602. } = options; // TODO: Make this as default behavior
  10603. const {
  10604. avoidAstMutation,
  10605. ownLine: handleOwnLineComment = returnFalse$1,
  10606. endOfLine: handleEndOfLineComment = returnFalse$1,
  10607. remaining: handleRemainingComment = returnFalse$1
  10608. } = handleComments;
  10609. const decoratedComments = comments.map((comment, index) => Object.assign(Object.assign({}, decorateComment(ast, comment, options)), {}, {
  10610. comment,
  10611. text,
  10612. options,
  10613. ast,
  10614. isLastComment: comments.length - 1 === index
  10615. }));
  10616. for (const [index, context] of decoratedComments.entries()) {
  10617. const {
  10618. comment,
  10619. precedingNode,
  10620. enclosingNode,
  10621. followingNode,
  10622. text,
  10623. options,
  10624. ast,
  10625. isLastComment
  10626. } = context;
  10627. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  10628. if (locStart(comment) - locStart(ast) <= 0) {
  10629. addLeadingComment$2(ast, comment);
  10630. continue;
  10631. }
  10632. if (locEnd(comment) - locEnd(ast) >= 0) {
  10633. addTrailingComment$2(ast, comment);
  10634. continue;
  10635. }
  10636. }
  10637. let args;
  10638. if (avoidAstMutation) {
  10639. args = [context];
  10640. } else {
  10641. comment.enclosingNode = enclosingNode;
  10642. comment.precedingNode = precedingNode;
  10643. comment.followingNode = followingNode;
  10644. args = [comment, text, options, ast, isLastComment];
  10645. }
  10646. if (isOwnLineComment(text, options, decoratedComments, index)) {
  10647. comment.placement = "ownLine"; // If a comment exists on its own line, prefer a leading comment.
  10648. // We also need to check if it's the first line of the file.
  10649. if (handleOwnLineComment(...args)) ; else if (followingNode) {
  10650. // Always a leading comment.
  10651. addLeadingComment$2(followingNode, comment);
  10652. } else if (precedingNode) {
  10653. addTrailingComment$2(precedingNode, comment);
  10654. } else if (enclosingNode) {
  10655. addDanglingComment$2(enclosingNode, comment);
  10656. } else {
  10657. // There are no nodes, let's attach it to the root of the ast
  10658. /* istanbul ignore next */
  10659. addDanglingComment$2(ast, comment);
  10660. }
  10661. } else if (isEndOfLineComment(text, options, decoratedComments, index)) {
  10662. comment.placement = "endOfLine";
  10663. if (handleEndOfLineComment(...args)) ; else if (precedingNode) {
  10664. // There is content before this comment on the same line, but
  10665. // none after it, so prefer a trailing comment of the previous node.
  10666. addTrailingComment$2(precedingNode, comment);
  10667. } else if (followingNode) {
  10668. addLeadingComment$2(followingNode, comment);
  10669. } else if (enclosingNode) {
  10670. addDanglingComment$2(enclosingNode, comment);
  10671. } else {
  10672. // There are no nodes, let's attach it to the root of the ast
  10673. /* istanbul ignore next */
  10674. addDanglingComment$2(ast, comment);
  10675. }
  10676. } else {
  10677. comment.placement = "remaining";
  10678. if (handleRemainingComment(...args)) ; else if (precedingNode && followingNode) {
  10679. // Otherwise, text exists both before and after the comment on
  10680. // the same line. If there is both a preceding and following
  10681. // node, use a tie-breaking algorithm to determine if it should
  10682. // be attached to the next or previous node. In the last case,
  10683. // simply attach the right node;
  10684. const tieCount = tiesToBreak.length;
  10685. if (tieCount > 0) {
  10686. const lastTie = tiesToBreak[tieCount - 1];
  10687. if (lastTie.followingNode !== followingNode) {
  10688. breakTies(tiesToBreak, text, options);
  10689. }
  10690. }
  10691. tiesToBreak.push(context);
  10692. } else if (precedingNode) {
  10693. addTrailingComment$2(precedingNode, comment);
  10694. } else if (followingNode) {
  10695. addLeadingComment$2(followingNode, comment);
  10696. } else if (enclosingNode) {
  10697. addDanglingComment$2(enclosingNode, comment);
  10698. } else {
  10699. // There are no nodes, let's attach it to the root of the ast
  10700. /* istanbul ignore next */
  10701. addDanglingComment$2(ast, comment);
  10702. }
  10703. }
  10704. }
  10705. breakTies(tiesToBreak, text, options);
  10706. if (!avoidAstMutation) {
  10707. for (const comment of comments) {
  10708. // These node references were useful for breaking ties, but we
  10709. // don't need them anymore, and they create cycles in the AST that
  10710. // may lead to infinite recursion if we don't delete them here.
  10711. delete comment.precedingNode;
  10712. delete comment.enclosingNode;
  10713. delete comment.followingNode;
  10714. }
  10715. }
  10716. }
  10717. const isAllEmptyAndNoLineBreak = text => !/[\S\n\u2028\u2029]/.test(text);
  10718. function isOwnLineComment(text, options, decoratedComments, commentIndex) {
  10719. const {
  10720. comment,
  10721. precedingNode
  10722. } = decoratedComments[commentIndex];
  10723. const {
  10724. locStart,
  10725. locEnd
  10726. } = options;
  10727. let start = locStart(comment);
  10728. if (precedingNode) {
  10729. // Find first comment on the same line
  10730. for (let index = commentIndex - 1; index >= 0; index--) {
  10731. const {
  10732. comment,
  10733. precedingNode: currentCommentPrecedingNode
  10734. } = decoratedComments[index];
  10735. if (currentCommentPrecedingNode !== precedingNode || !isAllEmptyAndNoLineBreak(text.slice(locEnd(comment), start))) {
  10736. break;
  10737. }
  10738. start = locStart(comment);
  10739. }
  10740. }
  10741. return hasNewline$9(text, start, {
  10742. backwards: true
  10743. });
  10744. }
  10745. function isEndOfLineComment(text, options, decoratedComments, commentIndex) {
  10746. const {
  10747. comment,
  10748. followingNode
  10749. } = decoratedComments[commentIndex];
  10750. const {
  10751. locStart,
  10752. locEnd
  10753. } = options;
  10754. let end = locEnd(comment);
  10755. if (followingNode) {
  10756. // Find last comment on the same line
  10757. for (let index = commentIndex + 1; index < decoratedComments.length; index++) {
  10758. const {
  10759. comment,
  10760. followingNode: currentCommentFollowingNode
  10761. } = decoratedComments[index];
  10762. if (currentCommentFollowingNode !== followingNode || !isAllEmptyAndNoLineBreak(text.slice(end, locStart(comment)))) {
  10763. break;
  10764. }
  10765. end = locEnd(comment);
  10766. }
  10767. }
  10768. return hasNewline$9(text, end);
  10769. }
  10770. function breakTies(tiesToBreak, text, options) {
  10771. const tieCount = tiesToBreak.length;
  10772. if (tieCount === 0) {
  10773. return;
  10774. }
  10775. const {
  10776. precedingNode,
  10777. followingNode,
  10778. enclosingNode
  10779. } = tiesToBreak[0];
  10780. const gapRegExp = options.printer.getGapRegex && options.printer.getGapRegex(enclosingNode) || /^[\s(]*$/;
  10781. let gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  10782. // between the tied comments. In order to qualify as leading, a
  10783. // comment must be separated from followingNode by an unbroken series of
  10784. // gaps (or other comments). Gaps should only contain whitespace or open
  10785. // parentheses.
  10786. let indexOfFirstLeadingComment;
  10787. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  10788. const {
  10789. comment,
  10790. precedingNode: currentCommentPrecedingNode,
  10791. followingNode: currentCommentFollowingNode
  10792. } = tiesToBreak[indexOfFirstLeadingComment - 1];
  10793. assert__default['default'].strictEqual(currentCommentPrecedingNode, precedingNode);
  10794. assert__default['default'].strictEqual(currentCommentFollowingNode, followingNode);
  10795. const gap = text.slice(options.locEnd(comment), gapEndPos);
  10796. if (gapRegExp.test(gap)) {
  10797. gapEndPos = options.locStart(comment);
  10798. } else {
  10799. // The gap string contained something other than whitespace or open
  10800. // parentheses.
  10801. break;
  10802. }
  10803. }
  10804. for (const [i, {
  10805. comment
  10806. }] of tiesToBreak.entries()) {
  10807. if (i < indexOfFirstLeadingComment) {
  10808. addTrailingComment$2(precedingNode, comment);
  10809. } else {
  10810. addLeadingComment$2(followingNode, comment);
  10811. }
  10812. }
  10813. for (const node of [precedingNode, followingNode]) {
  10814. if (node.comments && node.comments.length > 1) {
  10815. node.comments.sort((a, b) => options.locStart(a) - options.locStart(b));
  10816. }
  10817. }
  10818. tiesToBreak.length = 0;
  10819. }
  10820. function printComment$3(path, options) {
  10821. const comment = path.getValue();
  10822. comment.printed = true;
  10823. return options.printer.printComment(path, options);
  10824. }
  10825. function findExpressionIndexForComment(quasis, comment, options) {
  10826. const startPos = options.locStart(comment) - 1;
  10827. for (let i = 1; i < quasis.length; ++i) {
  10828. if (startPos < options.locStart(quasis[i])) {
  10829. return i - 1;
  10830. }
  10831. } // We haven't found it, it probably means that some of the locations are off.
  10832. // Let's just return the first one.
  10833. /* istanbul ignore next */
  10834. return 0;
  10835. }
  10836. function printLeadingComment(path, options) {
  10837. const comment = path.getValue();
  10838. const parts = [printComment$3(path, options)];
  10839. const {
  10840. printer,
  10841. originalText,
  10842. locStart,
  10843. locEnd
  10844. } = options;
  10845. const isBlock = printer.isBlockComment && printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  10846. // same line or not.
  10847. if (isBlock) {
  10848. const lineBreak = hasNewline$9(originalText, locEnd(comment)) ? hasNewline$9(originalText, locStart(comment), {
  10849. backwards: true
  10850. }) ? hardline$C : line$A : " ";
  10851. parts.push(lineBreak);
  10852. } else {
  10853. parts.push(hardline$C);
  10854. }
  10855. const index = skipNewline$1(originalText, skipSpaces$1(originalText, locEnd(comment)));
  10856. if (index !== false && hasNewline$9(originalText, index)) {
  10857. parts.push(hardline$C);
  10858. }
  10859. return parts;
  10860. }
  10861. function printTrailingComment(path, options) {
  10862. const comment = path.getValue();
  10863. const printed = printComment$3(path, options);
  10864. const {
  10865. printer,
  10866. originalText,
  10867. locStart
  10868. } = options;
  10869. const isBlock = printer.isBlockComment && printer.isBlockComment(comment);
  10870. if (hasNewline$9(originalText, locStart(comment), {
  10871. backwards: true
  10872. })) {
  10873. // This allows comments at the end of nested structures:
  10874. // {
  10875. // x: 1,
  10876. // y: 2
  10877. // // A comment
  10878. // }
  10879. // Those kinds of comments are almost always leading comments, but
  10880. // here it doesn't go "outside" the block and turns it into a
  10881. // trailing comment for `2`. We can simulate the above by checking
  10882. // if this a comment on its own line; normal trailing comments are
  10883. // always at the end of another expression.
  10884. const isLineBeforeEmpty = isPreviousLineEmpty$2(originalText, comment, locStart);
  10885. return lineSuffix$1([hardline$C, isLineBeforeEmpty ? hardline$C : "", printed]);
  10886. }
  10887. let parts = [" ", printed]; // Trailing block comments never need a newline
  10888. if (!isBlock) {
  10889. parts = [lineSuffix$1(parts), breakParent$a];
  10890. }
  10891. return parts;
  10892. }
  10893. function printDanglingComments$e(path, options, sameIndent, filter) {
  10894. const parts = [];
  10895. const node = path.getValue();
  10896. if (!node || !node.comments) {
  10897. return "";
  10898. }
  10899. path.each(() => {
  10900. const comment = path.getValue();
  10901. if (!comment.leading && !comment.trailing && (!filter || filter(comment))) {
  10902. parts.push(printComment$3(path, options));
  10903. }
  10904. }, "comments");
  10905. if (parts.length === 0) {
  10906. return "";
  10907. }
  10908. if (sameIndent) {
  10909. return join$v(hardline$C, parts);
  10910. }
  10911. return indent$A([hardline$C, join$v(hardline$C, parts)]);
  10912. }
  10913. function printCommentsSeparately$1(path, options, ignored) {
  10914. const value = path.getValue();
  10915. if (!value) {
  10916. return {};
  10917. }
  10918. let comments = value.comments || [];
  10919. if (ignored) {
  10920. comments = comments.filter(comment => !ignored.has(comment));
  10921. }
  10922. const isCursorNode = value === options.cursorNode;
  10923. if (comments.length === 0) {
  10924. const maybeCursor = isCursorNode ? cursor : "";
  10925. return {
  10926. leading: maybeCursor,
  10927. trailing: maybeCursor
  10928. };
  10929. }
  10930. const leadingParts = [];
  10931. const trailingParts = [];
  10932. path.each(() => {
  10933. const comment = path.getValue();
  10934. if (ignored && ignored.has(comment)) {
  10935. return;
  10936. }
  10937. const {
  10938. leading,
  10939. trailing
  10940. } = comment;
  10941. if (leading) {
  10942. leadingParts.push(printLeadingComment(path, options));
  10943. } else if (trailing) {
  10944. trailingParts.push(printTrailingComment(path, options));
  10945. }
  10946. }, "comments");
  10947. if (isCursorNode) {
  10948. leadingParts.unshift(cursor);
  10949. trailingParts.push(cursor);
  10950. }
  10951. return {
  10952. leading: leadingParts,
  10953. trailing: trailingParts
  10954. };
  10955. }
  10956. function printComments$7(path, doc, options, ignored) {
  10957. const {
  10958. leading,
  10959. trailing
  10960. } = printCommentsSeparately$1(path, options, ignored);
  10961. if (!leading && !trailing) {
  10962. return doc;
  10963. }
  10964. return [leading, doc, trailing];
  10965. }
  10966. function ensureAllCommentsPrinted(astComments) {
  10967. if (!astComments) {
  10968. return;
  10969. }
  10970. for (const comment of astComments) {
  10971. if (!comment.printed) {
  10972. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  10973. }
  10974. delete comment.printed;
  10975. }
  10976. }
  10977. var comments$1 = {
  10978. attach,
  10979. printComments: printComments$7,
  10980. printCommentsSeparately: printCommentsSeparately$1,
  10981. printDanglingComments: printDanglingComments$e,
  10982. getSortedChildNodes,
  10983. ensureAllCommentsPrinted
  10984. };
  10985. function getNodeHelper(path, count) {
  10986. const stackIndex = getNodeStackIndexHelper(path.stack, count);
  10987. return stackIndex === -1 ? null : path.stack[stackIndex];
  10988. }
  10989. function getNodeStackIndexHelper(stack, count) {
  10990. for (let i = stack.length - 1; i >= 0; i -= 2) {
  10991. const value = stack[i];
  10992. if (value && !Array.isArray(value) && --count < 0) {
  10993. return i;
  10994. }
  10995. }
  10996. return -1;
  10997. }
  10998. class AstPath {
  10999. constructor(value) {
  11000. this.stack = [value];
  11001. } // The name of the current property is always the penultimate element of
  11002. // this.stack, and always a String.
  11003. getName() {
  11004. const {
  11005. stack
  11006. } = this;
  11007. const {
  11008. length
  11009. } = stack;
  11010. if (length > 1) {
  11011. return stack[length - 2];
  11012. } // Since the name is always a string, null is a safe sentinel value to
  11013. // return if we do not know the name of the (root) value.
  11014. /* istanbul ignore next */
  11015. return null;
  11016. } // The value of the current property is always the final element of
  11017. // this.stack.
  11018. getValue() {
  11019. return getLast_1(this.stack);
  11020. }
  11021. getNode(count = 0) {
  11022. return getNodeHelper(this, count);
  11023. }
  11024. getParentNode(count = 0) {
  11025. return getNodeHelper(this, count + 1);
  11026. } // Temporarily push properties named by string arguments given after the
  11027. // callback function onto this.stack, then call the callback with a
  11028. // reference to this (modified) AstPath object. Note that the stack will
  11029. // be restored to its original state after the callback is finished, so it
  11030. // is probably a mistake to retain a reference to the path.
  11031. call(callback, ...names) {
  11032. const {
  11033. stack
  11034. } = this;
  11035. const {
  11036. length
  11037. } = stack;
  11038. let value = getLast_1(stack);
  11039. for (const name of names) {
  11040. value = value[name];
  11041. stack.push(name, value);
  11042. }
  11043. const result = callback(this);
  11044. stack.length = length;
  11045. return result;
  11046. }
  11047. callParent(callback, count = 0) {
  11048. const stackIndex = getNodeStackIndexHelper(this.stack, count + 1);
  11049. const parentValues = this.stack.splice(stackIndex + 1);
  11050. const result = callback(this);
  11051. this.stack.push(...parentValues);
  11052. return result;
  11053. } // Similar to AstPath.prototype.call, except that the value obtained by
  11054. // accessing this.getValue()[name1][name2]... should be array. The
  11055. // callback will be called with a reference to this path object for each
  11056. // element of the array.
  11057. each(callback, ...names) {
  11058. const {
  11059. stack
  11060. } = this;
  11061. const {
  11062. length
  11063. } = stack;
  11064. let value = getLast_1(stack);
  11065. for (const name of names) {
  11066. value = value[name];
  11067. stack.push(name, value);
  11068. }
  11069. for (let i = 0; i < value.length; ++i) {
  11070. stack.push(i, value[i]);
  11071. callback(this, i, value);
  11072. stack.length -= 2;
  11073. }
  11074. stack.length = length;
  11075. } // Similar to AstPath.prototype.each, except that the results of the
  11076. // callback function invocations are stored in an array and returned at
  11077. // the end of the iteration.
  11078. map(callback, ...names) {
  11079. const result = [];
  11080. this.each((path, index, value) => {
  11081. result[index] = callback(path, index, value);
  11082. }, ...names);
  11083. return result;
  11084. }
  11085. /**
  11086. * @param {() => void} callback
  11087. * @internal Unstable API. Don't use in plugins for now.
  11088. */
  11089. try(callback) {
  11090. const {
  11091. stack
  11092. } = this;
  11093. const stackBackup = [...stack];
  11094. try {
  11095. return callback();
  11096. } finally {
  11097. stack.length = 0;
  11098. stack.push(...stackBackup);
  11099. }
  11100. }
  11101. /**
  11102. * @param {...(
  11103. * | ((node: any, name: string | null, number: number | null) => boolean)
  11104. * | undefined
  11105. * )} predicates
  11106. */
  11107. match(...predicates) {
  11108. let stackPointer = this.stack.length - 1;
  11109. let name = null;
  11110. let node = this.stack[stackPointer--];
  11111. for (const predicate of predicates) {
  11112. /* istanbul ignore next */
  11113. if (node === undefined) {
  11114. return false;
  11115. } // skip index/array
  11116. let number = null;
  11117. if (typeof name === "number") {
  11118. number = name;
  11119. name = this.stack[stackPointer--];
  11120. node = this.stack[stackPointer--];
  11121. }
  11122. if (predicate && !predicate(node, name, number)) {
  11123. return false;
  11124. }
  11125. name = this.stack[stackPointer--];
  11126. node = this.stack[stackPointer--];
  11127. }
  11128. return true;
  11129. }
  11130. /**
  11131. * Traverses the ancestors of the current node heading toward the tree root
  11132. * until it finds a node that matches the provided predicate function. Will
  11133. * return the first matching ancestor. If no such node exists, returns undefined.
  11134. * @param {(node: any, name: string, number: number | null) => boolean} predicate
  11135. * @internal Unstable API. Don't use in plugins for now.
  11136. */
  11137. findAncestor(predicate) {
  11138. let stackPointer = this.stack.length - 1;
  11139. let name = null;
  11140. let node = this.stack[stackPointer--];
  11141. while (node) {
  11142. // skip index/array
  11143. let number = null;
  11144. if (typeof name === "number") {
  11145. number = name;
  11146. name = this.stack[stackPointer--];
  11147. node = this.stack[stackPointer--];
  11148. }
  11149. if (name !== null && predicate(node, name, number)) {
  11150. return node;
  11151. }
  11152. name = this.stack[stackPointer--];
  11153. node = this.stack[stackPointer--];
  11154. }
  11155. }
  11156. }
  11157. var astPath = AstPath;
  11158. const {
  11159. utils: {
  11160. stripTrailingHardline
  11161. }
  11162. } = doc;
  11163. const {
  11164. normalize
  11165. } = options$6;
  11166. function printSubtree(path, print, options, printAstToDoc) {
  11167. if (options.printer.embed && options.embeddedLanguageFormatting === "auto") {
  11168. return options.printer.embed(path, print, (text, partialNextOptions, textToDocOptions) => textToDoc(text, partialNextOptions, options, printAstToDoc, textToDocOptions), options);
  11169. }
  11170. }
  11171. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc, // TODO: remove `stripTrailingHardline` in v3.0.0
  11172. {
  11173. stripTrailingHardline: shouldStripTrailingHardline = false
  11174. } = {}) {
  11175. const nextOptions = normalize(Object.assign(Object.assign(Object.assign({}, parentOptions), partialNextOptions), {}, {
  11176. parentParser: parentOptions.parser,
  11177. originalText: text
  11178. }), {
  11179. passThrough: true
  11180. });
  11181. const result = parser$1.parse(text, nextOptions);
  11182. const {
  11183. ast
  11184. } = result;
  11185. text = result.text;
  11186. const astComments = ast.comments;
  11187. delete ast.comments;
  11188. comments$1.attach(astComments, ast, text, nextOptions);
  11189. nextOptions[Symbol.for("comments")] = astComments || [];
  11190. nextOptions[Symbol.for("tokens")] = ast.tokens || [];
  11191. const doc = printAstToDoc(ast, nextOptions);
  11192. comments$1.ensureAllCommentsPrinted(astComments);
  11193. if (shouldStripTrailingHardline) {
  11194. // TODO: move this to `stripTrailingHardline` function in `/src/document/doc-utils.js`
  11195. if (typeof doc === "string") {
  11196. return doc.replace(/(?:\r?\n)*$/, "");
  11197. }
  11198. return stripTrailingHardline(doc);
  11199. }
  11200. /* istanbul ignore next */
  11201. return doc;
  11202. }
  11203. var multiparser = {
  11204. printSubtree
  11205. };
  11206. const {
  11207. builders: {
  11208. hardline: hardline$B,
  11209. addAlignmentToDoc: addAlignmentToDoc$1
  11210. },
  11211. utils: {
  11212. propagateBreaks
  11213. }
  11214. } = doc;
  11215. const {
  11216. printComments: printComments$6
  11217. } = comments$1;
  11218. /**
  11219. * Takes an abstract syntax tree (AST) and recursively converts it to a
  11220. * document (series of printing primitives).
  11221. *
  11222. * This is done by descending down the AST recursively. The recursion
  11223. * involves two functions that call each other:
  11224. *
  11225. * 1. mainPrint(), which is defined as an inner function here.
  11226. * It basically takes care of node caching.
  11227. * 2. callPluginPrintFunction(), which checks for some options, and
  11228. * ultimately calls the print() function provided by the plugin.
  11229. *
  11230. * The plugin function will call mainPrint() again for child nodes
  11231. * of the current node. mainPrint() will do its housekeeping, then call
  11232. * the plugin function again, and so on.
  11233. *
  11234. * All the while, these functions pass a "path" variable around, which
  11235. * is a stack-like data structure (AstPath) that maintains the current
  11236. * state of the recursion. It is called "path", because it represents
  11237. * the path to the current node through the Abstract Syntax Tree.
  11238. */
  11239. function printAstToDoc(ast, options, alignmentSize = 0) {
  11240. const {
  11241. printer
  11242. } = options;
  11243. if (printer.preprocess) {
  11244. ast = printer.preprocess(ast, options);
  11245. }
  11246. const cache = new Map();
  11247. const path = new astPath(ast);
  11248. let doc = mainPrint();
  11249. if (alignmentSize > 0) {
  11250. // Add a hardline to make the indents take effect
  11251. // It should be removed in index.js format()
  11252. doc = addAlignmentToDoc$1([hardline$B, doc], alignmentSize, options.tabWidth);
  11253. }
  11254. propagateBreaks(doc);
  11255. return doc;
  11256. function mainPrint(selector, args) {
  11257. if (selector === undefined || selector === path) {
  11258. return mainPrintInternal(args);
  11259. }
  11260. if (Array.isArray(selector)) {
  11261. return path.call(() => mainPrintInternal(args), ...selector);
  11262. }
  11263. return path.call(() => mainPrintInternal(args), selector);
  11264. }
  11265. function mainPrintInternal(args) {
  11266. const value = path.getValue();
  11267. const shouldCache = value && typeof value === "object" && args === undefined;
  11268. if (shouldCache && cache.has(value)) {
  11269. return cache.get(value);
  11270. }
  11271. const doc = callPluginPrintFunction(path, options, mainPrint, args);
  11272. if (shouldCache) {
  11273. cache.set(value, doc);
  11274. }
  11275. return doc;
  11276. }
  11277. }
  11278. function printPrettierIgnoredNode(node, options) {
  11279. const {
  11280. originalText,
  11281. [Symbol.for("comments")]: comments,
  11282. locStart,
  11283. locEnd
  11284. } = options;
  11285. const start = locStart(node);
  11286. const end = locEnd(node);
  11287. const printedComments = new Set();
  11288. for (const comment of comments) {
  11289. if (locStart(comment) >= start && locEnd(comment) <= end) {
  11290. comment.printed = true;
  11291. printedComments.add(comment);
  11292. }
  11293. }
  11294. return {
  11295. doc: originalText.slice(start, end),
  11296. printedComments
  11297. };
  11298. }
  11299. function callPluginPrintFunction(path, options, printPath, args) {
  11300. const node = path.getValue();
  11301. const {
  11302. printer
  11303. } = options;
  11304. let doc;
  11305. let printedComments; // Escape hatch
  11306. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
  11307. ({
  11308. doc,
  11309. printedComments
  11310. } = printPrettierIgnoredNode(node, options));
  11311. } else {
  11312. if (node) {
  11313. try {
  11314. // Potentially switch to a different parser
  11315. doc = multiparser.printSubtree(path, printPath, options, printAstToDoc);
  11316. } catch (error) {
  11317. /* istanbul ignore if */
  11318. if (process.env.PRETTIER_DEBUG) {
  11319. throw error;
  11320. } // Continue with current parser
  11321. }
  11322. }
  11323. if (!doc) {
  11324. doc = printer.print(path, options, printPath, args);
  11325. }
  11326. } // We let JSXElement print its comments itself because it adds () around
  11327. // UnionTypeAnnotation has to align the child without the comments
  11328. if (!printer.willPrintOwnComments || !printer.willPrintOwnComments(path, options)) {
  11329. // printComments will call the plugin print function and check for
  11330. // comments to print
  11331. doc = printComments$6(path, doc, options, printedComments);
  11332. }
  11333. return doc;
  11334. }
  11335. var astToDoc = printAstToDoc;
  11336. const isJsonParser = ({
  11337. parser
  11338. }) => parser === "json" || parser === "json5" || parser === "json-stringify";
  11339. function findCommonAncestor(startNodeAndParents, endNodeAndParents) {
  11340. const startNodeAndAncestors = [startNodeAndParents.node, ...startNodeAndParents.parentNodes];
  11341. const endNodeAndAncestors = new Set([endNodeAndParents.node, ...endNodeAndParents.parentNodes]);
  11342. return startNodeAndAncestors.find(node => jsonSourceElements.has(node.type) && endNodeAndAncestors.has(node));
  11343. }
  11344. function dropRootParents(parents) {
  11345. let lastParentIndex = parents.length - 1;
  11346. for (;;) {
  11347. const parent = parents[lastParentIndex];
  11348. if (parent && (parent.type === "Program" || parent.type === "File")) {
  11349. lastParentIndex--;
  11350. } else {
  11351. break;
  11352. }
  11353. }
  11354. return parents.slice(0, lastParentIndex + 1);
  11355. }
  11356. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, {
  11357. locStart,
  11358. locEnd
  11359. }) {
  11360. let resultStartNode = startNodeAndParents.node;
  11361. let resultEndNode = endNodeAndParents.node;
  11362. if (resultStartNode === resultEndNode) {
  11363. return {
  11364. startNode: resultStartNode,
  11365. endNode: resultEndNode
  11366. };
  11367. }
  11368. const startNodeStart = locStart(startNodeAndParents.node);
  11369. for (const endParent of dropRootParents(endNodeAndParents.parentNodes)) {
  11370. if (locStart(endParent) >= startNodeStart) {
  11371. resultEndNode = endParent;
  11372. } else {
  11373. break;
  11374. }
  11375. }
  11376. const endNodeEnd = locEnd(endNodeAndParents.node);
  11377. for (const startParent of dropRootParents(startNodeAndParents.parentNodes)) {
  11378. if (locEnd(startParent) <= endNodeEnd) {
  11379. resultStartNode = startParent;
  11380. } else {
  11381. break;
  11382. }
  11383. }
  11384. return {
  11385. startNode: resultStartNode,
  11386. endNode: resultEndNode
  11387. };
  11388. }
  11389. function findNodeAtOffset(node, offset, options, predicate, parentNodes = [], type) {
  11390. const {
  11391. locStart,
  11392. locEnd
  11393. } = options;
  11394. const start = locStart(node);
  11395. const end = locEnd(node);
  11396. if (offset > end || offset < start || type === "rangeEnd" && offset === start || type === "rangeStart" && offset === end) {
  11397. return;
  11398. }
  11399. for (const childNode of comments$1.getSortedChildNodes(node, options)) {
  11400. const childResult = findNodeAtOffset(childNode, offset, options, predicate, [node, ...parentNodes], type);
  11401. if (childResult) {
  11402. return childResult;
  11403. }
  11404. }
  11405. if (!predicate || predicate(node, parentNodes[0])) {
  11406. return {
  11407. node,
  11408. parentNodes
  11409. };
  11410. }
  11411. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  11412. function isJsSourceElement(type, parentType) {
  11413. return parentType !== "DeclareExportDeclaration" && type !== "TypeParameterDeclaration" && (type === "Directive" || type === "TypeAlias" || type === "TSExportAssignment" || type.startsWith("Declare") || type.startsWith("TSDeclare") || type.endsWith("Statement") || type.endsWith("Declaration"));
  11414. }
  11415. const jsonSourceElements = new Set(["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral", "UnaryExpression", "TemplateLiteral"]);
  11416. const graphqlSourceElements = new Set(["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"]);
  11417. function isSourceElement(opts, node, parentNode) {
  11418. /* istanbul ignore next */
  11419. if (!node) {
  11420. return false;
  11421. }
  11422. switch (opts.parser) {
  11423. case "flow":
  11424. case "babel":
  11425. case "babel-flow":
  11426. case "babel-ts":
  11427. case "typescript":
  11428. case "espree":
  11429. case "meriyah":
  11430. case "__babel_estree":
  11431. return isJsSourceElement(node.type, parentNode && parentNode.type);
  11432. case "json":
  11433. case "json5":
  11434. case "json-stringify":
  11435. return jsonSourceElements.has(node.type);
  11436. case "graphql":
  11437. return graphqlSourceElements.has(node.kind);
  11438. case "vue":
  11439. return node.tag !== "root";
  11440. }
  11441. return false;
  11442. }
  11443. function calculateRange(text, opts, ast) {
  11444. let {
  11445. rangeStart: start,
  11446. rangeEnd: end,
  11447. locStart,
  11448. locEnd
  11449. } = opts;
  11450. assert__default['default'].ok(end > start); // Contract the range so that it has non-whitespace characters at its endpoints.
  11451. // This ensures we can format a range that doesn't end on a node.
  11452. const firstNonWhitespaceCharacterIndex = text.slice(start, end).search(/\S/);
  11453. const isAllWhitespace = firstNonWhitespaceCharacterIndex === -1;
  11454. if (!isAllWhitespace) {
  11455. start += firstNonWhitespaceCharacterIndex;
  11456. for (; end > start; --end) {
  11457. if (/\S/.test(text[end - 1])) {
  11458. break;
  11459. }
  11460. }
  11461. }
  11462. const startNodeAndParents = findNodeAtOffset(ast, start, opts, (node, parentNode) => isSourceElement(opts, node, parentNode), [], "rangeStart");
  11463. const endNodeAndParents = // No need find Node at `end`, it will be the same as `startNodeAndParents`
  11464. isAllWhitespace ? startNodeAndParents : findNodeAtOffset(ast, end, opts, node => isSourceElement(opts, node), [], "rangeEnd");
  11465. if (!startNodeAndParents || !endNodeAndParents) {
  11466. return {
  11467. rangeStart: 0,
  11468. rangeEnd: 0
  11469. };
  11470. }
  11471. let startNode;
  11472. let endNode;
  11473. if (isJsonParser(opts)) {
  11474. const commonAncestor = findCommonAncestor(startNodeAndParents, endNodeAndParents);
  11475. startNode = commonAncestor;
  11476. endNode = commonAncestor;
  11477. } else {
  11478. ({
  11479. startNode,
  11480. endNode
  11481. } = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts));
  11482. }
  11483. return {
  11484. rangeStart: Math.min(locStart(startNode), locStart(endNode)),
  11485. rangeEnd: Math.max(locEnd(startNode), locEnd(endNode))
  11486. };
  11487. }
  11488. var rangeUtil = {
  11489. calculateRange,
  11490. findNodeAtOffset
  11491. };
  11492. const {
  11493. printer: {
  11494. printDocToString: printDocToString$2
  11495. },
  11496. debug: {
  11497. printDocToDebug
  11498. }
  11499. } = doc;
  11500. const {
  11501. getAlignmentSize: getAlignmentSize$1
  11502. } = util$5;
  11503. const {
  11504. guessEndOfLine,
  11505. convertEndOfLineToChars,
  11506. countEndOfLineChars,
  11507. normalizeEndOfLine: normalizeEndOfLine$1
  11508. } = endOfLine;
  11509. const normalizeOptions$2 = options$6.normalize;
  11510. const BOM = "\uFEFF";
  11511. const CURSOR = Symbol("cursor");
  11512. function attachComments(text, ast, opts) {
  11513. const astComments = ast.comments;
  11514. if (astComments) {
  11515. delete ast.comments;
  11516. comments$1.attach(astComments, ast, text, opts);
  11517. }
  11518. opts[Symbol.for("comments")] = astComments || [];
  11519. opts[Symbol.for("tokens")] = ast.tokens || [];
  11520. opts.originalText = text;
  11521. return astComments;
  11522. }
  11523. function coreFormat(originalText, opts, addAlignmentSize = 0) {
  11524. if (!originalText || originalText.trim().length === 0) {
  11525. return {
  11526. formatted: "",
  11527. cursorOffset: -1,
  11528. comments: []
  11529. };
  11530. }
  11531. const {
  11532. ast,
  11533. text
  11534. } = parser$1.parse(originalText, opts);
  11535. if (opts.cursorOffset >= 0) {
  11536. const nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  11537. if (nodeResult && nodeResult.node) {
  11538. opts.cursorNode = nodeResult.node;
  11539. }
  11540. }
  11541. const astComments = attachComments(text, ast, opts);
  11542. const doc = astToDoc(ast, opts, addAlignmentSize);
  11543. const result = printDocToString$2(doc, opts);
  11544. comments$1.ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  11545. if (addAlignmentSize > 0) {
  11546. const trimmed = result.formatted.trim();
  11547. if (result.cursorNodeStart !== undefined) {
  11548. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  11549. }
  11550. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  11551. }
  11552. if (opts.cursorOffset >= 0) {
  11553. let oldCursorNodeStart;
  11554. let oldCursorNodeText;
  11555. let cursorOffsetRelativeToOldCursorNode;
  11556. let newCursorNodeStart;
  11557. let newCursorNodeText;
  11558. if (opts.cursorNode && result.cursorNodeText) {
  11559. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  11560. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  11561. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  11562. newCursorNodeStart = result.cursorNodeStart;
  11563. newCursorNodeText = result.cursorNodeText;
  11564. } else {
  11565. oldCursorNodeStart = 0;
  11566. oldCursorNodeText = text;
  11567. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  11568. newCursorNodeStart = 0;
  11569. newCursorNodeText = result.formatted;
  11570. }
  11571. if (oldCursorNodeText === newCursorNodeText) {
  11572. return {
  11573. formatted: result.formatted,
  11574. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode,
  11575. comments: astComments
  11576. };
  11577. } // diff old and new cursor node texts, with a special cursor
  11578. // symbol inserted to find out where it moves to
  11579. const oldCursorNodeCharArray = [...oldCursorNodeText];
  11580. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  11581. const newCursorNodeCharArray = [...newCursorNodeText];
  11582. const cursorNodeDiff = lib$6.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  11583. let cursorOffset = newCursorNodeStart;
  11584. for (const entry of cursorNodeDiff) {
  11585. if (entry.removed) {
  11586. if (entry.value.includes(CURSOR)) {
  11587. break;
  11588. }
  11589. } else {
  11590. cursorOffset += entry.count;
  11591. }
  11592. }
  11593. return {
  11594. formatted: result.formatted,
  11595. cursorOffset,
  11596. comments: astComments
  11597. };
  11598. }
  11599. return {
  11600. formatted: result.formatted,
  11601. cursorOffset: -1,
  11602. comments: astComments
  11603. };
  11604. }
  11605. function formatRange(originalText, opts) {
  11606. const {
  11607. ast,
  11608. text
  11609. } = parser$1.parse(originalText, opts);
  11610. const {
  11611. rangeStart,
  11612. rangeEnd
  11613. } = rangeUtil.calculateRange(text, opts, ast);
  11614. const rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  11615. // This is so we can detect indentation correctly and restore it.
  11616. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  11617. const rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  11618. const indentString = text.slice(rangeStart2, rangeStart).match(/^\s*/)[0];
  11619. const alignmentSize = getAlignmentSize$1(indentString, opts.tabWidth);
  11620. const rangeResult = coreFormat(rangeString, Object.assign(Object.assign({}, opts), {}, {
  11621. rangeStart: 0,
  11622. rangeEnd: Number.POSITIVE_INFINITY,
  11623. // Track the cursor offset only if it's within our range
  11624. cursorOffset: opts.cursorOffset > rangeStart && opts.cursorOffset <= rangeEnd ? opts.cursorOffset - rangeStart : -1,
  11625. // Always use `lf` to format, we'll replace it later
  11626. endOfLine: "lf"
  11627. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  11628. // we need to remove the newline that was inserted by the `format` call.
  11629. const rangeTrimmed = rangeResult.formatted.trimEnd();
  11630. let {
  11631. cursorOffset
  11632. } = opts;
  11633. if (cursorOffset > rangeEnd) {
  11634. // handle the case where the cursor was past the end of the range
  11635. cursorOffset += rangeTrimmed.length - rangeString.length;
  11636. } else if (rangeResult.cursorOffset >= 0) {
  11637. // handle the case where the cursor was in the range
  11638. cursorOffset = rangeResult.cursorOffset + rangeStart;
  11639. } // keep the cursor as it was if it was before the start of the range
  11640. let formatted = text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd);
  11641. if (opts.endOfLine !== "lf") {
  11642. const eol = convertEndOfLineToChars(opts.endOfLine);
  11643. if (cursorOffset >= 0 && eol === "\r\n") {
  11644. cursorOffset += countEndOfLineChars(formatted.slice(0, cursorOffset), "\n");
  11645. }
  11646. formatted = formatted.replace(/\n/g, eol);
  11647. }
  11648. return {
  11649. formatted,
  11650. cursorOffset,
  11651. comments: rangeResult.comments
  11652. };
  11653. }
  11654. function ensureIndexInText(text, index, defaultValue) {
  11655. if (typeof index !== "number" || Number.isNaN(index) || index < 0 || index > text.length) {
  11656. return defaultValue;
  11657. }
  11658. return index;
  11659. }
  11660. function normalizeIndexes(text, options) {
  11661. let {
  11662. cursorOffset,
  11663. rangeStart,
  11664. rangeEnd
  11665. } = options;
  11666. cursorOffset = ensureIndexInText(text, cursorOffset, -1);
  11667. rangeStart = ensureIndexInText(text, rangeStart, 0);
  11668. rangeEnd = ensureIndexInText(text, rangeEnd, text.length);
  11669. return Object.assign(Object.assign({}, options), {}, {
  11670. cursorOffset,
  11671. rangeStart,
  11672. rangeEnd
  11673. });
  11674. }
  11675. function normalizeInputAndOptions(text, options) {
  11676. let {
  11677. cursorOffset,
  11678. rangeStart,
  11679. rangeEnd,
  11680. endOfLine
  11681. } = normalizeIndexes(text, options);
  11682. const hasBOM = text.charAt(0) === BOM;
  11683. if (hasBOM) {
  11684. text = text.slice(1);
  11685. cursorOffset--;
  11686. rangeStart--;
  11687. rangeEnd--;
  11688. }
  11689. if (endOfLine === "auto") {
  11690. endOfLine = guessEndOfLine(text);
  11691. } // get rid of CR/CRLF parsing
  11692. if (text.includes("\r")) {
  11693. const countCrlfBefore = index => countEndOfLineChars(text.slice(0, Math.max(index, 0)), "\r\n");
  11694. cursorOffset -= countCrlfBefore(cursorOffset);
  11695. rangeStart -= countCrlfBefore(rangeStart);
  11696. rangeEnd -= countCrlfBefore(rangeEnd);
  11697. text = normalizeEndOfLine$1(text);
  11698. }
  11699. return {
  11700. hasBOM,
  11701. text,
  11702. options: normalizeIndexes(text, Object.assign(Object.assign({}, options), {}, {
  11703. cursorOffset,
  11704. rangeStart,
  11705. rangeEnd,
  11706. endOfLine
  11707. }))
  11708. };
  11709. }
  11710. function hasPragma$5(text, options) {
  11711. const selectedParser = parser$1.resolveParser(options);
  11712. return !selectedParser.hasPragma || selectedParser.hasPragma(text);
  11713. }
  11714. function formatWithCursor$1(originalText, originalOptions) {
  11715. let {
  11716. hasBOM,
  11717. text,
  11718. options
  11719. } = normalizeInputAndOptions(originalText, normalizeOptions$2(originalOptions));
  11720. if (options.rangeStart >= options.rangeEnd && text !== "" || options.requirePragma && !hasPragma$5(text, options)) {
  11721. return {
  11722. formatted: originalText,
  11723. cursorOffset: originalOptions.cursorOffset,
  11724. comments: []
  11725. };
  11726. }
  11727. let result;
  11728. if (options.rangeStart > 0 || options.rangeEnd < text.length) {
  11729. result = formatRange(text, options);
  11730. } else {
  11731. if (!options.requirePragma && options.insertPragma && options.printer.insertPragma && !hasPragma$5(text, options)) {
  11732. text = options.printer.insertPragma(text);
  11733. }
  11734. result = coreFormat(text, options);
  11735. }
  11736. if (hasBOM) {
  11737. result.formatted = BOM + result.formatted;
  11738. if (result.cursorOffset >= 0) {
  11739. result.cursorOffset++;
  11740. }
  11741. }
  11742. return result;
  11743. }
  11744. var core$1 = {
  11745. formatWithCursor: formatWithCursor$1,
  11746. parse(originalText, originalOptions, massage) {
  11747. const {
  11748. text,
  11749. options
  11750. } = normalizeInputAndOptions(originalText, normalizeOptions$2(originalOptions));
  11751. const parsed = parser$1.parse(text, options);
  11752. if (massage) {
  11753. parsed.ast = massageAst(parsed.ast, options);
  11754. }
  11755. return parsed;
  11756. },
  11757. formatAST(ast, options) {
  11758. options = normalizeOptions$2(options);
  11759. const doc = astToDoc(ast, options);
  11760. return printDocToString$2(doc, options);
  11761. },
  11762. // Doesn't handle shebang for now
  11763. formatDoc(doc, options) {
  11764. return formatWithCursor$1(printDocToDebug(doc), Object.assign(Object.assign({}, options), {}, {
  11765. parser: "__js_expression"
  11766. })).formatted;
  11767. },
  11768. printToDoc(originalText, options) {
  11769. options = normalizeOptions$2(options);
  11770. const {
  11771. ast,
  11772. text
  11773. } = parser$1.parse(originalText, options);
  11774. attachComments(text, ast, options);
  11775. return astToDoc(ast, options);
  11776. },
  11777. printDocToString(doc, options) {
  11778. return printDocToString$2(doc, normalizeOptions$2(options));
  11779. }
  11780. };
  11781. var concatMap = function (xs, fn) {
  11782. var res = [];
  11783. for (var i = 0; i < xs.length; i++) {
  11784. var x = fn(xs[i], i);
  11785. if (isArray$1(x)) res.push.apply(res, x);else res.push(x);
  11786. }
  11787. return res;
  11788. };
  11789. var isArray$1 = Array.isArray || function (xs) {
  11790. return Object.prototype.toString.call(xs) === '[object Array]';
  11791. };
  11792. var balancedMatch = balanced;
  11793. function balanced(a, b, str) {
  11794. if (a instanceof RegExp) a = maybeMatch(a, str);
  11795. if (b instanceof RegExp) b = maybeMatch(b, str);
  11796. var r = range(a, b, str);
  11797. return r && {
  11798. start: r[0],
  11799. end: r[1],
  11800. pre: str.slice(0, r[0]),
  11801. body: str.slice(r[0] + a.length, r[1]),
  11802. post: str.slice(r[1] + b.length)
  11803. };
  11804. }
  11805. function maybeMatch(reg, str) {
  11806. var m = str.match(reg);
  11807. return m ? m[0] : null;
  11808. }
  11809. balanced.range = range;
  11810. function range(a, b, str) {
  11811. var begs, beg, left, right, result;
  11812. var ai = str.indexOf(a);
  11813. var bi = str.indexOf(b, ai + 1);
  11814. var i = ai;
  11815. if (ai >= 0 && bi > 0) {
  11816. if (a === b) {
  11817. return [ai, bi];
  11818. }
  11819. begs = [];
  11820. left = str.length;
  11821. while (i >= 0 && !result) {
  11822. if (i == ai) {
  11823. begs.push(i);
  11824. ai = str.indexOf(a, i + 1);
  11825. } else if (begs.length == 1) {
  11826. result = [begs.pop(), bi];
  11827. } else {
  11828. beg = begs.pop();
  11829. if (beg < left) {
  11830. left = beg;
  11831. right = bi;
  11832. }
  11833. bi = str.indexOf(b, i + 1);
  11834. }
  11835. i = ai < bi && ai >= 0 ? ai : bi;
  11836. }
  11837. if (begs.length) {
  11838. result = [left, right];
  11839. }
  11840. }
  11841. return result;
  11842. }
  11843. var braceExpansion = expandTop;
  11844. var escSlash = '\0SLASH' + Math.random() + '\0';
  11845. var escOpen = '\0OPEN' + Math.random() + '\0';
  11846. var escClose = '\0CLOSE' + Math.random() + '\0';
  11847. var escComma = '\0COMMA' + Math.random() + '\0';
  11848. var escPeriod = '\0PERIOD' + Math.random() + '\0';
  11849. function numeric(str) {
  11850. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  11851. }
  11852. function escapeBraces(str) {
  11853. return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
  11854. }
  11855. function unescapeBraces(str) {
  11856. return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
  11857. } // Basically just str.split(","), but handling cases
  11858. // where we have nested braced sections, which should be
  11859. // treated as individual members, like {a,{b,c},d}
  11860. function parseCommaParts(str) {
  11861. if (!str) return [''];
  11862. var parts = [];
  11863. var m = balancedMatch('{', '}', str);
  11864. if (!m) return str.split(',');
  11865. var pre = m.pre;
  11866. var body = m.body;
  11867. var post = m.post;
  11868. var p = pre.split(',');
  11869. p[p.length - 1] += '{' + body + '}';
  11870. var postParts = parseCommaParts(post);
  11871. if (post.length) {
  11872. p[p.length - 1] += postParts.shift();
  11873. p.push.apply(p, postParts);
  11874. }
  11875. parts.push.apply(parts, p);
  11876. return parts;
  11877. }
  11878. function expandTop(str) {
  11879. if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
  11880. // Anything starting with {} will have the first two bytes preserved
  11881. // but *only* at the top level, so {},a}b will not expand to anything,
  11882. // but a{},b}c will be expanded to [a}c,abc].
  11883. // One could argue that this is a bug in Bash, but since the goal of
  11884. // this module is to match Bash's rules, we escape a leading {}
  11885. if (str.substr(0, 2) === '{}') {
  11886. str = '\\{\\}' + str.substr(2);
  11887. }
  11888. return expand$1(escapeBraces(str), true).map(unescapeBraces);
  11889. }
  11890. function embrace(str) {
  11891. return '{' + str + '}';
  11892. }
  11893. function isPadded(el) {
  11894. return /^-?0\d/.test(el);
  11895. }
  11896. function lte(i, y) {
  11897. return i <= y;
  11898. }
  11899. function gte(i, y) {
  11900. return i >= y;
  11901. }
  11902. function expand$1(str, isTop) {
  11903. var expansions = [];
  11904. var m = balancedMatch('{', '}', str);
  11905. if (!m || /\$$/.test(m.pre)) return [str];
  11906. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  11907. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  11908. var isSequence = isNumericSequence || isAlphaSequence;
  11909. var isOptions = m.body.indexOf(',') >= 0;
  11910. if (!isSequence && !isOptions) {
  11911. // {a},b}
  11912. if (m.post.match(/,.*\}/)) {
  11913. str = m.pre + '{' + m.body + escClose + m.post;
  11914. return expand$1(str);
  11915. }
  11916. return [str];
  11917. }
  11918. var n;
  11919. if (isSequence) {
  11920. n = m.body.split(/\.\./);
  11921. } else {
  11922. n = parseCommaParts(m.body);
  11923. if (n.length === 1) {
  11924. // x{{a,b}}y ==> x{a}y x{b}y
  11925. n = expand$1(n[0], false).map(embrace);
  11926. if (n.length === 1) {
  11927. var post = m.post.length ? expand$1(m.post, false) : [''];
  11928. return post.map(function (p) {
  11929. return m.pre + n[0] + p;
  11930. });
  11931. }
  11932. }
  11933. } // at this point, n is the parts, and we know it's not a comma set
  11934. // with a single entry.
  11935. // no need to expand pre, since it is guaranteed to be free of brace-sets
  11936. var pre = m.pre;
  11937. var post = m.post.length ? expand$1(m.post, false) : [''];
  11938. var N;
  11939. if (isSequence) {
  11940. var x = numeric(n[0]);
  11941. var y = numeric(n[1]);
  11942. var width = Math.max(n[0].length, n[1].length);
  11943. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  11944. var test = lte;
  11945. var reverse = y < x;
  11946. if (reverse) {
  11947. incr *= -1;
  11948. test = gte;
  11949. }
  11950. var pad = n.some(isPadded);
  11951. N = [];
  11952. for (var i = x; test(i, y); i += incr) {
  11953. var c;
  11954. if (isAlphaSequence) {
  11955. c = String.fromCharCode(i);
  11956. if (c === '\\') c = '';
  11957. } else {
  11958. c = String(i);
  11959. if (pad) {
  11960. var need = width - c.length;
  11961. if (need > 0) {
  11962. var z = new Array(need + 1).join('0');
  11963. if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
  11964. }
  11965. }
  11966. }
  11967. N.push(c);
  11968. }
  11969. } else {
  11970. N = concatMap(n, function (el) {
  11971. return expand$1(el, false);
  11972. });
  11973. }
  11974. for (var j = 0; j < N.length; j++) {
  11975. for (var k = 0; k < post.length; k++) {
  11976. var expansion = pre + N[j] + post[k];
  11977. if (!isTop || isSequence || expansion) expansions.push(expansion);
  11978. }
  11979. }
  11980. return expansions;
  11981. }
  11982. var minimatch_1 = minimatch;
  11983. minimatch.Minimatch = Minimatch;
  11984. var path$3 = {
  11985. sep: '/'
  11986. };
  11987. try {
  11988. path$3 = require('path');
  11989. } catch (er) {}
  11990. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  11991. var plTypes = {
  11992. '!': {
  11993. open: '(?:(?!(?:',
  11994. close: '))[^/]*?)'
  11995. },
  11996. '?': {
  11997. open: '(?:',
  11998. close: ')?'
  11999. },
  12000. '+': {
  12001. open: '(?:',
  12002. close: ')+'
  12003. },
  12004. '*': {
  12005. open: '(?:',
  12006. close: ')*'
  12007. },
  12008. '@': {
  12009. open: '(?:',
  12010. close: ')'
  12011. }
  12012. }; // any single thing other than /
  12013. // don't need to escape / when using new RegExp()
  12014. var qmark = '[^/]'; // * => any number of characters
  12015. var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
  12016. // not (^ or / followed by one or two dots followed by $ or /),
  12017. // followed by anything, any number of times.
  12018. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
  12019. // followed by anything, any number of times.
  12020. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
  12021. var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
  12022. function charSet(s) {
  12023. return s.split('').reduce(function (set, c) {
  12024. set[c] = true;
  12025. return set;
  12026. }, {});
  12027. } // normalizes slashes.
  12028. var slashSplit = /\/+/;
  12029. minimatch.filter = filter;
  12030. function filter(pattern, options) {
  12031. options = options || {};
  12032. return function (p, i, list) {
  12033. return minimatch(p, pattern, options);
  12034. };
  12035. }
  12036. function ext(a, b) {
  12037. a = a || {};
  12038. b = b || {};
  12039. var t = {};
  12040. Object.keys(b).forEach(function (k) {
  12041. t[k] = b[k];
  12042. });
  12043. Object.keys(a).forEach(function (k) {
  12044. t[k] = a[k];
  12045. });
  12046. return t;
  12047. }
  12048. minimatch.defaults = function (def) {
  12049. if (!def || !Object.keys(def).length) return minimatch;
  12050. var orig = minimatch;
  12051. var m = function minimatch(p, pattern, options) {
  12052. return orig.minimatch(p, pattern, ext(def, options));
  12053. };
  12054. m.Minimatch = function Minimatch(pattern, options) {
  12055. return new orig.Minimatch(pattern, ext(def, options));
  12056. };
  12057. return m;
  12058. };
  12059. Minimatch.defaults = function (def) {
  12060. if (!def || !Object.keys(def).length) return Minimatch;
  12061. return minimatch.defaults(def).Minimatch;
  12062. };
  12063. function minimatch(p, pattern, options) {
  12064. if (typeof pattern !== 'string') {
  12065. throw new TypeError('glob pattern string required');
  12066. }
  12067. if (!options) options = {}; // shortcut: comments match nothing.
  12068. if (!options.nocomment && pattern.charAt(0) === '#') {
  12069. return false;
  12070. } // "" only matches ""
  12071. if (pattern.trim() === '') return p === '';
  12072. return new Minimatch(pattern, options).match(p);
  12073. }
  12074. function Minimatch(pattern, options) {
  12075. if (!(this instanceof Minimatch)) {
  12076. return new Minimatch(pattern, options);
  12077. }
  12078. if (typeof pattern !== 'string') {
  12079. throw new TypeError('glob pattern string required');
  12080. }
  12081. if (!options) options = {};
  12082. pattern = pattern.trim(); // windows support: need to use /, not \
  12083. if (path$3.sep !== '/') {
  12084. pattern = pattern.split(path$3.sep).join('/');
  12085. }
  12086. this.options = options;
  12087. this.set = [];
  12088. this.pattern = pattern;
  12089. this.regexp = null;
  12090. this.negate = false;
  12091. this.comment = false;
  12092. this.empty = false; // make the set of regexps etc.
  12093. this.make();
  12094. }
  12095. Minimatch.prototype.debug = function () {};
  12096. Minimatch.prototype.make = make;
  12097. function make() {
  12098. // don't do it more than once.
  12099. if (this._made) return;
  12100. var pattern = this.pattern;
  12101. var options = this.options; // empty patterns and comments match nothing.
  12102. if (!options.nocomment && pattern.charAt(0) === '#') {
  12103. this.comment = true;
  12104. return;
  12105. }
  12106. if (!pattern) {
  12107. this.empty = true;
  12108. return;
  12109. } // step 1: figure out negation, etc.
  12110. this.parseNegate(); // step 2: expand braces
  12111. var set = this.globSet = this.braceExpand();
  12112. if (options.debug) this.debug = console.error;
  12113. this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  12114. // matching patterns.
  12115. // These will be regexps, except in the case of "**", which is
  12116. // set to the GLOBSTAR object for globstar behavior,
  12117. // and will not contain any / characters
  12118. set = this.globParts = set.map(function (s) {
  12119. return s.split(slashSplit);
  12120. });
  12121. this.debug(this.pattern, set); // glob --> regexps
  12122. set = set.map(function (s, si, set) {
  12123. return s.map(this.parse, this);
  12124. }, this);
  12125. this.debug(this.pattern, set); // filter out everything that didn't compile properly.
  12126. set = set.filter(function (s) {
  12127. return s.indexOf(false) === -1;
  12128. });
  12129. this.debug(this.pattern, set);
  12130. this.set = set;
  12131. }
  12132. Minimatch.prototype.parseNegate = parseNegate;
  12133. function parseNegate() {
  12134. var pattern = this.pattern;
  12135. var negate = false;
  12136. var options = this.options;
  12137. var negateOffset = 0;
  12138. if (options.nonegate) return;
  12139. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
  12140. negate = !negate;
  12141. negateOffset++;
  12142. }
  12143. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  12144. this.negate = negate;
  12145. } // Brace expansion:
  12146. // a{b,c}d -> abd acd
  12147. // a{b,}c -> abc ac
  12148. // a{0..3}d -> a0d a1d a2d a3d
  12149. // a{b,c{d,e}f}g -> abg acdfg acefg
  12150. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  12151. //
  12152. // Invalid sets are not expanded.
  12153. // a{2..}b -> a{2..}b
  12154. // a{b}c -> a{b}c
  12155. minimatch.braceExpand = function (pattern, options) {
  12156. return braceExpand(pattern, options);
  12157. };
  12158. Minimatch.prototype.braceExpand = braceExpand;
  12159. function braceExpand(pattern, options) {
  12160. if (!options) {
  12161. if (this instanceof Minimatch) {
  12162. options = this.options;
  12163. } else {
  12164. options = {};
  12165. }
  12166. }
  12167. pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
  12168. if (typeof pattern === 'undefined') {
  12169. throw new TypeError('undefined pattern');
  12170. }
  12171. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  12172. // shortcut. no need to expand.
  12173. return [pattern];
  12174. }
  12175. return braceExpansion(pattern);
  12176. } // parse a component of the expanded set.
  12177. // At this point, no pattern may contain "/" in it
  12178. // so we're going to return a 2d array, where each entry is the full
  12179. // pattern, split on '/', and then turned into a regular expression.
  12180. // A regexp is made at the end which joins each array with an
  12181. // escaped /, and another full one which joins each regexp with |.
  12182. //
  12183. // Following the lead of Bash 4.1, note that "**" only has special meaning
  12184. // when it is the *only* thing in a path portion. Otherwise, any series
  12185. // of * is equivalent to a single *. Globstar behavior is enabled by
  12186. // default, and can be disabled by setting options.noglobstar.
  12187. Minimatch.prototype.parse = parse$9;
  12188. var SUBPARSE = {};
  12189. function parse$9(pattern, isSub) {
  12190. if (pattern.length > 1024 * 64) {
  12191. throw new TypeError('pattern is too long');
  12192. }
  12193. var options = this.options; // shortcuts
  12194. if (!options.noglobstar && pattern === '**') return GLOBSTAR;
  12195. if (pattern === '') return '';
  12196. var re = '';
  12197. var hasMagic = !!options.nocase;
  12198. var escaping = false; // ? => one single character
  12199. var patternListStack = [];
  12200. var negativeLists = [];
  12201. var stateChar;
  12202. var inClass = false;
  12203. var reClassStart = -1;
  12204. var classStart = -1; // . and .. never match anything that doesn't start with .,
  12205. // even when options.dot is set.
  12206. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  12207. // not (start or / followed by . or .. followed by / or end)
  12208. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
  12209. var self = this;
  12210. function clearStateChar() {
  12211. if (stateChar) {
  12212. // we had some state-tracking character
  12213. // that wasn't consumed by this pass.
  12214. switch (stateChar) {
  12215. case '*':
  12216. re += star;
  12217. hasMagic = true;
  12218. break;
  12219. case '?':
  12220. re += qmark;
  12221. hasMagic = true;
  12222. break;
  12223. default:
  12224. re += '\\' + stateChar;
  12225. break;
  12226. }
  12227. self.debug('clearStateChar %j %j', stateChar, re);
  12228. stateChar = false;
  12229. }
  12230. }
  12231. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  12232. this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
  12233. if (escaping && reSpecials[c]) {
  12234. re += '\\' + c;
  12235. escaping = false;
  12236. continue;
  12237. }
  12238. switch (c) {
  12239. case '/':
  12240. // completely not allowed, even escaped.
  12241. // Should already be path-split by now.
  12242. return false;
  12243. case '\\':
  12244. clearStateChar();
  12245. escaping = true;
  12246. continue;
  12247. // the various stateChar values
  12248. // for the "extglob" stuff.
  12249. case '?':
  12250. case '*':
  12251. case '+':
  12252. case '@':
  12253. case '!':
  12254. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
  12255. // the glob [!a] means [^a] in regexp
  12256. if (inClass) {
  12257. this.debug(' in class');
  12258. if (c === '!' && i === classStart + 1) c = '^';
  12259. re += c;
  12260. continue;
  12261. } // if we already have a stateChar, then it means
  12262. // that there was something like ** or +? in there.
  12263. // Handle the stateChar, then proceed with this one.
  12264. self.debug('call clearStateChar %j', stateChar);
  12265. clearStateChar();
  12266. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  12267. // just clear the statechar *now*, rather than even diving into
  12268. // the patternList stuff.
  12269. if (options.noext) clearStateChar();
  12270. continue;
  12271. case '(':
  12272. if (inClass) {
  12273. re += '(';
  12274. continue;
  12275. }
  12276. if (!stateChar) {
  12277. re += '\\(';
  12278. continue;
  12279. }
  12280. patternListStack.push({
  12281. type: stateChar,
  12282. start: i - 1,
  12283. reStart: re.length,
  12284. open: plTypes[stateChar].open,
  12285. close: plTypes[stateChar].close
  12286. }); // negation is (?:(?!js)[^/]*)
  12287. re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
  12288. this.debug('plType %j %j', stateChar, re);
  12289. stateChar = false;
  12290. continue;
  12291. case ')':
  12292. if (inClass || !patternListStack.length) {
  12293. re += '\\)';
  12294. continue;
  12295. }
  12296. clearStateChar();
  12297. hasMagic = true;
  12298. var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
  12299. // The others are (?:<pattern>)<type>
  12300. re += pl.close;
  12301. if (pl.type === '!') {
  12302. negativeLists.push(pl);
  12303. }
  12304. pl.reEnd = re.length;
  12305. continue;
  12306. case '|':
  12307. if (inClass || !patternListStack.length || escaping) {
  12308. re += '\\|';
  12309. escaping = false;
  12310. continue;
  12311. }
  12312. clearStateChar();
  12313. re += '|';
  12314. continue;
  12315. // these are mostly the same in regexp and glob
  12316. case '[':
  12317. // swallow any state-tracking char before the [
  12318. clearStateChar();
  12319. if (inClass) {
  12320. re += '\\' + c;
  12321. continue;
  12322. }
  12323. inClass = true;
  12324. classStart = i;
  12325. reClassStart = re.length;
  12326. re += c;
  12327. continue;
  12328. case ']':
  12329. // a right bracket shall lose its special
  12330. // meaning and represent itself in
  12331. // a bracket expression if it occurs
  12332. // first in the list. -- POSIX.2 2.8.3.2
  12333. if (i === classStart + 1 || !inClass) {
  12334. re += '\\' + c;
  12335. escaping = false;
  12336. continue;
  12337. } // handle the case where we left a class open.
  12338. // "[z-a]" is valid, equivalent to "\[z-a\]"
  12339. if (inClass) {
  12340. // split where the last [ was, make sure we don't have
  12341. // an invalid re. if so, re-walk the contents of the
  12342. // would-be class to re-translate any characters that
  12343. // were passed through as-is
  12344. // TODO: It would probably be faster to determine this
  12345. // without a try/catch and a new RegExp, but it's tricky
  12346. // to do safely. For now, this is safe and works.
  12347. var cs = pattern.substring(classStart + 1, i);
  12348. try {
  12349. RegExp('[' + cs + ']');
  12350. } catch (er) {
  12351. // not a valid class!
  12352. var sp = this.parse(cs, SUBPARSE);
  12353. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
  12354. hasMagic = hasMagic || sp[1];
  12355. inClass = false;
  12356. continue;
  12357. }
  12358. } // finish up the class.
  12359. hasMagic = true;
  12360. inClass = false;
  12361. re += c;
  12362. continue;
  12363. default:
  12364. // swallow any state char that wasn't consumed
  12365. clearStateChar();
  12366. if (escaping) {
  12367. // no need
  12368. escaping = false;
  12369. } else if (reSpecials[c] && !(c === '^' && inClass)) {
  12370. re += '\\';
  12371. }
  12372. re += c;
  12373. } // switch
  12374. } // for
  12375. // handle the case where we left a class open.
  12376. // "[abc" is valid, equivalent to "\[abc"
  12377. if (inClass) {
  12378. // split where the last [ was, and escape it
  12379. // this is a huge pita. We now have to re-walk
  12380. // the contents of the would-be class to re-translate
  12381. // any characters that were passed through as-is
  12382. cs = pattern.substr(classStart + 1);
  12383. sp = this.parse(cs, SUBPARSE);
  12384. re = re.substr(0, reClassStart) + '\\[' + sp[0];
  12385. hasMagic = hasMagic || sp[1];
  12386. } // handle the case where we had a +( thing at the *end*
  12387. // of the pattern.
  12388. // each pattern list stack adds 3 chars, and we need to go through
  12389. // and escape any | chars that were passed through as-is for the regexp.
  12390. // Go through and escape them, taking care not to double-escape any
  12391. // | chars that were already escaped.
  12392. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  12393. var tail = re.slice(pl.reStart + pl.open.length);
  12394. this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
  12395. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  12396. if (!$2) {
  12397. // the | isn't already escaped, so escape it.
  12398. $2 = '\\';
  12399. } // need to escape all those slashes *again*, without escaping the
  12400. // one that we need for escaping the | character. As it works out,
  12401. // escaping an even number of slashes can be done by simply repeating
  12402. // it exactly after itself. That's why this trick works.
  12403. //
  12404. // I am sorry that you have to see this.
  12405. return $1 + $1 + $2 + '|';
  12406. });
  12407. this.debug('tail=%j\n %s', tail, tail, pl, re);
  12408. var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
  12409. hasMagic = true;
  12410. re = re.slice(0, pl.reStart) + t + '\\(' + tail;
  12411. } // handle trailing things that only matter at the very end.
  12412. clearStateChar();
  12413. if (escaping) {
  12414. // trailing \\
  12415. re += '\\\\';
  12416. } // only need to apply the nodot start if the re starts with
  12417. // something that could conceivably capture a dot
  12418. var addPatternStart = false;
  12419. switch (re.charAt(0)) {
  12420. case '.':
  12421. case '[':
  12422. case '(':
  12423. addPatternStart = true;
  12424. } // Hack to work around lack of negative lookbehind in JS
  12425. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  12426. // like 'a.xyz.yz' doesn't match. So, the first negative
  12427. // lookahead, has to look ALL the way ahead, to the end of
  12428. // the pattern.
  12429. for (var n = negativeLists.length - 1; n > -1; n--) {
  12430. var nl = negativeLists[n];
  12431. var nlBefore = re.slice(0, nl.reStart);
  12432. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  12433. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  12434. var nlAfter = re.slice(nl.reEnd);
  12435. nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
  12436. // mean that we should *not* include the ) in the bit that is considered
  12437. // "after" the negated section.
  12438. var openParensBefore = nlBefore.split('(').length - 1;
  12439. var cleanAfter = nlAfter;
  12440. for (i = 0; i < openParensBefore; i++) {
  12441. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
  12442. }
  12443. nlAfter = cleanAfter;
  12444. var dollar = '';
  12445. if (nlAfter === '' && isSub !== SUBPARSE) {
  12446. dollar = '$';
  12447. }
  12448. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  12449. re = newRe;
  12450. } // if the re is not "" at this point, then we need to make sure
  12451. // it doesn't match against an empty path part.
  12452. // Otherwise a/* will match a/, which it should not.
  12453. if (re !== '' && hasMagic) {
  12454. re = '(?=.)' + re;
  12455. }
  12456. if (addPatternStart) {
  12457. re = patternStart + re;
  12458. } // parsing just a piece of a larger pattern.
  12459. if (isSub === SUBPARSE) {
  12460. return [re, hasMagic];
  12461. } // skip the regexp for non-magical patterns
  12462. // unescape anything in it, though, so that it'll be
  12463. // an exact match against a file etc.
  12464. if (!hasMagic) {
  12465. return globUnescape(pattern);
  12466. }
  12467. var flags = options.nocase ? 'i' : '';
  12468. try {
  12469. var regExp = new RegExp('^' + re + '$', flags);
  12470. } catch (er) {
  12471. // If it was an invalid regular expression, then it can't match
  12472. // anything. This trick looks for a character after the end of
  12473. // the string, which is of course impossible, except in multi-line
  12474. // mode, but it's not a /m regex.
  12475. return new RegExp('$.');
  12476. }
  12477. regExp._glob = pattern;
  12478. regExp._src = re;
  12479. return regExp;
  12480. }
  12481. minimatch.makeRe = function (pattern, options) {
  12482. return new Minimatch(pattern, options || {}).makeRe();
  12483. };
  12484. Minimatch.prototype.makeRe = makeRe;
  12485. function makeRe() {
  12486. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  12487. // pattern strings, or "**".
  12488. //
  12489. // It's better to use .match(). This function shouldn't
  12490. // be used, really, but it's pretty convenient sometimes,
  12491. // when you just want to work with a regex.
  12492. var set = this.set;
  12493. if (!set.length) {
  12494. this.regexp = false;
  12495. return this.regexp;
  12496. }
  12497. var options = this.options;
  12498. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  12499. var flags = options.nocase ? 'i' : '';
  12500. var re = set.map(function (pattern) {
  12501. return pattern.map(function (p) {
  12502. return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
  12503. }).join('\\\/');
  12504. }).join('|'); // must match entire pattern
  12505. // ending in a * or ** will make it less strict.
  12506. re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
  12507. if (this.negate) re = '^(?!' + re + ').*$';
  12508. try {
  12509. this.regexp = new RegExp(re, flags);
  12510. } catch (ex) {
  12511. this.regexp = false;
  12512. }
  12513. return this.regexp;
  12514. }
  12515. minimatch.match = function (list, pattern, options) {
  12516. options = options || {};
  12517. var mm = new Minimatch(pattern, options);
  12518. list = list.filter(function (f) {
  12519. return mm.match(f);
  12520. });
  12521. if (mm.options.nonull && !list.length) {
  12522. list.push(pattern);
  12523. }
  12524. return list;
  12525. };
  12526. Minimatch.prototype.match = match;
  12527. function match(f, partial) {
  12528. this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
  12529. // comments, etc.
  12530. if (this.comment) return false;
  12531. if (this.empty) return f === '';
  12532. if (f === '/' && partial) return true;
  12533. var options = this.options; // windows: need to use /, not \
  12534. if (path$3.sep !== '/') {
  12535. f = f.split(path$3.sep).join('/');
  12536. } // treat the test path as a set of pathparts.
  12537. f = f.split(slashSplit);
  12538. this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
  12539. // in order for it to be valid. If negating, then just one
  12540. // match means that we have failed.
  12541. // Either way, return on the first hit.
  12542. var set = this.set;
  12543. this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
  12544. var filename;
  12545. var i;
  12546. for (i = f.length - 1; i >= 0; i--) {
  12547. filename = f[i];
  12548. if (filename) break;
  12549. }
  12550. for (i = 0; i < set.length; i++) {
  12551. var pattern = set[i];
  12552. var file = f;
  12553. if (options.matchBase && pattern.length === 1) {
  12554. file = [filename];
  12555. }
  12556. var hit = this.matchOne(file, pattern, partial);
  12557. if (hit) {
  12558. if (options.flipNegate) return true;
  12559. return !this.negate;
  12560. }
  12561. } // didn't get any hits. this is success if it's a negative
  12562. // pattern, failure otherwise.
  12563. if (options.flipNegate) return false;
  12564. return this.negate;
  12565. } // set partial to true to test if, for example,
  12566. // "/a/b" matches the start of "/*/b/*/d"
  12567. // Partial means, if you run out of file before you run
  12568. // out of pattern, then that's fine, as long as all
  12569. // the parts match.
  12570. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  12571. var options = this.options;
  12572. this.debug('matchOne', {
  12573. 'this': this,
  12574. file: file,
  12575. pattern: pattern
  12576. });
  12577. this.debug('matchOne', file.length, pattern.length);
  12578. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  12579. this.debug('matchOne loop');
  12580. var p = pattern[pi];
  12581. var f = file[fi];
  12582. this.debug(pattern, p, f); // should be impossible.
  12583. // some invalid regexp stuff in the set.
  12584. if (p === false) return false;
  12585. if (p === GLOBSTAR) {
  12586. this.debug('GLOBSTAR', [pattern, p, f]); // "**"
  12587. // a/**/b/**/c would match the following:
  12588. // a/b/x/y/z/c
  12589. // a/x/y/z/b/c
  12590. // a/b/x/b/x/c
  12591. // a/b/c
  12592. // To do this, take the rest of the pattern after
  12593. // the **, and see if it would match the file remainder.
  12594. // If so, return success.
  12595. // If not, the ** "swallows" a segment, and try again.
  12596. // This is recursively awful.
  12597. //
  12598. // a/**/b/**/c matching a/b/x/y/z/c
  12599. // - a matches a
  12600. // - doublestar
  12601. // - matchOne(b/x/y/z/c, b/**/c)
  12602. // - b matches b
  12603. // - doublestar
  12604. // - matchOne(x/y/z/c, c) -> no
  12605. // - matchOne(y/z/c, c) -> no
  12606. // - matchOne(z/c, c) -> no
  12607. // - matchOne(c, c) yes, hit
  12608. var fr = fi;
  12609. var pr = pi + 1;
  12610. if (pr === pl) {
  12611. this.debug('** at the end'); // a ** at the end will just swallow the rest.
  12612. // We have found a match.
  12613. // however, it will not swallow /.x, unless
  12614. // options.dot is set.
  12615. // . and .. are *never* matched by **, for explosively
  12616. // exponential reasons.
  12617. for (; fi < fl; fi++) {
  12618. if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
  12619. }
  12620. return true;
  12621. } // ok, let's see if we can swallow whatever we can.
  12622. while (fr < fl) {
  12623. var swallowee = file[fr];
  12624. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
  12625. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  12626. this.debug('globstar found match!', fr, fl, swallowee); // found a match.
  12627. return true;
  12628. } else {
  12629. // can't swallow "." or ".." ever.
  12630. // can only swallow ".foo" when explicitly asked.
  12631. if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
  12632. this.debug('dot detected!', file, fr, pattern, pr);
  12633. break;
  12634. } // ** swallows a segment, and continue.
  12635. this.debug('globstar swallow a segment, and continue');
  12636. fr++;
  12637. }
  12638. } // no match was found.
  12639. // However, in partial mode, we can't say this is necessarily over.
  12640. // If there's more *pattern* left, then
  12641. if (partial) {
  12642. // ran out of file
  12643. this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
  12644. if (fr === fl) return true;
  12645. }
  12646. return false;
  12647. } // something other than **
  12648. // non-magic patterns just have to match exactly
  12649. // patterns with magic have been turned into regexps.
  12650. var hit;
  12651. if (typeof p === 'string') {
  12652. if (options.nocase) {
  12653. hit = f.toLowerCase() === p.toLowerCase();
  12654. } else {
  12655. hit = f === p;
  12656. }
  12657. this.debug('string match', p, f, hit);
  12658. } else {
  12659. hit = f.match(p);
  12660. this.debug('pattern match', p, f, hit);
  12661. }
  12662. if (!hit) return false;
  12663. } // Note: ending in / means that we'll get a final ""
  12664. // at the end of the pattern. This can only match a
  12665. // corresponding "" at the end of the file.
  12666. // If the file ends in /, then it can only match a
  12667. // a pattern that ends in /, unless the pattern just
  12668. // doesn't have any more for it. But, a/b/ should *not*
  12669. // match "a/b/*", even though "" matches against the
  12670. // [^/]*? pattern, except in partial mode, where it might
  12671. // simply not be reached yet.
  12672. // However, a/b/ should still satisfy a/*
  12673. // now either we fell off the end of the pattern, or we're done.
  12674. if (fi === fl && pi === pl) {
  12675. // ran out of pattern and filename at the same time.
  12676. // an exact hit!
  12677. return true;
  12678. } else if (fi === fl) {
  12679. // ran out of file, but still had pattern left.
  12680. // this is ok if we're doing the match as part of
  12681. // a glob fs traversal.
  12682. return partial;
  12683. } else if (pi === pl) {
  12684. // ran out of pattern, still have file left.
  12685. // this is only acceptable if we're on the very last
  12686. // empty segment of a file with a trailing slash.
  12687. // a/* should match a/b/
  12688. var emptyFileEnd = fi === fl - 1 && file[fi] === '';
  12689. return emptyFileEnd;
  12690. } // should be unreachable.
  12691. throw new Error('wtf?');
  12692. }; // replace stuff like \* with *
  12693. function globUnescape(s) {
  12694. return s.replace(/\\(.)/g, '$1');
  12695. }
  12696. function regExpEscape(s) {
  12697. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  12698. }
  12699. const copyProperty = (to, from, property, ignoreNonConfigurable) => {
  12700. // `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
  12701. // `Function#prototype` is non-writable and non-configurable so can never be modified.
  12702. if (property === 'length' || property === 'prototype') {
  12703. return;
  12704. } // `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
  12705. if (property === 'arguments' || property === 'caller') {
  12706. return;
  12707. }
  12708. const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
  12709. const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
  12710. if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
  12711. return;
  12712. }
  12713. Object.defineProperty(to, property, fromDescriptor);
  12714. }; // `Object.defineProperty()` throws if the property exists, is not configurable and either:
  12715. // - one its descriptors is changed
  12716. // - it is non-writable and its value is changed
  12717. const canCopyProperty = function (toDescriptor, fromDescriptor) {
  12718. return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
  12719. };
  12720. const changePrototype = (to, from) => {
  12721. const fromPrototype = Object.getPrototypeOf(from);
  12722. if (fromPrototype === Object.getPrototypeOf(to)) {
  12723. return;
  12724. }
  12725. Object.setPrototypeOf(to, fromPrototype);
  12726. };
  12727. const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
  12728. const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
  12729. const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name'); // We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
  12730. // We use `bind()` instead of a closure for the same reason.
  12731. // Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
  12732. const changeToString = (to, from, name) => {
  12733. const withName = name === '' ? '' : `with ${name.trim()}() `;
  12734. const newToString = wrappedToString.bind(null, withName, from.toString()); // Ensure `to.toString.toString` is non-enumerable and has the same `same`
  12735. Object.defineProperty(newToString, 'name', toStringName);
  12736. Object.defineProperty(to, 'toString', Object.assign(Object.assign({}, toStringDescriptor), {}, {
  12737. value: newToString
  12738. }));
  12739. };
  12740. const mimicFn = (to, from, {
  12741. ignoreNonConfigurable = false
  12742. } = {}) => {
  12743. const {
  12744. name
  12745. } = to;
  12746. for (const property of Reflect.ownKeys(from)) {
  12747. copyProperty(to, from, property, ignoreNonConfigurable);
  12748. }
  12749. changePrototype(to, from);
  12750. changeToString(to, from, name);
  12751. return to;
  12752. };
  12753. var mimicFn_1 = mimicFn;
  12754. var pDefer = () => {
  12755. const ret = {};
  12756. ret.promise = new Promise((resolve, reject) => {
  12757. ret.resolve = resolve;
  12758. ret.reject = reject;
  12759. });
  12760. return ret;
  12761. };
  12762. var dist$2 = createCommonjsModule(function (module, exports) {
  12763. var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
  12764. return new (P || (P = Promise))(function (resolve, reject) {
  12765. function fulfilled(value) {
  12766. try {
  12767. step(generator.next(value));
  12768. } catch (e) {
  12769. reject(e);
  12770. }
  12771. }
  12772. function rejected(value) {
  12773. try {
  12774. step(generator["throw"](value));
  12775. } catch (e) {
  12776. reject(e);
  12777. }
  12778. }
  12779. function step(result) {
  12780. result.done ? resolve(result.value) : new P(function (resolve) {
  12781. resolve(result.value);
  12782. }).then(fulfilled, rejected);
  12783. }
  12784. step((generator = generator.apply(thisArg, _arguments || [])).next());
  12785. });
  12786. };
  12787. var __importDefault = this && this.__importDefault || function (mod) {
  12788. return mod && mod.__esModule ? mod : {
  12789. "default": mod
  12790. };
  12791. };
  12792. Object.defineProperty(exports, "__esModule", {
  12793. value: true
  12794. });
  12795. const p_defer_1 = __importDefault(pDefer);
  12796. function mapAgeCleaner(map, property = 'maxAge') {
  12797. let processingKey;
  12798. let processingTimer;
  12799. let processingDeferred;
  12800. const cleanup = () => __awaiter(this, void 0, void 0, function* () {
  12801. if (processingKey !== undefined) {
  12802. // If we are already processing an item, we can safely exit
  12803. return;
  12804. }
  12805. const setupTimer = item => __awaiter(this, void 0, void 0, function* () {
  12806. processingDeferred = p_defer_1.default();
  12807. const delay = item[1][property] - Date.now();
  12808. if (delay <= 0) {
  12809. // Remove the item immediately if the delay is equal to or below 0
  12810. map.delete(item[0]);
  12811. processingDeferred.resolve();
  12812. return;
  12813. } // Keep track of the current processed key
  12814. processingKey = item[0];
  12815. processingTimer = setTimeout(() => {
  12816. // Remove the item when the timeout fires
  12817. map.delete(item[0]);
  12818. if (processingDeferred) {
  12819. processingDeferred.resolve();
  12820. }
  12821. }, delay); // tslint:disable-next-line:strict-type-predicates
  12822. if (typeof processingTimer.unref === 'function') {
  12823. // Don't hold up the process from exiting
  12824. processingTimer.unref();
  12825. }
  12826. return processingDeferred.promise;
  12827. });
  12828. try {
  12829. for (const entry of map) {
  12830. yield setupTimer(entry);
  12831. }
  12832. } catch (_a) {// Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing
  12833. }
  12834. processingKey = undefined;
  12835. });
  12836. const reset = () => {
  12837. processingKey = undefined;
  12838. if (processingTimer !== undefined) {
  12839. clearTimeout(processingTimer);
  12840. processingTimer = undefined;
  12841. }
  12842. if (processingDeferred !== undefined) {
  12843. // tslint:disable-line:early-exit
  12844. processingDeferred.reject(undefined);
  12845. processingDeferred = undefined;
  12846. }
  12847. };
  12848. const originalSet = map.set.bind(map);
  12849. map.set = (key, value) => {
  12850. if (map.has(key)) {
  12851. // If the key already exist, remove it so we can add it back at the end of the map.
  12852. map.delete(key);
  12853. } // Call the original `map.set`
  12854. const result = originalSet(key, value); // If we are already processing a key and the key added is the current processed key, stop processing it
  12855. if (processingKey && processingKey === key) {
  12856. reset();
  12857. } // Always run the cleanup method in case it wasn't started yet
  12858. cleanup(); // tslint:disable-line:no-floating-promises
  12859. return result;
  12860. };
  12861. cleanup(); // tslint:disable-line:no-floating-promises
  12862. return map;
  12863. }
  12864. exports.default = mapAgeCleaner; // Add support for CJS
  12865. module.exports = mapAgeCleaner;
  12866. module.exports.default = mapAgeCleaner;
  12867. });
  12868. const decoratorInstanceMap = new WeakMap();
  12869. const cacheStore = new WeakMap();
  12870. /**
  12871. [Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
  12872. @param fn - Function to be memoized.
  12873. @example
  12874. ```
  12875. import mem = require('mem');
  12876. let i = 0;
  12877. const counter = () => ++i;
  12878. const memoized = mem(counter);
  12879. memoized('foo');
  12880. //=> 1
  12881. // Cached as it's the same arguments
  12882. memoized('foo');
  12883. //=> 1
  12884. // Not cached anymore as the arguments changed
  12885. memoized('bar');
  12886. //=> 2
  12887. memoized('bar');
  12888. //=> 2
  12889. ```
  12890. */
  12891. const mem = (fn, {
  12892. cacheKey,
  12893. cache = new Map(),
  12894. maxAge
  12895. } = {}) => {
  12896. if (typeof maxAge === 'number') {
  12897. // TODO: Drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
  12898. // @ts-expect-error
  12899. dist$2(cache);
  12900. }
  12901. const memoized = function (...arguments_) {
  12902. const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
  12903. const cacheItem = cache.get(key);
  12904. if (cacheItem) {
  12905. return cacheItem.data;
  12906. }
  12907. const result = fn.apply(this, arguments_);
  12908. cache.set(key, {
  12909. data: result,
  12910. maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY
  12911. });
  12912. return result;
  12913. };
  12914. mimicFn_1(memoized, fn, {
  12915. ignoreNonConfigurable: true
  12916. });
  12917. cacheStore.set(memoized, cache);
  12918. return memoized;
  12919. };
  12920. /**
  12921. @returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
  12922. @example
  12923. ```
  12924. import mem = require('mem');
  12925. class Example {
  12926. index = 0
  12927. @mem.decorator()
  12928. counter() {
  12929. return ++this.index;
  12930. }
  12931. }
  12932. class ExampleWithOptions {
  12933. index = 0
  12934. @mem.decorator({maxAge: 1000})
  12935. counter() {
  12936. return ++this.index;
  12937. }
  12938. }
  12939. ```
  12940. */
  12941. mem.decorator = (options = {}) => (target, propertyKey, descriptor) => {
  12942. const input = target[propertyKey];
  12943. if (typeof input !== 'function') {
  12944. throw new TypeError('The decorated value must be a function');
  12945. }
  12946. delete descriptor.value;
  12947. delete descriptor.writable;
  12948. descriptor.get = function () {
  12949. if (!decoratorInstanceMap.has(this)) {
  12950. const value = mem(input, options);
  12951. decoratorInstanceMap.set(this, value);
  12952. return value;
  12953. }
  12954. return decoratorInstanceMap.get(this);
  12955. };
  12956. };
  12957. /**
  12958. Clear all cached data of a memoized function.
  12959. @param fn - Memoized function.
  12960. */
  12961. mem.clear = fn => {
  12962. const cache = cacheStore.get(fn);
  12963. if (!cache) {
  12964. throw new TypeError('Can\'t clear a function that was not memoized!');
  12965. }
  12966. if (typeof cache.clear !== 'function') {
  12967. throw new TypeError('The cache Map can\'t be cleared!');
  12968. }
  12969. cache.clear();
  12970. };
  12971. var dist$1 = mem;
  12972. var thirdParty = require("./third-party.js");
  12973. const ParserEND = 0x110000;
  12974. class ParserError extends Error {
  12975. /* istanbul ignore next */
  12976. constructor(msg, filename, linenumber) {
  12977. super('[ParserError] ' + msg, filename, linenumber);
  12978. this.name = 'ParserError';
  12979. this.code = 'ParserError';
  12980. if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError);
  12981. }
  12982. }
  12983. class State {
  12984. constructor(parser) {
  12985. this.parser = parser;
  12986. this.buf = '';
  12987. this.returned = null;
  12988. this.result = null;
  12989. this.resultTable = null;
  12990. this.resultArr = null;
  12991. }
  12992. }
  12993. class Parser {
  12994. constructor() {
  12995. this.pos = 0;
  12996. this.col = 0;
  12997. this.line = 0;
  12998. this.obj = {};
  12999. this.ctx = this.obj;
  13000. this.stack = [];
  13001. this._buf = '';
  13002. this.char = null;
  13003. this.ii = 0;
  13004. this.state = new State(this.parseStart);
  13005. }
  13006. parse(str) {
  13007. /* istanbul ignore next */
  13008. if (str.length === 0 || str.length == null) return;
  13009. this._buf = String(str);
  13010. this.ii = -1;
  13011. this.char = -1;
  13012. let getNext;
  13013. while (getNext === false || this.nextChar()) {
  13014. getNext = this.runOne();
  13015. }
  13016. this._buf = null;
  13017. }
  13018. nextChar() {
  13019. if (this.char === 0x0A) {
  13020. ++this.line;
  13021. this.col = -1;
  13022. }
  13023. ++this.ii;
  13024. this.char = this._buf.codePointAt(this.ii);
  13025. ++this.pos;
  13026. ++this.col;
  13027. return this.haveBuffer();
  13028. }
  13029. haveBuffer() {
  13030. return this.ii < this._buf.length;
  13031. }
  13032. runOne() {
  13033. return this.state.parser.call(this, this.state.returned);
  13034. }
  13035. finish() {
  13036. this.char = ParserEND;
  13037. let last;
  13038. do {
  13039. last = this.state.parser;
  13040. this.runOne();
  13041. } while (this.state.parser !== last);
  13042. this.ctx = null;
  13043. this.state = null;
  13044. this._buf = null;
  13045. return this.obj;
  13046. }
  13047. next(fn) {
  13048. /* istanbul ignore next */
  13049. if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
  13050. this.state.parser = fn;
  13051. }
  13052. goto(fn) {
  13053. this.next(fn);
  13054. return this.runOne();
  13055. }
  13056. call(fn, returnWith) {
  13057. if (returnWith) this.next(returnWith);
  13058. this.stack.push(this.state);
  13059. this.state = new State(fn);
  13060. }
  13061. callNow(fn, returnWith) {
  13062. this.call(fn, returnWith);
  13063. return this.runOne();
  13064. }
  13065. return(value) {
  13066. /* istanbul ignore next */
  13067. if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'));
  13068. if (value === undefined) value = this.state.buf;
  13069. this.state = this.stack.pop();
  13070. this.state.returned = value;
  13071. }
  13072. returnNow(value) {
  13073. this.return(value);
  13074. return this.runOne();
  13075. }
  13076. consume() {
  13077. /* istanbul ignore next */
  13078. if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
  13079. this.state.buf += this._buf[this.ii];
  13080. }
  13081. error(err) {
  13082. err.line = this.line;
  13083. err.col = this.col;
  13084. err.pos = this.pos;
  13085. return err;
  13086. }
  13087. /* istanbul ignore next */
  13088. parseStart() {
  13089. throw new ParserError('Must declare a parseStart method');
  13090. }
  13091. }
  13092. Parser.END = ParserEND;
  13093. Parser.Error = ParserError;
  13094. var parser = Parser;
  13095. var createDatetime = value => {
  13096. const date = new Date(value);
  13097. /* istanbul ignore if */
  13098. if (isNaN(date)) {
  13099. throw new TypeError('Invalid Datetime');
  13100. } else {
  13101. return date;
  13102. }
  13103. };
  13104. var formatNum = (d, num) => {
  13105. num = String(num);
  13106. while (num.length < d) num = '0' + num;
  13107. return num;
  13108. };
  13109. class FloatingDateTime extends Date {
  13110. constructor(value) {
  13111. super(value + 'Z');
  13112. this.isFloating = true;
  13113. }
  13114. toISOString() {
  13115. const date = `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  13116. const time = `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  13117. return `${date}T${time}`;
  13118. }
  13119. }
  13120. var createDatetimeFloat = value => {
  13121. const date = new FloatingDateTime(value);
  13122. /* istanbul ignore if */
  13123. if (isNaN(date)) {
  13124. throw new TypeError('Invalid Datetime');
  13125. } else {
  13126. return date;
  13127. }
  13128. };
  13129. const DateTime = global.Date;
  13130. class Date$1 extends DateTime {
  13131. constructor(value) {
  13132. super(value);
  13133. this.isDate = true;
  13134. }
  13135. toISOString() {
  13136. return `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  13137. }
  13138. }
  13139. var createDate = value => {
  13140. const date = new Date$1(value);
  13141. /* istanbul ignore if */
  13142. if (isNaN(date)) {
  13143. throw new TypeError('Invalid Datetime');
  13144. } else {
  13145. return date;
  13146. }
  13147. };
  13148. class Time extends Date {
  13149. constructor(value) {
  13150. super(`0000-01-01T${value}Z`);
  13151. this.isTime = true;
  13152. }
  13153. toISOString() {
  13154. return `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  13155. }
  13156. }
  13157. var createTime = value => {
  13158. const date = new Time(value);
  13159. /* istanbul ignore if */
  13160. if (isNaN(date)) {
  13161. throw new TypeError('Invalid Datetime');
  13162. } else {
  13163. return date;
  13164. }
  13165. };
  13166. /* eslint-disable no-new-wrappers, no-eval, camelcase, operator-linebreak */
  13167. var tomlParser = makeParserClass(parser);
  13168. var makeParserClass_1 = makeParserClass;
  13169. class TomlError extends Error {
  13170. constructor(msg) {
  13171. super(msg);
  13172. this.name = 'TomlError';
  13173. /* istanbul ignore next */
  13174. if (Error.captureStackTrace) Error.captureStackTrace(this, TomlError);
  13175. this.fromTOML = true;
  13176. this.wrapped = null;
  13177. }
  13178. }
  13179. TomlError.wrap = err => {
  13180. const terr = new TomlError(err.message);
  13181. terr.code = err.code;
  13182. terr.wrapped = err;
  13183. return terr;
  13184. };
  13185. var TomlError_1 = TomlError;
  13186. const CTRL_I = 0x09;
  13187. const CTRL_J = 0x0A;
  13188. const CTRL_M = 0x0D;
  13189. const CTRL_CHAR_BOUNDARY = 0x1F; // the last non-character in the latin1 region of unicode, except DEL
  13190. const CHAR_SP = 0x20;
  13191. const CHAR_QUOT = 0x22;
  13192. const CHAR_NUM = 0x23;
  13193. const CHAR_APOS = 0x27;
  13194. const CHAR_PLUS$1 = 0x2B;
  13195. const CHAR_COMMA$2 = 0x2C;
  13196. const CHAR_HYPHEN = 0x2D;
  13197. const CHAR_PERIOD = 0x2E;
  13198. const CHAR_0 = 0x30;
  13199. const CHAR_1 = 0x31;
  13200. const CHAR_7 = 0x37;
  13201. const CHAR_9 = 0x39;
  13202. const CHAR_COLON = 0x3A;
  13203. const CHAR_EQUALS = 0x3D;
  13204. const CHAR_A = 0x41;
  13205. const CHAR_E = 0x45;
  13206. const CHAR_F = 0x46;
  13207. const CHAR_T = 0x54;
  13208. const CHAR_U = 0x55;
  13209. const CHAR_Z = 0x5A;
  13210. const CHAR_LOWBAR = 0x5F;
  13211. const CHAR_a = 0x61;
  13212. const CHAR_b = 0x62;
  13213. const CHAR_e = 0x65;
  13214. const CHAR_f = 0x66;
  13215. const CHAR_i = 0x69;
  13216. const CHAR_l = 0x6C;
  13217. const CHAR_n = 0x6E;
  13218. const CHAR_o = 0x6F;
  13219. const CHAR_r = 0x72;
  13220. const CHAR_s = 0x73;
  13221. const CHAR_t = 0x74;
  13222. const CHAR_u = 0x75;
  13223. const CHAR_x = 0x78;
  13224. const CHAR_z = 0x7A;
  13225. const CHAR_LCUB = 0x7B;
  13226. const CHAR_RCUB = 0x7D;
  13227. const CHAR_LSQB = 0x5B;
  13228. const CHAR_BSOL = 0x5C;
  13229. const CHAR_RSQB = 0x5D;
  13230. const CHAR_DEL = 0x7F;
  13231. const SURROGATE_FIRST = 0xD800;
  13232. const SURROGATE_LAST = 0xDFFF;
  13233. const escapes = {
  13234. [CHAR_b]: '\u0008',
  13235. [CHAR_t]: '\u0009',
  13236. [CHAR_n]: '\u000A',
  13237. [CHAR_f]: '\u000C',
  13238. [CHAR_r]: '\u000D',
  13239. [CHAR_QUOT]: '\u0022',
  13240. [CHAR_BSOL]: '\u005C'
  13241. };
  13242. function isDigit(cp) {
  13243. return cp >= CHAR_0 && cp <= CHAR_9;
  13244. }
  13245. function isHexit(cp) {
  13246. return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
  13247. }
  13248. function isBit(cp) {
  13249. return cp === CHAR_1 || cp === CHAR_0;
  13250. }
  13251. function isOctit(cp) {
  13252. return cp >= CHAR_0 && cp <= CHAR_7;
  13253. }
  13254. function isAlphaNumQuoteHyphen(cp) {
  13255. return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
  13256. }
  13257. function isAlphaNumHyphen(cp) {
  13258. return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
  13259. }
  13260. const _type = Symbol('type');
  13261. const _declared = Symbol('declared');
  13262. const hasOwnProperty$a = Object.prototype.hasOwnProperty;
  13263. const defineProperty = Object.defineProperty;
  13264. const descriptor = {
  13265. configurable: true,
  13266. enumerable: true,
  13267. writable: true,
  13268. value: undefined
  13269. };
  13270. function hasKey(obj, key) {
  13271. if (hasOwnProperty$a.call(obj, key)) return true;
  13272. if (key === '__proto__') defineProperty(obj, '__proto__', descriptor);
  13273. return false;
  13274. }
  13275. const INLINE_TABLE = Symbol('inline-table');
  13276. function InlineTable() {
  13277. return Object.defineProperties({}, {
  13278. [_type]: {
  13279. value: INLINE_TABLE
  13280. }
  13281. });
  13282. }
  13283. function isInlineTable(obj) {
  13284. if (obj === null || typeof obj !== 'object') return false;
  13285. return obj[_type] === INLINE_TABLE;
  13286. }
  13287. const TABLE = Symbol('table');
  13288. function Table() {
  13289. return Object.defineProperties({}, {
  13290. [_type]: {
  13291. value: TABLE
  13292. },
  13293. [_declared]: {
  13294. value: false,
  13295. writable: true
  13296. }
  13297. });
  13298. }
  13299. function isTable(obj) {
  13300. if (obj === null || typeof obj !== 'object') return false;
  13301. return obj[_type] === TABLE;
  13302. }
  13303. const _contentType = Symbol('content-type');
  13304. const INLINE_LIST = Symbol('inline-list');
  13305. function InlineList(type) {
  13306. return Object.defineProperties([], {
  13307. [_type]: {
  13308. value: INLINE_LIST
  13309. },
  13310. [_contentType]: {
  13311. value: type
  13312. }
  13313. });
  13314. }
  13315. function isInlineList(obj) {
  13316. if (obj === null || typeof obj !== 'object') return false;
  13317. return obj[_type] === INLINE_LIST;
  13318. }
  13319. const LIST = Symbol('list');
  13320. function List() {
  13321. return Object.defineProperties([], {
  13322. [_type]: {
  13323. value: LIST
  13324. }
  13325. });
  13326. }
  13327. function isList(obj) {
  13328. if (obj === null || typeof obj !== 'object') return false;
  13329. return obj[_type] === LIST;
  13330. } // in an eval, to let bundlers not slurp in a util proxy
  13331. let _custom;
  13332. try {
  13333. const utilInspect = require('util').inspect;
  13334. _custom = utilInspect.custom;
  13335. } catch (_) {
  13336. /* eval require not available in transpiled bundle */
  13337. }
  13338. /* istanbul ignore next */
  13339. const _inspect = _custom || 'inspect';
  13340. class BoxedBigInt {
  13341. constructor(value) {
  13342. try {
  13343. this.value = global.BigInt.asIntN(64, value);
  13344. } catch (_) {
  13345. /* istanbul ignore next */
  13346. this.value = null;
  13347. }
  13348. Object.defineProperty(this, _type, {
  13349. value: INTEGER
  13350. });
  13351. }
  13352. isNaN() {
  13353. return this.value === null;
  13354. }
  13355. /* istanbul ignore next */
  13356. toString() {
  13357. return String(this.value);
  13358. }
  13359. /* istanbul ignore next */
  13360. [_inspect]() {
  13361. return `[BigInt: ${this.toString()}]}`;
  13362. }
  13363. valueOf() {
  13364. return this.value;
  13365. }
  13366. }
  13367. const INTEGER = Symbol('integer');
  13368. function Integer(value) {
  13369. let num = Number(value); // -0 is a float thing, not an int thing
  13370. if (Object.is(num, -0)) num = 0;
  13371. /* istanbul ignore else */
  13372. if (global.BigInt && !Number.isSafeInteger(num)) {
  13373. return new BoxedBigInt(value);
  13374. } else {
  13375. /* istanbul ignore next */
  13376. return Object.defineProperties(new Number(num), {
  13377. isNaN: {
  13378. value: function () {
  13379. return isNaN(this);
  13380. }
  13381. },
  13382. [_type]: {
  13383. value: INTEGER
  13384. },
  13385. [_inspect]: {
  13386. value: () => `[Integer: ${value}]`
  13387. }
  13388. });
  13389. }
  13390. }
  13391. function isInteger(obj) {
  13392. if (obj === null || typeof obj !== 'object') return false;
  13393. return obj[_type] === INTEGER;
  13394. }
  13395. const FLOAT = Symbol('float');
  13396. function Float(value) {
  13397. /* istanbul ignore next */
  13398. return Object.defineProperties(new Number(value), {
  13399. [_type]: {
  13400. value: FLOAT
  13401. },
  13402. [_inspect]: {
  13403. value: () => `[Float: ${value}]`
  13404. }
  13405. });
  13406. }
  13407. function isFloat(obj) {
  13408. if (obj === null || typeof obj !== 'object') return false;
  13409. return obj[_type] === FLOAT;
  13410. }
  13411. function tomlType(value) {
  13412. const type = typeof value;
  13413. if (type === 'object') {
  13414. /* istanbul ignore if */
  13415. if (value === null) return 'null';
  13416. if (value instanceof Date) return 'datetime';
  13417. /* istanbul ignore else */
  13418. if (_type in value) {
  13419. switch (value[_type]) {
  13420. case INLINE_TABLE:
  13421. return 'inline-table';
  13422. case INLINE_LIST:
  13423. return 'inline-list';
  13424. /* istanbul ignore next */
  13425. case TABLE:
  13426. return 'table';
  13427. /* istanbul ignore next */
  13428. case LIST:
  13429. return 'list';
  13430. case FLOAT:
  13431. return 'float';
  13432. case INTEGER:
  13433. return 'integer';
  13434. }
  13435. }
  13436. }
  13437. return type;
  13438. }
  13439. function makeParserClass(Parser) {
  13440. class TOMLParser extends Parser {
  13441. constructor() {
  13442. super();
  13443. this.ctx = this.obj = Table();
  13444. }
  13445. /* MATCH HELPER */
  13446. atEndOfWord() {
  13447. return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
  13448. }
  13449. atEndOfLine() {
  13450. return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
  13451. }
  13452. parseStart() {
  13453. if (this.char === Parser.END) {
  13454. return null;
  13455. } else if (this.char === CHAR_LSQB) {
  13456. return this.call(this.parseTableOrList);
  13457. } else if (this.char === CHAR_NUM) {
  13458. return this.call(this.parseComment);
  13459. } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  13460. return null;
  13461. } else if (isAlphaNumQuoteHyphen(this.char)) {
  13462. return this.callNow(this.parseAssignStatement);
  13463. } else {
  13464. throw this.error(new TomlError(`Unknown character "${this.char}"`));
  13465. }
  13466. } // HELPER, this strips any whitespace and comments to the end of the line
  13467. // then RETURNS. Last state in a production.
  13468. parseWhitespaceToEOL() {
  13469. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  13470. return null;
  13471. } else if (this.char === CHAR_NUM) {
  13472. return this.goto(this.parseComment);
  13473. } else if (this.char === Parser.END || this.char === CTRL_J) {
  13474. return this.return();
  13475. } else {
  13476. throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
  13477. }
  13478. }
  13479. /* ASSIGNMENT: key = value */
  13480. parseAssignStatement() {
  13481. return this.callNow(this.parseAssign, this.recordAssignStatement);
  13482. }
  13483. recordAssignStatement(kv) {
  13484. let target = this.ctx;
  13485. let finalKey = kv.key.pop();
  13486. for (let kw of kv.key) {
  13487. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  13488. throw this.error(new TomlError("Can't redefine existing key"));
  13489. }
  13490. target = target[kw] = target[kw] || Table();
  13491. }
  13492. if (hasKey(target, finalKey)) {
  13493. throw this.error(new TomlError("Can't redefine existing key"));
  13494. } // unbox our numbers
  13495. if (isInteger(kv.value) || isFloat(kv.value)) {
  13496. target[finalKey] = kv.value.valueOf();
  13497. } else {
  13498. target[finalKey] = kv.value;
  13499. }
  13500. return this.goto(this.parseWhitespaceToEOL);
  13501. }
  13502. /* ASSSIGNMENT expression, key = value possibly inside an inline table */
  13503. parseAssign() {
  13504. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  13505. }
  13506. recordAssignKeyword(key) {
  13507. if (this.state.resultTable) {
  13508. this.state.resultTable.push(key);
  13509. } else {
  13510. this.state.resultTable = [key];
  13511. }
  13512. return this.goto(this.parseAssignKeywordPreDot);
  13513. }
  13514. parseAssignKeywordPreDot() {
  13515. if (this.char === CHAR_PERIOD) {
  13516. return this.next(this.parseAssignKeywordPostDot);
  13517. } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  13518. return this.goto(this.parseAssignEqual);
  13519. }
  13520. }
  13521. parseAssignKeywordPostDot() {
  13522. if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  13523. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  13524. }
  13525. }
  13526. parseAssignEqual() {
  13527. if (this.char === CHAR_EQUALS) {
  13528. return this.next(this.parseAssignPreValue);
  13529. } else {
  13530. throw this.error(new TomlError('Invalid character, expected "="'));
  13531. }
  13532. }
  13533. parseAssignPreValue() {
  13534. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13535. return null;
  13536. } else {
  13537. return this.callNow(this.parseValue, this.recordAssignValue);
  13538. }
  13539. }
  13540. recordAssignValue(value) {
  13541. return this.returnNow({
  13542. key: this.state.resultTable,
  13543. value: value
  13544. });
  13545. }
  13546. /* COMMENTS: #...eol */
  13547. parseComment() {
  13548. do {
  13549. if (this.char === Parser.END || this.char === CTRL_J) {
  13550. return this.return();
  13551. }
  13552. } while (this.nextChar());
  13553. }
  13554. /* TABLES AND LISTS, [foo] and [[foo]] */
  13555. parseTableOrList() {
  13556. if (this.char === CHAR_LSQB) {
  13557. this.next(this.parseList);
  13558. } else {
  13559. return this.goto(this.parseTable);
  13560. }
  13561. }
  13562. /* TABLE [foo.bar.baz] */
  13563. parseTable() {
  13564. this.ctx = this.obj;
  13565. return this.goto(this.parseTableNext);
  13566. }
  13567. parseTableNext() {
  13568. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13569. return null;
  13570. } else {
  13571. return this.callNow(this.parseKeyword, this.parseTableMore);
  13572. }
  13573. }
  13574. parseTableMore(keyword) {
  13575. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13576. return null;
  13577. } else if (this.char === CHAR_RSQB) {
  13578. if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
  13579. throw this.error(new TomlError("Can't redefine existing key"));
  13580. } else {
  13581. this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
  13582. this.ctx[_declared] = true;
  13583. }
  13584. return this.next(this.parseWhitespaceToEOL);
  13585. } else if (this.char === CHAR_PERIOD) {
  13586. if (!hasKey(this.ctx, keyword)) {
  13587. this.ctx = this.ctx[keyword] = Table();
  13588. } else if (isTable(this.ctx[keyword])) {
  13589. this.ctx = this.ctx[keyword];
  13590. } else if (isList(this.ctx[keyword])) {
  13591. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  13592. } else {
  13593. throw this.error(new TomlError("Can't redefine existing key"));
  13594. }
  13595. return this.next(this.parseTableNext);
  13596. } else {
  13597. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  13598. }
  13599. }
  13600. /* LIST [[a.b.c]] */
  13601. parseList() {
  13602. this.ctx = this.obj;
  13603. return this.goto(this.parseListNext);
  13604. }
  13605. parseListNext() {
  13606. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13607. return null;
  13608. } else {
  13609. return this.callNow(this.parseKeyword, this.parseListMore);
  13610. }
  13611. }
  13612. parseListMore(keyword) {
  13613. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13614. return null;
  13615. } else if (this.char === CHAR_RSQB) {
  13616. if (!hasKey(this.ctx, keyword)) {
  13617. this.ctx[keyword] = List();
  13618. }
  13619. if (isInlineList(this.ctx[keyword])) {
  13620. throw this.error(new TomlError("Can't extend an inline array"));
  13621. } else if (isList(this.ctx[keyword])) {
  13622. const next = Table();
  13623. this.ctx[keyword].push(next);
  13624. this.ctx = next;
  13625. } else {
  13626. throw this.error(new TomlError("Can't redefine an existing key"));
  13627. }
  13628. return this.next(this.parseListEnd);
  13629. } else if (this.char === CHAR_PERIOD) {
  13630. if (!hasKey(this.ctx, keyword)) {
  13631. this.ctx = this.ctx[keyword] = Table();
  13632. } else if (isInlineList(this.ctx[keyword])) {
  13633. throw this.error(new TomlError("Can't extend an inline array"));
  13634. } else if (isInlineTable(this.ctx[keyword])) {
  13635. throw this.error(new TomlError("Can't extend an inline table"));
  13636. } else if (isList(this.ctx[keyword])) {
  13637. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  13638. } else if (isTable(this.ctx[keyword])) {
  13639. this.ctx = this.ctx[keyword];
  13640. } else {
  13641. throw this.error(new TomlError("Can't redefine an existing key"));
  13642. }
  13643. return this.next(this.parseListNext);
  13644. } else {
  13645. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  13646. }
  13647. }
  13648. parseListEnd(keyword) {
  13649. if (this.char === CHAR_RSQB) {
  13650. return this.next(this.parseWhitespaceToEOL);
  13651. } else {
  13652. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  13653. }
  13654. }
  13655. /* VALUE string, number, boolean, inline list, inline object */
  13656. parseValue() {
  13657. if (this.char === Parser.END) {
  13658. throw this.error(new TomlError('Key without value'));
  13659. } else if (this.char === CHAR_QUOT) {
  13660. return this.next(this.parseDoubleString);
  13661. }
  13662. if (this.char === CHAR_APOS) {
  13663. return this.next(this.parseSingleString);
  13664. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  13665. return this.goto(this.parseNumberSign);
  13666. } else if (this.char === CHAR_i) {
  13667. return this.next(this.parseInf);
  13668. } else if (this.char === CHAR_n) {
  13669. return this.next(this.parseNan);
  13670. } else if (isDigit(this.char)) {
  13671. return this.goto(this.parseNumberOrDateTime);
  13672. } else if (this.char === CHAR_t || this.char === CHAR_f) {
  13673. return this.goto(this.parseBoolean);
  13674. } else if (this.char === CHAR_LSQB) {
  13675. return this.call(this.parseInlineList, this.recordValue);
  13676. } else if (this.char === CHAR_LCUB) {
  13677. return this.call(this.parseInlineTable, this.recordValue);
  13678. } else {
  13679. throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
  13680. }
  13681. }
  13682. recordValue(value) {
  13683. return this.returnNow(value);
  13684. }
  13685. parseInf() {
  13686. if (this.char === CHAR_n) {
  13687. return this.next(this.parseInf2);
  13688. } else {
  13689. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  13690. }
  13691. }
  13692. parseInf2() {
  13693. if (this.char === CHAR_f) {
  13694. if (this.state.buf === '-') {
  13695. return this.return(-Infinity);
  13696. } else {
  13697. return this.return(Infinity);
  13698. }
  13699. } else {
  13700. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  13701. }
  13702. }
  13703. parseNan() {
  13704. if (this.char === CHAR_a) {
  13705. return this.next(this.parseNan2);
  13706. } else {
  13707. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  13708. }
  13709. }
  13710. parseNan2() {
  13711. if (this.char === CHAR_n) {
  13712. return this.return(NaN);
  13713. } else {
  13714. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  13715. }
  13716. }
  13717. /* KEYS, barewords or basic, literal, or dotted */
  13718. parseKeyword() {
  13719. if (this.char === CHAR_QUOT) {
  13720. return this.next(this.parseBasicString);
  13721. } else if (this.char === CHAR_APOS) {
  13722. return this.next(this.parseLiteralString);
  13723. } else {
  13724. return this.goto(this.parseBareKey);
  13725. }
  13726. }
  13727. /* KEYS: barewords */
  13728. parseBareKey() {
  13729. do {
  13730. if (this.char === Parser.END) {
  13731. throw this.error(new TomlError('Key ended without value'));
  13732. } else if (isAlphaNumHyphen(this.char)) {
  13733. this.consume();
  13734. } else if (this.state.buf.length === 0) {
  13735. throw this.error(new TomlError('Empty bare keys are not allowed'));
  13736. } else {
  13737. return this.returnNow();
  13738. }
  13739. } while (this.nextChar());
  13740. }
  13741. /* STRINGS, single quoted (literal) */
  13742. parseSingleString() {
  13743. if (this.char === CHAR_APOS) {
  13744. return this.next(this.parseLiteralMultiStringMaybe);
  13745. } else {
  13746. return this.goto(this.parseLiteralString);
  13747. }
  13748. }
  13749. parseLiteralString() {
  13750. do {
  13751. if (this.char === CHAR_APOS) {
  13752. return this.return();
  13753. } else if (this.atEndOfLine()) {
  13754. throw this.error(new TomlError('Unterminated string'));
  13755. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  13756. throw this.errorControlCharInString();
  13757. } else {
  13758. this.consume();
  13759. }
  13760. } while (this.nextChar());
  13761. }
  13762. parseLiteralMultiStringMaybe() {
  13763. if (this.char === CHAR_APOS) {
  13764. return this.next(this.parseLiteralMultiString);
  13765. } else {
  13766. return this.returnNow();
  13767. }
  13768. }
  13769. parseLiteralMultiString() {
  13770. if (this.char === CTRL_M) {
  13771. return null;
  13772. } else if (this.char === CTRL_J) {
  13773. return this.next(this.parseLiteralMultiStringContent);
  13774. } else {
  13775. return this.goto(this.parseLiteralMultiStringContent);
  13776. }
  13777. }
  13778. parseLiteralMultiStringContent() {
  13779. do {
  13780. if (this.char === CHAR_APOS) {
  13781. return this.next(this.parseLiteralMultiEnd);
  13782. } else if (this.char === Parser.END) {
  13783. throw this.error(new TomlError('Unterminated multi-line string'));
  13784. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  13785. throw this.errorControlCharInString();
  13786. } else {
  13787. this.consume();
  13788. }
  13789. } while (this.nextChar());
  13790. }
  13791. parseLiteralMultiEnd() {
  13792. if (this.char === CHAR_APOS) {
  13793. return this.next(this.parseLiteralMultiEnd2);
  13794. } else {
  13795. this.state.buf += "'";
  13796. return this.goto(this.parseLiteralMultiStringContent);
  13797. }
  13798. }
  13799. parseLiteralMultiEnd2() {
  13800. if (this.char === CHAR_APOS) {
  13801. return this.return();
  13802. } else {
  13803. this.state.buf += "''";
  13804. return this.goto(this.parseLiteralMultiStringContent);
  13805. }
  13806. }
  13807. /* STRINGS double quoted */
  13808. parseDoubleString() {
  13809. if (this.char === CHAR_QUOT) {
  13810. return this.next(this.parseMultiStringMaybe);
  13811. } else {
  13812. return this.goto(this.parseBasicString);
  13813. }
  13814. }
  13815. parseBasicString() {
  13816. do {
  13817. if (this.char === CHAR_BSOL) {
  13818. return this.call(this.parseEscape, this.recordEscapeReplacement);
  13819. } else if (this.char === CHAR_QUOT) {
  13820. return this.return();
  13821. } else if (this.atEndOfLine()) {
  13822. throw this.error(new TomlError('Unterminated string'));
  13823. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  13824. throw this.errorControlCharInString();
  13825. } else {
  13826. this.consume();
  13827. }
  13828. } while (this.nextChar());
  13829. }
  13830. recordEscapeReplacement(replacement) {
  13831. this.state.buf += replacement;
  13832. return this.goto(this.parseBasicString);
  13833. }
  13834. parseMultiStringMaybe() {
  13835. if (this.char === CHAR_QUOT) {
  13836. return this.next(this.parseMultiString);
  13837. } else {
  13838. return this.returnNow();
  13839. }
  13840. }
  13841. parseMultiString() {
  13842. if (this.char === CTRL_M) {
  13843. return null;
  13844. } else if (this.char === CTRL_J) {
  13845. return this.next(this.parseMultiStringContent);
  13846. } else {
  13847. return this.goto(this.parseMultiStringContent);
  13848. }
  13849. }
  13850. parseMultiStringContent() {
  13851. do {
  13852. if (this.char === CHAR_BSOL) {
  13853. return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
  13854. } else if (this.char === CHAR_QUOT) {
  13855. return this.next(this.parseMultiEnd);
  13856. } else if (this.char === Parser.END) {
  13857. throw this.error(new TomlError('Unterminated multi-line string'));
  13858. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  13859. throw this.errorControlCharInString();
  13860. } else {
  13861. this.consume();
  13862. }
  13863. } while (this.nextChar());
  13864. }
  13865. errorControlCharInString() {
  13866. let displayCode = '\\u00';
  13867. if (this.char < 16) {
  13868. displayCode += '0';
  13869. }
  13870. displayCode += this.char.toString(16);
  13871. return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
  13872. }
  13873. recordMultiEscapeReplacement(replacement) {
  13874. this.state.buf += replacement;
  13875. return this.goto(this.parseMultiStringContent);
  13876. }
  13877. parseMultiEnd() {
  13878. if (this.char === CHAR_QUOT) {
  13879. return this.next(this.parseMultiEnd2);
  13880. } else {
  13881. this.state.buf += '"';
  13882. return this.goto(this.parseMultiStringContent);
  13883. }
  13884. }
  13885. parseMultiEnd2() {
  13886. if (this.char === CHAR_QUOT) {
  13887. return this.return();
  13888. } else {
  13889. this.state.buf += '""';
  13890. return this.goto(this.parseMultiStringContent);
  13891. }
  13892. }
  13893. parseMultiEscape() {
  13894. if (this.char === CTRL_M || this.char === CTRL_J) {
  13895. return this.next(this.parseMultiTrim);
  13896. } else if (this.char === CHAR_SP || this.char === CTRL_I) {
  13897. return this.next(this.parsePreMultiTrim);
  13898. } else {
  13899. return this.goto(this.parseEscape);
  13900. }
  13901. }
  13902. parsePreMultiTrim() {
  13903. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13904. return null;
  13905. } else if (this.char === CTRL_M || this.char === CTRL_J) {
  13906. return this.next(this.parseMultiTrim);
  13907. } else {
  13908. throw this.error(new TomlError("Can't escape whitespace"));
  13909. }
  13910. }
  13911. parseMultiTrim() {
  13912. // explicitly whitespace here, END should follow the same path as chars
  13913. if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  13914. return null;
  13915. } else {
  13916. return this.returnNow();
  13917. }
  13918. }
  13919. parseEscape() {
  13920. if (this.char in escapes) {
  13921. return this.return(escapes[this.char]);
  13922. } else if (this.char === CHAR_u) {
  13923. return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
  13924. } else if (this.char === CHAR_U) {
  13925. return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
  13926. } else {
  13927. throw this.error(new TomlError('Unknown escape character: ' + this.char));
  13928. }
  13929. }
  13930. parseUnicodeReturn(char) {
  13931. try {
  13932. const codePoint = parseInt(char, 16);
  13933. if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
  13934. throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
  13935. }
  13936. return this.returnNow(String.fromCodePoint(codePoint));
  13937. } catch (err) {
  13938. throw this.error(TomlError.wrap(err));
  13939. }
  13940. }
  13941. parseSmallUnicode() {
  13942. if (!isHexit(this.char)) {
  13943. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  13944. } else {
  13945. this.consume();
  13946. if (this.state.buf.length >= 4) return this.return();
  13947. }
  13948. }
  13949. parseLargeUnicode() {
  13950. if (!isHexit(this.char)) {
  13951. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  13952. } else {
  13953. this.consume();
  13954. if (this.state.buf.length >= 8) return this.return();
  13955. }
  13956. }
  13957. /* NUMBERS */
  13958. parseNumberSign() {
  13959. this.consume();
  13960. return this.next(this.parseMaybeSignedInfOrNan);
  13961. }
  13962. parseMaybeSignedInfOrNan() {
  13963. if (this.char === CHAR_i) {
  13964. return this.next(this.parseInf);
  13965. } else if (this.char === CHAR_n) {
  13966. return this.next(this.parseNan);
  13967. } else {
  13968. return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
  13969. }
  13970. }
  13971. parseNumberIntegerStart() {
  13972. if (this.char === CHAR_0) {
  13973. this.consume();
  13974. return this.next(this.parseNumberIntegerExponentOrDecimal);
  13975. } else {
  13976. return this.goto(this.parseNumberInteger);
  13977. }
  13978. }
  13979. parseNumberIntegerExponentOrDecimal() {
  13980. if (this.char === CHAR_PERIOD) {
  13981. this.consume();
  13982. return this.call(this.parseNoUnder, this.parseNumberFloat);
  13983. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  13984. this.consume();
  13985. return this.next(this.parseNumberExponentSign);
  13986. } else {
  13987. return this.returnNow(Integer(this.state.buf));
  13988. }
  13989. }
  13990. parseNumberInteger() {
  13991. if (isDigit(this.char)) {
  13992. this.consume();
  13993. } else if (this.char === CHAR_LOWBAR) {
  13994. return this.call(this.parseNoUnder);
  13995. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  13996. this.consume();
  13997. return this.next(this.parseNumberExponentSign);
  13998. } else if (this.char === CHAR_PERIOD) {
  13999. this.consume();
  14000. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14001. } else {
  14002. const result = Integer(this.state.buf);
  14003. /* istanbul ignore if */
  14004. if (result.isNaN()) {
  14005. throw this.error(new TomlError('Invalid number'));
  14006. } else {
  14007. return this.returnNow(result);
  14008. }
  14009. }
  14010. }
  14011. parseNoUnder() {
  14012. if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
  14013. throw this.error(new TomlError('Unexpected character, expected digit'));
  14014. } else if (this.atEndOfWord()) {
  14015. throw this.error(new TomlError('Incomplete number'));
  14016. }
  14017. return this.returnNow();
  14018. }
  14019. parseNoUnderHexOctBinLiteral() {
  14020. if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) {
  14021. throw this.error(new TomlError('Unexpected character, expected digit'));
  14022. } else if (this.atEndOfWord()) {
  14023. throw this.error(new TomlError('Incomplete number'));
  14024. }
  14025. return this.returnNow();
  14026. }
  14027. parseNumberFloat() {
  14028. if (this.char === CHAR_LOWBAR) {
  14029. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14030. } else if (isDigit(this.char)) {
  14031. this.consume();
  14032. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14033. this.consume();
  14034. return this.next(this.parseNumberExponentSign);
  14035. } else {
  14036. return this.returnNow(Float(this.state.buf));
  14037. }
  14038. }
  14039. parseNumberExponentSign() {
  14040. if (isDigit(this.char)) {
  14041. return this.goto(this.parseNumberExponent);
  14042. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14043. this.consume();
  14044. this.call(this.parseNoUnder, this.parseNumberExponent);
  14045. } else {
  14046. throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
  14047. }
  14048. }
  14049. parseNumberExponent() {
  14050. if (isDigit(this.char)) {
  14051. this.consume();
  14052. } else if (this.char === CHAR_LOWBAR) {
  14053. return this.call(this.parseNoUnder);
  14054. } else {
  14055. return this.returnNow(Float(this.state.buf));
  14056. }
  14057. }
  14058. /* NUMBERS or DATETIMES */
  14059. parseNumberOrDateTime() {
  14060. if (this.char === CHAR_0) {
  14061. this.consume();
  14062. return this.next(this.parseNumberBaseOrDateTime);
  14063. } else {
  14064. return this.goto(this.parseNumberOrDateTimeOnly);
  14065. }
  14066. }
  14067. parseNumberOrDateTimeOnly() {
  14068. // note, if two zeros are in a row then it MUST be a date
  14069. if (this.char === CHAR_LOWBAR) {
  14070. return this.call(this.parseNoUnder, this.parseNumberInteger);
  14071. } else if (isDigit(this.char)) {
  14072. this.consume();
  14073. if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
  14074. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14075. this.consume();
  14076. return this.next(this.parseNumberExponentSign);
  14077. } else if (this.char === CHAR_PERIOD) {
  14078. this.consume();
  14079. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14080. } else if (this.char === CHAR_HYPHEN) {
  14081. return this.goto(this.parseDateTime);
  14082. } else if (this.char === CHAR_COLON) {
  14083. return this.goto(this.parseOnlyTimeHour);
  14084. } else {
  14085. return this.returnNow(Integer(this.state.buf));
  14086. }
  14087. }
  14088. parseDateTimeOnly() {
  14089. if (this.state.buf.length < 4) {
  14090. if (isDigit(this.char)) {
  14091. return this.consume();
  14092. } else if (this.char === CHAR_COLON) {
  14093. return this.goto(this.parseOnlyTimeHour);
  14094. } else {
  14095. throw this.error(new TomlError('Expected digit while parsing year part of a date'));
  14096. }
  14097. } else {
  14098. if (this.char === CHAR_HYPHEN) {
  14099. return this.goto(this.parseDateTime);
  14100. } else {
  14101. throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
  14102. }
  14103. }
  14104. }
  14105. parseNumberBaseOrDateTime() {
  14106. if (this.char === CHAR_b) {
  14107. this.consume();
  14108. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin);
  14109. } else if (this.char === CHAR_o) {
  14110. this.consume();
  14111. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct);
  14112. } else if (this.char === CHAR_x) {
  14113. this.consume();
  14114. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex);
  14115. } else if (this.char === CHAR_PERIOD) {
  14116. return this.goto(this.parseNumberInteger);
  14117. } else if (isDigit(this.char)) {
  14118. return this.goto(this.parseDateTimeOnly);
  14119. } else {
  14120. return this.returnNow(Integer(this.state.buf));
  14121. }
  14122. }
  14123. parseIntegerHex() {
  14124. if (isHexit(this.char)) {
  14125. this.consume();
  14126. } else if (this.char === CHAR_LOWBAR) {
  14127. return this.call(this.parseNoUnderHexOctBinLiteral);
  14128. } else {
  14129. const result = Integer(this.state.buf);
  14130. /* istanbul ignore if */
  14131. if (result.isNaN()) {
  14132. throw this.error(new TomlError('Invalid number'));
  14133. } else {
  14134. return this.returnNow(result);
  14135. }
  14136. }
  14137. }
  14138. parseIntegerOct() {
  14139. if (isOctit(this.char)) {
  14140. this.consume();
  14141. } else if (this.char === CHAR_LOWBAR) {
  14142. return this.call(this.parseNoUnderHexOctBinLiteral);
  14143. } else {
  14144. const result = Integer(this.state.buf);
  14145. /* istanbul ignore if */
  14146. if (result.isNaN()) {
  14147. throw this.error(new TomlError('Invalid number'));
  14148. } else {
  14149. return this.returnNow(result);
  14150. }
  14151. }
  14152. }
  14153. parseIntegerBin() {
  14154. if (isBit(this.char)) {
  14155. this.consume();
  14156. } else if (this.char === CHAR_LOWBAR) {
  14157. return this.call(this.parseNoUnderHexOctBinLiteral);
  14158. } else {
  14159. const result = Integer(this.state.buf);
  14160. /* istanbul ignore if */
  14161. if (result.isNaN()) {
  14162. throw this.error(new TomlError('Invalid number'));
  14163. } else {
  14164. return this.returnNow(result);
  14165. }
  14166. }
  14167. }
  14168. /* DATETIME */
  14169. parseDateTime() {
  14170. // we enter here having just consumed the year and about to consume the hyphen
  14171. if (this.state.buf.length < 4) {
  14172. throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
  14173. }
  14174. this.state.result = this.state.buf;
  14175. this.state.buf = '';
  14176. return this.next(this.parseDateMonth);
  14177. }
  14178. parseDateMonth() {
  14179. if (this.char === CHAR_HYPHEN) {
  14180. if (this.state.buf.length < 2) {
  14181. throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
  14182. }
  14183. this.state.result += '-' + this.state.buf;
  14184. this.state.buf = '';
  14185. return this.next(this.parseDateDay);
  14186. } else if (isDigit(this.char)) {
  14187. this.consume();
  14188. } else {
  14189. throw this.error(new TomlError('Incomplete datetime'));
  14190. }
  14191. }
  14192. parseDateDay() {
  14193. if (this.char === CHAR_T || this.char === CHAR_SP) {
  14194. if (this.state.buf.length < 2) {
  14195. throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
  14196. }
  14197. this.state.result += '-' + this.state.buf;
  14198. this.state.buf = '';
  14199. return this.next(this.parseStartTimeHour);
  14200. } else if (this.atEndOfWord()) {
  14201. return this.returnNow(createDate(this.state.result + '-' + this.state.buf));
  14202. } else if (isDigit(this.char)) {
  14203. this.consume();
  14204. } else {
  14205. throw this.error(new TomlError('Incomplete datetime'));
  14206. }
  14207. }
  14208. parseStartTimeHour() {
  14209. if (this.atEndOfWord()) {
  14210. return this.returnNow(createDate(this.state.result));
  14211. } else {
  14212. return this.goto(this.parseTimeHour);
  14213. }
  14214. }
  14215. parseTimeHour() {
  14216. if (this.char === CHAR_COLON) {
  14217. if (this.state.buf.length < 2) {
  14218. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  14219. }
  14220. this.state.result += 'T' + this.state.buf;
  14221. this.state.buf = '';
  14222. return this.next(this.parseTimeMin);
  14223. } else if (isDigit(this.char)) {
  14224. this.consume();
  14225. } else {
  14226. throw this.error(new TomlError('Incomplete datetime'));
  14227. }
  14228. }
  14229. parseTimeMin() {
  14230. if (this.state.buf.length < 2 && isDigit(this.char)) {
  14231. this.consume();
  14232. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  14233. this.state.result += ':' + this.state.buf;
  14234. this.state.buf = '';
  14235. return this.next(this.parseTimeSec);
  14236. } else {
  14237. throw this.error(new TomlError('Incomplete datetime'));
  14238. }
  14239. }
  14240. parseTimeSec() {
  14241. if (isDigit(this.char)) {
  14242. this.consume();
  14243. if (this.state.buf.length === 2) {
  14244. this.state.result += ':' + this.state.buf;
  14245. this.state.buf = '';
  14246. return this.next(this.parseTimeZoneOrFraction);
  14247. }
  14248. } else {
  14249. throw this.error(new TomlError('Incomplete datetime'));
  14250. }
  14251. }
  14252. parseOnlyTimeHour() {
  14253. /* istanbul ignore else */
  14254. if (this.char === CHAR_COLON) {
  14255. if (this.state.buf.length < 2) {
  14256. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  14257. }
  14258. this.state.result = this.state.buf;
  14259. this.state.buf = '';
  14260. return this.next(this.parseOnlyTimeMin);
  14261. } else {
  14262. throw this.error(new TomlError('Incomplete time'));
  14263. }
  14264. }
  14265. parseOnlyTimeMin() {
  14266. if (this.state.buf.length < 2 && isDigit(this.char)) {
  14267. this.consume();
  14268. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  14269. this.state.result += ':' + this.state.buf;
  14270. this.state.buf = '';
  14271. return this.next(this.parseOnlyTimeSec);
  14272. } else {
  14273. throw this.error(new TomlError('Incomplete time'));
  14274. }
  14275. }
  14276. parseOnlyTimeSec() {
  14277. if (isDigit(this.char)) {
  14278. this.consume();
  14279. if (this.state.buf.length === 2) {
  14280. return this.next(this.parseOnlyTimeFractionMaybe);
  14281. }
  14282. } else {
  14283. throw this.error(new TomlError('Incomplete time'));
  14284. }
  14285. }
  14286. parseOnlyTimeFractionMaybe() {
  14287. this.state.result += ':' + this.state.buf;
  14288. if (this.char === CHAR_PERIOD) {
  14289. this.state.buf = '';
  14290. this.next(this.parseOnlyTimeFraction);
  14291. } else {
  14292. return this.return(createTime(this.state.result));
  14293. }
  14294. }
  14295. parseOnlyTimeFraction() {
  14296. if (isDigit(this.char)) {
  14297. this.consume();
  14298. } else if (this.atEndOfWord()) {
  14299. if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
  14300. return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
  14301. } else {
  14302. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14303. }
  14304. }
  14305. parseTimeZoneOrFraction() {
  14306. if (this.char === CHAR_PERIOD) {
  14307. this.consume();
  14308. this.next(this.parseDateTimeFraction);
  14309. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14310. this.consume();
  14311. this.next(this.parseTimeZoneHour);
  14312. } else if (this.char === CHAR_Z) {
  14313. this.consume();
  14314. return this.return(createDatetime(this.state.result + this.state.buf));
  14315. } else if (this.atEndOfWord()) {
  14316. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  14317. } else {
  14318. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14319. }
  14320. }
  14321. parseDateTimeFraction() {
  14322. if (isDigit(this.char)) {
  14323. this.consume();
  14324. } else if (this.state.buf.length === 1) {
  14325. throw this.error(new TomlError('Expected digit in milliseconds'));
  14326. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14327. this.consume();
  14328. this.next(this.parseTimeZoneHour);
  14329. } else if (this.char === CHAR_Z) {
  14330. this.consume();
  14331. return this.return(createDatetime(this.state.result + this.state.buf));
  14332. } else if (this.atEndOfWord()) {
  14333. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  14334. } else {
  14335. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14336. }
  14337. }
  14338. parseTimeZoneHour() {
  14339. if (isDigit(this.char)) {
  14340. this.consume(); // FIXME: No more regexps
  14341. if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
  14342. } else {
  14343. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  14344. }
  14345. }
  14346. parseTimeZoneSep() {
  14347. if (this.char === CHAR_COLON) {
  14348. this.consume();
  14349. this.next(this.parseTimeZoneMin);
  14350. } else {
  14351. throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
  14352. }
  14353. }
  14354. parseTimeZoneMin() {
  14355. if (isDigit(this.char)) {
  14356. this.consume();
  14357. if (/\d\d$/.test(this.state.buf)) return this.return(createDatetime(this.state.result + this.state.buf));
  14358. } else {
  14359. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  14360. }
  14361. }
  14362. /* BOOLEAN */
  14363. parseBoolean() {
  14364. /* istanbul ignore else */
  14365. if (this.char === CHAR_t) {
  14366. this.consume();
  14367. return this.next(this.parseTrue_r);
  14368. } else if (this.char === CHAR_f) {
  14369. this.consume();
  14370. return this.next(this.parseFalse_a);
  14371. }
  14372. }
  14373. parseTrue_r() {
  14374. if (this.char === CHAR_r) {
  14375. this.consume();
  14376. return this.next(this.parseTrue_u);
  14377. } else {
  14378. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14379. }
  14380. }
  14381. parseTrue_u() {
  14382. if (this.char === CHAR_u) {
  14383. this.consume();
  14384. return this.next(this.parseTrue_e);
  14385. } else {
  14386. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14387. }
  14388. }
  14389. parseTrue_e() {
  14390. if (this.char === CHAR_e) {
  14391. return this.return(true);
  14392. } else {
  14393. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14394. }
  14395. }
  14396. parseFalse_a() {
  14397. if (this.char === CHAR_a) {
  14398. this.consume();
  14399. return this.next(this.parseFalse_l);
  14400. } else {
  14401. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14402. }
  14403. }
  14404. parseFalse_l() {
  14405. if (this.char === CHAR_l) {
  14406. this.consume();
  14407. return this.next(this.parseFalse_s);
  14408. } else {
  14409. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14410. }
  14411. }
  14412. parseFalse_s() {
  14413. if (this.char === CHAR_s) {
  14414. this.consume();
  14415. return this.next(this.parseFalse_e);
  14416. } else {
  14417. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14418. }
  14419. }
  14420. parseFalse_e() {
  14421. if (this.char === CHAR_e) {
  14422. return this.return(false);
  14423. } else {
  14424. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14425. }
  14426. }
  14427. /* INLINE LISTS */
  14428. parseInlineList() {
  14429. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  14430. return null;
  14431. } else if (this.char === Parser.END) {
  14432. throw this.error(new TomlError('Unterminated inline array'));
  14433. } else if (this.char === CHAR_NUM) {
  14434. return this.call(this.parseComment);
  14435. } else if (this.char === CHAR_RSQB) {
  14436. return this.return(this.state.resultArr || InlineList());
  14437. } else {
  14438. return this.callNow(this.parseValue, this.recordInlineListValue);
  14439. }
  14440. }
  14441. recordInlineListValue(value) {
  14442. if (this.state.resultArr) {
  14443. const listType = this.state.resultArr[_contentType];
  14444. const valueType = tomlType(value);
  14445. if (listType !== valueType) {
  14446. throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
  14447. }
  14448. } else {
  14449. this.state.resultArr = InlineList(tomlType(value));
  14450. }
  14451. if (isFloat(value) || isInteger(value)) {
  14452. // unbox now that we've verified they're ok
  14453. this.state.resultArr.push(value.valueOf());
  14454. } else {
  14455. this.state.resultArr.push(value);
  14456. }
  14457. return this.goto(this.parseInlineListNext);
  14458. }
  14459. parseInlineListNext() {
  14460. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  14461. return null;
  14462. } else if (this.char === CHAR_NUM) {
  14463. return this.call(this.parseComment);
  14464. } else if (this.char === CHAR_COMMA$2) {
  14465. return this.next(this.parseInlineList);
  14466. } else if (this.char === CHAR_RSQB) {
  14467. return this.goto(this.parseInlineList);
  14468. } else {
  14469. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  14470. }
  14471. }
  14472. /* INLINE TABLE */
  14473. parseInlineTable() {
  14474. if (this.char === CHAR_SP || this.char === CTRL_I) {
  14475. return null;
  14476. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  14477. throw this.error(new TomlError('Unterminated inline array'));
  14478. } else if (this.char === CHAR_RCUB) {
  14479. return this.return(this.state.resultTable || InlineTable());
  14480. } else {
  14481. if (!this.state.resultTable) this.state.resultTable = InlineTable();
  14482. return this.callNow(this.parseAssign, this.recordInlineTableValue);
  14483. }
  14484. }
  14485. recordInlineTableValue(kv) {
  14486. let target = this.state.resultTable;
  14487. let finalKey = kv.key.pop();
  14488. for (let kw of kv.key) {
  14489. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  14490. throw this.error(new TomlError("Can't redefine existing key"));
  14491. }
  14492. target = target[kw] = target[kw] || Table();
  14493. }
  14494. if (hasKey(target, finalKey)) {
  14495. throw this.error(new TomlError("Can't redefine existing key"));
  14496. }
  14497. if (isInteger(kv.value) || isFloat(kv.value)) {
  14498. target[finalKey] = kv.value.valueOf();
  14499. } else {
  14500. target[finalKey] = kv.value;
  14501. }
  14502. return this.goto(this.parseInlineTableNext);
  14503. }
  14504. parseInlineTableNext() {
  14505. if (this.char === CHAR_SP || this.char === CTRL_I) {
  14506. return null;
  14507. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  14508. throw this.error(new TomlError('Unterminated inline array'));
  14509. } else if (this.char === CHAR_COMMA$2) {
  14510. return this.next(this.parseInlineTable);
  14511. } else if (this.char === CHAR_RCUB) {
  14512. return this.goto(this.parseInlineTable);
  14513. } else {
  14514. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  14515. }
  14516. }
  14517. }
  14518. return TOMLParser;
  14519. }
  14520. tomlParser.makeParserClass = makeParserClass_1;
  14521. tomlParser.TomlError = TomlError_1;
  14522. var parsePrettyError = prettyError;
  14523. function prettyError(err, buf) {
  14524. /* istanbul ignore if */
  14525. if (err.pos == null || err.line == null) return err;
  14526. let msg = err.message;
  14527. msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
  14528. /* istanbul ignore else */
  14529. if (buf && buf.split) {
  14530. const lines = buf.split(/\n/);
  14531. const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
  14532. let linePadding = ' ';
  14533. while (linePadding.length < lineNumWidth) linePadding += ' ';
  14534. for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
  14535. let lineNum = String(ii + 1);
  14536. if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
  14537. if (err.line === ii) {
  14538. msg += lineNum + '> ' + lines[ii] + '\n';
  14539. msg += linePadding + ' ';
  14540. for (let hh = 0; hh < err.col; ++hh) {
  14541. msg += ' ';
  14542. }
  14543. msg += '^\n';
  14544. } else {
  14545. msg += lineNum + ': ' + lines[ii] + '\n';
  14546. }
  14547. }
  14548. }
  14549. err.message = msg + '\n';
  14550. return err;
  14551. }
  14552. var parseString_1$1 = parseString$2;
  14553. function parseString$2(str) {
  14554. if (global.Buffer && global.Buffer.isBuffer(str)) {
  14555. str = str.toString('utf8');
  14556. }
  14557. const parser = new tomlParser();
  14558. try {
  14559. parser.parse(str);
  14560. return parser.finish();
  14561. } catch (err) {
  14562. throw parsePrettyError(err, str);
  14563. }
  14564. }
  14565. var loadToml = function (filePath, content) {
  14566. try {
  14567. return parseString_1$1(content);
  14568. } catch (error) {
  14569. error.message = `TOML Error in ${filePath}:\n${error.message}`;
  14570. throw error;
  14571. }
  14572. };
  14573. // This is a generated file. Do not edit.
  14574. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  14575. var ID_Start = /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
  14576. var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\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\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
  14577. var unicode = {
  14578. Space_Separator: Space_Separator,
  14579. ID_Start: ID_Start,
  14580. ID_Continue: ID_Continue
  14581. };
  14582. var util$3 = {
  14583. isSpaceSeparator(c) {
  14584. return typeof c === 'string' && unicode.Space_Separator.test(c);
  14585. },
  14586. isIdStartChar(c) {
  14587. return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c === '$' || c === '_' || unicode.ID_Start.test(c));
  14588. },
  14589. isIdContinueChar(c) {
  14590. return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '$' || c === '_' || c === '\u200C' || c === '\u200D' || unicode.ID_Continue.test(c));
  14591. },
  14592. isDigit(c) {
  14593. return typeof c === 'string' && /[0-9]/.test(c);
  14594. },
  14595. isHexDigit(c) {
  14596. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c);
  14597. }
  14598. };
  14599. let source$1;
  14600. let parseState;
  14601. let stack;
  14602. let pos;
  14603. let line$z;
  14604. let column;
  14605. let token;
  14606. let key;
  14607. let root$1;
  14608. var parse$8 = function parse(text, reviver) {
  14609. source$1 = String(text);
  14610. parseState = 'start';
  14611. stack = [];
  14612. pos = 0;
  14613. line$z = 1;
  14614. column = 0;
  14615. token = undefined;
  14616. key = undefined;
  14617. root$1 = undefined;
  14618. do {
  14619. token = lex(); // This code is unreachable.
  14620. // if (!parseStates[parseState]) {
  14621. // throw invalidParseState()
  14622. // }
  14623. parseStates[parseState]();
  14624. } while (token.type !== 'eof');
  14625. if (typeof reviver === 'function') {
  14626. return internalize({
  14627. '': root$1
  14628. }, '', reviver);
  14629. }
  14630. return root$1;
  14631. };
  14632. function internalize(holder, name, reviver) {
  14633. const value = holder[name];
  14634. if (value != null && typeof value === 'object') {
  14635. for (const key in value) {
  14636. const replacement = internalize(value, key, reviver);
  14637. if (replacement === undefined) {
  14638. delete value[key];
  14639. } else {
  14640. value[key] = replacement;
  14641. }
  14642. }
  14643. }
  14644. return reviver.call(holder, name, value);
  14645. }
  14646. let lexState;
  14647. let buffer$2;
  14648. let doubleQuote;
  14649. let sign;
  14650. let c;
  14651. function lex() {
  14652. lexState = 'default';
  14653. buffer$2 = '';
  14654. doubleQuote = false;
  14655. sign = 1;
  14656. for (;;) {
  14657. c = peek(); // This code is unreachable.
  14658. // if (!lexStates[lexState]) {
  14659. // throw invalidLexState(lexState)
  14660. // }
  14661. const token = lexStates[lexState]();
  14662. if (token) {
  14663. return token;
  14664. }
  14665. }
  14666. }
  14667. function peek() {
  14668. if (source$1[pos]) {
  14669. return String.fromCodePoint(source$1.codePointAt(pos));
  14670. }
  14671. }
  14672. function read() {
  14673. const c = peek();
  14674. if (c === '\n') {
  14675. line$z++;
  14676. column = 0;
  14677. } else if (c) {
  14678. column += c.length;
  14679. } else {
  14680. column++;
  14681. }
  14682. if (c) {
  14683. pos += c.length;
  14684. }
  14685. return c;
  14686. }
  14687. const lexStates = {
  14688. default() {
  14689. switch (c) {
  14690. case '\t':
  14691. case '\v':
  14692. case '\f':
  14693. case ' ':
  14694. case '\u00A0':
  14695. case '\uFEFF':
  14696. case '\n':
  14697. case '\r':
  14698. case '\u2028':
  14699. case '\u2029':
  14700. read();
  14701. return;
  14702. case '/':
  14703. read();
  14704. lexState = 'comment';
  14705. return;
  14706. case undefined:
  14707. read();
  14708. return newToken('eof');
  14709. }
  14710. if (util$3.isSpaceSeparator(c)) {
  14711. read();
  14712. return;
  14713. } // This code is unreachable.
  14714. // if (!lexStates[parseState]) {
  14715. // throw invalidLexState(parseState)
  14716. // }
  14717. return lexStates[parseState]();
  14718. },
  14719. comment() {
  14720. switch (c) {
  14721. case '*':
  14722. read();
  14723. lexState = 'multiLineComment';
  14724. return;
  14725. case '/':
  14726. read();
  14727. lexState = 'singleLineComment';
  14728. return;
  14729. }
  14730. throw invalidChar(read());
  14731. },
  14732. multiLineComment() {
  14733. switch (c) {
  14734. case '*':
  14735. read();
  14736. lexState = 'multiLineCommentAsterisk';
  14737. return;
  14738. case undefined:
  14739. throw invalidChar(read());
  14740. }
  14741. read();
  14742. },
  14743. multiLineCommentAsterisk() {
  14744. switch (c) {
  14745. case '*':
  14746. read();
  14747. return;
  14748. case '/':
  14749. read();
  14750. lexState = 'default';
  14751. return;
  14752. case undefined:
  14753. throw invalidChar(read());
  14754. }
  14755. read();
  14756. lexState = 'multiLineComment';
  14757. },
  14758. singleLineComment() {
  14759. switch (c) {
  14760. case '\n':
  14761. case '\r':
  14762. case '\u2028':
  14763. case '\u2029':
  14764. read();
  14765. lexState = 'default';
  14766. return;
  14767. case undefined:
  14768. read();
  14769. return newToken('eof');
  14770. }
  14771. read();
  14772. },
  14773. value() {
  14774. switch (c) {
  14775. case '{':
  14776. case '[':
  14777. return newToken('punctuator', read());
  14778. case 'n':
  14779. read();
  14780. literal$1('ull');
  14781. return newToken('null', null);
  14782. case 't':
  14783. read();
  14784. literal$1('rue');
  14785. return newToken('boolean', true);
  14786. case 'f':
  14787. read();
  14788. literal$1('alse');
  14789. return newToken('boolean', false);
  14790. case '-':
  14791. case '+':
  14792. if (read() === '-') {
  14793. sign = -1;
  14794. }
  14795. lexState = 'sign';
  14796. return;
  14797. case '.':
  14798. buffer$2 = read();
  14799. lexState = 'decimalPointLeading';
  14800. return;
  14801. case '0':
  14802. buffer$2 = read();
  14803. lexState = 'zero';
  14804. return;
  14805. case '1':
  14806. case '2':
  14807. case '3':
  14808. case '4':
  14809. case '5':
  14810. case '6':
  14811. case '7':
  14812. case '8':
  14813. case '9':
  14814. buffer$2 = read();
  14815. lexState = 'decimalInteger';
  14816. return;
  14817. case 'I':
  14818. read();
  14819. literal$1('nfinity');
  14820. return newToken('numeric', Infinity);
  14821. case 'N':
  14822. read();
  14823. literal$1('aN');
  14824. return newToken('numeric', NaN);
  14825. case '"':
  14826. case "'":
  14827. doubleQuote = read() === '"';
  14828. buffer$2 = '';
  14829. lexState = 'string';
  14830. return;
  14831. }
  14832. throw invalidChar(read());
  14833. },
  14834. identifierNameStartEscape() {
  14835. if (c !== 'u') {
  14836. throw invalidChar(read());
  14837. }
  14838. read();
  14839. const u = unicodeEscape();
  14840. switch (u) {
  14841. case '$':
  14842. case '_':
  14843. break;
  14844. default:
  14845. if (!util$3.isIdStartChar(u)) {
  14846. throw invalidIdentifier();
  14847. }
  14848. break;
  14849. }
  14850. buffer$2 += u;
  14851. lexState = 'identifierName';
  14852. },
  14853. identifierName() {
  14854. switch (c) {
  14855. case '$':
  14856. case '_':
  14857. case '\u200C':
  14858. case '\u200D':
  14859. buffer$2 += read();
  14860. return;
  14861. case '\\':
  14862. read();
  14863. lexState = 'identifierNameEscape';
  14864. return;
  14865. }
  14866. if (util$3.isIdContinueChar(c)) {
  14867. buffer$2 += read();
  14868. return;
  14869. }
  14870. return newToken('identifier', buffer$2);
  14871. },
  14872. identifierNameEscape() {
  14873. if (c !== 'u') {
  14874. throw invalidChar(read());
  14875. }
  14876. read();
  14877. const u = unicodeEscape();
  14878. switch (u) {
  14879. case '$':
  14880. case '_':
  14881. case '\u200C':
  14882. case '\u200D':
  14883. break;
  14884. default:
  14885. if (!util$3.isIdContinueChar(u)) {
  14886. throw invalidIdentifier();
  14887. }
  14888. break;
  14889. }
  14890. buffer$2 += u;
  14891. lexState = 'identifierName';
  14892. },
  14893. sign() {
  14894. switch (c) {
  14895. case '.':
  14896. buffer$2 = read();
  14897. lexState = 'decimalPointLeading';
  14898. return;
  14899. case '0':
  14900. buffer$2 = read();
  14901. lexState = 'zero';
  14902. return;
  14903. case '1':
  14904. case '2':
  14905. case '3':
  14906. case '4':
  14907. case '5':
  14908. case '6':
  14909. case '7':
  14910. case '8':
  14911. case '9':
  14912. buffer$2 = read();
  14913. lexState = 'decimalInteger';
  14914. return;
  14915. case 'I':
  14916. read();
  14917. literal$1('nfinity');
  14918. return newToken('numeric', sign * Infinity);
  14919. case 'N':
  14920. read();
  14921. literal$1('aN');
  14922. return newToken('numeric', NaN);
  14923. }
  14924. throw invalidChar(read());
  14925. },
  14926. zero() {
  14927. switch (c) {
  14928. case '.':
  14929. buffer$2 += read();
  14930. lexState = 'decimalPoint';
  14931. return;
  14932. case 'e':
  14933. case 'E':
  14934. buffer$2 += read();
  14935. lexState = 'decimalExponent';
  14936. return;
  14937. case 'x':
  14938. case 'X':
  14939. buffer$2 += read();
  14940. lexState = 'hexadecimal';
  14941. return;
  14942. }
  14943. return newToken('numeric', sign * 0);
  14944. },
  14945. decimalInteger() {
  14946. switch (c) {
  14947. case '.':
  14948. buffer$2 += read();
  14949. lexState = 'decimalPoint';
  14950. return;
  14951. case 'e':
  14952. case 'E':
  14953. buffer$2 += read();
  14954. lexState = 'decimalExponent';
  14955. return;
  14956. }
  14957. if (util$3.isDigit(c)) {
  14958. buffer$2 += read();
  14959. return;
  14960. }
  14961. return newToken('numeric', sign * Number(buffer$2));
  14962. },
  14963. decimalPointLeading() {
  14964. if (util$3.isDigit(c)) {
  14965. buffer$2 += read();
  14966. lexState = 'decimalFraction';
  14967. return;
  14968. }
  14969. throw invalidChar(read());
  14970. },
  14971. decimalPoint() {
  14972. switch (c) {
  14973. case 'e':
  14974. case 'E':
  14975. buffer$2 += read();
  14976. lexState = 'decimalExponent';
  14977. return;
  14978. }
  14979. if (util$3.isDigit(c)) {
  14980. buffer$2 += read();
  14981. lexState = 'decimalFraction';
  14982. return;
  14983. }
  14984. return newToken('numeric', sign * Number(buffer$2));
  14985. },
  14986. decimalFraction() {
  14987. switch (c) {
  14988. case 'e':
  14989. case 'E':
  14990. buffer$2 += read();
  14991. lexState = 'decimalExponent';
  14992. return;
  14993. }
  14994. if (util$3.isDigit(c)) {
  14995. buffer$2 += read();
  14996. return;
  14997. }
  14998. return newToken('numeric', sign * Number(buffer$2));
  14999. },
  15000. decimalExponent() {
  15001. switch (c) {
  15002. case '+':
  15003. case '-':
  15004. buffer$2 += read();
  15005. lexState = 'decimalExponentSign';
  15006. return;
  15007. }
  15008. if (util$3.isDigit(c)) {
  15009. buffer$2 += read();
  15010. lexState = 'decimalExponentInteger';
  15011. return;
  15012. }
  15013. throw invalidChar(read());
  15014. },
  15015. decimalExponentSign() {
  15016. if (util$3.isDigit(c)) {
  15017. buffer$2 += read();
  15018. lexState = 'decimalExponentInteger';
  15019. return;
  15020. }
  15021. throw invalidChar(read());
  15022. },
  15023. decimalExponentInteger() {
  15024. if (util$3.isDigit(c)) {
  15025. buffer$2 += read();
  15026. return;
  15027. }
  15028. return newToken('numeric', sign * Number(buffer$2));
  15029. },
  15030. hexadecimal() {
  15031. if (util$3.isHexDigit(c)) {
  15032. buffer$2 += read();
  15033. lexState = 'hexadecimalInteger';
  15034. return;
  15035. }
  15036. throw invalidChar(read());
  15037. },
  15038. hexadecimalInteger() {
  15039. if (util$3.isHexDigit(c)) {
  15040. buffer$2 += read();
  15041. return;
  15042. }
  15043. return newToken('numeric', sign * Number(buffer$2));
  15044. },
  15045. string() {
  15046. switch (c) {
  15047. case '\\':
  15048. read();
  15049. buffer$2 += escape();
  15050. return;
  15051. case '"':
  15052. if (doubleQuote) {
  15053. read();
  15054. return newToken('string', buffer$2);
  15055. }
  15056. buffer$2 += read();
  15057. return;
  15058. case "'":
  15059. if (!doubleQuote) {
  15060. read();
  15061. return newToken('string', buffer$2);
  15062. }
  15063. buffer$2 += read();
  15064. return;
  15065. case '\n':
  15066. case '\r':
  15067. throw invalidChar(read());
  15068. case '\u2028':
  15069. case '\u2029':
  15070. separatorChar(c);
  15071. break;
  15072. case undefined:
  15073. throw invalidChar(read());
  15074. }
  15075. buffer$2 += read();
  15076. },
  15077. start() {
  15078. switch (c) {
  15079. case '{':
  15080. case '[':
  15081. return newToken('punctuator', read());
  15082. // This code is unreachable since the default lexState handles eof.
  15083. // case undefined:
  15084. // return newToken('eof')
  15085. }
  15086. lexState = 'value';
  15087. },
  15088. beforePropertyName() {
  15089. switch (c) {
  15090. case '$':
  15091. case '_':
  15092. buffer$2 = read();
  15093. lexState = 'identifierName';
  15094. return;
  15095. case '\\':
  15096. read();
  15097. lexState = 'identifierNameStartEscape';
  15098. return;
  15099. case '}':
  15100. return newToken('punctuator', read());
  15101. case '"':
  15102. case "'":
  15103. doubleQuote = read() === '"';
  15104. lexState = 'string';
  15105. return;
  15106. }
  15107. if (util$3.isIdStartChar(c)) {
  15108. buffer$2 += read();
  15109. lexState = 'identifierName';
  15110. return;
  15111. }
  15112. throw invalidChar(read());
  15113. },
  15114. afterPropertyName() {
  15115. if (c === ':') {
  15116. return newToken('punctuator', read());
  15117. }
  15118. throw invalidChar(read());
  15119. },
  15120. beforePropertyValue() {
  15121. lexState = 'value';
  15122. },
  15123. afterPropertyValue() {
  15124. switch (c) {
  15125. case ',':
  15126. case '}':
  15127. return newToken('punctuator', read());
  15128. }
  15129. throw invalidChar(read());
  15130. },
  15131. beforeArrayValue() {
  15132. if (c === ']') {
  15133. return newToken('punctuator', read());
  15134. }
  15135. lexState = 'value';
  15136. },
  15137. afterArrayValue() {
  15138. switch (c) {
  15139. case ',':
  15140. case ']':
  15141. return newToken('punctuator', read());
  15142. }
  15143. throw invalidChar(read());
  15144. },
  15145. end() {
  15146. // This code is unreachable since it's handled by the default lexState.
  15147. // if (c === undefined) {
  15148. // read()
  15149. // return newToken('eof')
  15150. // }
  15151. throw invalidChar(read());
  15152. }
  15153. };
  15154. function newToken(type, value) {
  15155. return {
  15156. type,
  15157. value,
  15158. line: line$z,
  15159. column
  15160. };
  15161. }
  15162. function literal$1(s) {
  15163. for (const c of s) {
  15164. const p = peek();
  15165. if (p !== c) {
  15166. throw invalidChar(read());
  15167. }
  15168. read();
  15169. }
  15170. }
  15171. function escape() {
  15172. const c = peek();
  15173. switch (c) {
  15174. case 'b':
  15175. read();
  15176. return '\b';
  15177. case 'f':
  15178. read();
  15179. return '\f';
  15180. case 'n':
  15181. read();
  15182. return '\n';
  15183. case 'r':
  15184. read();
  15185. return '\r';
  15186. case 't':
  15187. read();
  15188. return '\t';
  15189. case 'v':
  15190. read();
  15191. return '\v';
  15192. case '0':
  15193. read();
  15194. if (util$3.isDigit(peek())) {
  15195. throw invalidChar(read());
  15196. }
  15197. return '\0';
  15198. case 'x':
  15199. read();
  15200. return hexEscape();
  15201. case 'u':
  15202. read();
  15203. return unicodeEscape();
  15204. case '\n':
  15205. case '\u2028':
  15206. case '\u2029':
  15207. read();
  15208. return '';
  15209. case '\r':
  15210. read();
  15211. if (peek() === '\n') {
  15212. read();
  15213. }
  15214. return '';
  15215. case '1':
  15216. case '2':
  15217. case '3':
  15218. case '4':
  15219. case '5':
  15220. case '6':
  15221. case '7':
  15222. case '8':
  15223. case '9':
  15224. throw invalidChar(read());
  15225. case undefined:
  15226. throw invalidChar(read());
  15227. }
  15228. return read();
  15229. }
  15230. function hexEscape() {
  15231. let buffer = '';
  15232. let c = peek();
  15233. if (!util$3.isHexDigit(c)) {
  15234. throw invalidChar(read());
  15235. }
  15236. buffer += read();
  15237. c = peek();
  15238. if (!util$3.isHexDigit(c)) {
  15239. throw invalidChar(read());
  15240. }
  15241. buffer += read();
  15242. return String.fromCodePoint(parseInt(buffer, 16));
  15243. }
  15244. function unicodeEscape() {
  15245. let buffer = '';
  15246. let count = 4;
  15247. while (count-- > 0) {
  15248. const c = peek();
  15249. if (!util$3.isHexDigit(c)) {
  15250. throw invalidChar(read());
  15251. }
  15252. buffer += read();
  15253. }
  15254. return String.fromCodePoint(parseInt(buffer, 16));
  15255. }
  15256. const parseStates = {
  15257. start() {
  15258. if (token.type === 'eof') {
  15259. throw invalidEOF();
  15260. }
  15261. push$1();
  15262. },
  15263. beforePropertyName() {
  15264. switch (token.type) {
  15265. case 'identifier':
  15266. case 'string':
  15267. key = token.value;
  15268. parseState = 'afterPropertyName';
  15269. return;
  15270. case 'punctuator':
  15271. // This code is unreachable since it's handled by the lexState.
  15272. // if (token.value !== '}') {
  15273. // throw invalidToken()
  15274. // }
  15275. pop();
  15276. return;
  15277. case 'eof':
  15278. throw invalidEOF();
  15279. } // This code is unreachable since it's handled by the lexState.
  15280. // throw invalidToken()
  15281. },
  15282. afterPropertyName() {
  15283. // This code is unreachable since it's handled by the lexState.
  15284. // if (token.type !== 'punctuator' || token.value !== ':') {
  15285. // throw invalidToken()
  15286. // }
  15287. if (token.type === 'eof') {
  15288. throw invalidEOF();
  15289. }
  15290. parseState = 'beforePropertyValue';
  15291. },
  15292. beforePropertyValue() {
  15293. if (token.type === 'eof') {
  15294. throw invalidEOF();
  15295. }
  15296. push$1();
  15297. },
  15298. beforeArrayValue() {
  15299. if (token.type === 'eof') {
  15300. throw invalidEOF();
  15301. }
  15302. if (token.type === 'punctuator' && token.value === ']') {
  15303. pop();
  15304. return;
  15305. }
  15306. push$1();
  15307. },
  15308. afterPropertyValue() {
  15309. // This code is unreachable since it's handled by the lexState.
  15310. // if (token.type !== 'punctuator') {
  15311. // throw invalidToken()
  15312. // }
  15313. if (token.type === 'eof') {
  15314. throw invalidEOF();
  15315. }
  15316. switch (token.value) {
  15317. case ',':
  15318. parseState = 'beforePropertyName';
  15319. return;
  15320. case '}':
  15321. pop();
  15322. } // This code is unreachable since it's handled by the lexState.
  15323. // throw invalidToken()
  15324. },
  15325. afterArrayValue() {
  15326. // This code is unreachable since it's handled by the lexState.
  15327. // if (token.type !== 'punctuator') {
  15328. // throw invalidToken()
  15329. // }
  15330. if (token.type === 'eof') {
  15331. throw invalidEOF();
  15332. }
  15333. switch (token.value) {
  15334. case ',':
  15335. parseState = 'beforeArrayValue';
  15336. return;
  15337. case ']':
  15338. pop();
  15339. } // This code is unreachable since it's handled by the lexState.
  15340. // throw invalidToken()
  15341. },
  15342. end() {// This code is unreachable since it's handled by the lexState.
  15343. // if (token.type !== 'eof') {
  15344. // throw invalidToken()
  15345. // }
  15346. }
  15347. };
  15348. function push$1() {
  15349. let value;
  15350. switch (token.type) {
  15351. case 'punctuator':
  15352. switch (token.value) {
  15353. case '{':
  15354. value = {};
  15355. break;
  15356. case '[':
  15357. value = [];
  15358. break;
  15359. }
  15360. break;
  15361. case 'null':
  15362. case 'boolean':
  15363. case 'numeric':
  15364. case 'string':
  15365. value = token.value;
  15366. break;
  15367. // This code is unreachable.
  15368. // default:
  15369. // throw invalidToken()
  15370. }
  15371. if (root$1 === undefined) {
  15372. root$1 = value;
  15373. } else {
  15374. const parent = stack[stack.length - 1];
  15375. if (Array.isArray(parent)) {
  15376. parent.push(value);
  15377. } else {
  15378. parent[key] = value;
  15379. }
  15380. }
  15381. if (value !== null && typeof value === 'object') {
  15382. stack.push(value);
  15383. if (Array.isArray(value)) {
  15384. parseState = 'beforeArrayValue';
  15385. } else {
  15386. parseState = 'beforePropertyName';
  15387. }
  15388. } else {
  15389. const current = stack[stack.length - 1];
  15390. if (current == null) {
  15391. parseState = 'end';
  15392. } else if (Array.isArray(current)) {
  15393. parseState = 'afterArrayValue';
  15394. } else {
  15395. parseState = 'afterPropertyValue';
  15396. }
  15397. }
  15398. }
  15399. function pop() {
  15400. stack.pop();
  15401. const current = stack[stack.length - 1];
  15402. if (current == null) {
  15403. parseState = 'end';
  15404. } else if (Array.isArray(current)) {
  15405. parseState = 'afterArrayValue';
  15406. } else {
  15407. parseState = 'afterPropertyValue';
  15408. }
  15409. } // This code is unreachable.
  15410. // function invalidParseState () {
  15411. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  15412. // }
  15413. // This code is unreachable.
  15414. // function invalidLexState (state) {
  15415. // return new Error(`JSON5: invalid lex state '${state}'`)
  15416. // }
  15417. function invalidChar(c) {
  15418. if (c === undefined) {
  15419. return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
  15420. }
  15421. return syntaxError$2(`JSON5: invalid character '${formatChar(c)}' at ${line$z}:${column}`);
  15422. }
  15423. function invalidEOF() {
  15424. return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
  15425. } // This code is unreachable.
  15426. // function invalidToken () {
  15427. // if (token.type === 'eof') {
  15428. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  15429. // }
  15430. // const c = String.fromCodePoint(token.value.codePointAt(0))
  15431. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  15432. // }
  15433. function invalidIdentifier() {
  15434. column -= 5;
  15435. return syntaxError$2(`JSON5: invalid identifier character at ${line$z}:${column}`);
  15436. }
  15437. function separatorChar(c) {
  15438. console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`);
  15439. }
  15440. function formatChar(c) {
  15441. const replacements = {
  15442. "'": "\\'",
  15443. '"': '\\"',
  15444. '\\': '\\\\',
  15445. '\b': '\\b',
  15446. '\f': '\\f',
  15447. '\n': '\\n',
  15448. '\r': '\\r',
  15449. '\t': '\\t',
  15450. '\v': '\\v',
  15451. '\0': '\\0',
  15452. '\u2028': '\\u2028',
  15453. '\u2029': '\\u2029'
  15454. };
  15455. if (replacements[c]) {
  15456. return replacements[c];
  15457. }
  15458. if (c < ' ') {
  15459. const hexString = c.charCodeAt(0).toString(16);
  15460. return '\\x' + ('00' + hexString).substring(hexString.length);
  15461. }
  15462. return c;
  15463. }
  15464. function syntaxError$2(message) {
  15465. const err = new SyntaxError(message);
  15466. err.lineNumber = line$z;
  15467. err.columnNumber = column;
  15468. return err;
  15469. }
  15470. var stringify$3 = function stringify(value, replacer, space) {
  15471. const stack = [];
  15472. let indent = '';
  15473. let propertyList;
  15474. let replacerFunc;
  15475. let gap = '';
  15476. let quote;
  15477. if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
  15478. space = replacer.space;
  15479. quote = replacer.quote;
  15480. replacer = replacer.replacer;
  15481. }
  15482. if (typeof replacer === 'function') {
  15483. replacerFunc = replacer;
  15484. } else if (Array.isArray(replacer)) {
  15485. propertyList = [];
  15486. for (const v of replacer) {
  15487. let item;
  15488. if (typeof v === 'string') {
  15489. item = v;
  15490. } else if (typeof v === 'number' || v instanceof String || v instanceof Number) {
  15491. item = String(v);
  15492. }
  15493. if (item !== undefined && propertyList.indexOf(item) < 0) {
  15494. propertyList.push(item);
  15495. }
  15496. }
  15497. }
  15498. if (space instanceof Number) {
  15499. space = Number(space);
  15500. } else if (space instanceof String) {
  15501. space = String(space);
  15502. }
  15503. if (typeof space === 'number') {
  15504. if (space > 0) {
  15505. space = Math.min(10, Math.floor(space));
  15506. gap = ' '.substr(0, space);
  15507. }
  15508. } else if (typeof space === 'string') {
  15509. gap = space.substr(0, 10);
  15510. }
  15511. return serializeProperty('', {
  15512. '': value
  15513. });
  15514. function serializeProperty(key, holder) {
  15515. let value = holder[key];
  15516. if (value != null) {
  15517. if (typeof value.toJSON5 === 'function') {
  15518. value = value.toJSON5(key);
  15519. } else if (typeof value.toJSON === 'function') {
  15520. value = value.toJSON(key);
  15521. }
  15522. }
  15523. if (replacerFunc) {
  15524. value = replacerFunc.call(holder, key, value);
  15525. }
  15526. if (value instanceof Number) {
  15527. value = Number(value);
  15528. } else if (value instanceof String) {
  15529. value = String(value);
  15530. } else if (value instanceof Boolean) {
  15531. value = value.valueOf();
  15532. }
  15533. switch (value) {
  15534. case null:
  15535. return 'null';
  15536. case true:
  15537. return 'true';
  15538. case false:
  15539. return 'false';
  15540. }
  15541. if (typeof value === 'string') {
  15542. return quoteString(value);
  15543. }
  15544. if (typeof value === 'number') {
  15545. return String(value);
  15546. }
  15547. if (typeof value === 'object') {
  15548. return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
  15549. }
  15550. return undefined;
  15551. }
  15552. function quoteString(value) {
  15553. const quotes = {
  15554. "'": 0.1,
  15555. '"': 0.2
  15556. };
  15557. const replacements = {
  15558. "'": "\\'",
  15559. '"': '\\"',
  15560. '\\': '\\\\',
  15561. '\b': '\\b',
  15562. '\f': '\\f',
  15563. '\n': '\\n',
  15564. '\r': '\\r',
  15565. '\t': '\\t',
  15566. '\v': '\\v',
  15567. '\0': '\\0',
  15568. '\u2028': '\\u2028',
  15569. '\u2029': '\\u2029'
  15570. };
  15571. let product = '';
  15572. for (let i = 0; i < value.length; i++) {
  15573. const c = value[i];
  15574. switch (c) {
  15575. case "'":
  15576. case '"':
  15577. quotes[c]++;
  15578. product += c;
  15579. continue;
  15580. case '\0':
  15581. if (util$3.isDigit(value[i + 1])) {
  15582. product += '\\x00';
  15583. continue;
  15584. }
  15585. }
  15586. if (replacements[c]) {
  15587. product += replacements[c];
  15588. continue;
  15589. }
  15590. if (c < ' ') {
  15591. let hexString = c.charCodeAt(0).toString(16);
  15592. product += '\\x' + ('00' + hexString).substring(hexString.length);
  15593. continue;
  15594. }
  15595. product += c;
  15596. }
  15597. const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
  15598. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  15599. return quoteChar + product + quoteChar;
  15600. }
  15601. function serializeObject(value) {
  15602. if (stack.indexOf(value) >= 0) {
  15603. throw TypeError('Converting circular structure to JSON5');
  15604. }
  15605. stack.push(value);
  15606. let stepback = indent;
  15607. indent = indent + gap;
  15608. let keys = propertyList || Object.keys(value);
  15609. let partial = [];
  15610. for (const key of keys) {
  15611. const propertyString = serializeProperty(key, value);
  15612. if (propertyString !== undefined) {
  15613. let member = serializeKey(key) + ':';
  15614. if (gap !== '') {
  15615. member += ' ';
  15616. }
  15617. member += propertyString;
  15618. partial.push(member);
  15619. }
  15620. }
  15621. let final;
  15622. if (partial.length === 0) {
  15623. final = '{}';
  15624. } else {
  15625. let properties;
  15626. if (gap === '') {
  15627. properties = partial.join(',');
  15628. final = '{' + properties + '}';
  15629. } else {
  15630. let separator = ',\n' + indent;
  15631. properties = partial.join(separator);
  15632. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  15633. }
  15634. }
  15635. stack.pop();
  15636. indent = stepback;
  15637. return final;
  15638. }
  15639. function serializeKey(key) {
  15640. if (key.length === 0) {
  15641. return quoteString(key);
  15642. }
  15643. const firstChar = String.fromCodePoint(key.codePointAt(0));
  15644. if (!util$3.isIdStartChar(firstChar)) {
  15645. return quoteString(key);
  15646. }
  15647. for (let i = firstChar.length; i < key.length; i++) {
  15648. if (!util$3.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  15649. return quoteString(key);
  15650. }
  15651. }
  15652. return key;
  15653. }
  15654. function serializeArray(value) {
  15655. if (stack.indexOf(value) >= 0) {
  15656. throw TypeError('Converting circular structure to JSON5');
  15657. }
  15658. stack.push(value);
  15659. let stepback = indent;
  15660. indent = indent + gap;
  15661. let partial = [];
  15662. for (let i = 0; i < value.length; i++) {
  15663. const propertyString = serializeProperty(String(i), value);
  15664. partial.push(propertyString !== undefined ? propertyString : 'null');
  15665. }
  15666. let final;
  15667. if (partial.length === 0) {
  15668. final = '[]';
  15669. } else {
  15670. if (gap === '') {
  15671. let properties = partial.join(',');
  15672. final = '[' + properties + ']';
  15673. } else {
  15674. let separator = ',\n' + indent;
  15675. let properties = partial.join(separator);
  15676. final = '[\n' + indent + properties + ',\n' + stepback + ']';
  15677. }
  15678. }
  15679. stack.pop();
  15680. indent = stepback;
  15681. return final;
  15682. }
  15683. };
  15684. const JSON5 = {
  15685. parse: parse$8,
  15686. stringify: stringify$3
  15687. };
  15688. var lib = JSON5;
  15689. var dist = /*#__PURE__*/Object.freeze({
  15690. __proto__: null,
  15691. 'default': lib
  15692. });
  15693. var require$$0$8 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(dist);
  15694. const {
  15695. parse: parse$7
  15696. } = require$$0$8;
  15697. var loadJson5 = function (filePath, content) {
  15698. try {
  15699. return parse$7(content);
  15700. } catch (error) {
  15701. error.message = `JSON5 Error in ${filePath}:\n${error.message}`;
  15702. throw error;
  15703. }
  15704. };
  15705. var caller = function () {
  15706. // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  15707. var origPrepareStackTrace = Error.prepareStackTrace;
  15708. Error.prepareStackTrace = function (_, stack) {
  15709. return stack;
  15710. };
  15711. var stack = new Error().stack;
  15712. Error.prepareStackTrace = origPrepareStackTrace;
  15713. return stack[2].getFileName();
  15714. };
  15715. var pathParse = createCommonjsModule(function (module) {
  15716. var isWindows = process.platform === 'win32'; // Regex to split a windows path into into [dir, root, basename, name, ext]
  15717. var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
  15718. var win32 = {};
  15719. function win32SplitPath(filename) {
  15720. return splitWindowsRe.exec(filename).slice(1);
  15721. }
  15722. win32.parse = function (pathString) {
  15723. if (typeof pathString !== 'string') {
  15724. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  15725. }
  15726. var allParts = win32SplitPath(pathString);
  15727. if (!allParts || allParts.length !== 5) {
  15728. throw new TypeError("Invalid path '" + pathString + "'");
  15729. }
  15730. return {
  15731. root: allParts[1],
  15732. dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
  15733. base: allParts[2],
  15734. ext: allParts[4],
  15735. name: allParts[3]
  15736. };
  15737. }; // Split a filename into [dir, root, basename, name, ext], unix version
  15738. // 'root' is just a slash, or nothing.
  15739. var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
  15740. var posix = {};
  15741. function posixSplitPath(filename) {
  15742. return splitPathRe.exec(filename).slice(1);
  15743. }
  15744. posix.parse = function (pathString) {
  15745. if (typeof pathString !== 'string') {
  15746. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  15747. }
  15748. var allParts = posixSplitPath(pathString);
  15749. if (!allParts || allParts.length !== 5) {
  15750. throw new TypeError("Invalid path '" + pathString + "'");
  15751. }
  15752. return {
  15753. root: allParts[1],
  15754. dir: allParts[0].slice(0, -1),
  15755. base: allParts[2],
  15756. ext: allParts[4],
  15757. name: allParts[3]
  15758. };
  15759. };
  15760. if (isWindows) module.exports = win32.parse;else
  15761. /* posix */
  15762. module.exports = posix.parse;
  15763. module.exports.posix = posix.parse;
  15764. module.exports.win32 = win32.parse;
  15765. });
  15766. var parse$6 = path__default['default'].parse || pathParse;
  15767. var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
  15768. var prefix = '/';
  15769. if (/^([A-Za-z]:)/.test(absoluteStart)) {
  15770. prefix = '';
  15771. } else if (/^\\\\/.test(absoluteStart)) {
  15772. prefix = '\\\\';
  15773. }
  15774. var paths = [absoluteStart];
  15775. var parsed = parse$6(absoluteStart);
  15776. while (parsed.dir !== paths[paths.length - 1]) {
  15777. paths.push(parsed.dir);
  15778. parsed = parse$6(parsed.dir);
  15779. }
  15780. return paths.reduce(function (dirs, aPath) {
  15781. return dirs.concat(modules.map(function (moduleDir) {
  15782. return path__default['default'].resolve(prefix, aPath, moduleDir);
  15783. }));
  15784. }, []);
  15785. };
  15786. var nodeModulesPaths = function nodeModulesPaths(start, opts, request) {
  15787. var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules'];
  15788. if (opts && typeof opts.paths === 'function') {
  15789. return opts.paths(request, start, function () {
  15790. return getNodeModulesDirs(start, modules);
  15791. }, opts);
  15792. }
  15793. var dirs = getNodeModulesDirs(start, modules);
  15794. return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
  15795. };
  15796. var normalizeOptions$1 = function (x, opts) {
  15797. /**
  15798. * This file is purposefully a passthrough. It's expected that third-party
  15799. * environments will override it at runtime in order to inject special logic
  15800. * into `resolve` (by manipulating the options). One such example is the PnP
  15801. * code path in Yarn.
  15802. */
  15803. return opts || {};
  15804. };
  15805. /* eslint no-invalid-this: 1 */
  15806. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  15807. var slice$1 = Array.prototype.slice;
  15808. var toStr = Object.prototype.toString;
  15809. var funcType = '[object Function]';
  15810. var implementation = function bind(that) {
  15811. var target = this;
  15812. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  15813. throw new TypeError(ERROR_MESSAGE + target);
  15814. }
  15815. var args = slice$1.call(arguments, 1);
  15816. var bound;
  15817. var binder = function () {
  15818. if (this instanceof bound) {
  15819. var result = target.apply(this, args.concat(slice$1.call(arguments)));
  15820. if (Object(result) === result) {
  15821. return result;
  15822. }
  15823. return this;
  15824. } else {
  15825. return target.apply(that, args.concat(slice$1.call(arguments)));
  15826. }
  15827. };
  15828. var boundLength = Math.max(0, target.length - args.length);
  15829. var boundArgs = [];
  15830. for (var i = 0; i < boundLength; i++) {
  15831. boundArgs.push('$' + i);
  15832. }
  15833. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  15834. if (target.prototype) {
  15835. var Empty = function Empty() {};
  15836. Empty.prototype = target.prototype;
  15837. bound.prototype = new Empty();
  15838. Empty.prototype = null;
  15839. }
  15840. return bound;
  15841. };
  15842. var functionBind = Function.prototype.bind || implementation;
  15843. var src$2 = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
  15844. var assert$1 = true;
  15845. var async_hooks$1 = ">= 8";
  15846. var buffer_ieee754$1 = "< 0.9.7";
  15847. var buffer$1 = true;
  15848. var child_process$1 = true;
  15849. var cluster$1 = true;
  15850. var console$2 = true;
  15851. var constants$4 = true;
  15852. var crypto$1 = true;
  15853. var _debug_agent$1 = ">= 1 && < 8";
  15854. var _debugger$1 = "< 8";
  15855. var dgram$1 = true;
  15856. var diagnostics_channel$1 = [
  15857. ">= 14.17 && < 15",
  15858. ">= 15.1"
  15859. ];
  15860. var dns$1 = true;
  15861. var domain$1 = ">= 0.7.12";
  15862. var events$1 = true;
  15863. var freelist$1 = "< 6";
  15864. var fs$5 = true;
  15865. var _http_agent$1 = ">= 0.11.1";
  15866. var _http_client$1 = ">= 0.11.1";
  15867. var _http_common$1 = ">= 0.11.1";
  15868. var _http_incoming$1 = ">= 0.11.1";
  15869. var _http_outgoing$1 = ">= 0.11.1";
  15870. var _http_server$1 = ">= 0.11.1";
  15871. var http$1 = true;
  15872. var http2$1 = ">= 8.8";
  15873. var https$1 = true;
  15874. var inspector$1 = ">= 8";
  15875. var _linklist$1 = "< 8";
  15876. var module$3 = true;
  15877. var net$1 = true;
  15878. var os$1 = true;
  15879. var path$2 = true;
  15880. var perf_hooks$1 = ">= 8.5";
  15881. var process$2 = ">= 1";
  15882. var punycode$1 = true;
  15883. var querystring$1 = true;
  15884. var readline$1 = true;
  15885. var repl$1 = true;
  15886. var smalloc$1 = ">= 0.11.5 && < 3";
  15887. var _stream_duplex$1 = ">= 0.9.4";
  15888. var _stream_transform$1 = ">= 0.9.4";
  15889. var _stream_wrap$1 = ">= 1.4.1";
  15890. var _stream_passthrough$1 = ">= 0.9.4";
  15891. var _stream_readable$1 = ">= 0.9.4";
  15892. var _stream_writable$1 = ">= 0.9.4";
  15893. var stream$6 = true;
  15894. var string_decoder$1 = true;
  15895. var sys$1 = [
  15896. ">= 0.6 && < 0.7",
  15897. ">= 0.8"
  15898. ];
  15899. var timers$1 = true;
  15900. var _tls_common$1 = ">= 0.11.13";
  15901. var _tls_legacy$1 = ">= 0.11.3 && < 10";
  15902. var _tls_wrap$1 = ">= 0.11.3";
  15903. var tls$1 = true;
  15904. var trace_events$1 = ">= 10";
  15905. var tty$1 = true;
  15906. var url$1 = true;
  15907. var util$2 = true;
  15908. var v8$1 = ">= 1";
  15909. var vm$1 = true;
  15910. var wasi$1 = ">= 13.4 && < 13.5";
  15911. var worker_threads$1 = ">= 11.7";
  15912. var zlib$1 = true;
  15913. var data$2 = {
  15914. assert: assert$1,
  15915. "node:assert": ">= 16",
  15916. "assert/strict": ">= 15",
  15917. "node:assert/strict": ">= 16",
  15918. async_hooks: async_hooks$1,
  15919. "node:async_hooks": ">= 16",
  15920. buffer_ieee754: buffer_ieee754$1,
  15921. buffer: buffer$1,
  15922. "node:buffer": ">= 16",
  15923. child_process: child_process$1,
  15924. "node:child_process": ">= 16",
  15925. cluster: cluster$1,
  15926. "node:cluster": ">= 16",
  15927. console: console$2,
  15928. "node:console": ">= 16",
  15929. constants: constants$4,
  15930. "node:constants": ">= 16",
  15931. crypto: crypto$1,
  15932. "node:crypto": ">= 16",
  15933. _debug_agent: _debug_agent$1,
  15934. _debugger: _debugger$1,
  15935. dgram: dgram$1,
  15936. "node:dgram": ">= 16",
  15937. diagnostics_channel: diagnostics_channel$1,
  15938. "node:diagnostics_channel": ">= 16",
  15939. dns: dns$1,
  15940. "node:dns": ">= 16",
  15941. "dns/promises": ">= 15",
  15942. "node:dns/promises": ">= 16",
  15943. domain: domain$1,
  15944. "node:domain": ">= 16",
  15945. events: events$1,
  15946. "node:events": ">= 16",
  15947. freelist: freelist$1,
  15948. fs: fs$5,
  15949. "node:fs": ">= 16",
  15950. "fs/promises": [
  15951. ">= 10 && < 10.1",
  15952. ">= 14"
  15953. ],
  15954. "node:fs/promises": ">= 16",
  15955. _http_agent: _http_agent$1,
  15956. "node:_http_agent": ">= 16",
  15957. _http_client: _http_client$1,
  15958. "node:_http_client": ">= 16",
  15959. _http_common: _http_common$1,
  15960. "node:_http_common": ">= 16",
  15961. _http_incoming: _http_incoming$1,
  15962. "node:_http_incoming": ">= 16",
  15963. _http_outgoing: _http_outgoing$1,
  15964. "node:_http_outgoing": ">= 16",
  15965. _http_server: _http_server$1,
  15966. "node:_http_server": ">= 16",
  15967. http: http$1,
  15968. "node:http": ">= 16",
  15969. http2: http2$1,
  15970. "node:http2": ">= 16",
  15971. https: https$1,
  15972. "node:https": ">= 16",
  15973. inspector: inspector$1,
  15974. "node:inspector": ">= 16",
  15975. _linklist: _linklist$1,
  15976. module: module$3,
  15977. "node:module": ">= 16",
  15978. net: net$1,
  15979. "node:net": ">= 16",
  15980. "node-inspect/lib/_inspect": ">= 7.6 && < 12",
  15981. "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
  15982. "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
  15983. os: os$1,
  15984. "node:os": ">= 16",
  15985. path: path$2,
  15986. "node:path": ">= 16",
  15987. "path/posix": ">= 15.3",
  15988. "node:path/posix": ">= 16",
  15989. "path/win32": ">= 15.3",
  15990. "node:path/win32": ">= 16",
  15991. perf_hooks: perf_hooks$1,
  15992. "node:perf_hooks": ">= 16",
  15993. process: process$2,
  15994. "node:process": ">= 16",
  15995. punycode: punycode$1,
  15996. "node:punycode": ">= 16",
  15997. querystring: querystring$1,
  15998. "node:querystring": ">= 16",
  15999. readline: readline$1,
  16000. "node:readline": ">= 16",
  16001. repl: repl$1,
  16002. "node:repl": ">= 16",
  16003. smalloc: smalloc$1,
  16004. _stream_duplex: _stream_duplex$1,
  16005. "node:_stream_duplex": ">= 16",
  16006. _stream_transform: _stream_transform$1,
  16007. "node:_stream_transform": ">= 16",
  16008. _stream_wrap: _stream_wrap$1,
  16009. "node:_stream_wrap": ">= 16",
  16010. _stream_passthrough: _stream_passthrough$1,
  16011. "node:_stream_passthrough": ">= 16",
  16012. _stream_readable: _stream_readable$1,
  16013. "node:_stream_readable": ">= 16",
  16014. _stream_writable: _stream_writable$1,
  16015. "node:_stream_writable": ">= 16",
  16016. stream: stream$6,
  16017. "node:stream": ">= 16",
  16018. "stream/consumers": ">= 16.7",
  16019. "node:stream/consumers": ">= 16.7",
  16020. "stream/promises": ">= 15",
  16021. "node:stream/promises": ">= 16",
  16022. "stream/web": ">= 16.5",
  16023. "node:stream/web": ">= 16.5",
  16024. string_decoder: string_decoder$1,
  16025. "node:string_decoder": ">= 16",
  16026. sys: sys$1,
  16027. "node:sys": ">= 16",
  16028. timers: timers$1,
  16029. "node:timers": ">= 16",
  16030. "timers/promises": ">= 15",
  16031. "node:timers/promises": ">= 16",
  16032. _tls_common: _tls_common$1,
  16033. "node:_tls_common": ">= 16",
  16034. _tls_legacy: _tls_legacy$1,
  16035. _tls_wrap: _tls_wrap$1,
  16036. "node:_tls_wrap": ">= 16",
  16037. tls: tls$1,
  16038. "node:tls": ">= 16",
  16039. trace_events: trace_events$1,
  16040. "node:trace_events": ">= 16",
  16041. tty: tty$1,
  16042. "node:tty": ">= 16",
  16043. url: url$1,
  16044. "node:url": ">= 16",
  16045. util: util$2,
  16046. "node:util": ">= 16",
  16047. "util/types": ">= 15.3",
  16048. "node:util/types": ">= 16",
  16049. "v8/tools/arguments": ">= 10 && < 12",
  16050. "v8/tools/codemap": [
  16051. ">= 4.4 && < 5",
  16052. ">= 5.2 && < 12"
  16053. ],
  16054. "v8/tools/consarray": [
  16055. ">= 4.4 && < 5",
  16056. ">= 5.2 && < 12"
  16057. ],
  16058. "v8/tools/csvparser": [
  16059. ">= 4.4 && < 5",
  16060. ">= 5.2 && < 12"
  16061. ],
  16062. "v8/tools/logreader": [
  16063. ">= 4.4 && < 5",
  16064. ">= 5.2 && < 12"
  16065. ],
  16066. "v8/tools/profile_view": [
  16067. ">= 4.4 && < 5",
  16068. ">= 5.2 && < 12"
  16069. ],
  16070. "v8/tools/splaytree": [
  16071. ">= 4.4 && < 5",
  16072. ">= 5.2 && < 12"
  16073. ],
  16074. v8: v8$1,
  16075. "node:v8": ">= 16",
  16076. vm: vm$1,
  16077. "node:vm": ">= 16",
  16078. wasi: wasi$1,
  16079. worker_threads: worker_threads$1,
  16080. "node:worker_threads": ">= 16",
  16081. zlib: zlib$1,
  16082. "node:zlib": ">= 16"
  16083. };
  16084. function specifierIncluded$1(current, specifier) {
  16085. var nodeParts = current.split('.');
  16086. var parts = specifier.split(' ');
  16087. var op = parts.length > 1 ? parts[0] : '=';
  16088. var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
  16089. for (var i = 0; i < 3; ++i) {
  16090. var cur = parseInt(nodeParts[i] || 0, 10);
  16091. var ver = parseInt(versionParts[i] || 0, 10);
  16092. if (cur === ver) {
  16093. continue; // eslint-disable-line no-restricted-syntax, no-continue
  16094. }
  16095. if (op === '<') {
  16096. return cur < ver;
  16097. }
  16098. if (op === '>=') {
  16099. return cur >= ver;
  16100. }
  16101. return false;
  16102. }
  16103. return op === '>=';
  16104. }
  16105. function matchesRange$1(current, range) {
  16106. var specifiers = range.split(/ ?&& ?/);
  16107. if (specifiers.length === 0) {
  16108. return false;
  16109. }
  16110. for (var i = 0; i < specifiers.length; ++i) {
  16111. if (!specifierIncluded$1(current, specifiers[i])) {
  16112. return false;
  16113. }
  16114. }
  16115. return true;
  16116. }
  16117. function versionIncluded$1(nodeVersion, specifierValue) {
  16118. if (typeof specifierValue === 'boolean') {
  16119. return specifierValue;
  16120. }
  16121. var current = typeof nodeVersion === 'undefined' ? process.versions && process.versions.node : nodeVersion;
  16122. if (typeof current !== 'string') {
  16123. throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
  16124. }
  16125. if (specifierValue && typeof specifierValue === 'object') {
  16126. for (var i = 0; i < specifierValue.length; ++i) {
  16127. if (matchesRange$1(current, specifierValue[i])) {
  16128. return true;
  16129. }
  16130. }
  16131. return false;
  16132. }
  16133. return matchesRange$1(current, specifierValue);
  16134. }
  16135. var isCoreModule = function isCore(x, nodeVersion) {
  16136. return src$2(data$2, x) && versionIncluded$1(nodeVersion, data$2[x]);
  16137. };
  16138. var realpathFS$1 = fs__default['default'].realpath && typeof fs__default['default'].realpath.native === 'function' ? fs__default['default'].realpath.native : fs__default['default'].realpath;
  16139. var defaultIsFile$1 = function isFile(file, cb) {
  16140. fs__default['default'].stat(file, function (err, stat) {
  16141. if (!err) {
  16142. return cb(null, stat.isFile() || stat.isFIFO());
  16143. }
  16144. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  16145. return cb(err);
  16146. });
  16147. };
  16148. var defaultIsDir$1 = function isDirectory(dir, cb) {
  16149. fs__default['default'].stat(dir, function (err, stat) {
  16150. if (!err) {
  16151. return cb(null, stat.isDirectory());
  16152. }
  16153. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  16154. return cb(err);
  16155. });
  16156. };
  16157. var defaultRealpath = function realpath(x, cb) {
  16158. realpathFS$1(x, function (realpathErr, realPath) {
  16159. if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);else cb(null, realpathErr ? x : realPath);
  16160. });
  16161. };
  16162. var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
  16163. if (opts && opts.preserveSymlinks === false) {
  16164. realpath(x, cb);
  16165. } else {
  16166. cb(null, x);
  16167. }
  16168. };
  16169. var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) {
  16170. readFile(pkgfile, function (readFileErr, body) {
  16171. if (readFileErr) cb(readFileErr);else {
  16172. try {
  16173. var pkg = JSON.parse(body);
  16174. cb(null, pkg);
  16175. } catch (jsonErr) {
  16176. cb(null);
  16177. }
  16178. }
  16179. });
  16180. };
  16181. var getPackageCandidates$1 = function getPackageCandidates(x, start, opts) {
  16182. var dirs = nodeModulesPaths(start, opts, x);
  16183. for (var i = 0; i < dirs.length; i++) {
  16184. dirs[i] = path__default['default'].join(dirs[i], x);
  16185. }
  16186. return dirs;
  16187. };
  16188. var async$5 = function resolve(x, options, callback) {
  16189. var cb = callback;
  16190. var opts = options;
  16191. if (typeof options === 'function') {
  16192. cb = opts;
  16193. opts = {};
  16194. }
  16195. if (typeof x !== 'string') {
  16196. var err = new TypeError('Path must be a string.');
  16197. return process.nextTick(function () {
  16198. cb(err);
  16199. });
  16200. }
  16201. opts = normalizeOptions$1(x, opts);
  16202. var isFile = opts.isFile || defaultIsFile$1;
  16203. var isDirectory = opts.isDirectory || defaultIsDir$1;
  16204. var readFile = opts.readFile || fs__default['default'].readFile;
  16205. var realpath = opts.realpath || defaultRealpath;
  16206. var readPackage = opts.readPackage || defaultReadPackage;
  16207. if (opts.readFile && opts.readPackage) {
  16208. var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.');
  16209. return process.nextTick(function () {
  16210. cb(conflictErr);
  16211. });
  16212. }
  16213. var packageIterator = opts.packageIterator;
  16214. var extensions = opts.extensions || ['.js'];
  16215. var includeCoreModules = opts.includeCoreModules !== false;
  16216. var basedir = opts.basedir || path__default['default'].dirname(caller());
  16217. var parent = opts.filename || basedir;
  16218. opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
  16219. var absoluteStart = path__default['default'].resolve(basedir);
  16220. maybeRealpath(realpath, absoluteStart, opts, function (err, realStart) {
  16221. if (err) cb(err);else init(realStart);
  16222. });
  16223. var res;
  16224. function init(basedir) {
  16225. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  16226. res = path__default['default'].resolve(basedir, x);
  16227. if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
  16228. if (/\/$/.test(x) && res === basedir) {
  16229. loadAsDirectory(res, opts.package, onfile);
  16230. } else loadAsFile(res, opts.package, onfile);
  16231. } else if (includeCoreModules && isCoreModule(x)) {
  16232. return cb(null, x);
  16233. } else loadNodeModules(x, basedir, function (err, n, pkg) {
  16234. if (err) cb(err);else if (n) {
  16235. return maybeRealpath(realpath, n, opts, function (err, realN) {
  16236. if (err) {
  16237. cb(err);
  16238. } else {
  16239. cb(null, realN, pkg);
  16240. }
  16241. });
  16242. } else {
  16243. var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  16244. moduleError.code = 'MODULE_NOT_FOUND';
  16245. cb(moduleError);
  16246. }
  16247. });
  16248. }
  16249. function onfile(err, m, pkg) {
  16250. if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
  16251. if (err) cb(err);else if (d) {
  16252. maybeRealpath(realpath, d, opts, function (err, realD) {
  16253. if (err) {
  16254. cb(err);
  16255. } else {
  16256. cb(null, realD, pkg);
  16257. }
  16258. });
  16259. } else {
  16260. var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  16261. moduleError.code = 'MODULE_NOT_FOUND';
  16262. cb(moduleError);
  16263. }
  16264. });
  16265. }
  16266. function loadAsFile(x, thePackage, callback) {
  16267. var loadAsFilePackage = thePackage;
  16268. var cb = callback;
  16269. if (typeof loadAsFilePackage === 'function') {
  16270. cb = loadAsFilePackage;
  16271. loadAsFilePackage = undefined;
  16272. }
  16273. var exts = [''].concat(extensions);
  16274. load(exts, x, loadAsFilePackage);
  16275. function load(exts, x, loadPackage) {
  16276. if (exts.length === 0) return cb(null, undefined, loadPackage);
  16277. var file = x + exts[0];
  16278. var pkg = loadPackage;
  16279. if (pkg) onpkg(null, pkg);else loadpkg(path__default['default'].dirname(file), onpkg);
  16280. function onpkg(err, pkg_, dir) {
  16281. pkg = pkg_;
  16282. if (err) return cb(err);
  16283. if (dir && pkg && opts.pathFilter) {
  16284. var rfile = path__default['default'].relative(dir, file);
  16285. var rel = rfile.slice(0, rfile.length - exts[0].length);
  16286. var r = opts.pathFilter(pkg, x, rel);
  16287. if (r) return load([''].concat(extensions.slice()), path__default['default'].resolve(dir, r), pkg);
  16288. }
  16289. isFile(file, onex);
  16290. }
  16291. function onex(err, ex) {
  16292. if (err) return cb(err);
  16293. if (ex) return cb(null, file, pkg);
  16294. load(exts.slice(1), x, pkg);
  16295. }
  16296. }
  16297. }
  16298. function loadpkg(dir, cb) {
  16299. if (dir === '' || dir === '/') return cb(null);
  16300. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  16301. return cb(null);
  16302. }
  16303. if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
  16304. maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
  16305. if (unwrapErr) return loadpkg(path__default['default'].dirname(dir), cb);
  16306. var pkgfile = path__default['default'].join(pkgdir, 'package.json');
  16307. isFile(pkgfile, function (err, ex) {
  16308. // on err, ex is false
  16309. if (!ex) return loadpkg(path__default['default'].dirname(dir), cb);
  16310. readPackage(readFile, pkgfile, function (err, pkgParam) {
  16311. if (err) cb(err);
  16312. var pkg = pkgParam;
  16313. if (pkg && opts.packageFilter) {
  16314. pkg = opts.packageFilter(pkg, pkgfile);
  16315. }
  16316. cb(null, pkg, dir);
  16317. });
  16318. });
  16319. });
  16320. }
  16321. function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
  16322. var cb = callback;
  16323. var fpkg = loadAsDirectoryPackage;
  16324. if (typeof fpkg === 'function') {
  16325. cb = fpkg;
  16326. fpkg = opts.package;
  16327. }
  16328. maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
  16329. if (unwrapErr) return cb(unwrapErr);
  16330. var pkgfile = path__default['default'].join(pkgdir, 'package.json');
  16331. isFile(pkgfile, function (err, ex) {
  16332. if (err) return cb(err);
  16333. if (!ex) return loadAsFile(path__default['default'].join(x, 'index'), fpkg, cb);
  16334. readPackage(readFile, pkgfile, function (err, pkgParam) {
  16335. if (err) return cb(err);
  16336. var pkg = pkgParam;
  16337. if (pkg && opts.packageFilter) {
  16338. pkg = opts.packageFilter(pkg, pkgfile);
  16339. }
  16340. if (pkg && pkg.main) {
  16341. if (typeof pkg.main !== 'string') {
  16342. var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
  16343. mainError.code = 'INVALID_PACKAGE_MAIN';
  16344. return cb(mainError);
  16345. }
  16346. if (pkg.main === '.' || pkg.main === './') {
  16347. pkg.main = 'index';
  16348. }
  16349. loadAsFile(path__default['default'].resolve(x, pkg.main), pkg, function (err, m, pkg) {
  16350. if (err) return cb(err);
  16351. if (m) return cb(null, m, pkg);
  16352. if (!pkg) return loadAsFile(path__default['default'].join(x, 'index'), pkg, cb);
  16353. var dir = path__default['default'].resolve(x, pkg.main);
  16354. loadAsDirectory(dir, pkg, function (err, n, pkg) {
  16355. if (err) return cb(err);
  16356. if (n) return cb(null, n, pkg);
  16357. loadAsFile(path__default['default'].join(x, 'index'), pkg, cb);
  16358. });
  16359. });
  16360. return;
  16361. }
  16362. loadAsFile(path__default['default'].join(x, '/index'), pkg, cb);
  16363. });
  16364. });
  16365. });
  16366. }
  16367. function processDirs(cb, dirs) {
  16368. if (dirs.length === 0) return cb(null, undefined);
  16369. var dir = dirs[0];
  16370. isDirectory(path__default['default'].dirname(dir), isdir);
  16371. function isdir(err, isdir) {
  16372. if (err) return cb(err);
  16373. if (!isdir) return processDirs(cb, dirs.slice(1));
  16374. loadAsFile(dir, opts.package, onfile);
  16375. }
  16376. function onfile(err, m, pkg) {
  16377. if (err) return cb(err);
  16378. if (m) return cb(null, m, pkg);
  16379. loadAsDirectory(dir, opts.package, ondir);
  16380. }
  16381. function ondir(err, n, pkg) {
  16382. if (err) return cb(err);
  16383. if (n) return cb(null, n, pkg);
  16384. processDirs(cb, dirs.slice(1));
  16385. }
  16386. }
  16387. function loadNodeModules(x, start, cb) {
  16388. var thunk = function () {
  16389. return getPackageCandidates$1(x, start, opts);
  16390. };
  16391. processDirs(cb, packageIterator ? packageIterator(x, start, thunk, opts) : thunk());
  16392. }
  16393. };
  16394. var assert = true;
  16395. var async_hooks = ">= 8";
  16396. var buffer_ieee754 = "< 0.9.7";
  16397. var buffer = true;
  16398. var child_process = true;
  16399. var cluster = true;
  16400. var console$1 = true;
  16401. var constants$3 = true;
  16402. var crypto = true;
  16403. var _debug_agent = ">= 1 && < 8";
  16404. var _debugger = "< 8";
  16405. var dgram = true;
  16406. var diagnostics_channel = ">= 15.1";
  16407. var dns = true;
  16408. var domain = ">= 0.7.12";
  16409. var events = true;
  16410. var freelist = "< 6";
  16411. var fs$4 = true;
  16412. var _http_agent = ">= 0.11.1";
  16413. var _http_client = ">= 0.11.1";
  16414. var _http_common = ">= 0.11.1";
  16415. var _http_incoming = ">= 0.11.1";
  16416. var _http_outgoing = ">= 0.11.1";
  16417. var _http_server = ">= 0.11.1";
  16418. var http = true;
  16419. var http2 = ">= 8.8";
  16420. var https = true;
  16421. var inspector = ">= 8.0.0";
  16422. var _linklist = "< 8";
  16423. var module$2 = true;
  16424. var net = true;
  16425. var os = true;
  16426. var path$1 = true;
  16427. var perf_hooks = ">= 8.5";
  16428. var process$1 = ">= 1";
  16429. var punycode = true;
  16430. var querystring = true;
  16431. var readline = true;
  16432. var repl = true;
  16433. var smalloc = ">= 0.11.5 && < 3";
  16434. var _stream_duplex = ">= 0.9.4";
  16435. var _stream_transform = ">= 0.9.4";
  16436. var _stream_wrap = ">= 1.4.1";
  16437. var _stream_passthrough = ">= 0.9.4";
  16438. var _stream_readable = ">= 0.9.4";
  16439. var _stream_writable = ">= 0.9.4";
  16440. var stream$5 = true;
  16441. var string_decoder = true;
  16442. var sys = [
  16443. ">= 0.6 && < 0.7",
  16444. ">= 0.8"
  16445. ];
  16446. var timers = true;
  16447. var _tls_common = ">= 0.11.13";
  16448. var _tls_legacy = ">= 0.11.3 && < 10";
  16449. var _tls_wrap = ">= 0.11.3";
  16450. var tls = true;
  16451. var trace_events = ">= 10";
  16452. var tty = true;
  16453. var url = true;
  16454. var util$1 = true;
  16455. var v8 = ">= 1";
  16456. var vm = true;
  16457. var wasi = ">= 13.4 && < 13.5";
  16458. var worker_threads = ">= 11.7";
  16459. var zlib = true;
  16460. var data$1 = {
  16461. assert: assert,
  16462. "assert/strict": ">= 15",
  16463. async_hooks: async_hooks,
  16464. buffer_ieee754: buffer_ieee754,
  16465. buffer: buffer,
  16466. child_process: child_process,
  16467. cluster: cluster,
  16468. console: console$1,
  16469. constants: constants$3,
  16470. crypto: crypto,
  16471. _debug_agent: _debug_agent,
  16472. _debugger: _debugger,
  16473. dgram: dgram,
  16474. diagnostics_channel: diagnostics_channel,
  16475. dns: dns,
  16476. "dns/promises": ">= 15",
  16477. domain: domain,
  16478. events: events,
  16479. freelist: freelist,
  16480. fs: fs$4,
  16481. "fs/promises": [
  16482. ">= 10 && < 10.1",
  16483. ">= 14"
  16484. ],
  16485. _http_agent: _http_agent,
  16486. _http_client: _http_client,
  16487. _http_common: _http_common,
  16488. _http_incoming: _http_incoming,
  16489. _http_outgoing: _http_outgoing,
  16490. _http_server: _http_server,
  16491. http: http,
  16492. http2: http2,
  16493. https: https,
  16494. inspector: inspector,
  16495. _linklist: _linklist,
  16496. module: module$2,
  16497. net: net,
  16498. "node-inspect/lib/_inspect": ">= 7.6.0 && < 12",
  16499. "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12",
  16500. "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12",
  16501. os: os,
  16502. path: path$1,
  16503. "path/posix": ">= 15.3",
  16504. "path/win32": ">= 15.3",
  16505. perf_hooks: perf_hooks,
  16506. process: process$1,
  16507. punycode: punycode,
  16508. querystring: querystring,
  16509. readline: readline,
  16510. repl: repl,
  16511. smalloc: smalloc,
  16512. _stream_duplex: _stream_duplex,
  16513. _stream_transform: _stream_transform,
  16514. _stream_wrap: _stream_wrap,
  16515. _stream_passthrough: _stream_passthrough,
  16516. _stream_readable: _stream_readable,
  16517. _stream_writable: _stream_writable,
  16518. stream: stream$5,
  16519. "stream/promises": ">= 15",
  16520. string_decoder: string_decoder,
  16521. sys: sys,
  16522. timers: timers,
  16523. "timers/promises": ">= 15",
  16524. _tls_common: _tls_common,
  16525. _tls_legacy: _tls_legacy,
  16526. _tls_wrap: _tls_wrap,
  16527. tls: tls,
  16528. trace_events: trace_events,
  16529. tty: tty,
  16530. url: url,
  16531. util: util$1,
  16532. "util/types": ">= 15.3",
  16533. "v8/tools/arguments": ">= 10 && < 12",
  16534. "v8/tools/codemap": [
  16535. ">= 4.4.0 && < 5",
  16536. ">= 5.2.0 && < 12"
  16537. ],
  16538. "v8/tools/consarray": [
  16539. ">= 4.4.0 && < 5",
  16540. ">= 5.2.0 && < 12"
  16541. ],
  16542. "v8/tools/csvparser": [
  16543. ">= 4.4.0 && < 5",
  16544. ">= 5.2.0 && < 12"
  16545. ],
  16546. "v8/tools/logreader": [
  16547. ">= 4.4.0 && < 5",
  16548. ">= 5.2.0 && < 12"
  16549. ],
  16550. "v8/tools/profile_view": [
  16551. ">= 4.4.0 && < 5",
  16552. ">= 5.2.0 && < 12"
  16553. ],
  16554. "v8/tools/splaytree": [
  16555. ">= 4.4.0 && < 5",
  16556. ">= 5.2.0 && < 12"
  16557. ],
  16558. v8: v8,
  16559. vm: vm,
  16560. wasi: wasi,
  16561. worker_threads: worker_threads,
  16562. zlib: zlib
  16563. };
  16564. var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
  16565. function specifierIncluded(specifier) {
  16566. var parts = specifier.split(' ');
  16567. var op = parts.length > 1 ? parts[0] : '=';
  16568. var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
  16569. for (var i = 0; i < 3; ++i) {
  16570. var cur = parseInt(current[i] || 0, 10);
  16571. var ver = parseInt(versionParts[i] || 0, 10);
  16572. if (cur === ver) {
  16573. continue; // eslint-disable-line no-restricted-syntax, no-continue
  16574. }
  16575. if (op === '<') {
  16576. return cur < ver;
  16577. } else if (op === '>=') {
  16578. return cur >= ver;
  16579. } else {
  16580. return false;
  16581. }
  16582. }
  16583. return op === '>=';
  16584. }
  16585. function matchesRange(range) {
  16586. var specifiers = range.split(/ ?&& ?/);
  16587. if (specifiers.length === 0) {
  16588. return false;
  16589. }
  16590. for (var i = 0; i < specifiers.length; ++i) {
  16591. if (!specifierIncluded(specifiers[i])) {
  16592. return false;
  16593. }
  16594. }
  16595. return true;
  16596. }
  16597. function versionIncluded(specifierValue) {
  16598. if (typeof specifierValue === 'boolean') {
  16599. return specifierValue;
  16600. }
  16601. if (specifierValue && typeof specifierValue === 'object') {
  16602. for (var i = 0; i < specifierValue.length; ++i) {
  16603. if (matchesRange(specifierValue[i])) {
  16604. return true;
  16605. }
  16606. }
  16607. return false;
  16608. }
  16609. return matchesRange(specifierValue);
  16610. }
  16611. var core = {};
  16612. for (var mod in data$1) {
  16613. // eslint-disable-line no-restricted-syntax
  16614. if (Object.prototype.hasOwnProperty.call(data$1, mod)) {
  16615. core[mod] = versionIncluded(data$1[mod]);
  16616. }
  16617. }
  16618. var core_1 = core;
  16619. var isCore = function isCore(x) {
  16620. return isCoreModule(x);
  16621. };
  16622. var realpathFS = fs__default['default'].realpathSync && typeof fs__default['default'].realpathSync.native === 'function' ? fs__default['default'].realpathSync.native : fs__default['default'].realpathSync;
  16623. var defaultIsFile = function isFile(file) {
  16624. try {
  16625. var stat = fs__default['default'].statSync(file);
  16626. } catch (e) {
  16627. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  16628. throw e;
  16629. }
  16630. return stat.isFile() || stat.isFIFO();
  16631. };
  16632. var defaultIsDir = function isDirectory(dir) {
  16633. try {
  16634. var stat = fs__default['default'].statSync(dir);
  16635. } catch (e) {
  16636. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  16637. throw e;
  16638. }
  16639. return stat.isDirectory();
  16640. };
  16641. var defaultRealpathSync = function realpathSync(x) {
  16642. try {
  16643. return realpathFS(x);
  16644. } catch (realpathErr) {
  16645. if (realpathErr.code !== 'ENOENT') {
  16646. throw realpathErr;
  16647. }
  16648. }
  16649. return x;
  16650. };
  16651. var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
  16652. if (opts && opts.preserveSymlinks === false) {
  16653. return realpathSync(x);
  16654. }
  16655. return x;
  16656. };
  16657. var defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) {
  16658. var body = readFileSync(pkgfile);
  16659. try {
  16660. var pkg = JSON.parse(body);
  16661. return pkg;
  16662. } catch (jsonErr) {}
  16663. };
  16664. var getPackageCandidates = function getPackageCandidates(x, start, opts) {
  16665. var dirs = nodeModulesPaths(start, opts, x);
  16666. for (var i = 0; i < dirs.length; i++) {
  16667. dirs[i] = path__default['default'].join(dirs[i], x);
  16668. }
  16669. return dirs;
  16670. };
  16671. var sync$9 = function resolveSync(x, options) {
  16672. if (typeof x !== 'string') {
  16673. throw new TypeError('Path must be a string.');
  16674. }
  16675. var opts = normalizeOptions$1(x, options);
  16676. var isFile = opts.isFile || defaultIsFile;
  16677. var readFileSync = opts.readFileSync || fs__default['default'].readFileSync;
  16678. var isDirectory = opts.isDirectory || defaultIsDir;
  16679. var realpathSync = opts.realpathSync || defaultRealpathSync;
  16680. var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
  16681. if (opts.readFileSync && opts.readPackageSync) {
  16682. throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.');
  16683. }
  16684. var packageIterator = opts.packageIterator;
  16685. var extensions = opts.extensions || ['.js'];
  16686. var includeCoreModules = opts.includeCoreModules !== false;
  16687. var basedir = opts.basedir || path__default['default'].dirname(caller());
  16688. var parent = opts.filename || basedir;
  16689. opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
  16690. var absoluteStart = maybeRealpathSync(realpathSync, path__default['default'].resolve(basedir), opts);
  16691. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  16692. var res = path__default['default'].resolve(absoluteStart, x);
  16693. if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
  16694. var m = loadAsFileSync(res) || loadAsDirectorySync(res);
  16695. if (m) return maybeRealpathSync(realpathSync, m, opts);
  16696. } else if (includeCoreModules && isCoreModule(x)) {
  16697. return x;
  16698. } else {
  16699. var n = loadNodeModulesSync(x, absoluteStart);
  16700. if (n) return maybeRealpathSync(realpathSync, n, opts);
  16701. }
  16702. var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  16703. err.code = 'MODULE_NOT_FOUND';
  16704. throw err;
  16705. function loadAsFileSync(x) {
  16706. var pkg = loadpkg(path__default['default'].dirname(x));
  16707. if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
  16708. var rfile = path__default['default'].relative(pkg.dir, x);
  16709. var r = opts.pathFilter(pkg.pkg, x, rfile);
  16710. if (r) {
  16711. x = path__default['default'].resolve(pkg.dir, r); // eslint-disable-line no-param-reassign
  16712. }
  16713. }
  16714. if (isFile(x)) {
  16715. return x;
  16716. }
  16717. for (var i = 0; i < extensions.length; i++) {
  16718. var file = x + extensions[i];
  16719. if (isFile(file)) {
  16720. return file;
  16721. }
  16722. }
  16723. }
  16724. function loadpkg(dir) {
  16725. if (dir === '' || dir === '/') return;
  16726. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  16727. return;
  16728. }
  16729. if (/[/\\]node_modules[/\\]*$/.test(dir)) return;
  16730. var pkgfile = path__default['default'].join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
  16731. if (!isFile(pkgfile)) {
  16732. return loadpkg(path__default['default'].dirname(dir));
  16733. }
  16734. var pkg = readPackageSync(readFileSync, pkgfile);
  16735. if (pkg && opts.packageFilter) {
  16736. // v2 will pass pkgfile
  16737. pkg = opts.packageFilter(pkg,
  16738. /*pkgfile,*/
  16739. dir); // eslint-disable-line spaced-comment
  16740. }
  16741. return {
  16742. pkg: pkg,
  16743. dir: dir
  16744. };
  16745. }
  16746. function loadAsDirectorySync(x) {
  16747. var pkgfile = path__default['default'].join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
  16748. if (isFile(pkgfile)) {
  16749. try {
  16750. var pkg = readPackageSync(readFileSync, pkgfile);
  16751. } catch (e) {}
  16752. if (pkg && opts.packageFilter) {
  16753. // v2 will pass pkgfile
  16754. pkg = opts.packageFilter(pkg,
  16755. /*pkgfile,*/
  16756. x); // eslint-disable-line spaced-comment
  16757. }
  16758. if (pkg && pkg.main) {
  16759. if (typeof pkg.main !== 'string') {
  16760. var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
  16761. mainError.code = 'INVALID_PACKAGE_MAIN';
  16762. throw mainError;
  16763. }
  16764. if (pkg.main === '.' || pkg.main === './') {
  16765. pkg.main = 'index';
  16766. }
  16767. try {
  16768. var m = loadAsFileSync(path__default['default'].resolve(x, pkg.main));
  16769. if (m) return m;
  16770. var n = loadAsDirectorySync(path__default['default'].resolve(x, pkg.main));
  16771. if (n) return n;
  16772. } catch (e) {}
  16773. }
  16774. }
  16775. return loadAsFileSync(path__default['default'].join(x, '/index'));
  16776. }
  16777. function loadNodeModulesSync(x, start) {
  16778. var thunk = function () {
  16779. return getPackageCandidates(x, start, opts);
  16780. };
  16781. var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
  16782. for (var i = 0; i < dirs.length; i++) {
  16783. var dir = dirs[i];
  16784. if (isDirectory(path__default['default'].dirname(dir))) {
  16785. var m = loadAsFileSync(dir);
  16786. if (m) return m;
  16787. var n = loadAsDirectorySync(dir);
  16788. if (n) return n;
  16789. }
  16790. }
  16791. }
  16792. };
  16793. async$5.core = core_1;
  16794. async$5.isCore = isCore;
  16795. async$5.sync = sync$9;
  16796. var resolve$1 = async$5;
  16797. let {
  16798. resolve
  16799. } = require; // In the VS Code and Atom extensions `require` is overridden and `require.resolve` doesn't support the 2nd argument.
  16800. if (resolve.length === 1 || process.env.PRETTIER_FALLBACK_RESOLVE) {
  16801. // @ts-expect-error
  16802. resolve = (id, options) => {
  16803. let basedir;
  16804. if (options && options.paths && options.paths.length === 1) {
  16805. basedir = options.paths[0];
  16806. }
  16807. return resolve$1.sync(id, {
  16808. basedir
  16809. });
  16810. };
  16811. }
  16812. var resolve_1 = resolve;
  16813. var semver$1 = createCommonjsModule(function (module, exports) {
  16814. exports = module.exports = SemVer;
  16815. var debug;
  16816. /* istanbul ignore next */
  16817. if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
  16818. debug = function () {
  16819. var args = Array.prototype.slice.call(arguments, 0);
  16820. args.unshift('SEMVER');
  16821. console.log.apply(console, args);
  16822. };
  16823. } else {
  16824. debug = function () {};
  16825. } // Note: this is the semver.org version of the spec that it implements
  16826. // Not necessarily the package version of this code.
  16827. exports.SEMVER_SPEC_VERSION = '2.0.0';
  16828. var MAX_LENGTH = 256;
  16829. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  16830. /* istanbul ignore next */
  16831. 9007199254740991; // Max safe segment length for coercion.
  16832. var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
  16833. var re = exports.re = [];
  16834. var src = exports.src = [];
  16835. var R = 0; // The following Regular Expressions can be used for tokenizing,
  16836. // validating, and parsing SemVer version strings.
  16837. // ## Numeric Identifier
  16838. // A single `0`, or a non-zero digit followed by zero or more digits.
  16839. var NUMERICIDENTIFIER = R++;
  16840. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  16841. var NUMERICIDENTIFIERLOOSE = R++;
  16842. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  16843. // Zero or more digits, followed by a letter or hyphen, and then zero or
  16844. // more letters, digits, or hyphens.
  16845. var NONNUMERICIDENTIFIER = R++;
  16846. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  16847. // Three dot-separated numeric identifiers.
  16848. var MAINVERSION = R++;
  16849. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  16850. var MAINVERSIONLOOSE = R++;
  16851. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  16852. // A numeric identifier, or a non-numeric identifier.
  16853. var PRERELEASEIDENTIFIER = R++;
  16854. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  16855. var PRERELEASEIDENTIFIERLOOSE = R++;
  16856. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  16857. // Hyphen, followed by one or more dot-separated pre-release version
  16858. // identifiers.
  16859. var PRERELEASE = R++;
  16860. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  16861. var PRERELEASELOOSE = R++;
  16862. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  16863. // Any combination of digits, letters, or hyphens.
  16864. var BUILDIDENTIFIER = R++;
  16865. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  16866. // Plus sign, followed by one or more period-separated build metadata
  16867. // identifiers.
  16868. var BUILD = R++;
  16869. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  16870. // A main version, followed optionally by a pre-release version and
  16871. // build metadata.
  16872. // Note that the only major, minor, patch, and pre-release sections of
  16873. // the version string are capturing groups. The build metadata is not a
  16874. // capturing group, because it should not ever be used in version
  16875. // comparison.
  16876. var FULL = R++;
  16877. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  16878. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  16879. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  16880. // common in the npm registry.
  16881. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  16882. var LOOSE = R++;
  16883. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  16884. var GTLT = R++;
  16885. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  16886. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  16887. // Only the first item is strictly required.
  16888. var XRANGEIDENTIFIERLOOSE = R++;
  16889. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  16890. var XRANGEIDENTIFIER = R++;
  16891. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  16892. var XRANGEPLAIN = R++;
  16893. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  16894. var XRANGEPLAINLOOSE = R++;
  16895. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  16896. var XRANGE = R++;
  16897. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  16898. var XRANGELOOSE = R++;
  16899. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Coercion.
  16900. // Extract anything that could conceivably be a part of a valid semver
  16901. var COERCE = R++;
  16902. src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; // Tilde ranges.
  16903. // Meaning is "reasonably at or greater than"
  16904. var LONETILDE = R++;
  16905. src[LONETILDE] = '(?:~>?)';
  16906. var TILDETRIM = R++;
  16907. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  16908. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  16909. var tildeTrimReplace = '$1~';
  16910. var TILDE = R++;
  16911. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  16912. var TILDELOOSE = R++;
  16913. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  16914. // Meaning is "at least and backwards compatible with"
  16915. var LONECARET = R++;
  16916. src[LONECARET] = '(?:\\^)';
  16917. var CARETTRIM = R++;
  16918. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  16919. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  16920. var caretTrimReplace = '$1^';
  16921. var CARET = R++;
  16922. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  16923. var CARETLOOSE = R++;
  16924. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  16925. var COMPARATORLOOSE = R++;
  16926. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  16927. var COMPARATOR = R++;
  16928. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  16929. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  16930. var COMPARATORTRIM = R++;
  16931. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  16932. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  16933. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  16934. // Note that these all use the loose form, because they'll be
  16935. // checked against either the strict or loose comparator form
  16936. // later.
  16937. var HYPHENRANGE = R++;
  16938. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  16939. var HYPHENRANGELOOSE = R++;
  16940. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  16941. var STAR = R++;
  16942. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  16943. // All are flag-free, unless they were created above with a flag.
  16944. for (var i = 0; i < R; i++) {
  16945. debug(i, src[i]);
  16946. if (!re[i]) {
  16947. re[i] = new RegExp(src[i]);
  16948. }
  16949. }
  16950. exports.parse = parse;
  16951. function parse(version, options) {
  16952. if (!options || typeof options !== 'object') {
  16953. options = {
  16954. loose: !!options,
  16955. includePrerelease: false
  16956. };
  16957. }
  16958. if (version instanceof SemVer) {
  16959. return version;
  16960. }
  16961. if (typeof version !== 'string') {
  16962. return null;
  16963. }
  16964. if (version.length > MAX_LENGTH) {
  16965. return null;
  16966. }
  16967. var r = options.loose ? re[LOOSE] : re[FULL];
  16968. if (!r.test(version)) {
  16969. return null;
  16970. }
  16971. try {
  16972. return new SemVer(version, options);
  16973. } catch (er) {
  16974. return null;
  16975. }
  16976. }
  16977. exports.valid = valid;
  16978. function valid(version, options) {
  16979. var v = parse(version, options);
  16980. return v ? v.version : null;
  16981. }
  16982. exports.clean = clean;
  16983. function clean(version, options) {
  16984. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  16985. return s ? s.version : null;
  16986. }
  16987. exports.SemVer = SemVer;
  16988. function SemVer(version, options) {
  16989. if (!options || typeof options !== 'object') {
  16990. options = {
  16991. loose: !!options,
  16992. includePrerelease: false
  16993. };
  16994. }
  16995. if (version instanceof SemVer) {
  16996. if (version.loose === options.loose) {
  16997. return version;
  16998. } else {
  16999. version = version.version;
  17000. }
  17001. } else if (typeof version !== 'string') {
  17002. throw new TypeError('Invalid Version: ' + version);
  17003. }
  17004. if (version.length > MAX_LENGTH) {
  17005. throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  17006. }
  17007. if (!(this instanceof SemVer)) {
  17008. return new SemVer(version, options);
  17009. }
  17010. debug('SemVer', version, options);
  17011. this.options = options;
  17012. this.loose = !!options.loose;
  17013. var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
  17014. if (!m) {
  17015. throw new TypeError('Invalid Version: ' + version);
  17016. }
  17017. this.raw = version; // these are actually numbers
  17018. this.major = +m[1];
  17019. this.minor = +m[2];
  17020. this.patch = +m[3];
  17021. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  17022. throw new TypeError('Invalid major version');
  17023. }
  17024. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  17025. throw new TypeError('Invalid minor version');
  17026. }
  17027. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  17028. throw new TypeError('Invalid patch version');
  17029. } // numberify any prerelease numeric ids
  17030. if (!m[4]) {
  17031. this.prerelease = [];
  17032. } else {
  17033. this.prerelease = m[4].split('.').map(function (id) {
  17034. if (/^[0-9]+$/.test(id)) {
  17035. var num = +id;
  17036. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  17037. return num;
  17038. }
  17039. }
  17040. return id;
  17041. });
  17042. }
  17043. this.build = m[5] ? m[5].split('.') : [];
  17044. this.format();
  17045. }
  17046. SemVer.prototype.format = function () {
  17047. this.version = this.major + '.' + this.minor + '.' + this.patch;
  17048. if (this.prerelease.length) {
  17049. this.version += '-' + this.prerelease.join('.');
  17050. }
  17051. return this.version;
  17052. };
  17053. SemVer.prototype.toString = function () {
  17054. return this.version;
  17055. };
  17056. SemVer.prototype.compare = function (other) {
  17057. debug('SemVer.compare', this.version, this.options, other);
  17058. if (!(other instanceof SemVer)) {
  17059. other = new SemVer(other, this.options);
  17060. }
  17061. return this.compareMain(other) || this.comparePre(other);
  17062. };
  17063. SemVer.prototype.compareMain = function (other) {
  17064. if (!(other instanceof SemVer)) {
  17065. other = new SemVer(other, this.options);
  17066. }
  17067. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  17068. };
  17069. SemVer.prototype.comparePre = function (other) {
  17070. if (!(other instanceof SemVer)) {
  17071. other = new SemVer(other, this.options);
  17072. } // NOT having a prerelease is > having one
  17073. if (this.prerelease.length && !other.prerelease.length) {
  17074. return -1;
  17075. } else if (!this.prerelease.length && other.prerelease.length) {
  17076. return 1;
  17077. } else if (!this.prerelease.length && !other.prerelease.length) {
  17078. return 0;
  17079. }
  17080. var i = 0;
  17081. do {
  17082. var a = this.prerelease[i];
  17083. var b = other.prerelease[i];
  17084. debug('prerelease compare', i, a, b);
  17085. if (a === undefined && b === undefined) {
  17086. return 0;
  17087. } else if (b === undefined) {
  17088. return 1;
  17089. } else if (a === undefined) {
  17090. return -1;
  17091. } else if (a === b) {
  17092. continue;
  17093. } else {
  17094. return compareIdentifiers(a, b);
  17095. }
  17096. } while (++i);
  17097. }; // preminor will bump the version up to the next minor release, and immediately
  17098. // down to pre-release. premajor and prepatch work the same way.
  17099. SemVer.prototype.inc = function (release, identifier) {
  17100. switch (release) {
  17101. case 'premajor':
  17102. this.prerelease.length = 0;
  17103. this.patch = 0;
  17104. this.minor = 0;
  17105. this.major++;
  17106. this.inc('pre', identifier);
  17107. break;
  17108. case 'preminor':
  17109. this.prerelease.length = 0;
  17110. this.patch = 0;
  17111. this.minor++;
  17112. this.inc('pre', identifier);
  17113. break;
  17114. case 'prepatch':
  17115. // If this is already a prerelease, it will bump to the next version
  17116. // drop any prereleases that might already exist, since they are not
  17117. // relevant at this point.
  17118. this.prerelease.length = 0;
  17119. this.inc('patch', identifier);
  17120. this.inc('pre', identifier);
  17121. break;
  17122. // If the input is a non-prerelease version, this acts the same as
  17123. // prepatch.
  17124. case 'prerelease':
  17125. if (this.prerelease.length === 0) {
  17126. this.inc('patch', identifier);
  17127. }
  17128. this.inc('pre', identifier);
  17129. break;
  17130. case 'major':
  17131. // If this is a pre-major version, bump up to the same major version.
  17132. // Otherwise increment major.
  17133. // 1.0.0-5 bumps to 1.0.0
  17134. // 1.1.0 bumps to 2.0.0
  17135. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
  17136. this.major++;
  17137. }
  17138. this.minor = 0;
  17139. this.patch = 0;
  17140. this.prerelease = [];
  17141. break;
  17142. case 'minor':
  17143. // If this is a pre-minor version, bump up to the same minor version.
  17144. // Otherwise increment minor.
  17145. // 1.2.0-5 bumps to 1.2.0
  17146. // 1.2.1 bumps to 1.3.0
  17147. if (this.patch !== 0 || this.prerelease.length === 0) {
  17148. this.minor++;
  17149. }
  17150. this.patch = 0;
  17151. this.prerelease = [];
  17152. break;
  17153. case 'patch':
  17154. // If this is not a pre-release version, it will increment the patch.
  17155. // If it is a pre-release it will bump up to the same patch version.
  17156. // 1.2.0-5 patches to 1.2.0
  17157. // 1.2.0 patches to 1.2.1
  17158. if (this.prerelease.length === 0) {
  17159. this.patch++;
  17160. }
  17161. this.prerelease = [];
  17162. break;
  17163. // This probably shouldn't be used publicly.
  17164. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  17165. case 'pre':
  17166. if (this.prerelease.length === 0) {
  17167. this.prerelease = [0];
  17168. } else {
  17169. var i = this.prerelease.length;
  17170. while (--i >= 0) {
  17171. if (typeof this.prerelease[i] === 'number') {
  17172. this.prerelease[i]++;
  17173. i = -2;
  17174. }
  17175. }
  17176. if (i === -1) {
  17177. // didn't increment anything
  17178. this.prerelease.push(0);
  17179. }
  17180. }
  17181. if (identifier) {
  17182. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  17183. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  17184. if (this.prerelease[0] === identifier) {
  17185. if (isNaN(this.prerelease[1])) {
  17186. this.prerelease = [identifier, 0];
  17187. }
  17188. } else {
  17189. this.prerelease = [identifier, 0];
  17190. }
  17191. }
  17192. break;
  17193. default:
  17194. throw new Error('invalid increment argument: ' + release);
  17195. }
  17196. this.format();
  17197. this.raw = this.version;
  17198. return this;
  17199. };
  17200. exports.inc = inc;
  17201. function inc(version, release, loose, identifier) {
  17202. if (typeof loose === 'string') {
  17203. identifier = loose;
  17204. loose = undefined;
  17205. }
  17206. try {
  17207. return new SemVer(version, loose).inc(release, identifier).version;
  17208. } catch (er) {
  17209. return null;
  17210. }
  17211. }
  17212. exports.diff = diff;
  17213. function diff(version1, version2) {
  17214. if (eq(version1, version2)) {
  17215. return null;
  17216. } else {
  17217. var v1 = parse(version1);
  17218. var v2 = parse(version2);
  17219. var prefix = '';
  17220. if (v1.prerelease.length || v2.prerelease.length) {
  17221. prefix = 'pre';
  17222. var defaultResult = 'prerelease';
  17223. }
  17224. for (var key in v1) {
  17225. if (key === 'major' || key === 'minor' || key === 'patch') {
  17226. if (v1[key] !== v2[key]) {
  17227. return prefix + key;
  17228. }
  17229. }
  17230. }
  17231. return defaultResult; // may be undefined
  17232. }
  17233. }
  17234. exports.compareIdentifiers = compareIdentifiers;
  17235. var numeric = /^[0-9]+$/;
  17236. function compareIdentifiers(a, b) {
  17237. var anum = numeric.test(a);
  17238. var bnum = numeric.test(b);
  17239. if (anum && bnum) {
  17240. a = +a;
  17241. b = +b;
  17242. }
  17243. return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
  17244. }
  17245. exports.rcompareIdentifiers = rcompareIdentifiers;
  17246. function rcompareIdentifiers(a, b) {
  17247. return compareIdentifiers(b, a);
  17248. }
  17249. exports.major = major;
  17250. function major(a, loose) {
  17251. return new SemVer(a, loose).major;
  17252. }
  17253. exports.minor = minor;
  17254. function minor(a, loose) {
  17255. return new SemVer(a, loose).minor;
  17256. }
  17257. exports.patch = patch;
  17258. function patch(a, loose) {
  17259. return new SemVer(a, loose).patch;
  17260. }
  17261. exports.compare = compare;
  17262. function compare(a, b, loose) {
  17263. return new SemVer(a, loose).compare(new SemVer(b, loose));
  17264. }
  17265. exports.compareLoose = compareLoose;
  17266. function compareLoose(a, b) {
  17267. return compare(a, b, true);
  17268. }
  17269. exports.rcompare = rcompare;
  17270. function rcompare(a, b, loose) {
  17271. return compare(b, a, loose);
  17272. }
  17273. exports.sort = sort;
  17274. function sort(list, loose) {
  17275. return list.sort(function (a, b) {
  17276. return exports.compare(a, b, loose);
  17277. });
  17278. }
  17279. exports.rsort = rsort;
  17280. function rsort(list, loose) {
  17281. return list.sort(function (a, b) {
  17282. return exports.rcompare(a, b, loose);
  17283. });
  17284. }
  17285. exports.gt = gt;
  17286. function gt(a, b, loose) {
  17287. return compare(a, b, loose) > 0;
  17288. }
  17289. exports.lt = lt;
  17290. function lt(a, b, loose) {
  17291. return compare(a, b, loose) < 0;
  17292. }
  17293. exports.eq = eq;
  17294. function eq(a, b, loose) {
  17295. return compare(a, b, loose) === 0;
  17296. }
  17297. exports.neq = neq;
  17298. function neq(a, b, loose) {
  17299. return compare(a, b, loose) !== 0;
  17300. }
  17301. exports.gte = gte;
  17302. function gte(a, b, loose) {
  17303. return compare(a, b, loose) >= 0;
  17304. }
  17305. exports.lte = lte;
  17306. function lte(a, b, loose) {
  17307. return compare(a, b, loose) <= 0;
  17308. }
  17309. exports.cmp = cmp;
  17310. function cmp(a, op, b, loose) {
  17311. switch (op) {
  17312. case '===':
  17313. if (typeof a === 'object') a = a.version;
  17314. if (typeof b === 'object') b = b.version;
  17315. return a === b;
  17316. case '!==':
  17317. if (typeof a === 'object') a = a.version;
  17318. if (typeof b === 'object') b = b.version;
  17319. return a !== b;
  17320. case '':
  17321. case '=':
  17322. case '==':
  17323. return eq(a, b, loose);
  17324. case '!=':
  17325. return neq(a, b, loose);
  17326. case '>':
  17327. return gt(a, b, loose);
  17328. case '>=':
  17329. return gte(a, b, loose);
  17330. case '<':
  17331. return lt(a, b, loose);
  17332. case '<=':
  17333. return lte(a, b, loose);
  17334. default:
  17335. throw new TypeError('Invalid operator: ' + op);
  17336. }
  17337. }
  17338. exports.Comparator = Comparator;
  17339. function Comparator(comp, options) {
  17340. if (!options || typeof options !== 'object') {
  17341. options = {
  17342. loose: !!options,
  17343. includePrerelease: false
  17344. };
  17345. }
  17346. if (comp instanceof Comparator) {
  17347. if (comp.loose === !!options.loose) {
  17348. return comp;
  17349. } else {
  17350. comp = comp.value;
  17351. }
  17352. }
  17353. if (!(this instanceof Comparator)) {
  17354. return new Comparator(comp, options);
  17355. }
  17356. debug('comparator', comp, options);
  17357. this.options = options;
  17358. this.loose = !!options.loose;
  17359. this.parse(comp);
  17360. if (this.semver === ANY) {
  17361. this.value = '';
  17362. } else {
  17363. this.value = this.operator + this.semver.version;
  17364. }
  17365. debug('comp', this);
  17366. }
  17367. var ANY = {};
  17368. Comparator.prototype.parse = function (comp) {
  17369. var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  17370. var m = comp.match(r);
  17371. if (!m) {
  17372. throw new TypeError('Invalid comparator: ' + comp);
  17373. }
  17374. this.operator = m[1];
  17375. if (this.operator === '=') {
  17376. this.operator = '';
  17377. } // if it literally is just '>' or '' then allow anything.
  17378. if (!m[2]) {
  17379. this.semver = ANY;
  17380. } else {
  17381. this.semver = new SemVer(m[2], this.options.loose);
  17382. }
  17383. };
  17384. Comparator.prototype.toString = function () {
  17385. return this.value;
  17386. };
  17387. Comparator.prototype.test = function (version) {
  17388. debug('Comparator.test', version, this.options.loose);
  17389. if (this.semver === ANY) {
  17390. return true;
  17391. }
  17392. if (typeof version === 'string') {
  17393. version = new SemVer(version, this.options);
  17394. }
  17395. return cmp(version, this.operator, this.semver, this.options);
  17396. };
  17397. Comparator.prototype.intersects = function (comp, options) {
  17398. if (!(comp instanceof Comparator)) {
  17399. throw new TypeError('a Comparator is required');
  17400. }
  17401. if (!options || typeof options !== 'object') {
  17402. options = {
  17403. loose: !!options,
  17404. includePrerelease: false
  17405. };
  17406. }
  17407. var rangeTmp;
  17408. if (this.operator === '') {
  17409. rangeTmp = new Range(comp.value, options);
  17410. return satisfies(this.value, rangeTmp, options);
  17411. } else if (comp.operator === '') {
  17412. rangeTmp = new Range(this.value, options);
  17413. return satisfies(comp.semver, rangeTmp, options);
  17414. }
  17415. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  17416. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  17417. var sameSemVer = this.semver.version === comp.semver.version;
  17418. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  17419. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  17420. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  17421. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  17422. };
  17423. exports.Range = Range;
  17424. function Range(range, options) {
  17425. if (!options || typeof options !== 'object') {
  17426. options = {
  17427. loose: !!options,
  17428. includePrerelease: false
  17429. };
  17430. }
  17431. if (range instanceof Range) {
  17432. if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
  17433. return range;
  17434. } else {
  17435. return new Range(range.raw, options);
  17436. }
  17437. }
  17438. if (range instanceof Comparator) {
  17439. return new Range(range.value, options);
  17440. }
  17441. if (!(this instanceof Range)) {
  17442. return new Range(range, options);
  17443. }
  17444. this.options = options;
  17445. this.loose = !!options.loose;
  17446. this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
  17447. this.raw = range;
  17448. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  17449. return this.parseRange(range.trim());
  17450. }, this).filter(function (c) {
  17451. // throw out any that are not relevant for whatever reason
  17452. return c.length;
  17453. });
  17454. if (!this.set.length) {
  17455. throw new TypeError('Invalid SemVer Range: ' + range);
  17456. }
  17457. this.format();
  17458. }
  17459. Range.prototype.format = function () {
  17460. this.range = this.set.map(function (comps) {
  17461. return comps.join(' ').trim();
  17462. }).join('||').trim();
  17463. return this.range;
  17464. };
  17465. Range.prototype.toString = function () {
  17466. return this.range;
  17467. };
  17468. Range.prototype.parseRange = function (range) {
  17469. var loose = this.options.loose;
  17470. range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  17471. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  17472. range = range.replace(hr, hyphenReplace);
  17473. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  17474. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  17475. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  17476. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  17477. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  17478. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  17479. // ready to be split into comparators.
  17480. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  17481. var set = range.split(' ').map(function (comp) {
  17482. return parseComparator(comp, this.options);
  17483. }, this).join(' ').split(/\s+/);
  17484. if (this.options.loose) {
  17485. // in loose mode, throw out any that are not valid comparators
  17486. set = set.filter(function (comp) {
  17487. return !!comp.match(compRe);
  17488. });
  17489. }
  17490. set = set.map(function (comp) {
  17491. return new Comparator(comp, this.options);
  17492. }, this);
  17493. return set;
  17494. };
  17495. Range.prototype.intersects = function (range, options) {
  17496. if (!(range instanceof Range)) {
  17497. throw new TypeError('a Range is required');
  17498. }
  17499. return this.set.some(function (thisComparators) {
  17500. return thisComparators.every(function (thisComparator) {
  17501. return range.set.some(function (rangeComparators) {
  17502. return rangeComparators.every(function (rangeComparator) {
  17503. return thisComparator.intersects(rangeComparator, options);
  17504. });
  17505. });
  17506. });
  17507. });
  17508. }; // Mostly just for testing and legacy API reasons
  17509. exports.toComparators = toComparators;
  17510. function toComparators(range, options) {
  17511. return new Range(range, options).set.map(function (comp) {
  17512. return comp.map(function (c) {
  17513. return c.value;
  17514. }).join(' ').trim().split(' ');
  17515. });
  17516. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  17517. // already replaced the hyphen ranges
  17518. // turn into a set of JUST comparators.
  17519. function parseComparator(comp, options) {
  17520. debug('comp', comp, options);
  17521. comp = replaceCarets(comp, options);
  17522. debug('caret', comp);
  17523. comp = replaceTildes(comp, options);
  17524. debug('tildes', comp);
  17525. comp = replaceXRanges(comp, options);
  17526. debug('xrange', comp);
  17527. comp = replaceStars(comp, options);
  17528. debug('stars', comp);
  17529. return comp;
  17530. }
  17531. function isX(id) {
  17532. return !id || id.toLowerCase() === 'x' || id === '*';
  17533. } // ~, ~> --> * (any, kinda silly)
  17534. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  17535. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  17536. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  17537. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  17538. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  17539. function replaceTildes(comp, options) {
  17540. return comp.trim().split(/\s+/).map(function (comp) {
  17541. return replaceTilde(comp, options);
  17542. }).join(' ');
  17543. }
  17544. function replaceTilde(comp, options) {
  17545. var r = options.loose ? re[TILDELOOSE] : re[TILDE];
  17546. return comp.replace(r, function (_, M, m, p, pr) {
  17547. debug('tilde', comp, _, M, m, p, pr);
  17548. var ret;
  17549. if (isX(M)) {
  17550. ret = '';
  17551. } else if (isX(m)) {
  17552. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  17553. } else if (isX(p)) {
  17554. // ~1.2 == >=1.2.0 <1.3.0
  17555. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  17556. } else if (pr) {
  17557. debug('replaceTilde pr', pr);
  17558. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
  17559. } else {
  17560. // ~1.2.3 == >=1.2.3 <1.3.0
  17561. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  17562. }
  17563. debug('tilde return', ret);
  17564. return ret;
  17565. });
  17566. } // ^ --> * (any, kinda silly)
  17567. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  17568. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  17569. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  17570. // ^1.2.3 --> >=1.2.3 <2.0.0
  17571. // ^1.2.0 --> >=1.2.0 <2.0.0
  17572. function replaceCarets(comp, options) {
  17573. return comp.trim().split(/\s+/).map(function (comp) {
  17574. return replaceCaret(comp, options);
  17575. }).join(' ');
  17576. }
  17577. function replaceCaret(comp, options) {
  17578. debug('caret', comp, options);
  17579. var r = options.loose ? re[CARETLOOSE] : re[CARET];
  17580. return comp.replace(r, function (_, M, m, p, pr) {
  17581. debug('caret', comp, _, M, m, p, pr);
  17582. var ret;
  17583. if (isX(M)) {
  17584. ret = '';
  17585. } else if (isX(m)) {
  17586. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  17587. } else if (isX(p)) {
  17588. if (M === '0') {
  17589. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  17590. } else {
  17591. ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  17592. }
  17593. } else if (pr) {
  17594. debug('replaceCaret pr', pr);
  17595. if (M === '0') {
  17596. if (m === '0') {
  17597. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
  17598. } else {
  17599. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
  17600. }
  17601. } else {
  17602. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
  17603. }
  17604. } else {
  17605. debug('no pr');
  17606. if (M === '0') {
  17607. if (m === '0') {
  17608. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
  17609. } else {
  17610. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  17611. }
  17612. } else {
  17613. ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  17614. }
  17615. }
  17616. debug('caret return', ret);
  17617. return ret;
  17618. });
  17619. }
  17620. function replaceXRanges(comp, options) {
  17621. debug('replaceXRanges', comp, options);
  17622. return comp.split(/\s+/).map(function (comp) {
  17623. return replaceXRange(comp, options);
  17624. }).join(' ');
  17625. }
  17626. function replaceXRange(comp, options) {
  17627. comp = comp.trim();
  17628. var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
  17629. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  17630. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  17631. var xM = isX(M);
  17632. var xm = xM || isX(m);
  17633. var xp = xm || isX(p);
  17634. var anyX = xp;
  17635. if (gtlt === '=' && anyX) {
  17636. gtlt = '';
  17637. }
  17638. if (xM) {
  17639. if (gtlt === '>' || gtlt === '<') {
  17640. // nothing is allowed
  17641. ret = '<0.0.0';
  17642. } else {
  17643. // nothing is forbidden
  17644. ret = '*';
  17645. }
  17646. } else if (gtlt && anyX) {
  17647. // we know patch is an x, because we have any x at all.
  17648. // replace X with 0
  17649. if (xm) {
  17650. m = 0;
  17651. }
  17652. p = 0;
  17653. if (gtlt === '>') {
  17654. // >1 => >=2.0.0
  17655. // >1.2 => >=1.3.0
  17656. // >1.2.3 => >= 1.2.4
  17657. gtlt = '>=';
  17658. if (xm) {
  17659. M = +M + 1;
  17660. m = 0;
  17661. p = 0;
  17662. } else {
  17663. m = +m + 1;
  17664. p = 0;
  17665. }
  17666. } else if (gtlt === '<=') {
  17667. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  17668. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  17669. gtlt = '<';
  17670. if (xm) {
  17671. M = +M + 1;
  17672. } else {
  17673. m = +m + 1;
  17674. }
  17675. }
  17676. ret = gtlt + M + '.' + m + '.' + p;
  17677. } else if (xm) {
  17678. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  17679. } else if (xp) {
  17680. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  17681. }
  17682. debug('xRange return', ret);
  17683. return ret;
  17684. });
  17685. } // Because * is AND-ed with everything else in the comparator,
  17686. // and '' means "any version", just remove the *s entirely.
  17687. function replaceStars(comp, options) {
  17688. debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
  17689. return comp.trim().replace(re[STAR], '');
  17690. } // This function is passed to string.replace(re[HYPHENRANGE])
  17691. // M, m, patch, prerelease, build
  17692. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  17693. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  17694. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  17695. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  17696. if (isX(fM)) {
  17697. from = '';
  17698. } else if (isX(fm)) {
  17699. from = '>=' + fM + '.0.0';
  17700. } else if (isX(fp)) {
  17701. from = '>=' + fM + '.' + fm + '.0';
  17702. } else {
  17703. from = '>=' + from;
  17704. }
  17705. if (isX(tM)) {
  17706. to = '';
  17707. } else if (isX(tm)) {
  17708. to = '<' + (+tM + 1) + '.0.0';
  17709. } else if (isX(tp)) {
  17710. to = '<' + tM + '.' + (+tm + 1) + '.0';
  17711. } else if (tpr) {
  17712. to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
  17713. } else {
  17714. to = '<=' + to;
  17715. }
  17716. return (from + ' ' + to).trim();
  17717. } // if ANY of the sets match ALL of its comparators, then pass
  17718. Range.prototype.test = function (version) {
  17719. if (!version) {
  17720. return false;
  17721. }
  17722. if (typeof version === 'string') {
  17723. version = new SemVer(version, this.options);
  17724. }
  17725. for (var i = 0; i < this.set.length; i++) {
  17726. if (testSet(this.set[i], version, this.options)) {
  17727. return true;
  17728. }
  17729. }
  17730. return false;
  17731. };
  17732. function testSet(set, version, options) {
  17733. for (var i = 0; i < set.length; i++) {
  17734. if (!set[i].test(version)) {
  17735. return false;
  17736. }
  17737. }
  17738. if (version.prerelease.length && !options.includePrerelease) {
  17739. // Find the set of versions that are allowed to have prereleases
  17740. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  17741. // That should allow `1.2.3-pr.2` to pass.
  17742. // However, `1.2.4-alpha.notready` should NOT be allowed,
  17743. // even though it's within the range set by the comparators.
  17744. for (i = 0; i < set.length; i++) {
  17745. debug(set[i].semver);
  17746. if (set[i].semver === ANY) {
  17747. continue;
  17748. }
  17749. if (set[i].semver.prerelease.length > 0) {
  17750. var allowed = set[i].semver;
  17751. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
  17752. return true;
  17753. }
  17754. }
  17755. } // Version has a -pre, but it's not one of the ones we like.
  17756. return false;
  17757. }
  17758. return true;
  17759. }
  17760. exports.satisfies = satisfies;
  17761. function satisfies(version, range, options) {
  17762. try {
  17763. range = new Range(range, options);
  17764. } catch (er) {
  17765. return false;
  17766. }
  17767. return range.test(version);
  17768. }
  17769. exports.maxSatisfying = maxSatisfying;
  17770. function maxSatisfying(versions, range, options) {
  17771. var max = null;
  17772. var maxSV = null;
  17773. try {
  17774. var rangeObj = new Range(range, options);
  17775. } catch (er) {
  17776. return null;
  17777. }
  17778. versions.forEach(function (v) {
  17779. if (rangeObj.test(v)) {
  17780. // satisfies(v, range, options)
  17781. if (!max || maxSV.compare(v) === -1) {
  17782. // compare(max, v, true)
  17783. max = v;
  17784. maxSV = new SemVer(max, options);
  17785. }
  17786. }
  17787. });
  17788. return max;
  17789. }
  17790. exports.minSatisfying = minSatisfying;
  17791. function minSatisfying(versions, range, options) {
  17792. var min = null;
  17793. var minSV = null;
  17794. try {
  17795. var rangeObj = new Range(range, options);
  17796. } catch (er) {
  17797. return null;
  17798. }
  17799. versions.forEach(function (v) {
  17800. if (rangeObj.test(v)) {
  17801. // satisfies(v, range, options)
  17802. if (!min || minSV.compare(v) === 1) {
  17803. // compare(min, v, true)
  17804. min = v;
  17805. minSV = new SemVer(min, options);
  17806. }
  17807. }
  17808. });
  17809. return min;
  17810. }
  17811. exports.minVersion = minVersion;
  17812. function minVersion(range, loose) {
  17813. range = new Range(range, loose);
  17814. var minver = new SemVer('0.0.0');
  17815. if (range.test(minver)) {
  17816. return minver;
  17817. }
  17818. minver = new SemVer('0.0.0-0');
  17819. if (range.test(minver)) {
  17820. return minver;
  17821. }
  17822. minver = null;
  17823. for (var i = 0; i < range.set.length; ++i) {
  17824. var comparators = range.set[i];
  17825. comparators.forEach(function (comparator) {
  17826. // Clone to avoid manipulating the comparator's semver object.
  17827. var compver = new SemVer(comparator.semver.version);
  17828. switch (comparator.operator) {
  17829. case '>':
  17830. if (compver.prerelease.length === 0) {
  17831. compver.patch++;
  17832. } else {
  17833. compver.prerelease.push(0);
  17834. }
  17835. compver.raw = compver.format();
  17836. /* fallthrough */
  17837. case '':
  17838. case '>=':
  17839. if (!minver || gt(minver, compver)) {
  17840. minver = compver;
  17841. }
  17842. break;
  17843. case '<':
  17844. case '<=':
  17845. /* Ignore maximum versions */
  17846. break;
  17847. /* istanbul ignore next */
  17848. default:
  17849. throw new Error('Unexpected operation: ' + comparator.operator);
  17850. }
  17851. });
  17852. }
  17853. if (minver && range.test(minver)) {
  17854. return minver;
  17855. }
  17856. return null;
  17857. }
  17858. exports.validRange = validRange;
  17859. function validRange(range, options) {
  17860. try {
  17861. // Return '*' instead of '' so that truthiness works.
  17862. // This will throw if it's invalid anyway
  17863. return new Range(range, options).range || '*';
  17864. } catch (er) {
  17865. return null;
  17866. }
  17867. } // Determine if version is less than all the versions possible in the range
  17868. exports.ltr = ltr;
  17869. function ltr(version, range, options) {
  17870. return outside(version, range, '<', options);
  17871. } // Determine if version is greater than all the versions possible in the range.
  17872. exports.gtr = gtr;
  17873. function gtr(version, range, options) {
  17874. return outside(version, range, '>', options);
  17875. }
  17876. exports.outside = outside;
  17877. function outside(version, range, hilo, options) {
  17878. version = new SemVer(version, options);
  17879. range = new Range(range, options);
  17880. var gtfn, ltefn, ltfn, comp, ecomp;
  17881. switch (hilo) {
  17882. case '>':
  17883. gtfn = gt;
  17884. ltefn = lte;
  17885. ltfn = lt;
  17886. comp = '>';
  17887. ecomp = '>=';
  17888. break;
  17889. case '<':
  17890. gtfn = lt;
  17891. ltefn = gte;
  17892. ltfn = gt;
  17893. comp = '<';
  17894. ecomp = '<=';
  17895. break;
  17896. default:
  17897. throw new TypeError('Must provide a hilo val of "<" or ">"');
  17898. } // If it satisifes the range it is not outside
  17899. if (satisfies(version, range, options)) {
  17900. return false;
  17901. } // From now on, variable terms are as if we're in "gtr" mode.
  17902. // but note that everything is flipped for the "ltr" function.
  17903. for (var i = 0; i < range.set.length; ++i) {
  17904. var comparators = range.set[i];
  17905. var high = null;
  17906. var low = null;
  17907. comparators.forEach(function (comparator) {
  17908. if (comparator.semver === ANY) {
  17909. comparator = new Comparator('>=0.0.0');
  17910. }
  17911. high = high || comparator;
  17912. low = low || comparator;
  17913. if (gtfn(comparator.semver, high.semver, options)) {
  17914. high = comparator;
  17915. } else if (ltfn(comparator.semver, low.semver, options)) {
  17916. low = comparator;
  17917. }
  17918. }); // If the edge version comparator has a operator then our version
  17919. // isn't outside it
  17920. if (high.operator === comp || high.operator === ecomp) {
  17921. return false;
  17922. } // If the lowest version comparator has an operator and our version
  17923. // is less than it then it isn't higher than the range
  17924. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  17925. return false;
  17926. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  17927. return false;
  17928. }
  17929. }
  17930. return true;
  17931. }
  17932. exports.prerelease = prerelease;
  17933. function prerelease(version, options) {
  17934. var parsed = parse(version, options);
  17935. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  17936. }
  17937. exports.intersects = intersects;
  17938. function intersects(r1, r2, options) {
  17939. r1 = new Range(r1, options);
  17940. r2 = new Range(r2, options);
  17941. return r1.intersects(r2);
  17942. }
  17943. exports.coerce = coerce;
  17944. function coerce(version) {
  17945. if (version instanceof SemVer) {
  17946. return version;
  17947. }
  17948. if (typeof version !== 'string') {
  17949. return null;
  17950. }
  17951. var match = version.match(re[COERCE]);
  17952. if (match == null) {
  17953. return null;
  17954. }
  17955. return parse(match[1] + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
  17956. }
  17957. });
  17958. var hasOwnProperty$9 = Object.prototype.hasOwnProperty;
  17959. var pseudomap = PseudoMap;
  17960. function PseudoMap(set) {
  17961. if (!(this instanceof PseudoMap)) // whyyyyyyy
  17962. throw new TypeError("Constructor PseudoMap requires 'new'");
  17963. this.clear();
  17964. if (set) {
  17965. if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
  17966. this.set(key, value);
  17967. }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
  17968. this.set(kv[0], kv[1]);
  17969. }, this);else throw new TypeError('invalid argument');
  17970. }
  17971. }
  17972. PseudoMap.prototype.forEach = function (fn, thisp) {
  17973. thisp = thisp || this;
  17974. Object.keys(this._data).forEach(function (k) {
  17975. if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
  17976. }, this);
  17977. };
  17978. PseudoMap.prototype.has = function (k) {
  17979. return !!find(this._data, k);
  17980. };
  17981. PseudoMap.prototype.get = function (k) {
  17982. var res = find(this._data, k);
  17983. return res && res.value;
  17984. };
  17985. PseudoMap.prototype.set = function (k, v) {
  17986. set(this._data, k, v);
  17987. };
  17988. PseudoMap.prototype.delete = function (k) {
  17989. var res = find(this._data, k);
  17990. if (res) {
  17991. delete this._data[res._index];
  17992. this._data.size--;
  17993. }
  17994. };
  17995. PseudoMap.prototype.clear = function () {
  17996. var data = Object.create(null);
  17997. data.size = 0;
  17998. Object.defineProperty(this, '_data', {
  17999. value: data,
  18000. enumerable: false,
  18001. configurable: true,
  18002. writable: false
  18003. });
  18004. };
  18005. Object.defineProperty(PseudoMap.prototype, 'size', {
  18006. get: function () {
  18007. return this._data.size;
  18008. },
  18009. set: function (n) {},
  18010. enumerable: true,
  18011. configurable: true
  18012. });
  18013. PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
  18014. throw new Error('iterators are not implemented in this version');
  18015. }; // Either identical, or both NaN
  18016. function same(a, b) {
  18017. return a === b || a !== a && b !== b;
  18018. }
  18019. function Entry$1(k, v, i) {
  18020. this.key = k;
  18021. this.value = v;
  18022. this._index = i;
  18023. }
  18024. function find(data, k) {
  18025. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
  18026. if (same(data[key].key, k)) return data[key];
  18027. }
  18028. }
  18029. function set(data, k, v) {
  18030. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
  18031. if (same(data[key].key, k)) {
  18032. data[key].value = v;
  18033. return;
  18034. }
  18035. }
  18036. data.size++;
  18037. data[key] = new Entry$1(k, v, key);
  18038. }
  18039. var map$1 = createCommonjsModule(function (module) {
  18040. if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
  18041. if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
  18042. module.exports = Map;
  18043. } else {
  18044. module.exports = pseudomap;
  18045. }
  18046. });
  18047. var yallist = Yallist;
  18048. Yallist.Node = Node;
  18049. Yallist.create = Yallist;
  18050. function Yallist(list) {
  18051. var self = this;
  18052. if (!(self instanceof Yallist)) {
  18053. self = new Yallist();
  18054. }
  18055. self.tail = null;
  18056. self.head = null;
  18057. self.length = 0;
  18058. if (list && typeof list.forEach === 'function') {
  18059. list.forEach(function (item) {
  18060. self.push(item);
  18061. });
  18062. } else if (arguments.length > 0) {
  18063. for (var i = 0, l = arguments.length; i < l; i++) {
  18064. self.push(arguments[i]);
  18065. }
  18066. }
  18067. return self;
  18068. }
  18069. Yallist.prototype.removeNode = function (node) {
  18070. if (node.list !== this) {
  18071. throw new Error('removing node which does not belong to this list');
  18072. }
  18073. var next = node.next;
  18074. var prev = node.prev;
  18075. if (next) {
  18076. next.prev = prev;
  18077. }
  18078. if (prev) {
  18079. prev.next = next;
  18080. }
  18081. if (node === this.head) {
  18082. this.head = next;
  18083. }
  18084. if (node === this.tail) {
  18085. this.tail = prev;
  18086. }
  18087. node.list.length--;
  18088. node.next = null;
  18089. node.prev = null;
  18090. node.list = null;
  18091. };
  18092. Yallist.prototype.unshiftNode = function (node) {
  18093. if (node === this.head) {
  18094. return;
  18095. }
  18096. if (node.list) {
  18097. node.list.removeNode(node);
  18098. }
  18099. var head = this.head;
  18100. node.list = this;
  18101. node.next = head;
  18102. if (head) {
  18103. head.prev = node;
  18104. }
  18105. this.head = node;
  18106. if (!this.tail) {
  18107. this.tail = node;
  18108. }
  18109. this.length++;
  18110. };
  18111. Yallist.prototype.pushNode = function (node) {
  18112. if (node === this.tail) {
  18113. return;
  18114. }
  18115. if (node.list) {
  18116. node.list.removeNode(node);
  18117. }
  18118. var tail = this.tail;
  18119. node.list = this;
  18120. node.prev = tail;
  18121. if (tail) {
  18122. tail.next = node;
  18123. }
  18124. this.tail = node;
  18125. if (!this.head) {
  18126. this.head = node;
  18127. }
  18128. this.length++;
  18129. };
  18130. Yallist.prototype.push = function () {
  18131. for (var i = 0, l = arguments.length; i < l; i++) {
  18132. push(this, arguments[i]);
  18133. }
  18134. return this.length;
  18135. };
  18136. Yallist.prototype.unshift = function () {
  18137. for (var i = 0, l = arguments.length; i < l; i++) {
  18138. unshift(this, arguments[i]);
  18139. }
  18140. return this.length;
  18141. };
  18142. Yallist.prototype.pop = function () {
  18143. if (!this.tail) {
  18144. return undefined;
  18145. }
  18146. var res = this.tail.value;
  18147. this.tail = this.tail.prev;
  18148. if (this.tail) {
  18149. this.tail.next = null;
  18150. } else {
  18151. this.head = null;
  18152. }
  18153. this.length--;
  18154. return res;
  18155. };
  18156. Yallist.prototype.shift = function () {
  18157. if (!this.head) {
  18158. return undefined;
  18159. }
  18160. var res = this.head.value;
  18161. this.head = this.head.next;
  18162. if (this.head) {
  18163. this.head.prev = null;
  18164. } else {
  18165. this.tail = null;
  18166. }
  18167. this.length--;
  18168. return res;
  18169. };
  18170. Yallist.prototype.forEach = function (fn, thisp) {
  18171. thisp = thisp || this;
  18172. for (var walker = this.head, i = 0; walker !== null; i++) {
  18173. fn.call(thisp, walker.value, i, this);
  18174. walker = walker.next;
  18175. }
  18176. };
  18177. Yallist.prototype.forEachReverse = function (fn, thisp) {
  18178. thisp = thisp || this;
  18179. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  18180. fn.call(thisp, walker.value, i, this);
  18181. walker = walker.prev;
  18182. }
  18183. };
  18184. Yallist.prototype.get = function (n) {
  18185. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  18186. // abort out of the list early if we hit a cycle
  18187. walker = walker.next;
  18188. }
  18189. if (i === n && walker !== null) {
  18190. return walker.value;
  18191. }
  18192. };
  18193. Yallist.prototype.getReverse = function (n) {
  18194. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  18195. // abort out of the list early if we hit a cycle
  18196. walker = walker.prev;
  18197. }
  18198. if (i === n && walker !== null) {
  18199. return walker.value;
  18200. }
  18201. };
  18202. Yallist.prototype.map = function (fn, thisp) {
  18203. thisp = thisp || this;
  18204. var res = new Yallist();
  18205. for (var walker = this.head; walker !== null;) {
  18206. res.push(fn.call(thisp, walker.value, this));
  18207. walker = walker.next;
  18208. }
  18209. return res;
  18210. };
  18211. Yallist.prototype.mapReverse = function (fn, thisp) {
  18212. thisp = thisp || this;
  18213. var res = new Yallist();
  18214. for (var walker = this.tail; walker !== null;) {
  18215. res.push(fn.call(thisp, walker.value, this));
  18216. walker = walker.prev;
  18217. }
  18218. return res;
  18219. };
  18220. Yallist.prototype.reduce = function (fn, initial) {
  18221. var acc;
  18222. var walker = this.head;
  18223. if (arguments.length > 1) {
  18224. acc = initial;
  18225. } else if (this.head) {
  18226. walker = this.head.next;
  18227. acc = this.head.value;
  18228. } else {
  18229. throw new TypeError('Reduce of empty list with no initial value');
  18230. }
  18231. for (var i = 0; walker !== null; i++) {
  18232. acc = fn(acc, walker.value, i);
  18233. walker = walker.next;
  18234. }
  18235. return acc;
  18236. };
  18237. Yallist.prototype.reduceReverse = function (fn, initial) {
  18238. var acc;
  18239. var walker = this.tail;
  18240. if (arguments.length > 1) {
  18241. acc = initial;
  18242. } else if (this.tail) {
  18243. walker = this.tail.prev;
  18244. acc = this.tail.value;
  18245. } else {
  18246. throw new TypeError('Reduce of empty list with no initial value');
  18247. }
  18248. for (var i = this.length - 1; walker !== null; i--) {
  18249. acc = fn(acc, walker.value, i);
  18250. walker = walker.prev;
  18251. }
  18252. return acc;
  18253. };
  18254. Yallist.prototype.toArray = function () {
  18255. var arr = new Array(this.length);
  18256. for (var i = 0, walker = this.head; walker !== null; i++) {
  18257. arr[i] = walker.value;
  18258. walker = walker.next;
  18259. }
  18260. return arr;
  18261. };
  18262. Yallist.prototype.toArrayReverse = function () {
  18263. var arr = new Array(this.length);
  18264. for (var i = 0, walker = this.tail; walker !== null; i++) {
  18265. arr[i] = walker.value;
  18266. walker = walker.prev;
  18267. }
  18268. return arr;
  18269. };
  18270. Yallist.prototype.slice = function (from, to) {
  18271. to = to || this.length;
  18272. if (to < 0) {
  18273. to += this.length;
  18274. }
  18275. from = from || 0;
  18276. if (from < 0) {
  18277. from += this.length;
  18278. }
  18279. var ret = new Yallist();
  18280. if (to < from || to < 0) {
  18281. return ret;
  18282. }
  18283. if (from < 0) {
  18284. from = 0;
  18285. }
  18286. if (to > this.length) {
  18287. to = this.length;
  18288. }
  18289. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  18290. walker = walker.next;
  18291. }
  18292. for (; walker !== null && i < to; i++, walker = walker.next) {
  18293. ret.push(walker.value);
  18294. }
  18295. return ret;
  18296. };
  18297. Yallist.prototype.sliceReverse = function (from, to) {
  18298. to = to || this.length;
  18299. if (to < 0) {
  18300. to += this.length;
  18301. }
  18302. from = from || 0;
  18303. if (from < 0) {
  18304. from += this.length;
  18305. }
  18306. var ret = new Yallist();
  18307. if (to < from || to < 0) {
  18308. return ret;
  18309. }
  18310. if (from < 0) {
  18311. from = 0;
  18312. }
  18313. if (to > this.length) {
  18314. to = this.length;
  18315. }
  18316. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  18317. walker = walker.prev;
  18318. }
  18319. for (; walker !== null && i > from; i--, walker = walker.prev) {
  18320. ret.push(walker.value);
  18321. }
  18322. return ret;
  18323. };
  18324. Yallist.prototype.reverse = function () {
  18325. var head = this.head;
  18326. var tail = this.tail;
  18327. for (var walker = head; walker !== null; walker = walker.prev) {
  18328. var p = walker.prev;
  18329. walker.prev = walker.next;
  18330. walker.next = p;
  18331. }
  18332. this.head = tail;
  18333. this.tail = head;
  18334. return this;
  18335. };
  18336. function push(self, item) {
  18337. self.tail = new Node(item, self.tail, null, self);
  18338. if (!self.head) {
  18339. self.head = self.tail;
  18340. }
  18341. self.length++;
  18342. }
  18343. function unshift(self, item) {
  18344. self.head = new Node(item, null, self.head, self);
  18345. if (!self.tail) {
  18346. self.tail = self.head;
  18347. }
  18348. self.length++;
  18349. }
  18350. function Node(value, prev, next, list) {
  18351. if (!(this instanceof Node)) {
  18352. return new Node(value, prev, next, list);
  18353. }
  18354. this.list = list;
  18355. this.value = value;
  18356. if (prev) {
  18357. prev.next = this;
  18358. this.prev = prev;
  18359. } else {
  18360. this.prev = null;
  18361. }
  18362. if (next) {
  18363. next.prev = this;
  18364. this.next = next;
  18365. } else {
  18366. this.next = null;
  18367. }
  18368. }
  18369. var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
  18370. // or a fakey-fake PseudoMap in older versions.
  18371. // A linked list to keep track of recently-used-ness
  18372. // use symbols if possible, otherwise just _props
  18373. var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1';
  18374. var makeSymbol;
  18375. if (hasSymbol) {
  18376. makeSymbol = function (key) {
  18377. return Symbol(key);
  18378. };
  18379. } else {
  18380. makeSymbol = function (key) {
  18381. return '_' + key;
  18382. };
  18383. }
  18384. var MAX = makeSymbol('max');
  18385. var LENGTH = makeSymbol('length');
  18386. var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
  18387. var ALLOW_STALE = makeSymbol('allowStale');
  18388. var MAX_AGE = makeSymbol('maxAge');
  18389. var DISPOSE = makeSymbol('dispose');
  18390. var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
  18391. var LRU_LIST = makeSymbol('lruList');
  18392. var CACHE = makeSymbol('cache');
  18393. function naiveLength() {
  18394. return 1;
  18395. } // lruList is a yallist where the head is the youngest
  18396. // item, and the tail is the oldest. the list contains the Hit
  18397. // objects as the entries.
  18398. // Each Hit object has a reference to its Yallist.Node. This
  18399. // never changes.
  18400. //
  18401. // cache is a Map (or PseudoMap) that matches the keys to
  18402. // the Yallist.Node object.
  18403. function LRUCache(options) {
  18404. if (!(this instanceof LRUCache)) {
  18405. return new LRUCache(options);
  18406. }
  18407. if (typeof options === 'number') {
  18408. options = {
  18409. max: options
  18410. };
  18411. }
  18412. if (!options) {
  18413. options = {};
  18414. }
  18415. var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
  18416. if (!max || !(typeof max === 'number') || max <= 0) {
  18417. this[MAX] = Infinity;
  18418. }
  18419. var lc = options.length || naiveLength;
  18420. if (typeof lc !== 'function') {
  18421. lc = naiveLength;
  18422. }
  18423. this[LENGTH_CALCULATOR] = lc;
  18424. this[ALLOW_STALE] = options.stale || false;
  18425. this[MAX_AGE] = options.maxAge || 0;
  18426. this[DISPOSE] = options.dispose;
  18427. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  18428. this.reset();
  18429. } // resize the cache when the max changes.
  18430. Object.defineProperty(LRUCache.prototype, 'max', {
  18431. set: function (mL) {
  18432. if (!mL || !(typeof mL === 'number') || mL <= 0) {
  18433. mL = Infinity;
  18434. }
  18435. this[MAX] = mL;
  18436. trim(this);
  18437. },
  18438. get: function () {
  18439. return this[MAX];
  18440. },
  18441. enumerable: true
  18442. });
  18443. Object.defineProperty(LRUCache.prototype, 'allowStale', {
  18444. set: function (allowStale) {
  18445. this[ALLOW_STALE] = !!allowStale;
  18446. },
  18447. get: function () {
  18448. return this[ALLOW_STALE];
  18449. },
  18450. enumerable: true
  18451. });
  18452. Object.defineProperty(LRUCache.prototype, 'maxAge', {
  18453. set: function (mA) {
  18454. if (!mA || !(typeof mA === 'number') || mA < 0) {
  18455. mA = 0;
  18456. }
  18457. this[MAX_AGE] = mA;
  18458. trim(this);
  18459. },
  18460. get: function () {
  18461. return this[MAX_AGE];
  18462. },
  18463. enumerable: true
  18464. }); // resize the cache when the lengthCalculator changes.
  18465. Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
  18466. set: function (lC) {
  18467. if (typeof lC !== 'function') {
  18468. lC = naiveLength;
  18469. }
  18470. if (lC !== this[LENGTH_CALCULATOR]) {
  18471. this[LENGTH_CALCULATOR] = lC;
  18472. this[LENGTH] = 0;
  18473. this[LRU_LIST].forEach(function (hit) {
  18474. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  18475. this[LENGTH] += hit.length;
  18476. }, this);
  18477. }
  18478. trim(this);
  18479. },
  18480. get: function () {
  18481. return this[LENGTH_CALCULATOR];
  18482. },
  18483. enumerable: true
  18484. });
  18485. Object.defineProperty(LRUCache.prototype, 'length', {
  18486. get: function () {
  18487. return this[LENGTH];
  18488. },
  18489. enumerable: true
  18490. });
  18491. Object.defineProperty(LRUCache.prototype, 'itemCount', {
  18492. get: function () {
  18493. return this[LRU_LIST].length;
  18494. },
  18495. enumerable: true
  18496. });
  18497. LRUCache.prototype.rforEach = function (fn, thisp) {
  18498. thisp = thisp || this;
  18499. for (var walker = this[LRU_LIST].tail; walker !== null;) {
  18500. var prev = walker.prev;
  18501. forEachStep(this, fn, walker, thisp);
  18502. walker = prev;
  18503. }
  18504. };
  18505. function forEachStep(self, fn, node, thisp) {
  18506. var hit = node.value;
  18507. if (isStale(self, hit)) {
  18508. del$1(self, node);
  18509. if (!self[ALLOW_STALE]) {
  18510. hit = undefined;
  18511. }
  18512. }
  18513. if (hit) {
  18514. fn.call(thisp, hit.value, hit.key, self);
  18515. }
  18516. }
  18517. LRUCache.prototype.forEach = function (fn, thisp) {
  18518. thisp = thisp || this;
  18519. for (var walker = this[LRU_LIST].head; walker !== null;) {
  18520. var next = walker.next;
  18521. forEachStep(this, fn, walker, thisp);
  18522. walker = next;
  18523. }
  18524. };
  18525. LRUCache.prototype.keys = function () {
  18526. return this[LRU_LIST].toArray().map(function (k) {
  18527. return k.key;
  18528. }, this);
  18529. };
  18530. LRUCache.prototype.values = function () {
  18531. return this[LRU_LIST].toArray().map(function (k) {
  18532. return k.value;
  18533. }, this);
  18534. };
  18535. LRUCache.prototype.reset = function () {
  18536. if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
  18537. this[LRU_LIST].forEach(function (hit) {
  18538. this[DISPOSE](hit.key, hit.value);
  18539. }, this);
  18540. }
  18541. this[CACHE] = new map$1(); // hash of items by key
  18542. this[LRU_LIST] = new yallist(); // list of items in order of use recency
  18543. this[LENGTH] = 0; // length of items in the list
  18544. };
  18545. LRUCache.prototype.dump = function () {
  18546. return this[LRU_LIST].map(function (hit) {
  18547. if (!isStale(this, hit)) {
  18548. return {
  18549. k: hit.key,
  18550. v: hit.value,
  18551. e: hit.now + (hit.maxAge || 0)
  18552. };
  18553. }
  18554. }, this).toArray().filter(function (h) {
  18555. return h;
  18556. });
  18557. };
  18558. LRUCache.prototype.dumpLru = function () {
  18559. return this[LRU_LIST];
  18560. };
  18561. /* istanbul ignore next */
  18562. LRUCache.prototype.inspect = function (n, opts) {
  18563. var str = 'LRUCache {';
  18564. var extras = false;
  18565. var as = this[ALLOW_STALE];
  18566. if (as) {
  18567. str += '\n allowStale: true';
  18568. extras = true;
  18569. }
  18570. var max = this[MAX];
  18571. if (max && max !== Infinity) {
  18572. if (extras) {
  18573. str += ',';
  18574. }
  18575. str += '\n max: ' + util__default['default'].inspect(max, opts);
  18576. extras = true;
  18577. }
  18578. var maxAge = this[MAX_AGE];
  18579. if (maxAge) {
  18580. if (extras) {
  18581. str += ',';
  18582. }
  18583. str += '\n maxAge: ' + util__default['default'].inspect(maxAge, opts);
  18584. extras = true;
  18585. }
  18586. var lc = this[LENGTH_CALCULATOR];
  18587. if (lc && lc !== naiveLength) {
  18588. if (extras) {
  18589. str += ',';
  18590. }
  18591. str += '\n length: ' + util__default['default'].inspect(this[LENGTH], opts);
  18592. extras = true;
  18593. }
  18594. var didFirst = false;
  18595. this[LRU_LIST].forEach(function (item) {
  18596. if (didFirst) {
  18597. str += ',\n ';
  18598. } else {
  18599. if (extras) {
  18600. str += ',\n';
  18601. }
  18602. didFirst = true;
  18603. str += '\n ';
  18604. }
  18605. var key = util__default['default'].inspect(item.key).split('\n').join('\n ');
  18606. var val = {
  18607. value: item.value
  18608. };
  18609. if (item.maxAge !== maxAge) {
  18610. val.maxAge = item.maxAge;
  18611. }
  18612. if (lc !== naiveLength) {
  18613. val.length = item.length;
  18614. }
  18615. if (isStale(this, item)) {
  18616. val.stale = true;
  18617. }
  18618. val = util__default['default'].inspect(val, opts).split('\n').join('\n ');
  18619. str += key + ' => ' + val;
  18620. });
  18621. if (didFirst || extras) {
  18622. str += '\n';
  18623. }
  18624. str += '}';
  18625. return str;
  18626. };
  18627. LRUCache.prototype.set = function (key, value, maxAge) {
  18628. maxAge = maxAge || this[MAX_AGE];
  18629. var now = maxAge ? Date.now() : 0;
  18630. var len = this[LENGTH_CALCULATOR](value, key);
  18631. if (this[CACHE].has(key)) {
  18632. if (len > this[MAX]) {
  18633. del$1(this, this[CACHE].get(key));
  18634. return false;
  18635. }
  18636. var node = this[CACHE].get(key);
  18637. var item = node.value; // dispose of the old one before overwriting
  18638. // split out into 2 ifs for better coverage tracking
  18639. if (this[DISPOSE]) {
  18640. if (!this[NO_DISPOSE_ON_SET]) {
  18641. this[DISPOSE](key, item.value);
  18642. }
  18643. }
  18644. item.now = now;
  18645. item.maxAge = maxAge;
  18646. item.value = value;
  18647. this[LENGTH] += len - item.length;
  18648. item.length = len;
  18649. this.get(key);
  18650. trim(this);
  18651. return true;
  18652. }
  18653. var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
  18654. if (hit.length > this[MAX]) {
  18655. if (this[DISPOSE]) {
  18656. this[DISPOSE](key, value);
  18657. }
  18658. return false;
  18659. }
  18660. this[LENGTH] += hit.length;
  18661. this[LRU_LIST].unshift(hit);
  18662. this[CACHE].set(key, this[LRU_LIST].head);
  18663. trim(this);
  18664. return true;
  18665. };
  18666. LRUCache.prototype.has = function (key) {
  18667. if (!this[CACHE].has(key)) return false;
  18668. var hit = this[CACHE].get(key).value;
  18669. if (isStale(this, hit)) {
  18670. return false;
  18671. }
  18672. return true;
  18673. };
  18674. LRUCache.prototype.get = function (key) {
  18675. return get$1(this, key, true);
  18676. };
  18677. LRUCache.prototype.peek = function (key) {
  18678. return get$1(this, key, false);
  18679. };
  18680. LRUCache.prototype.pop = function () {
  18681. var node = this[LRU_LIST].tail;
  18682. if (!node) return null;
  18683. del$1(this, node);
  18684. return node.value;
  18685. };
  18686. LRUCache.prototype.del = function (key) {
  18687. del$1(this, this[CACHE].get(key));
  18688. };
  18689. LRUCache.prototype.load = function (arr) {
  18690. // reset the cache
  18691. this.reset();
  18692. var now = Date.now(); // A previous serialized cache has the most recent items first
  18693. for (var l = arr.length - 1; l >= 0; l--) {
  18694. var hit = arr[l];
  18695. var expiresAt = hit.e || 0;
  18696. if (expiresAt === 0) {
  18697. // the item was created without expiration in a non aged cache
  18698. this.set(hit.k, hit.v);
  18699. } else {
  18700. var maxAge = expiresAt - now; // dont add already expired items
  18701. if (maxAge > 0) {
  18702. this.set(hit.k, hit.v, maxAge);
  18703. }
  18704. }
  18705. }
  18706. };
  18707. LRUCache.prototype.prune = function () {
  18708. var self = this;
  18709. this[CACHE].forEach(function (value, key) {
  18710. get$1(self, key, false);
  18711. });
  18712. };
  18713. function get$1(self, key, doUse) {
  18714. var node = self[CACHE].get(key);
  18715. if (node) {
  18716. var hit = node.value;
  18717. if (isStale(self, hit)) {
  18718. del$1(self, node);
  18719. if (!self[ALLOW_STALE]) hit = undefined;
  18720. } else {
  18721. if (doUse) {
  18722. self[LRU_LIST].unshiftNode(node);
  18723. }
  18724. }
  18725. if (hit) hit = hit.value;
  18726. }
  18727. return hit;
  18728. }
  18729. function isStale(self, hit) {
  18730. if (!hit || !hit.maxAge && !self[MAX_AGE]) {
  18731. return false;
  18732. }
  18733. var stale = false;
  18734. var diff = Date.now() - hit.now;
  18735. if (hit.maxAge) {
  18736. stale = diff > hit.maxAge;
  18737. } else {
  18738. stale = self[MAX_AGE] && diff > self[MAX_AGE];
  18739. }
  18740. return stale;
  18741. }
  18742. function trim(self) {
  18743. if (self[LENGTH] > self[MAX]) {
  18744. for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
  18745. // We know that we're about to delete this one, and also
  18746. // what the next least recently used key will be, so just
  18747. // go ahead and set it now.
  18748. var prev = walker.prev;
  18749. del$1(self, walker);
  18750. walker = prev;
  18751. }
  18752. }
  18753. }
  18754. function del$1(self, node) {
  18755. if (node) {
  18756. var hit = node.value;
  18757. if (self[DISPOSE]) {
  18758. self[DISPOSE](hit.key, hit.value);
  18759. }
  18760. self[LENGTH] -= hit.length;
  18761. self[CACHE].delete(hit.key);
  18762. self[LRU_LIST].removeNode(node);
  18763. }
  18764. } // classy, since V8 prefers predictable objects.
  18765. function Entry(key, value, length, now, maxAge) {
  18766. this.key = key;
  18767. this.value = value;
  18768. this.length = length;
  18769. this.now = now;
  18770. this.maxAge = maxAge || 0;
  18771. }
  18772. var sigmund_1 = sigmund;
  18773. function sigmund(subject, maxSessions) {
  18774. maxSessions = maxSessions || 10;
  18775. var notes = [];
  18776. var analysis = '';
  18777. var RE = RegExp;
  18778. function psychoAnalyze(subject, session) {
  18779. if (session > maxSessions) return;
  18780. if (typeof subject === 'function' || typeof subject === 'undefined') {
  18781. return;
  18782. }
  18783. if (typeof subject !== 'object' || !subject || subject instanceof RE) {
  18784. analysis += subject;
  18785. return;
  18786. }
  18787. if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
  18788. notes.push(subject);
  18789. analysis += '{';
  18790. Object.keys(subject).forEach(function (issue, _, __) {
  18791. // pseudo-private values. skip those.
  18792. if (issue.charAt(0) === '_') return;
  18793. var to = typeof subject[issue];
  18794. if (to === 'function' || to === 'undefined') return;
  18795. analysis += issue;
  18796. psychoAnalyze(subject[issue], session + 1);
  18797. });
  18798. }
  18799. psychoAnalyze(subject, 0);
  18800. return analysis;
  18801. } // vim: set softtabstop=4 shiftwidth=4:
  18802. var fnmatch$1 = createCommonjsModule(function (module, exports) {
  18803. // Based on minimatch.js by isaacs <https://npmjs.org/package/minimatch>
  18804. var platform = typeof process === "object" ? process.platform : "win32";
  18805. if (module) module.exports = minimatch;else exports.minimatch = minimatch;
  18806. minimatch.Minimatch = Minimatch;
  18807. var cache = minimatch.cache = new lruCache({
  18808. max: 100
  18809. }),
  18810. GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  18811. var qmark = "[^/]" // * => any number of characters
  18812. ,
  18813. star = qmark + "*?" // ** when dots are allowed. Anything goes, except .. and .
  18814. // not (^ or / followed by one or two dots followed by $ or /),
  18815. // followed by anything, any number of times.
  18816. ,
  18817. twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" // not a ^ or / followed by a dot,
  18818. // followed by anything, any number of times.
  18819. ,
  18820. twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" // characters that need to be escaped in RegExp.
  18821. ,
  18822. reSpecials = charSet("().*{}+?[]^$\\!"); // "abc" -> { a:true, b:true, c:true }
  18823. function charSet(s) {
  18824. return s.split("").reduce(function (set, c) {
  18825. set[c] = true;
  18826. return set;
  18827. }, {});
  18828. } // normalizes slashes.
  18829. var slashSplit = /\/+/;
  18830. minimatch.monkeyPatch = monkeyPatch;
  18831. function monkeyPatch() {
  18832. var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
  18833. var orig = desc.value;
  18834. desc.value = function (p) {
  18835. if (p instanceof Minimatch) return p.match(this);
  18836. return orig.call(this, p);
  18837. };
  18838. Object.defineProperty(String.prototype, desc);
  18839. }
  18840. minimatch.filter = filter;
  18841. function filter(pattern, options) {
  18842. options = options || {};
  18843. return function (p, i, list) {
  18844. return minimatch(p, pattern, options);
  18845. };
  18846. }
  18847. function ext(a, b) {
  18848. a = a || {};
  18849. b = b || {};
  18850. var t = {};
  18851. Object.keys(b).forEach(function (k) {
  18852. t[k] = b[k];
  18853. });
  18854. Object.keys(a).forEach(function (k) {
  18855. t[k] = a[k];
  18856. });
  18857. return t;
  18858. }
  18859. minimatch.defaults = function (def) {
  18860. if (!def || !Object.keys(def).length) return minimatch;
  18861. var orig = minimatch;
  18862. var m = function minimatch(p, pattern, options) {
  18863. return orig.minimatch(p, pattern, ext(def, options));
  18864. };
  18865. m.Minimatch = function Minimatch(pattern, options) {
  18866. return new orig.Minimatch(pattern, ext(def, options));
  18867. };
  18868. return m;
  18869. };
  18870. Minimatch.defaults = function (def) {
  18871. if (!def || !Object.keys(def).length) return Minimatch;
  18872. return minimatch.defaults(def).Minimatch;
  18873. };
  18874. function minimatch(p, pattern, options) {
  18875. if (typeof pattern !== "string") {
  18876. throw new TypeError("glob pattern string required");
  18877. }
  18878. if (!options) options = {}; // shortcut: comments match nothing.
  18879. if (!options.nocomment && pattern.charAt(0) === "#") {
  18880. return false;
  18881. } // "" only matches ""
  18882. if (pattern.trim() === "") return p === "";
  18883. return new Minimatch(pattern, options).match(p);
  18884. }
  18885. function Minimatch(pattern, options) {
  18886. if (!(this instanceof Minimatch)) {
  18887. return new Minimatch(pattern, options, cache);
  18888. }
  18889. if (typeof pattern !== "string") {
  18890. throw new TypeError("glob pattern string required");
  18891. }
  18892. if (!options) options = {}; // windows: need to use /, not \
  18893. // On other platforms, \ is a valid (albeit bad) filename char.
  18894. if (platform === "win32") {
  18895. pattern = pattern.split("\\").join("/");
  18896. } // lru storage.
  18897. // these things aren't particularly big, but walking down the string
  18898. // and turning it into a regexp can get pretty costly.
  18899. var cacheKey = pattern + "\n" + sigmund_1(options);
  18900. var cached = minimatch.cache.get(cacheKey);
  18901. if (cached) return cached;
  18902. minimatch.cache.set(cacheKey, this);
  18903. this.options = options;
  18904. this.set = [];
  18905. this.pattern = pattern;
  18906. this.regexp = null;
  18907. this.negate = false;
  18908. this.comment = false;
  18909. this.empty = false; // make the set of regexps etc.
  18910. this.make();
  18911. }
  18912. Minimatch.prototype.make = make;
  18913. function make() {
  18914. // don't do it more than once.
  18915. if (this._made) return;
  18916. var pattern = this.pattern;
  18917. var options = this.options; // empty patterns and comments match nothing.
  18918. if (!options.nocomment && pattern.charAt(0) === "#") {
  18919. this.comment = true;
  18920. return;
  18921. }
  18922. if (!pattern) {
  18923. this.empty = true;
  18924. return;
  18925. } // step 1: figure out negation, etc.
  18926. this.parseNegate(); // step 2: expand braces
  18927. var set = this.globSet = this.braceExpand();
  18928. if (options.debug) console.error(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  18929. // matching patterns.
  18930. // These will be regexps, except in the case of "**", which is
  18931. // set to the GLOBSTAR object for globstar behavior,
  18932. // and will not contain any / characters
  18933. set = this.globParts = set.map(function (s) {
  18934. return s.split(slashSplit);
  18935. });
  18936. if (options.debug) console.error(this.pattern, set); // glob --> regexps
  18937. set = set.map(function (s, si, set) {
  18938. return s.map(this.parse, this);
  18939. }, this);
  18940. if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
  18941. set = set.filter(function (s) {
  18942. return -1 === s.indexOf(false);
  18943. });
  18944. if (options.debug) console.error(this.pattern, set);
  18945. this.set = set;
  18946. }
  18947. Minimatch.prototype.parseNegate = parseNegate;
  18948. function parseNegate() {
  18949. var pattern = this.pattern,
  18950. negate = false,
  18951. options = this.options,
  18952. negateOffset = 0;
  18953. if (options.nonegate) return;
  18954. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
  18955. negate = !negate;
  18956. negateOffset++;
  18957. }
  18958. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  18959. this.negate = negate;
  18960. } // Brace expansion:
  18961. // a{b,c}d -> abd acd
  18962. // a{b,}c -> abc ac
  18963. // a{0..3}d -> a0d a1d a2d a3d
  18964. // a{b,c{d,e}f}g -> abg acdfg acefg
  18965. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  18966. //
  18967. // Invalid sets are not expanded.
  18968. // a{2..}b -> a{2..}b
  18969. // a{b}c -> a{b}c
  18970. minimatch.braceExpand = function (pattern, options) {
  18971. return new Minimatch(pattern, options).braceExpand();
  18972. };
  18973. Minimatch.prototype.braceExpand = braceExpand;
  18974. function braceExpand(pattern, options) {
  18975. options = options || this.options;
  18976. pattern = typeof pattern === "undefined" ? this.pattern : pattern;
  18977. if (typeof pattern === "undefined") {
  18978. throw new Error("undefined pattern");
  18979. }
  18980. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  18981. // shortcut. no need to expand.
  18982. return [pattern];
  18983. }
  18984. var escaping = false; // examples and comments refer to this crazy pattern:
  18985. // a{b,c{d,e},{f,g}h}x{y,z}
  18986. // expected:
  18987. // abxy
  18988. // abxz
  18989. // acdxy
  18990. // acdxz
  18991. // acexy
  18992. // acexz
  18993. // afhxy
  18994. // afhxz
  18995. // aghxy
  18996. // aghxz
  18997. // everything before the first \{ is just a prefix.
  18998. // So, we pluck that off, and work with the rest,
  18999. // and then prepend it to everything we find.
  19000. if (pattern.charAt(0) !== "{") {
  19001. // console.error(pattern)
  19002. var prefix = null;
  19003. for (var i = 0, l = pattern.length; i < l; i++) {
  19004. var c = pattern.charAt(i); // console.error(i, c)
  19005. if (c === "\\") {
  19006. escaping = !escaping;
  19007. } else if (c === "{" && !escaping) {
  19008. prefix = pattern.substr(0, i);
  19009. break;
  19010. }
  19011. } // actually no sets, all { were escaped.
  19012. if (prefix === null) {
  19013. // console.error("no sets")
  19014. return [pattern];
  19015. }
  19016. var tail = braceExpand(pattern.substr(i), options);
  19017. return tail.map(function (t) {
  19018. return prefix + t;
  19019. });
  19020. } // now we have something like:
  19021. // {b,c{d,e},{f,g}h}x{y,z}
  19022. // walk through the set, expanding each part, until
  19023. // the set ends. then, we'll expand the suffix.
  19024. // If the set only has a single member, then'll put the {} back
  19025. // first, handle numeric sets, since they're easier
  19026. var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
  19027. if (numset) {
  19028. // console.error("numset", numset[1], numset[2])
  19029. var suf = braceExpand(pattern.substr(numset[0].length), options),
  19030. start = +numset[1],
  19031. end = +numset[2],
  19032. inc = start > end ? -1 : 1,
  19033. set = [];
  19034. for (var i = start; i != end + inc; i += inc) {
  19035. // append all the suffixes
  19036. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  19037. set.push(i + suf[ii]);
  19038. }
  19039. }
  19040. return set;
  19041. } // ok, walk through the set
  19042. // We hope, somewhat optimistically, that there
  19043. // will be a } at the end.
  19044. // If the closing brace isn't found, then the pattern is
  19045. // interpreted as braceExpand("\\" + pattern) so that
  19046. // the leading \{ will be interpreted literally.
  19047. var i = 1 // skip the \{
  19048. ,
  19049. depth = 1,
  19050. set = [],
  19051. member = "",
  19052. escaping = false;
  19053. function addMember() {
  19054. set.push(member);
  19055. member = "";
  19056. } // console.error("Entering for")
  19057. FOR: for (i = 1, l = pattern.length; i < l; i++) {
  19058. var c = pattern.charAt(i); // console.error("", i, c)
  19059. if (escaping) {
  19060. escaping = false;
  19061. member += "\\" + c;
  19062. } else {
  19063. switch (c) {
  19064. case "\\":
  19065. escaping = true;
  19066. continue;
  19067. case "{":
  19068. depth++;
  19069. member += "{";
  19070. continue;
  19071. case "}":
  19072. depth--; // if this closes the actual set, then we're done
  19073. if (depth === 0) {
  19074. addMember(); // pluck off the close-brace
  19075. i++;
  19076. break FOR;
  19077. } else {
  19078. member += c;
  19079. continue;
  19080. }
  19081. case ",":
  19082. if (depth === 1) {
  19083. addMember();
  19084. } else {
  19085. member += c;
  19086. }
  19087. continue;
  19088. default:
  19089. member += c;
  19090. continue;
  19091. } // switch
  19092. } // else
  19093. } // for
  19094. // now we've either finished the set, and the suffix is
  19095. // pattern.substr(i), or we have *not* closed the set,
  19096. // and need to escape the leading brace
  19097. if (depth !== 0) {
  19098. // console.error("didn't close", pattern)
  19099. return braceExpand("\\" + pattern, options);
  19100. } // x{y,z} -> ["xy", "xz"]
  19101. // console.error("set", set)
  19102. // console.error("suffix", pattern.substr(i))
  19103. var suf = braceExpand(pattern.substr(i), options); // ["b", "c{d,e}","{f,g}h"] ->
  19104. // [["b"], ["cd", "ce"], ["fh", "gh"]]
  19105. var addBraces = set.length === 1; // console.error("set pre-expanded", set)
  19106. set = set.map(function (p) {
  19107. return braceExpand(p, options);
  19108. }); // console.error("set expanded", set)
  19109. // [["b"], ["cd", "ce"], ["fh", "gh"]] ->
  19110. // ["b", "cd", "ce", "fh", "gh"]
  19111. set = set.reduce(function (l, r) {
  19112. return l.concat(r);
  19113. });
  19114. if (addBraces) {
  19115. set = set.map(function (s) {
  19116. return "{" + s + "}";
  19117. });
  19118. } // now attach the suffixes.
  19119. var ret = [];
  19120. for (var i = 0, l = set.length; i < l; i++) {
  19121. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  19122. ret.push(set[i] + suf[ii]);
  19123. }
  19124. }
  19125. return ret;
  19126. } // parse a component of the expanded set.
  19127. // At this point, no pattern may contain "/" in it
  19128. // so we're going to return a 2d array, where each entry is the full
  19129. // pattern, split on '/', and then turned into a regular expression.
  19130. // A regexp is made at the end which joins each array with an
  19131. // escaped /, and another full one which joins each regexp with |.
  19132. //
  19133. // Following the lead of Bash 4.1, note that "**" only has special meaning
  19134. // when it is the *only* thing in a path portion. Otherwise, any series
  19135. // of * is equivalent to a single *. Globstar behavior is enabled by
  19136. // default, and can be disabled by setting options.noglobstar.
  19137. Minimatch.prototype.parse = parse;
  19138. var SUBPARSE = {};
  19139. function parse(pattern, isSub) {
  19140. var options = this.options; // shortcuts
  19141. if (!options.noglobstar && pattern === "**") return GLOBSTAR;
  19142. if (pattern === "") return "";
  19143. var re = "",
  19144. hasMagic = !!options.nocase,
  19145. escaping = false // ? => one single character
  19146. ,
  19147. patternListStack = [],
  19148. plType,
  19149. stateChar,
  19150. inClass = false,
  19151. reClassStart = -1,
  19152. classStart = -1 // . and .. never match anything that doesn't start with .,
  19153. // even when options.dot is set.
  19154. ,
  19155. patternStart = pattern.charAt(0) === "." ? "" // anything
  19156. // not (start or / followed by . or .. followed by / or end)
  19157. : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
  19158. function clearStateChar() {
  19159. if (stateChar) {
  19160. // we had some state-tracking character
  19161. // that wasn't consumed by this pass.
  19162. switch (stateChar) {
  19163. case "*":
  19164. re += star;
  19165. hasMagic = true;
  19166. break;
  19167. case "?":
  19168. re += qmark;
  19169. hasMagic = true;
  19170. break;
  19171. default:
  19172. re += "\\" + stateChar;
  19173. break;
  19174. }
  19175. stateChar = false;
  19176. }
  19177. }
  19178. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  19179. if (options.debug) {
  19180. console.error("%s\t%s %s %j", pattern, i, re, c);
  19181. } // skip over any that are escaped.
  19182. if (escaping && reSpecials[c]) {
  19183. re += "\\" + c;
  19184. escaping = false;
  19185. continue;
  19186. }
  19187. switch (c) {
  19188. case "/":
  19189. // completely not allowed, even escaped.
  19190. // Should already be path-split by now.
  19191. return false;
  19192. case "\\":
  19193. clearStateChar();
  19194. escaping = true;
  19195. continue;
  19196. // the various stateChar values
  19197. // for the "extglob" stuff.
  19198. case "?":
  19199. case "*":
  19200. case "+":
  19201. case "@":
  19202. case "!":
  19203. if (options.debug) {
  19204. console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
  19205. } // all of those are literals inside a class, except that
  19206. // the glob [!a] means [^a] in regexp
  19207. if (inClass) {
  19208. if (c === "!" && i === classStart + 1) c = "^";
  19209. re += c;
  19210. continue;
  19211. } // if we already have a stateChar, then it means
  19212. // that there was something like ** or +? in there.
  19213. // Handle the stateChar, then proceed with this one.
  19214. clearStateChar();
  19215. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  19216. // just clear the statechar *now*, rather than even diving into
  19217. // the patternList stuff.
  19218. if (options.noext) clearStateChar();
  19219. continue;
  19220. case "(":
  19221. if (inClass) {
  19222. re += "(";
  19223. continue;
  19224. }
  19225. if (!stateChar) {
  19226. re += "\\(";
  19227. continue;
  19228. }
  19229. plType = stateChar;
  19230. patternListStack.push({
  19231. type: plType,
  19232. start: i - 1,
  19233. reStart: re.length
  19234. }); // negation is (?:(?!js)[^/]*)
  19235. re += stateChar === "!" ? "(?:(?!" : "(?:";
  19236. stateChar = false;
  19237. continue;
  19238. case ")":
  19239. if (inClass || !patternListStack.length) {
  19240. re += "\\)";
  19241. continue;
  19242. }
  19243. hasMagic = true;
  19244. re += ")";
  19245. plType = patternListStack.pop().type; // negation is (?:(?!js)[^/]*)
  19246. // The others are (?:<pattern>)<type>
  19247. switch (plType) {
  19248. case "!":
  19249. re += "[^/]*?)";
  19250. break;
  19251. case "?":
  19252. case "+":
  19253. case "*":
  19254. re += plType;
  19255. // the default anyway
  19256. }
  19257. continue;
  19258. case "|":
  19259. if (inClass || !patternListStack.length || escaping) {
  19260. re += "\\|";
  19261. escaping = false;
  19262. continue;
  19263. }
  19264. re += "|";
  19265. continue;
  19266. // these are mostly the same in regexp and glob
  19267. case "[":
  19268. // swallow any state-tracking char before the [
  19269. clearStateChar();
  19270. if (inClass) {
  19271. re += "\\" + c;
  19272. continue;
  19273. }
  19274. inClass = true;
  19275. classStart = i;
  19276. reClassStart = re.length;
  19277. re += c;
  19278. continue;
  19279. case "]":
  19280. // a right bracket shall lose its special
  19281. // meaning and represent itself in
  19282. // a bracket expression if it occurs
  19283. // first in the list. -- POSIX.2 2.8.3.2
  19284. if (i === classStart + 1 || !inClass) {
  19285. re += "\\" + c;
  19286. escaping = false;
  19287. continue;
  19288. } // finish up the class.
  19289. hasMagic = true;
  19290. inClass = false;
  19291. re += c;
  19292. continue;
  19293. default:
  19294. // swallow any state char that wasn't consumed
  19295. clearStateChar();
  19296. if (escaping) {
  19297. // no need
  19298. escaping = false;
  19299. } else if (reSpecials[c] && !(c === "^" && inClass)) {
  19300. re += "\\";
  19301. }
  19302. re += c;
  19303. } // switch
  19304. } // for
  19305. // handle the case where we left a class open.
  19306. // "[abc" is valid, equivalent to "\[abc"
  19307. if (inClass) {
  19308. // split where the last [ was, and escape it
  19309. // this is a huge pita. We now have to re-walk
  19310. // the contents of the would-be class to re-translate
  19311. // any characters that were passed through as-is
  19312. var cs = pattern.substr(classStart + 1),
  19313. sp = this.parse(cs, SUBPARSE);
  19314. re = re.substr(0, reClassStart) + "\\[" + sp[0];
  19315. hasMagic = hasMagic || sp[1];
  19316. } // handle the case where we had a +( thing at the *end*
  19317. // of the pattern.
  19318. // each pattern list stack adds 3 chars, and we need to go through
  19319. // and escape any | chars that were passed through as-is for the regexp.
  19320. // Go through and escape them, taking care not to double-escape any
  19321. // | chars that were already escaped.
  19322. var pl;
  19323. while (pl = patternListStack.pop()) {
  19324. var tail = re.slice(pl.reStart + 3); // maybe some even number of \, then maybe 1 \, followed by a |
  19325. tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
  19326. if (!$2) {
  19327. // the | isn't already escaped, so escape it.
  19328. $2 = "\\";
  19329. } // need to escape all those slashes *again*, without escaping the
  19330. // one that we need for escaping the | character. As it works out,
  19331. // escaping an even number of slashes can be done by simply repeating
  19332. // it exactly after itself. That's why this trick works.
  19333. //
  19334. // I am sorry that you have to see this.
  19335. return $1 + $1 + $2 + "|";
  19336. }); // console.error("tail=%j\n %s", tail, tail)
  19337. var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
  19338. hasMagic = true;
  19339. re = re.slice(0, pl.reStart) + t + "\\(" + tail;
  19340. } // handle trailing things that only matter at the very end.
  19341. clearStateChar();
  19342. if (escaping) {
  19343. // trailing \\
  19344. re += "\\\\";
  19345. } // only need to apply the nodot start if the re starts with
  19346. // something that could conceivably capture a dot
  19347. var addPatternStart = false;
  19348. switch (re.charAt(0)) {
  19349. case ".":
  19350. case "[":
  19351. case "(":
  19352. addPatternStart = true;
  19353. } // if the re is not "" at this point, then we need to make sure
  19354. // it doesn't match against an empty path part.
  19355. // Otherwise a/* will match a/, which it should not.
  19356. if (re !== "" && hasMagic) re = "(?=.)" + re;
  19357. if (addPatternStart) re = patternStart + re; // parsing just a piece of a larger pattern.
  19358. if (isSub === SUBPARSE) {
  19359. return [re, hasMagic];
  19360. } // skip the regexp for non-magical patterns
  19361. // unescape anything in it, though, so that it'll be
  19362. // an exact match against a file etc.
  19363. if (!hasMagic) {
  19364. return globUnescape(pattern);
  19365. }
  19366. var flags = options.nocase ? "i" : "",
  19367. regExp = new RegExp("^" + re + "$", flags);
  19368. regExp._glob = pattern;
  19369. regExp._src = re;
  19370. return regExp;
  19371. }
  19372. minimatch.makeRe = function (pattern, options) {
  19373. return new Minimatch(pattern, options || {}).makeRe();
  19374. };
  19375. Minimatch.prototype.makeRe = makeRe;
  19376. function makeRe() {
  19377. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  19378. // pattern strings, or "**".
  19379. //
  19380. // It's better to use .match(). This function shouldn't
  19381. // be used, really, but it's pretty convenient sometimes,
  19382. // when you just want to work with a regex.
  19383. var set = this.set;
  19384. if (!set.length) return this.regexp = false;
  19385. var options = this.options;
  19386. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
  19387. flags = options.nocase ? "i" : "";
  19388. var re = set.map(function (pattern) {
  19389. return pattern.map(function (p) {
  19390. return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
  19391. }).join("\\\/");
  19392. }).join("|"); // must match entire pattern
  19393. // ending in a * or ** will make it less strict.
  19394. re = "^(?:" + re + ")$"; // can match anything, as long as it's not this.
  19395. if (this.negate) re = "^(?!" + re + ").*$";
  19396. try {
  19397. return this.regexp = new RegExp(re, flags);
  19398. } catch (ex) {
  19399. return this.regexp = false;
  19400. }
  19401. }
  19402. minimatch.match = function (list, pattern, options) {
  19403. var mm = new Minimatch(pattern, options);
  19404. list = list.filter(function (f) {
  19405. return mm.match(f);
  19406. });
  19407. if (options.nonull && !list.length) {
  19408. list.push(pattern);
  19409. }
  19410. return list;
  19411. };
  19412. Minimatch.prototype.match = match;
  19413. function match(f, partial) {
  19414. // console.error("match", f, this.pattern)
  19415. // short-circuit in the case of busted things.
  19416. // comments, etc.
  19417. if (this.comment) return false;
  19418. if (this.empty) return f === "";
  19419. if (f === "/" && partial) return true;
  19420. var options = this.options; // windows: need to use /, not \
  19421. // On other platforms, \ is a valid (albeit bad) filename char.
  19422. if (platform === "win32") {
  19423. f = f.split("\\").join("/");
  19424. } // treat the test path as a set of pathparts.
  19425. f = f.split(slashSplit);
  19426. if (options.debug) {
  19427. console.error(this.pattern, "split", f);
  19428. } // just ONE of the pattern sets in this.set needs to match
  19429. // in order for it to be valid. If negating, then just one
  19430. // match means that we have failed.
  19431. // Either way, return on the first hit.
  19432. var set = this.set; // console.error(this.pattern, "set", set)
  19433. for (var i = 0, l = set.length; i < l; i++) {
  19434. var pattern = set[i];
  19435. var hit = this.matchOne(f, pattern, partial);
  19436. if (hit) {
  19437. if (options.flipNegate) return true;
  19438. return !this.negate;
  19439. }
  19440. } // didn't get any hits. this is success if it's a negative
  19441. // pattern, failure otherwise.
  19442. if (options.flipNegate) return false;
  19443. return this.negate;
  19444. } // set partial to true to test if, for example,
  19445. // "/a/b" matches the start of "/*/b/*/d"
  19446. // Partial means, if you run out of file before you run
  19447. // out of pattern, then that's fine, as long as all
  19448. // the parts match.
  19449. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  19450. var options = this.options;
  19451. if (options.debug) {
  19452. console.error("matchOne", {
  19453. "this": this,
  19454. file: file,
  19455. pattern: pattern
  19456. });
  19457. }
  19458. if (options.matchBase && pattern.length === 1) {
  19459. file = path__default['default'].basename(file.join("/")).split("/");
  19460. }
  19461. if (options.debug) {
  19462. console.error("matchOne", file.length, pattern.length);
  19463. }
  19464. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  19465. if (options.debug) {
  19466. console.error("matchOne loop");
  19467. }
  19468. var p = pattern[pi],
  19469. f = file[fi];
  19470. if (options.debug) {
  19471. console.error(pattern, p, f);
  19472. } // should be impossible.
  19473. // some invalid regexp stuff in the set.
  19474. if (p === false) return false;
  19475. if (p === GLOBSTAR) {
  19476. if (options.debug) console.error('GLOBSTAR', [pattern, p, f]); // "**"
  19477. // a/**/b/**/c would match the following:
  19478. // a/b/x/y/z/c
  19479. // a/x/y/z/b/c
  19480. // a/b/x/b/x/c
  19481. // a/b/c
  19482. // To do this, take the rest of the pattern after
  19483. // the **, and see if it would match the file remainder.
  19484. // If so, return success.
  19485. // If not, the ** "swallows" a segment, and try again.
  19486. // This is recursively awful.
  19487. //
  19488. // a/**/b/**/c matching a/b/x/y/z/c
  19489. // - a matches a
  19490. // - doublestar
  19491. // - matchOne(b/x/y/z/c, b/**/c)
  19492. // - b matches b
  19493. // - doublestar
  19494. // - matchOne(x/y/z/c, c) -> no
  19495. // - matchOne(y/z/c, c) -> no
  19496. // - matchOne(z/c, c) -> no
  19497. // - matchOne(c, c) yes, hit
  19498. var fr = fi,
  19499. pr = pi + 1;
  19500. if (pr === pl) {
  19501. if (options.debug) console.error('** at the end'); // a ** at the end will just swallow the rest.
  19502. // We have found a match.
  19503. // however, it will not swallow /.x, unless
  19504. // options.dot is set.
  19505. // . and .. are *never* matched by **, for explosively
  19506. // exponential reasons.
  19507. for (; fi < fl; fi++) {
  19508. if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
  19509. }
  19510. return true;
  19511. } // ok, let's see if we can swallow whatever we can.
  19512. WHILE: while (fr < fl) {
  19513. var swallowee = file[fr];
  19514. if (options.debug) {
  19515. console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
  19516. } // XXX remove this slice. Just pass the start index.
  19517. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  19518. if (options.debug) console.error('globstar found match!', fr, fl, swallowee); // found a match.
  19519. return true;
  19520. } else {
  19521. // can't swallow "." or ".." ever.
  19522. // can only swallow ".foo" when explicitly asked.
  19523. if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
  19524. if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
  19525. break WHILE;
  19526. } // ** swallows a segment, and continue.
  19527. if (options.debug) console.error('globstar swallow a segment, and continue');
  19528. fr++;
  19529. }
  19530. } // no match was found.
  19531. // However, in partial mode, we can't say this is necessarily over.
  19532. // If there's more *pattern* left, then
  19533. if (partial) {
  19534. // ran out of file
  19535. // console.error("\n>>> no match, partial?", file, fr, pattern, pr)
  19536. if (fr === fl) return true;
  19537. }
  19538. return false;
  19539. } // something other than **
  19540. // non-magic patterns just have to match exactly
  19541. // patterns with magic have been turned into regexps.
  19542. var hit;
  19543. if (typeof p === "string") {
  19544. if (options.nocase) {
  19545. hit = f.toLowerCase() === p.toLowerCase();
  19546. } else {
  19547. hit = f === p;
  19548. }
  19549. if (options.debug) {
  19550. console.error("string match", p, f, hit);
  19551. }
  19552. } else {
  19553. hit = f.match(p);
  19554. if (options.debug) {
  19555. console.error("pattern match", p, f, hit);
  19556. }
  19557. }
  19558. if (!hit) return false;
  19559. } // Note: ending in / means that we'll get a final ""
  19560. // at the end of the pattern. This can only match a
  19561. // corresponding "" at the end of the file.
  19562. // If the file ends in /, then it can only match a
  19563. // a pattern that ends in /, unless the pattern just
  19564. // doesn't have any more for it. But, a/b/ should *not*
  19565. // match "a/b/*", even though "" matches against the
  19566. // [^/]*? pattern, except in partial mode, where it might
  19567. // simply not be reached yet.
  19568. // However, a/b/ should still satisfy a/*
  19569. // now either we fell off the end of the pattern, or we're done.
  19570. if (fi === fl && pi === pl) {
  19571. // ran out of pattern and filename at the same time.
  19572. // an exact hit!
  19573. return true;
  19574. } else if (fi === fl) {
  19575. // ran out of file, but still had pattern left.
  19576. // this is ok if we're doing the match as part of
  19577. // a glob fs traversal.
  19578. return partial;
  19579. } else if (pi === pl) {
  19580. // ran out of pattern, still have file left.
  19581. // this is only acceptable if we're on the very last
  19582. // empty segment of a file with a trailing slash.
  19583. // a/* should match a/b/
  19584. var emptyFileEnd = fi === fl - 1 && file[fi] === "";
  19585. return emptyFileEnd;
  19586. } // should be unreachable.
  19587. throw new Error("wtf?");
  19588. }; // replace stuff like \* with *
  19589. function globUnescape(s) {
  19590. return s.replace(/\\(.)/g, "$1");
  19591. }
  19592. function regExpEscape(s) {
  19593. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  19594. }
  19595. });
  19596. var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
  19597. return new (P || (P = Promise))(function (resolve, reject) {
  19598. function fulfilled(value) {
  19599. try {
  19600. step(generator.next(value));
  19601. } catch (e) {
  19602. reject(e);
  19603. }
  19604. }
  19605. function rejected(value) {
  19606. try {
  19607. step(generator["throw"](value));
  19608. } catch (e) {
  19609. reject(e);
  19610. }
  19611. }
  19612. function step(result) {
  19613. result.done ? resolve(result.value) : new P(function (resolve) {
  19614. resolve(result.value);
  19615. }).then(fulfilled, rejected);
  19616. }
  19617. step((generator = generator.apply(thisArg, _arguments || [])).next());
  19618. });
  19619. };
  19620. var __generator$1 = undefined && undefined.__generator || function (thisArg, body) {
  19621. var _ = {
  19622. label: 0,
  19623. sent: function () {
  19624. if (t[0] & 1) throw t[1];
  19625. return t[1];
  19626. },
  19627. trys: [],
  19628. ops: []
  19629. },
  19630. f,
  19631. y,
  19632. t,
  19633. g;
  19634. return g = {
  19635. next: verb(0),
  19636. "throw": verb(1),
  19637. "return": verb(2)
  19638. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  19639. return this;
  19640. }), g;
  19641. function verb(n) {
  19642. return function (v) {
  19643. return step([n, v]);
  19644. };
  19645. }
  19646. function step(op) {
  19647. if (f) throw new TypeError("Generator is already executing.");
  19648. while (_) try {
  19649. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  19650. if (y = 0, t) op = [op[0] & 2, t.value];
  19651. switch (op[0]) {
  19652. case 0:
  19653. case 1:
  19654. t = op;
  19655. break;
  19656. case 4:
  19657. _.label++;
  19658. return {
  19659. value: op[1],
  19660. done: false
  19661. };
  19662. case 5:
  19663. _.label++;
  19664. y = op[1];
  19665. op = [0];
  19666. continue;
  19667. case 7:
  19668. op = _.ops.pop();
  19669. _.trys.pop();
  19670. continue;
  19671. default:
  19672. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  19673. _ = 0;
  19674. continue;
  19675. }
  19676. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  19677. _.label = op[1];
  19678. break;
  19679. }
  19680. if (op[0] === 6 && _.label < t[1]) {
  19681. _.label = t[1];
  19682. t = op;
  19683. break;
  19684. }
  19685. if (t && _.label < t[2]) {
  19686. _.label = t[2];
  19687. _.ops.push(op);
  19688. break;
  19689. }
  19690. if (t[2]) _.ops.pop();
  19691. _.trys.pop();
  19692. continue;
  19693. }
  19694. op = body.call(thisArg, _);
  19695. } catch (e) {
  19696. op = [6, e];
  19697. y = 0;
  19698. } finally {
  19699. f = t = 0;
  19700. }
  19701. if (op[0] & 5) throw op[1];
  19702. return {
  19703. value: op[0] ? op[1] : void 0,
  19704. done: true
  19705. };
  19706. }
  19707. };
  19708. var __importStar$1 = undefined && undefined.__importStar || function (mod) {
  19709. if (mod && mod.__esModule) return mod;
  19710. var result = {};
  19711. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  19712. result["default"] = mod;
  19713. return result;
  19714. };
  19715. var fs$3 = __importStar$1(fs__default['default']);
  19716. /**
  19717. * define the possible values:
  19718. * section: [section]
  19719. * param: key=value
  19720. * comment: ;this is a comment
  19721. */
  19722. var regex = {
  19723. section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
  19724. param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
  19725. comment: /^\s*[#;].*$/
  19726. };
  19727. /**
  19728. * Parses an .ini file
  19729. * @param file The location of the .ini file
  19730. */
  19731. function parse$5(file) {
  19732. return __awaiter$1(this, void 0, void 0, function () {
  19733. return __generator$1(this, function (_a) {
  19734. return [2
  19735. /*return*/
  19736. , new Promise(function (resolve, reject) {
  19737. fs$3.readFile(file, 'utf8', function (err, data) {
  19738. if (err) {
  19739. reject(err);
  19740. return;
  19741. }
  19742. resolve(parseString$1(data));
  19743. });
  19744. })];
  19745. });
  19746. });
  19747. }
  19748. var parse_1$5 = parse$5;
  19749. function parseSync$1(file) {
  19750. return parseString$1(fs$3.readFileSync(file, 'utf8'));
  19751. }
  19752. var parseSync_1$1 = parseSync$1;
  19753. function parseString$1(data) {
  19754. var sectionBody = {};
  19755. var sectionName = null;
  19756. var value = [[sectionName, sectionBody]];
  19757. var lines = data.split(/\r\n|\r|\n/);
  19758. lines.forEach(function (line) {
  19759. var match;
  19760. if (regex.comment.test(line)) {
  19761. return;
  19762. }
  19763. if (regex.param.test(line)) {
  19764. match = line.match(regex.param);
  19765. sectionBody[match[1]] = match[2];
  19766. } else if (regex.section.test(line)) {
  19767. match = line.match(regex.section);
  19768. sectionName = match[1];
  19769. sectionBody = {};
  19770. value.push([sectionName, sectionBody]);
  19771. }
  19772. });
  19773. return value;
  19774. }
  19775. var parseString_1 = parseString$1;
  19776. var ini = /*#__PURE__*/Object.defineProperty({
  19777. parse: parse_1$5,
  19778. parseSync: parseSync_1$1,
  19779. parseString: parseString_1
  19780. }, '__esModule', {
  19781. value: true
  19782. });
  19783. var name$g = "editorconfig";
  19784. var version$1 = "0.15.3";
  19785. var description = "EditorConfig File Locator and Interpreter for Node.js";
  19786. var keywords = [
  19787. "editorconfig",
  19788. "core"
  19789. ];
  19790. var main = "src/index.js";
  19791. var contributors = [
  19792. "Hong Xu (topbug.net)",
  19793. "Jed Mao (https://github.com/jedmao/)",
  19794. "Trey Hunner (http://treyhunner.com)"
  19795. ];
  19796. var directories = {
  19797. bin: "./bin",
  19798. lib: "./lib"
  19799. };
  19800. var scripts = {
  19801. clean: "rimraf dist",
  19802. prebuild: "npm run clean",
  19803. build: "tsc",
  19804. pretest: "npm run lint && npm run build && npm run copy && cmake .",
  19805. test: "ctest .",
  19806. "pretest:ci": "npm run pretest",
  19807. "test:ci": "ctest -VV --output-on-failure .",
  19808. lint: "npm run eclint && npm run tslint",
  19809. eclint: "eclint check --indent_size ignore \"src/**\"",
  19810. tslint: "tslint --project tsconfig.json --exclude package.json",
  19811. copy: "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
  19812. prepub: "npm run lint && npm run build && npm run copy",
  19813. pub: "npm publish ./dist"
  19814. };
  19815. var repository = {
  19816. type: "git",
  19817. url: "git://github.com/editorconfig/editorconfig-core-js.git"
  19818. };
  19819. var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
  19820. var author = "EditorConfig Team";
  19821. var license = "MIT";
  19822. var dependencies = {
  19823. commander: "^2.19.0",
  19824. "lru-cache": "^4.1.5",
  19825. semver: "^5.6.0",
  19826. sigmund: "^1.0.1"
  19827. };
  19828. var devDependencies = {
  19829. "@types/mocha": "^5.2.6",
  19830. "@types/node": "^10.12.29",
  19831. "@types/semver": "^5.5.0",
  19832. "cpy-cli": "^2.0.0",
  19833. eclint: "^2.8.1",
  19834. mocha: "^5.2.0",
  19835. rimraf: "^2.6.3",
  19836. should: "^13.2.3",
  19837. tslint: "^5.13.1",
  19838. typescript: "^3.3.3333"
  19839. };
  19840. var require$$4$2 = {
  19841. name: name$g,
  19842. version: version$1,
  19843. description: description,
  19844. keywords: keywords,
  19845. main: main,
  19846. contributors: contributors,
  19847. directories: directories,
  19848. scripts: scripts,
  19849. repository: repository,
  19850. bugs: bugs,
  19851. author: author,
  19852. license: license,
  19853. dependencies: dependencies,
  19854. devDependencies: devDependencies
  19855. };
  19856. var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
  19857. return new (P || (P = Promise))(function (resolve, reject) {
  19858. function fulfilled(value) {
  19859. try {
  19860. step(generator.next(value));
  19861. } catch (e) {
  19862. reject(e);
  19863. }
  19864. }
  19865. function rejected(value) {
  19866. try {
  19867. step(generator["throw"](value));
  19868. } catch (e) {
  19869. reject(e);
  19870. }
  19871. }
  19872. function step(result) {
  19873. result.done ? resolve(result.value) : new P(function (resolve) {
  19874. resolve(result.value);
  19875. }).then(fulfilled, rejected);
  19876. }
  19877. step((generator = generator.apply(thisArg, _arguments || [])).next());
  19878. });
  19879. };
  19880. var __generator = undefined && undefined.__generator || function (thisArg, body) {
  19881. var _ = {
  19882. label: 0,
  19883. sent: function () {
  19884. if (t[0] & 1) throw t[1];
  19885. return t[1];
  19886. },
  19887. trys: [],
  19888. ops: []
  19889. },
  19890. f,
  19891. y,
  19892. t,
  19893. g;
  19894. return g = {
  19895. next: verb(0),
  19896. "throw": verb(1),
  19897. "return": verb(2)
  19898. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  19899. return this;
  19900. }), g;
  19901. function verb(n) {
  19902. return function (v) {
  19903. return step([n, v]);
  19904. };
  19905. }
  19906. function step(op) {
  19907. if (f) throw new TypeError("Generator is already executing.");
  19908. while (_) try {
  19909. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  19910. if (y = 0, t) op = [op[0] & 2, t.value];
  19911. switch (op[0]) {
  19912. case 0:
  19913. case 1:
  19914. t = op;
  19915. break;
  19916. case 4:
  19917. _.label++;
  19918. return {
  19919. value: op[1],
  19920. done: false
  19921. };
  19922. case 5:
  19923. _.label++;
  19924. y = op[1];
  19925. op = [0];
  19926. continue;
  19927. case 7:
  19928. op = _.ops.pop();
  19929. _.trys.pop();
  19930. continue;
  19931. default:
  19932. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  19933. _ = 0;
  19934. continue;
  19935. }
  19936. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  19937. _.label = op[1];
  19938. break;
  19939. }
  19940. if (op[0] === 6 && _.label < t[1]) {
  19941. _.label = t[1];
  19942. t = op;
  19943. break;
  19944. }
  19945. if (t && _.label < t[2]) {
  19946. _.label = t[2];
  19947. _.ops.push(op);
  19948. break;
  19949. }
  19950. if (t[2]) _.ops.pop();
  19951. _.trys.pop();
  19952. continue;
  19953. }
  19954. op = body.call(thisArg, _);
  19955. } catch (e) {
  19956. op = [6, e];
  19957. y = 0;
  19958. } finally {
  19959. f = t = 0;
  19960. }
  19961. if (op[0] & 5) throw op[1];
  19962. return {
  19963. value: op[0] ? op[1] : void 0,
  19964. done: true
  19965. };
  19966. }
  19967. };
  19968. var __importStar = undefined && undefined.__importStar || function (mod) {
  19969. if (mod && mod.__esModule) return mod;
  19970. var result = {};
  19971. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  19972. result["default"] = mod;
  19973. return result;
  19974. };
  19975. var __importDefault = undefined && undefined.__importDefault || function (mod) {
  19976. return mod && mod.__esModule ? mod : {
  19977. "default": mod
  19978. };
  19979. };
  19980. var fs$2 = __importStar(fs__default['default']);
  19981. var path = __importStar(path__default['default']);
  19982. var semver = __importStar(semver$1);
  19983. var fnmatch_1 = __importDefault(fnmatch$1);
  19984. var parseString = ini.parseString;
  19985. var package_json_1 = __importDefault(require$$4$2);
  19986. var knownProps = {
  19987. end_of_line: true,
  19988. indent_style: true,
  19989. indent_size: true,
  19990. insert_final_newline: true,
  19991. trim_trailing_whitespace: true,
  19992. charset: true
  19993. };
  19994. function fnmatch(filepath, glob) {
  19995. var matchOptions = {
  19996. matchBase: true,
  19997. dot: true,
  19998. noext: true
  19999. };
  20000. glob = glob.replace(/\*\*/g, '{*,**/**/**}');
  20001. return fnmatch_1.default(filepath, glob, matchOptions);
  20002. }
  20003. function getConfigFileNames(filepath, options) {
  20004. var paths = [];
  20005. do {
  20006. filepath = path.dirname(filepath);
  20007. paths.push(path.join(filepath, options.config));
  20008. } while (filepath !== options.root);
  20009. return paths;
  20010. }
  20011. function processMatches(matches, version) {
  20012. // Set indent_size to 'tab' if indent_size is unspecified and
  20013. // indent_style is set to 'tab'.
  20014. if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
  20015. matches.indent_size = 'tab';
  20016. } // Set tab_width to indent_size if indent_size is specified and
  20017. // tab_width is unspecified
  20018. if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
  20019. matches.tab_width = matches.indent_size;
  20020. } // Set indent_size to tab_width if indent_size is 'tab'
  20021. if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
  20022. matches.indent_size = matches.tab_width;
  20023. }
  20024. return matches;
  20025. }
  20026. function processOptions(options, filepath) {
  20027. if (options === void 0) {
  20028. options = {};
  20029. }
  20030. return {
  20031. config: options.config || '.editorconfig',
  20032. version: options.version || package_json_1.default.version,
  20033. root: path.resolve(options.root || path.parse(filepath).root)
  20034. };
  20035. }
  20036. function buildFullGlob(pathPrefix, glob) {
  20037. switch (glob.indexOf('/')) {
  20038. case -1:
  20039. glob = '**/' + glob;
  20040. break;
  20041. case 0:
  20042. glob = glob.substring(1);
  20043. break;
  20044. }
  20045. return path.join(pathPrefix, glob);
  20046. }
  20047. function extendProps(props, options) {
  20048. if (props === void 0) {
  20049. props = {};
  20050. }
  20051. if (options === void 0) {
  20052. options = {};
  20053. }
  20054. for (var key in options) {
  20055. if (options.hasOwnProperty(key)) {
  20056. var value = options[key];
  20057. var key2 = key.toLowerCase();
  20058. var value2 = value;
  20059. if (knownProps[key2]) {
  20060. value2 = value.toLowerCase();
  20061. }
  20062. try {
  20063. value2 = JSON.parse(value);
  20064. } catch (e) {}
  20065. if (typeof value === 'undefined' || value === null) {
  20066. // null and undefined are values specific to JSON (no special meaning
  20067. // in editorconfig) & should just be returned as regular strings.
  20068. value2 = String(value);
  20069. }
  20070. props[key2] = value2;
  20071. }
  20072. }
  20073. return props;
  20074. }
  20075. function parseFromConfigs(configs, filepath, options) {
  20076. return processMatches(configs.reverse().reduce(function (matches, file) {
  20077. var pathPrefix = path.dirname(file.name);
  20078. file.contents.forEach(function (section) {
  20079. var glob = section[0];
  20080. var options2 = section[1];
  20081. if (!glob) {
  20082. return;
  20083. }
  20084. var fullGlob = buildFullGlob(pathPrefix, glob);
  20085. if (!fnmatch(filepath, fullGlob)) {
  20086. return;
  20087. }
  20088. matches = extendProps(matches, options2);
  20089. });
  20090. return matches;
  20091. }, {}), options.version);
  20092. }
  20093. function getConfigsForFiles(files) {
  20094. var configs = [];
  20095. for (var i in files) {
  20096. if (files.hasOwnProperty(i)) {
  20097. var file = files[i];
  20098. var contents = ini.parseString(file.contents);
  20099. configs.push({
  20100. name: file.name,
  20101. contents: contents
  20102. });
  20103. if ((contents[0][1].root || '').toLowerCase() === 'true') {
  20104. break;
  20105. }
  20106. }
  20107. }
  20108. return configs;
  20109. }
  20110. function readConfigFiles(filepaths) {
  20111. return __awaiter(this, void 0, void 0, function () {
  20112. return __generator(this, function (_a) {
  20113. return [2
  20114. /*return*/
  20115. , Promise.all(filepaths.map(function (name) {
  20116. return new Promise(function (resolve) {
  20117. fs$2.readFile(name, 'utf8', function (err, data) {
  20118. resolve({
  20119. name: name,
  20120. contents: err ? '' : data
  20121. });
  20122. });
  20123. });
  20124. }))];
  20125. });
  20126. });
  20127. }
  20128. function readConfigFilesSync(filepaths) {
  20129. var files = [];
  20130. var file;
  20131. filepaths.forEach(function (filepath) {
  20132. try {
  20133. file = fs$2.readFileSync(filepath, 'utf8');
  20134. } catch (e) {
  20135. file = '';
  20136. }
  20137. files.push({
  20138. name: filepath,
  20139. contents: file
  20140. });
  20141. });
  20142. return files;
  20143. }
  20144. function opts(filepath, options) {
  20145. if (options === void 0) {
  20146. options = {};
  20147. }
  20148. var resolvedFilePath = path.resolve(filepath);
  20149. return [resolvedFilePath, processOptions(options, resolvedFilePath)];
  20150. }
  20151. function parseFromFiles(filepath, files, options) {
  20152. if (options === void 0) {
  20153. options = {};
  20154. }
  20155. return __awaiter(this, void 0, void 0, function () {
  20156. var _a, resolvedFilePath, processedOptions;
  20157. return __generator(this, function (_b) {
  20158. _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
  20159. return [2
  20160. /*return*/
  20161. , files.then(getConfigsForFiles).then(function (configs) {
  20162. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  20163. })];
  20164. });
  20165. });
  20166. }
  20167. var parseFromFiles_1 = parseFromFiles;
  20168. function parseFromFilesSync(filepath, files, options) {
  20169. if (options === void 0) {
  20170. options = {};
  20171. }
  20172. var _a = opts(filepath, options),
  20173. resolvedFilePath = _a[0],
  20174. processedOptions = _a[1];
  20175. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  20176. }
  20177. var parseFromFilesSync_1 = parseFromFilesSync;
  20178. function parse$4(_filepath, _options) {
  20179. if (_options === void 0) {
  20180. _options = {};
  20181. }
  20182. return __awaiter(this, void 0, void 0, function () {
  20183. var _a, resolvedFilePath, processedOptions, filepaths;
  20184. return __generator(this, function (_b) {
  20185. _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
  20186. filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  20187. return [2
  20188. /*return*/
  20189. , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
  20190. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  20191. })];
  20192. });
  20193. });
  20194. }
  20195. var parse_1$4 = parse$4;
  20196. function parseSync(_filepath, _options) {
  20197. if (_options === void 0) {
  20198. _options = {};
  20199. }
  20200. var _a = opts(_filepath, _options),
  20201. resolvedFilePath = _a[0],
  20202. processedOptions = _a[1];
  20203. var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  20204. var files = readConfigFilesSync(filepaths);
  20205. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  20206. }
  20207. var parseSync_1 = parseSync;
  20208. var src$1 = /*#__PURE__*/Object.defineProperty({
  20209. parseString: parseString,
  20210. parseFromFiles: parseFromFiles_1,
  20211. parseFromFilesSync: parseFromFilesSync_1,
  20212. parse: parse_1$4,
  20213. parseSync: parseSync_1
  20214. }, '__esModule', {
  20215. value: true
  20216. });
  20217. var editorconfigToPrettier = editorConfigToPrettier;
  20218. function removeUnset(editorConfig) {
  20219. const result = {};
  20220. const keys = Object.keys(editorConfig);
  20221. for (let i = 0; i < keys.length; i++) {
  20222. const key = keys[i];
  20223. if (editorConfig[key] === "unset") {
  20224. continue;
  20225. }
  20226. result[key] = editorConfig[key];
  20227. }
  20228. return result;
  20229. }
  20230. function editorConfigToPrettier(editorConfig) {
  20231. if (!editorConfig) {
  20232. return null;
  20233. }
  20234. editorConfig = removeUnset(editorConfig);
  20235. if (Object.keys(editorConfig).length === 0) {
  20236. return null;
  20237. }
  20238. const result = {};
  20239. if (editorConfig.indent_style) {
  20240. result.useTabs = editorConfig.indent_style === "tab";
  20241. }
  20242. if (editorConfig.indent_size === "tab") {
  20243. result.useTabs = true;
  20244. }
  20245. if (result.useTabs && editorConfig.tab_width) {
  20246. result.tabWidth = editorConfig.tab_width;
  20247. } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
  20248. result.tabWidth = editorConfig.indent_size;
  20249. } else if (editorConfig.tab_width !== undefined) {
  20250. result.tabWidth = editorConfig.tab_width;
  20251. }
  20252. if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
  20253. result.printWidth = editorConfig.max_line_length;
  20254. }
  20255. if (editorConfig.quote_type === "single") {
  20256. result.singleQuote = true;
  20257. } else if (editorConfig.quote_type === "double") {
  20258. result.singleQuote = false;
  20259. }
  20260. if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
  20261. result.endOfLine = editorConfig.end_of_line;
  20262. }
  20263. if (editorConfig.insert_final_newline === false || editorConfig.insert_final_newline === true) {
  20264. result.insertFinalNewline = editorConfig.insert_final_newline;
  20265. }
  20266. return result;
  20267. }
  20268. // https://github.com/kirstein/find-project-root/blob/master/index.js
  20269. const MARKERS = [".git", ".hg"];
  20270. const markerExists = directory => MARKERS.some(mark => fs__default['default'].existsSync(path__default['default'].join(directory, mark)));
  20271. function findProjectRoot(directory) {
  20272. while (!markerExists(directory)) {
  20273. const parentDirectory = path__default['default'].resolve(directory, "..");
  20274. if (parentDirectory === directory) {
  20275. break;
  20276. }
  20277. directory = parentDirectory;
  20278. }
  20279. return directory;
  20280. }
  20281. var findProjectRoot_1 = findProjectRoot;
  20282. const jsonStringifyMem = fn => dist$1(fn, {
  20283. cacheKey: JSON.stringify
  20284. });
  20285. const maybeParse = (filePath, parse) => filePath && parse(filePath, {
  20286. root: findProjectRoot_1(path__default['default'].dirname(path__default['default'].resolve(filePath)))
  20287. });
  20288. const editorconfigAsyncNoCache = async filePath => editorconfigToPrettier(await maybeParse(filePath, src$1.parse));
  20289. const editorconfigAsyncWithCache = jsonStringifyMem(editorconfigAsyncNoCache);
  20290. const editorconfigSyncNoCache = filePath => editorconfigToPrettier(maybeParse(filePath, src$1.parseSync));
  20291. const editorconfigSyncWithCache = jsonStringifyMem(editorconfigSyncNoCache);
  20292. function getLoadFunction(opts) {
  20293. if (!opts.editorconfig) {
  20294. return () => null;
  20295. }
  20296. if (opts.sync) {
  20297. return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
  20298. }
  20299. return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
  20300. }
  20301. function clearCache$2() {
  20302. dist$1.clear(editorconfigSyncWithCache);
  20303. dist$1.clear(editorconfigAsyncWithCache);
  20304. }
  20305. var resolveConfigEditorconfig = {
  20306. getLoadFunction,
  20307. clearCache: clearCache$2
  20308. };
  20309. const _excluded$1 = ["overrides"];
  20310. /**
  20311. * @typedef {import("cosmiconfig/dist/Explorer").Explorer} Explorer
  20312. * @typedef {{sync: boolean; cache: boolean }} Options
  20313. */
  20314. /**
  20315. * @type {(opts: Options) => Explorer}
  20316. */
  20317. const getExplorerMemoized = dist$1(opts => {
  20318. const cosmiconfig = thirdParty["cosmiconfig" + (opts.sync ? "Sync" : "")];
  20319. const explorer = cosmiconfig("prettier", {
  20320. cache: opts.cache,
  20321. transform: result => {
  20322. if (result && result.config) {
  20323. if (typeof result.config === "string") {
  20324. const dir = path__default['default'].dirname(result.filepath);
  20325. const modulePath = resolve_1(result.config, {
  20326. paths: [dir]
  20327. });
  20328. result.config = require(modulePath);
  20329. }
  20330. if (typeof result.config !== "object") {
  20331. throw new Error("Config is only allowed to be an object, " + `but received ${typeof result.config} in "${result.filepath}"`);
  20332. }
  20333. delete result.config.$schema;
  20334. }
  20335. return result;
  20336. },
  20337. searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.json5", ".prettierrc.js", ".prettierrc.cjs", "prettier.config.js", "prettier.config.cjs", ".prettierrc.toml"],
  20338. loaders: {
  20339. ".toml": loadToml,
  20340. ".json5": loadJson5
  20341. }
  20342. });
  20343. return explorer;
  20344. }, {
  20345. cacheKey: JSON.stringify
  20346. });
  20347. /**
  20348. * @param {Options} opts
  20349. * @return {Explorer}
  20350. */
  20351. function getExplorer(opts) {
  20352. // Normalize opts before passing to a memoized function
  20353. opts = Object.assign({
  20354. sync: false,
  20355. cache: false
  20356. }, opts);
  20357. return getExplorerMemoized(opts);
  20358. }
  20359. function _resolveConfig(filePath, opts, sync) {
  20360. opts = Object.assign({
  20361. useCache: true
  20362. }, opts);
  20363. const loadOpts = {
  20364. cache: Boolean(opts.useCache),
  20365. sync: Boolean(sync),
  20366. editorconfig: Boolean(opts.editorconfig)
  20367. };
  20368. const {
  20369. load,
  20370. search
  20371. } = getExplorer(loadOpts);
  20372. const loadEditorConfig = resolveConfigEditorconfig.getLoadFunction(loadOpts);
  20373. const arr = [opts.config ? load(opts.config) : search(filePath), loadEditorConfig(filePath)];
  20374. const unwrapAndMerge = ([result, editorConfigured]) => {
  20375. const merged = Object.assign(Object.assign({}, editorConfigured), mergeOverrides(result, filePath));
  20376. for (const optionName of ["plugins", "pluginSearchDirs"]) {
  20377. if (Array.isArray(merged[optionName])) {
  20378. merged[optionName] = merged[optionName].map(value => typeof value === "string" && value.startsWith(".") // relative path
  20379. ? path__default['default'].resolve(path__default['default'].dirname(result.filepath), value) : value);
  20380. }
  20381. }
  20382. if (!result && !editorConfigured) {
  20383. return null;
  20384. } // We are not using this option
  20385. delete merged.insertFinalNewline;
  20386. return merged;
  20387. };
  20388. if (loadOpts.sync) {
  20389. return unwrapAndMerge(arr);
  20390. }
  20391. return Promise.all(arr).then(unwrapAndMerge);
  20392. }
  20393. const resolveConfig = (filePath, opts) => _resolveConfig(filePath, opts, false);
  20394. resolveConfig.sync = (filePath, opts) => _resolveConfig(filePath, opts, true);
  20395. function clearCache$1() {
  20396. dist$1.clear(getExplorerMemoized);
  20397. resolveConfigEditorconfig.clearCache();
  20398. }
  20399. async function resolveConfigFile(filePath) {
  20400. const {
  20401. search
  20402. } = getExplorer({
  20403. sync: false
  20404. });
  20405. const result = await search(filePath);
  20406. return result ? result.filepath : null;
  20407. }
  20408. resolveConfigFile.sync = filePath => {
  20409. const {
  20410. search
  20411. } = getExplorer({
  20412. sync: true
  20413. });
  20414. const result = search(filePath);
  20415. return result ? result.filepath : null;
  20416. };
  20417. function mergeOverrides(configResult, filePath) {
  20418. const {
  20419. config,
  20420. filepath: configPath
  20421. } = configResult || {};
  20422. const _ref = config || {},
  20423. {
  20424. overrides
  20425. } = _ref,
  20426. options = _objectWithoutProperties(_ref, _excluded$1);
  20427. if (filePath && overrides) {
  20428. const relativeFilePath = path__default['default'].relative(path__default['default'].dirname(configPath), filePath);
  20429. for (const override of overrides) {
  20430. if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
  20431. Object.assign(options, override.options);
  20432. }
  20433. }
  20434. }
  20435. return options;
  20436. } // Based on eslint: https://github.com/eslint/eslint/blob/master/lib/config/config-ops.js
  20437. function pathMatchesGlobs(filePath, patterns, excludedPatterns = []) {
  20438. const patternList = Array.isArray(patterns) ? patterns : [patterns];
  20439. const excludedPatternList = Array.isArray(excludedPatterns) ? excludedPatterns : [excludedPatterns];
  20440. const opts = {
  20441. matchBase: true,
  20442. dot: true
  20443. };
  20444. return patternList.some(pattern => minimatch_1(filePath, pattern, opts)) && !excludedPatternList.some(excludedPattern => minimatch_1(filePath, excludedPattern, opts));
  20445. }
  20446. var resolveConfig_1 = {
  20447. resolveConfig,
  20448. resolveConfigFile,
  20449. clearCache: clearCache$1
  20450. };
  20451. // A simple implementation of make-array
  20452. function make_array(subject) {
  20453. return Array.isArray(subject) ? subject : [subject];
  20454. }
  20455. const REGEX_BLANK_LINE = /^\s+$/;
  20456. const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  20457. const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
  20458. const SLASH$1 = '/';
  20459. const KEY_IGNORE$1 = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  20460. /* istanbul ignore next */
  20461. : 'node-ignore';
  20462. const define$1 = (object, key, value) => Object.defineProperty(object, key, {
  20463. value
  20464. });
  20465. const REGEX_REGEXP_RANGE$1 = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
  20466. // The cases are complicated, see test cases for details
  20467. const sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
  20468. // fatal for JavaScript regular expression, so eliminate it.
  20469. : ''); // > If the pattern ends with a slash,
  20470. // > it is removed for the purpose of the following description,
  20471. // > but it would only find a match with a directory.
  20472. // > In other words, foo/ will match a directory foo and paths underneath it,
  20473. // > but will not match a regular file or a symbolic link foo
  20474. // > (this is consistent with the way how pathspec works in general in Git).
  20475. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  20476. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  20477. // you could use option `mark: true` with `glob`
  20478. // '`foo/`' should not continue with the '`..`'
  20479. const DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  20480. [// (a\ ) -> (a )
  20481. // (a ) -> (a)
  20482. // (a \ ) -> (a )
  20483. /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''], // replace (\ ) with ' '
  20484. [/\\\s/g, () => ' '], // Escape metacharacters
  20485. // which is written down by users but means special for regular expressions.
  20486. // > There are 12 characters with special meanings:
  20487. // > - the backslash \,
  20488. // > - the caret ^,
  20489. // > - the dollar sign $,
  20490. // > - the period or dot .,
  20491. // > - the vertical bar or pipe symbol |,
  20492. // > - the question mark ?,
  20493. // > - the asterisk or star *,
  20494. // > - the plus sign +,
  20495. // > - the opening parenthesis (,
  20496. // > - the closing parenthesis ),
  20497. // > - and the opening square bracket [,
  20498. // > - the opening curly brace {,
  20499. // > These special characters are often called "metacharacters".
  20500. [/[\\^$.|*+(){]/g, match => `\\${match}`], [// > [abc] matches any character inside the brackets
  20501. // > (in this case a, b, or c);
  20502. /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? `[${sanitizeRange$1(p1)}]` : `\\${match}`], [// > a question mark (?) matches a single character
  20503. /(?!\\)\?/g, () => '[^/]'], // leading slash
  20504. [// > A leading slash matches the beginning of the pathname.
  20505. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  20506. // A leading slash matches the beginning of the pathname
  20507. /^\//, () => '^'], // replace special metacharacter slash after the leading slash
  20508. [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
  20509. // > For example, "**/foo" matches file or directory "foo" anywhere,
  20510. // > the same as pattern "foo".
  20511. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  20512. // > under directory "foo".
  20513. // Notice that the '*'s have been replaced as '\\*'
  20514. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  20515. () => '^(?:.*\\/)?']];
  20516. const DEFAULT_REPLACER_SUFFIX = [// starting
  20517. [// there will be no leading '/'
  20518. // (which has been replaced by section "leading slash")
  20519. // If starts with '**', adding a '^' to the regular expression also works
  20520. /^(?=[^^])/, function startingReplacer() {
  20521. return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
  20522. // > Git treats it as a shell glob pattern
  20523. // Actually, if there is only a trailing slash,
  20524. // git also treats it as a shell glob pattern
  20525. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
  20526. // > consumption by fnmatch(3)
  20527. : '^';
  20528. }], // two globstars
  20529. [// Use lookahead assertions so that we could match more than one `'/**'`
  20530. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  20531. // should not use '*', or it will be replaced by the next replacer
  20532. // Check if it is not the last `'/**'`
  20533. (match, index, str) => index + 6 < str.length // case: /**/
  20534. // > A slash followed by two consecutive asterisks then a slash matches
  20535. // > zero or more directories.
  20536. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  20537. // '/**/'
  20538. ? '(?:\\/[^\\/]+)*' // case: /**
  20539. // > A trailing `"/**"` matches everything inside.
  20540. // #21: everything inside but it should not include the current folder
  20541. : '\\/.+'], // intermediate wildcards
  20542. [// Never replace escaped '*'
  20543. // ignore rule '\*' will match the path '*'
  20544. // 'abc.*/' -> go
  20545. // 'abc.*' -> skip this rule
  20546. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  20547. // '*.js' doesn't match 'abc'
  20548. (match, p1) => `${p1}[^\\/]*`], // trailing wildcard
  20549. [/(\^|\\\/)?\\\*$/, (match, p1) => {
  20550. const prefix = p1 // '\^':
  20551. // '/*' does not match ''
  20552. // '/*' does not match everything
  20553. // '\\\/':
  20554. // 'abc/*' does not match 'abc/'
  20555. ? `${p1}[^/]+` // 'a*' matches 'a'
  20556. // 'a*' matches 'aa'
  20557. : '[^/]*';
  20558. return `${prefix}(?=$|\\/$)`;
  20559. }], [// unescape
  20560. /\\\\\\/g, () => '\\']];
  20561. const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // 'f'
  20562. // matches
  20563. // - /f(end)
  20564. // - /f/
  20565. // - (start)f(end)
  20566. // - (start)f/
  20567. // doesn't match
  20568. // - oof
  20569. // - foo
  20570. // pseudo:
  20571. // -> (^|/)f(/|$)
  20572. // ending
  20573. [// 'js' will not match 'js.'
  20574. // 'ab' will not match 'abc'
  20575. /(?:[^*/])$/, // 'js*' will not match 'a.js'
  20576. // 'js/' will not match 'a.js'
  20577. // 'js' will match 'a.js' and 'a.js/'
  20578. match => `${match}(?=$|\\/)`], ...DEFAULT_REPLACER_SUFFIX];
  20579. const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // #24, #38
  20580. // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
  20581. // A negative pattern without a trailing wildcard should not
  20582. // re-include the things inside that directory.
  20583. // eg:
  20584. // ['node_modules/*', '!node_modules']
  20585. // should ignore `node_modules/a.js`
  20586. [/(?:[^*])$/, match => `${match}(?=$|\\/$)`], ...DEFAULT_REPLACER_SUFFIX]; // A simple cache, because an ignore rule only has only one certain meaning
  20587. const cache = Object.create(null); // @param {pattern}
  20588. const make_regex = (pattern, negative, ignorecase) => {
  20589. const r = cache[pattern];
  20590. if (r) {
  20591. return r;
  20592. }
  20593. const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
  20594. const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
  20595. return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  20596. }; // > A blank line matches no files, so it can serve as a separator for readability.
  20597. const checkPattern$1 = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  20598. && pattern.indexOf('#') !== 0;
  20599. const createRule$1 = (pattern, ignorecase) => {
  20600. const origin = pattern;
  20601. let negative = false; // > An optional prefix "!" which negates the pattern;
  20602. if (pattern.indexOf('!') === 0) {
  20603. negative = true;
  20604. pattern = pattern.substr(1);
  20605. }
  20606. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
  20607. // > begin with a literal "!", for example, `"\!important!.txt"`.
  20608. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
  20609. // > begin with a hash.
  20610. .replace(REGEX_LEADING_EXCAPED_HASH, '#');
  20611. const regex = make_regex(pattern, negative, ignorecase);
  20612. return {
  20613. origin,
  20614. pattern,
  20615. negative,
  20616. regex
  20617. };
  20618. };
  20619. class IgnoreBase {
  20620. constructor({
  20621. ignorecase = true
  20622. } = {}) {
  20623. this._rules = [];
  20624. this._ignorecase = ignorecase;
  20625. define$1(this, KEY_IGNORE$1, true);
  20626. this._initCache();
  20627. }
  20628. _initCache() {
  20629. this._cache = Object.create(null);
  20630. } // @param {Array.<string>|string|Ignore} pattern
  20631. add(pattern) {
  20632. this._added = false;
  20633. if (typeof pattern === 'string') {
  20634. pattern = pattern.split(/\r?\n/g);
  20635. }
  20636. make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  20637. // making the behavior changed.
  20638. if (this._added) {
  20639. this._initCache();
  20640. }
  20641. return this;
  20642. } // legacy
  20643. addPattern(pattern) {
  20644. return this.add(pattern);
  20645. }
  20646. _addPattern(pattern) {
  20647. // #32
  20648. if (pattern && pattern[KEY_IGNORE$1]) {
  20649. this._rules = this._rules.concat(pattern._rules);
  20650. this._added = true;
  20651. return;
  20652. }
  20653. if (checkPattern$1(pattern)) {
  20654. const rule = createRule$1(pattern, this._ignorecase);
  20655. this._added = true;
  20656. this._rules.push(rule);
  20657. }
  20658. }
  20659. filter(paths) {
  20660. return make_array(paths).filter(path => this._filter(path));
  20661. }
  20662. createFilter() {
  20663. return path => this._filter(path);
  20664. }
  20665. ignores(path) {
  20666. return !this._filter(path);
  20667. } // @returns `Boolean` true if the `path` is NOT ignored
  20668. _filter(path, slices) {
  20669. if (!path) {
  20670. return false;
  20671. }
  20672. if (path in this._cache) {
  20673. return this._cache[path];
  20674. }
  20675. if (!slices) {
  20676. // path/to/a.js
  20677. // ['path', 'to', 'a.js']
  20678. slices = path.split(SLASH$1);
  20679. }
  20680. slices.pop();
  20681. return this._cache[path] = slices.length // > It is not possible to re-include a file if a parent directory of
  20682. // > that file is excluded.
  20683. // If the path contains a parent directory, check the parent first
  20684. ? this._filter(slices.join(SLASH$1) + SLASH$1, slices) && this._test(path) // Or only test the path
  20685. : this._test(path);
  20686. } // @returns {Boolean} true if a file is NOT ignored
  20687. _test(path) {
  20688. // Explicitly define variable type by setting matched to `0`
  20689. let matched = 0;
  20690. this._rules.forEach(rule => {
  20691. // if matched = true, then we only test negative rules
  20692. // if matched = false, then we test non-negative rules
  20693. if (!(matched ^ rule.negative)) {
  20694. matched = rule.negative ^ rule.regex.test(path);
  20695. }
  20696. });
  20697. return !matched;
  20698. }
  20699. } // Windows
  20700. // --------------------------------------------------------------
  20701. /* istanbul ignore if */
  20702. if ( // Detect `process` so that it can run in browsers.
  20703. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  20704. const filter = IgnoreBase.prototype._filter;
  20705. /* eslint no-control-regex: "off" */
  20706. const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
  20707. IgnoreBase.prototype._filter = function filterWin32(path, slices) {
  20708. path = make_posix(path);
  20709. return filter.call(this, path, slices);
  20710. };
  20711. }
  20712. var ignore$1 = options => new IgnoreBase(options);
  20713. const fsAsync = fs__default['default'].promises;
  20714. /**
  20715. * @param {string} filename
  20716. * @returns {Promise<null | string>}
  20717. */
  20718. async function getFileContentOrNull(filename) {
  20719. try {
  20720. return await fsAsync.readFile(filename, "utf8");
  20721. } catch (error) {
  20722. return handleError(filename, error);
  20723. }
  20724. }
  20725. /**
  20726. * @param {string} filename
  20727. * @returns {null | string}
  20728. */
  20729. getFileContentOrNull.sync = function (filename) {
  20730. try {
  20731. return fs__default['default'].readFileSync(filename, "utf8");
  20732. } catch (error) {
  20733. return handleError(filename, error);
  20734. }
  20735. };
  20736. function handleError(filename, error) {
  20737. if (error && error.code === "ENOENT") {
  20738. return null;
  20739. }
  20740. throw new Error(`Unable to read ${filename}: ${error.message}`);
  20741. }
  20742. var getFileContentOrNull_1 = getFileContentOrNull;
  20743. /**
  20744. * @param {string?} ignorePath
  20745. * @param {boolean?} withNodeModules
  20746. */
  20747. async function createIgnorer(ignorePath, withNodeModules) {
  20748. const ignoreContent = ignorePath ? await getFileContentOrNull_1(path__default['default'].resolve(ignorePath)) : null;
  20749. return _createIgnorer(ignoreContent, withNodeModules);
  20750. }
  20751. /**
  20752. * @param {string?} ignorePath
  20753. * @param {boolean?} withNodeModules
  20754. */
  20755. createIgnorer.sync = function (ignorePath, withNodeModules) {
  20756. const ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path__default['default'].resolve(ignorePath));
  20757. return _createIgnorer(ignoreContent, withNodeModules);
  20758. };
  20759. /**
  20760. * @param {null | string} ignoreContent
  20761. * @param {boolean?} withNodeModules
  20762. */
  20763. function _createIgnorer(ignoreContent, withNodeModules) {
  20764. const ignorer = ignore$1().add(ignoreContent || "");
  20765. if (!withNodeModules) {
  20766. ignorer.add("node_modules");
  20767. }
  20768. return ignorer;
  20769. }
  20770. var createIgnorer_1 = createIgnorer;
  20771. /**
  20772. * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
  20773. * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
  20774. */
  20775. /**
  20776. * @param {string} filePath
  20777. * @param {FileInfoOptions} opts
  20778. * @returns {Promise<FileInfoResult>}
  20779. *
  20780. * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
  20781. * not an object. A transformation from this array to an object is automatically done
  20782. * internally by the method wrapper. See withPlugins() in index.js.
  20783. */
  20784. async function getFileInfo(filePath, opts) {
  20785. if (typeof filePath !== "string") {
  20786. throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
  20787. }
  20788. const ignorer = await createIgnorer_1(opts.ignorePath, opts.withNodeModules);
  20789. return _getFileInfo({
  20790. ignorer,
  20791. filePath,
  20792. plugins: opts.plugins,
  20793. resolveConfig: opts.resolveConfig,
  20794. ignorePath: opts.ignorePath,
  20795. sync: false
  20796. });
  20797. }
  20798. /**
  20799. * @param {string} filePath
  20800. * @param {FileInfoOptions} opts
  20801. * @returns {FileInfoResult}
  20802. */
  20803. getFileInfo.sync = function (filePath, opts) {
  20804. if (typeof filePath !== "string") {
  20805. throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
  20806. }
  20807. const ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
  20808. return _getFileInfo({
  20809. ignorer,
  20810. filePath,
  20811. plugins: opts.plugins,
  20812. resolveConfig: opts.resolveConfig,
  20813. ignorePath: opts.ignorePath,
  20814. sync: true
  20815. });
  20816. };
  20817. function getFileParser(resolvedConfig, filePath, plugins) {
  20818. if (resolvedConfig && resolvedConfig.parser) {
  20819. return resolvedConfig.parser;
  20820. }
  20821. const inferredParser = options$6.inferParser(filePath, plugins);
  20822. if (inferredParser) {
  20823. return inferredParser;
  20824. }
  20825. return null;
  20826. }
  20827. function _getFileInfo({
  20828. ignorer,
  20829. filePath,
  20830. plugins,
  20831. resolveConfig = false,
  20832. ignorePath,
  20833. sync = false
  20834. }) {
  20835. const normalizedFilePath = normalizeFilePath(filePath, ignorePath);
  20836. const fileInfo = {
  20837. ignored: ignorer.ignores(normalizedFilePath),
  20838. inferredParser: null
  20839. };
  20840. if (fileInfo.ignored) {
  20841. return fileInfo;
  20842. }
  20843. let resolvedConfig;
  20844. if (resolveConfig) {
  20845. if (sync) {
  20846. resolvedConfig = resolveConfig_1.resolveConfig.sync(filePath);
  20847. } else {
  20848. return resolveConfig_1.resolveConfig(filePath).then(resolvedConfig => {
  20849. fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
  20850. return fileInfo;
  20851. });
  20852. }
  20853. }
  20854. fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
  20855. return fileInfo;
  20856. }
  20857. function normalizeFilePath(filePath, ignorePath) {
  20858. return ignorePath ? path__default['default'].relative(path__default['default'].dirname(ignorePath), filePath) : filePath;
  20859. }
  20860. var getFileInfo_1 = getFileInfo;
  20861. const {
  20862. getMaxContinuousCount: getMaxContinuousCount$2,
  20863. getStringWidth: getStringWidth$4,
  20864. getAlignmentSize,
  20865. getIndentSize: getIndentSize$1,
  20866. skip,
  20867. skipWhitespace: skipWhitespace$1,
  20868. skipSpaces,
  20869. skipNewline,
  20870. skipToLineEnd,
  20871. skipEverythingButNewLine: skipEverythingButNewLine$1,
  20872. skipInlineComment,
  20873. skipTrailingComment,
  20874. hasNewline: hasNewline$8,
  20875. hasNewlineInRange: hasNewlineInRange$4,
  20876. hasSpaces,
  20877. isNextLineEmpty: isNextLineEmpty$d,
  20878. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
  20879. isPreviousLineEmpty: isPreviousLineEmpty$1,
  20880. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
  20881. makeString,
  20882. addLeadingComment: addLeadingComment$1,
  20883. addDanglingComment: addDanglingComment$1,
  20884. addTrailingComment: addTrailingComment$1
  20885. } = util$5;
  20886. var utilShared = {
  20887. getMaxContinuousCount: getMaxContinuousCount$2,
  20888. getStringWidth: getStringWidth$4,
  20889. getAlignmentSize,
  20890. getIndentSize: getIndentSize$1,
  20891. skip,
  20892. skipWhitespace: skipWhitespace$1,
  20893. skipSpaces,
  20894. skipNewline,
  20895. skipToLineEnd,
  20896. skipEverythingButNewLine: skipEverythingButNewLine$1,
  20897. skipInlineComment,
  20898. skipTrailingComment,
  20899. hasNewline: hasNewline$8,
  20900. hasNewlineInRange: hasNewlineInRange$4,
  20901. hasSpaces,
  20902. isNextLineEmpty: isNextLineEmpty$d,
  20903. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
  20904. isPreviousLineEmpty: isPreviousLineEmpty$1,
  20905. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
  20906. makeString,
  20907. addLeadingComment: addLeadingComment$1,
  20908. addDanglingComment: addDanglingComment$1,
  20909. addTrailingComment: addTrailingComment$1
  20910. };
  20911. /**
  20912. * Removes all key-value entries from the list cache.
  20913. *
  20914. * @private
  20915. * @name clear
  20916. * @memberOf ListCache
  20917. */
  20918. function listCacheClear() {
  20919. this.__data__ = [];
  20920. this.size = 0;
  20921. }
  20922. var _listCacheClear = listCacheClear;
  20923. /**
  20924. * Performs a
  20925. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20926. * comparison between two values to determine if they are equivalent.
  20927. *
  20928. * @static
  20929. * @memberOf _
  20930. * @since 4.0.0
  20931. * @category Lang
  20932. * @param {*} value The value to compare.
  20933. * @param {*} other The other value to compare.
  20934. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20935. * @example
  20936. *
  20937. * var object = { 'a': 1 };
  20938. * var other = { 'a': 1 };
  20939. *
  20940. * _.eq(object, object);
  20941. * // => true
  20942. *
  20943. * _.eq(object, other);
  20944. * // => false
  20945. *
  20946. * _.eq('a', 'a');
  20947. * // => true
  20948. *
  20949. * _.eq('a', Object('a'));
  20950. * // => false
  20951. *
  20952. * _.eq(NaN, NaN);
  20953. * // => true
  20954. */
  20955. function eq(value, other) {
  20956. return value === other || value !== value && other !== other;
  20957. }
  20958. var eq_1 = eq;
  20959. /**
  20960. * Gets the index at which the `key` is found in `array` of key-value pairs.
  20961. *
  20962. * @private
  20963. * @param {Array} array The array to inspect.
  20964. * @param {*} key The key to search for.
  20965. * @returns {number} Returns the index of the matched value, else `-1`.
  20966. */
  20967. function assocIndexOf(array, key) {
  20968. var length = array.length;
  20969. while (length--) {
  20970. if (eq_1(array[length][0], key)) {
  20971. return length;
  20972. }
  20973. }
  20974. return -1;
  20975. }
  20976. var _assocIndexOf = assocIndexOf;
  20977. /** Used for built-in method references. */
  20978. var arrayProto = Array.prototype;
  20979. /** Built-in value references. */
  20980. var splice = arrayProto.splice;
  20981. /**
  20982. * Removes `key` and its value from the list cache.
  20983. *
  20984. * @private
  20985. * @name delete
  20986. * @memberOf ListCache
  20987. * @param {string} key The key of the value to remove.
  20988. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  20989. */
  20990. function listCacheDelete(key) {
  20991. var data = this.__data__,
  20992. index = _assocIndexOf(data, key);
  20993. if (index < 0) {
  20994. return false;
  20995. }
  20996. var lastIndex = data.length - 1;
  20997. if (index == lastIndex) {
  20998. data.pop();
  20999. } else {
  21000. splice.call(data, index, 1);
  21001. }
  21002. --this.size;
  21003. return true;
  21004. }
  21005. var _listCacheDelete = listCacheDelete;
  21006. /**
  21007. * Gets the list cache value for `key`.
  21008. *
  21009. * @private
  21010. * @name get
  21011. * @memberOf ListCache
  21012. * @param {string} key The key of the value to get.
  21013. * @returns {*} Returns the entry value.
  21014. */
  21015. function listCacheGet(key) {
  21016. var data = this.__data__,
  21017. index = _assocIndexOf(data, key);
  21018. return index < 0 ? undefined : data[index][1];
  21019. }
  21020. var _listCacheGet = listCacheGet;
  21021. /**
  21022. * Checks if a list cache value for `key` exists.
  21023. *
  21024. * @private
  21025. * @name has
  21026. * @memberOf ListCache
  21027. * @param {string} key The key of the entry to check.
  21028. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21029. */
  21030. function listCacheHas(key) {
  21031. return _assocIndexOf(this.__data__, key) > -1;
  21032. }
  21033. var _listCacheHas = listCacheHas;
  21034. /**
  21035. * Sets the list cache `key` to `value`.
  21036. *
  21037. * @private
  21038. * @name set
  21039. * @memberOf ListCache
  21040. * @param {string} key The key of the value to set.
  21041. * @param {*} value The value to set.
  21042. * @returns {Object} Returns the list cache instance.
  21043. */
  21044. function listCacheSet(key, value) {
  21045. var data = this.__data__,
  21046. index = _assocIndexOf(data, key);
  21047. if (index < 0) {
  21048. ++this.size;
  21049. data.push([key, value]);
  21050. } else {
  21051. data[index][1] = value;
  21052. }
  21053. return this;
  21054. }
  21055. var _listCacheSet = listCacheSet;
  21056. /**
  21057. * Creates an list cache object.
  21058. *
  21059. * @private
  21060. * @constructor
  21061. * @param {Array} [entries] The key-value pairs to cache.
  21062. */
  21063. function ListCache(entries) {
  21064. var index = -1,
  21065. length = entries == null ? 0 : entries.length;
  21066. this.clear();
  21067. while (++index < length) {
  21068. var entry = entries[index];
  21069. this.set(entry[0], entry[1]);
  21070. }
  21071. } // Add methods to `ListCache`.
  21072. ListCache.prototype.clear = _listCacheClear;
  21073. ListCache.prototype['delete'] = _listCacheDelete;
  21074. ListCache.prototype.get = _listCacheGet;
  21075. ListCache.prototype.has = _listCacheHas;
  21076. ListCache.prototype.set = _listCacheSet;
  21077. var _ListCache = ListCache;
  21078. /**
  21079. * Removes all key-value entries from the stack.
  21080. *
  21081. * @private
  21082. * @name clear
  21083. * @memberOf Stack
  21084. */
  21085. function stackClear() {
  21086. this.__data__ = new _ListCache();
  21087. this.size = 0;
  21088. }
  21089. var _stackClear = stackClear;
  21090. /**
  21091. * Removes `key` and its value from the stack.
  21092. *
  21093. * @private
  21094. * @name delete
  21095. * @memberOf Stack
  21096. * @param {string} key The key of the value to remove.
  21097. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21098. */
  21099. function stackDelete(key) {
  21100. var data = this.__data__,
  21101. result = data['delete'](key);
  21102. this.size = data.size;
  21103. return result;
  21104. }
  21105. var _stackDelete = stackDelete;
  21106. /**
  21107. * Gets the stack value for `key`.
  21108. *
  21109. * @private
  21110. * @name get
  21111. * @memberOf Stack
  21112. * @param {string} key The key of the value to get.
  21113. * @returns {*} Returns the entry value.
  21114. */
  21115. function stackGet(key) {
  21116. return this.__data__.get(key);
  21117. }
  21118. var _stackGet = stackGet;
  21119. /**
  21120. * Checks if a stack value for `key` exists.
  21121. *
  21122. * @private
  21123. * @name has
  21124. * @memberOf Stack
  21125. * @param {string} key The key of the entry to check.
  21126. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21127. */
  21128. function stackHas(key) {
  21129. return this.__data__.has(key);
  21130. }
  21131. var _stackHas = stackHas;
  21132. /** Detect free variable `global` from Node.js. */
  21133. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  21134. var _freeGlobal = freeGlobal;
  21135. /** Detect free variable `self`. */
  21136. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  21137. /** Used as a reference to the global object. */
  21138. var root = _freeGlobal || freeSelf || Function('return this')();
  21139. var _root = root;
  21140. /** Built-in value references. */
  21141. var Symbol$1 = _root.Symbol;
  21142. var _Symbol = Symbol$1;
  21143. /** Used for built-in method references. */
  21144. var objectProto$b = Object.prototype;
  21145. /** Used to check objects for own properties. */
  21146. var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
  21147. /**
  21148. * Used to resolve the
  21149. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  21150. * of values.
  21151. */
  21152. var nativeObjectToString$1 = objectProto$b.toString;
  21153. /** Built-in value references. */
  21154. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  21155. /**
  21156. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  21157. *
  21158. * @private
  21159. * @param {*} value The value to query.
  21160. * @returns {string} Returns the raw `toStringTag`.
  21161. */
  21162. function getRawTag(value) {
  21163. var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
  21164. tag = value[symToStringTag$1];
  21165. try {
  21166. value[symToStringTag$1] = undefined;
  21167. var unmasked = true;
  21168. } catch (e) {}
  21169. var result = nativeObjectToString$1.call(value);
  21170. if (unmasked) {
  21171. if (isOwn) {
  21172. value[symToStringTag$1] = tag;
  21173. } else {
  21174. delete value[symToStringTag$1];
  21175. }
  21176. }
  21177. return result;
  21178. }
  21179. var _getRawTag = getRawTag;
  21180. /** Used for built-in method references. */
  21181. var objectProto$a = Object.prototype;
  21182. /**
  21183. * Used to resolve the
  21184. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  21185. * of values.
  21186. */
  21187. var nativeObjectToString = objectProto$a.toString;
  21188. /**
  21189. * Converts `value` to a string using `Object.prototype.toString`.
  21190. *
  21191. * @private
  21192. * @param {*} value The value to convert.
  21193. * @returns {string} Returns the converted string.
  21194. */
  21195. function objectToString(value) {
  21196. return nativeObjectToString.call(value);
  21197. }
  21198. var _objectToString = objectToString;
  21199. /** `Object#toString` result references. */
  21200. var nullTag = '[object Null]',
  21201. undefinedTag = '[object Undefined]';
  21202. /** Built-in value references. */
  21203. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  21204. /**
  21205. * The base implementation of `getTag` without fallbacks for buggy environments.
  21206. *
  21207. * @private
  21208. * @param {*} value The value to query.
  21209. * @returns {string} Returns the `toStringTag`.
  21210. */
  21211. function baseGetTag(value) {
  21212. if (value == null) {
  21213. return value === undefined ? undefinedTag : nullTag;
  21214. }
  21215. return symToStringTag && symToStringTag in Object(value) ? _getRawTag(value) : _objectToString(value);
  21216. }
  21217. var _baseGetTag = baseGetTag;
  21218. /**
  21219. * Checks if `value` is the
  21220. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  21221. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  21222. *
  21223. * @static
  21224. * @memberOf _
  21225. * @since 0.1.0
  21226. * @category Lang
  21227. * @param {*} value The value to check.
  21228. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  21229. * @example
  21230. *
  21231. * _.isObject({});
  21232. * // => true
  21233. *
  21234. * _.isObject([1, 2, 3]);
  21235. * // => true
  21236. *
  21237. * _.isObject(_.noop);
  21238. * // => true
  21239. *
  21240. * _.isObject(null);
  21241. * // => false
  21242. */
  21243. function isObject$2(value) {
  21244. var type = typeof value;
  21245. return value != null && (type == 'object' || type == 'function');
  21246. }
  21247. var isObject_1 = isObject$2;
  21248. /** `Object#toString` result references. */
  21249. var asyncTag = '[object AsyncFunction]',
  21250. funcTag$1 = '[object Function]',
  21251. genTag = '[object GeneratorFunction]',
  21252. proxyTag = '[object Proxy]';
  21253. /**
  21254. * Checks if `value` is classified as a `Function` object.
  21255. *
  21256. * @static
  21257. * @memberOf _
  21258. * @since 0.1.0
  21259. * @category Lang
  21260. * @param {*} value The value to check.
  21261. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  21262. * @example
  21263. *
  21264. * _.isFunction(_);
  21265. * // => true
  21266. *
  21267. * _.isFunction(/abc/);
  21268. * // => false
  21269. */
  21270. function isFunction(value) {
  21271. if (!isObject_1(value)) {
  21272. return false;
  21273. } // The use of `Object#toString` avoids issues with the `typeof` operator
  21274. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  21275. var tag = _baseGetTag(value);
  21276. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  21277. }
  21278. var isFunction_1 = isFunction;
  21279. /** Used to detect overreaching core-js shims. */
  21280. var coreJsData = _root['__core-js_shared__'];
  21281. var _coreJsData = coreJsData;
  21282. /** Used to detect methods masquerading as native. */
  21283. var maskSrcKey = function () {
  21284. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  21285. return uid ? 'Symbol(src)_1.' + uid : '';
  21286. }();
  21287. /**
  21288. * Checks if `func` has its source masked.
  21289. *
  21290. * @private
  21291. * @param {Function} func The function to check.
  21292. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  21293. */
  21294. function isMasked(func) {
  21295. return !!maskSrcKey && maskSrcKey in func;
  21296. }
  21297. var _isMasked = isMasked;
  21298. /** Used for built-in method references. */
  21299. var funcProto$1 = Function.prototype;
  21300. /** Used to resolve the decompiled source of functions. */
  21301. var funcToString$1 = funcProto$1.toString;
  21302. /**
  21303. * Converts `func` to its source code.
  21304. *
  21305. * @private
  21306. * @param {Function} func The function to convert.
  21307. * @returns {string} Returns the source code.
  21308. */
  21309. function toSource(func) {
  21310. if (func != null) {
  21311. try {
  21312. return funcToString$1.call(func);
  21313. } catch (e) {}
  21314. try {
  21315. return func + '';
  21316. } catch (e) {}
  21317. }
  21318. return '';
  21319. }
  21320. var _toSource = toSource;
  21321. /**
  21322. * Used to match `RegExp`
  21323. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  21324. */
  21325. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  21326. /** Used to detect host constructors (Safari). */
  21327. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  21328. /** Used for built-in method references. */
  21329. var funcProto = Function.prototype,
  21330. objectProto$9 = Object.prototype;
  21331. /** Used to resolve the decompiled source of functions. */
  21332. var funcToString = funcProto.toString;
  21333. /** Used to check objects for own properties. */
  21334. var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
  21335. /** Used to detect if a method is native. */
  21336. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  21337. /**
  21338. * The base implementation of `_.isNative` without bad shim checks.
  21339. *
  21340. * @private
  21341. * @param {*} value The value to check.
  21342. * @returns {boolean} Returns `true` if `value` is a native function,
  21343. * else `false`.
  21344. */
  21345. function baseIsNative(value) {
  21346. if (!isObject_1(value) || _isMasked(value)) {
  21347. return false;
  21348. }
  21349. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  21350. return pattern.test(_toSource(value));
  21351. }
  21352. var _baseIsNative = baseIsNative;
  21353. /**
  21354. * Gets the value at `key` of `object`.
  21355. *
  21356. * @private
  21357. * @param {Object} [object] The object to query.
  21358. * @param {string} key The key of the property to get.
  21359. * @returns {*} Returns the property value.
  21360. */
  21361. function getValue(object, key) {
  21362. return object == null ? undefined : object[key];
  21363. }
  21364. var _getValue = getValue;
  21365. /**
  21366. * Gets the native function at `key` of `object`.
  21367. *
  21368. * @private
  21369. * @param {Object} object The object to query.
  21370. * @param {string} key The key of the method to get.
  21371. * @returns {*} Returns the function if it's native, else `undefined`.
  21372. */
  21373. function getNative(object, key) {
  21374. var value = _getValue(object, key);
  21375. return _baseIsNative(value) ? value : undefined;
  21376. }
  21377. var _getNative = getNative;
  21378. /* Built-in method references that are verified to be native. */
  21379. var Map$1 = _getNative(_root, 'Map');
  21380. var _Map = Map$1;
  21381. /* Built-in method references that are verified to be native. */
  21382. var nativeCreate = _getNative(Object, 'create');
  21383. var _nativeCreate = nativeCreate;
  21384. /**
  21385. * Removes all key-value entries from the hash.
  21386. *
  21387. * @private
  21388. * @name clear
  21389. * @memberOf Hash
  21390. */
  21391. function hashClear() {
  21392. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  21393. this.size = 0;
  21394. }
  21395. var _hashClear = hashClear;
  21396. /**
  21397. * Removes `key` and its value from the hash.
  21398. *
  21399. * @private
  21400. * @name delete
  21401. * @memberOf Hash
  21402. * @param {Object} hash The hash to modify.
  21403. * @param {string} key The key of the value to remove.
  21404. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21405. */
  21406. function hashDelete(key) {
  21407. var result = this.has(key) && delete this.__data__[key];
  21408. this.size -= result ? 1 : 0;
  21409. return result;
  21410. }
  21411. var _hashDelete = hashDelete;
  21412. /** Used to stand-in for `undefined` hash values. */
  21413. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  21414. /** Used for built-in method references. */
  21415. var objectProto$8 = Object.prototype;
  21416. /** Used to check objects for own properties. */
  21417. var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
  21418. /**
  21419. * Gets the hash value for `key`.
  21420. *
  21421. * @private
  21422. * @name get
  21423. * @memberOf Hash
  21424. * @param {string} key The key of the value to get.
  21425. * @returns {*} Returns the entry value.
  21426. */
  21427. function hashGet(key) {
  21428. var data = this.__data__;
  21429. if (_nativeCreate) {
  21430. var result = data[key];
  21431. return result === HASH_UNDEFINED$2 ? undefined : result;
  21432. }
  21433. return hasOwnProperty$6.call(data, key) ? data[key] : undefined;
  21434. }
  21435. var _hashGet = hashGet;
  21436. /** Used for built-in method references. */
  21437. var objectProto$7 = Object.prototype;
  21438. /** Used to check objects for own properties. */
  21439. var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
  21440. /**
  21441. * Checks if a hash value for `key` exists.
  21442. *
  21443. * @private
  21444. * @name has
  21445. * @memberOf Hash
  21446. * @param {string} key The key of the entry to check.
  21447. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21448. */
  21449. function hashHas(key) {
  21450. var data = this.__data__;
  21451. return _nativeCreate ? data[key] !== undefined : hasOwnProperty$5.call(data, key);
  21452. }
  21453. var _hashHas = hashHas;
  21454. /** Used to stand-in for `undefined` hash values. */
  21455. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  21456. /**
  21457. * Sets the hash `key` to `value`.
  21458. *
  21459. * @private
  21460. * @name set
  21461. * @memberOf Hash
  21462. * @param {string} key The key of the value to set.
  21463. * @param {*} value The value to set.
  21464. * @returns {Object} Returns the hash instance.
  21465. */
  21466. function hashSet(key, value) {
  21467. var data = this.__data__;
  21468. this.size += this.has(key) ? 0 : 1;
  21469. data[key] = _nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
  21470. return this;
  21471. }
  21472. var _hashSet = hashSet;
  21473. /**
  21474. * Creates a hash object.
  21475. *
  21476. * @private
  21477. * @constructor
  21478. * @param {Array} [entries] The key-value pairs to cache.
  21479. */
  21480. function Hash(entries) {
  21481. var index = -1,
  21482. length = entries == null ? 0 : entries.length;
  21483. this.clear();
  21484. while (++index < length) {
  21485. var entry = entries[index];
  21486. this.set(entry[0], entry[1]);
  21487. }
  21488. } // Add methods to `Hash`.
  21489. Hash.prototype.clear = _hashClear;
  21490. Hash.prototype['delete'] = _hashDelete;
  21491. Hash.prototype.get = _hashGet;
  21492. Hash.prototype.has = _hashHas;
  21493. Hash.prototype.set = _hashSet;
  21494. var _Hash = Hash;
  21495. /**
  21496. * Removes all key-value entries from the map.
  21497. *
  21498. * @private
  21499. * @name clear
  21500. * @memberOf MapCache
  21501. */
  21502. function mapCacheClear() {
  21503. this.size = 0;
  21504. this.__data__ = {
  21505. 'hash': new _Hash(),
  21506. 'map': new (_Map || _ListCache)(),
  21507. 'string': new _Hash()
  21508. };
  21509. }
  21510. var _mapCacheClear = mapCacheClear;
  21511. /**
  21512. * Checks if `value` is suitable for use as unique object key.
  21513. *
  21514. * @private
  21515. * @param {*} value The value to check.
  21516. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  21517. */
  21518. function isKeyable(value) {
  21519. var type = typeof value;
  21520. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  21521. }
  21522. var _isKeyable = isKeyable;
  21523. /**
  21524. * Gets the data for `map`.
  21525. *
  21526. * @private
  21527. * @param {Object} map The map to query.
  21528. * @param {string} key The reference key.
  21529. * @returns {*} Returns the map data.
  21530. */
  21531. function getMapData(map, key) {
  21532. var data = map.__data__;
  21533. return _isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  21534. }
  21535. var _getMapData = getMapData;
  21536. /**
  21537. * Removes `key` and its value from the map.
  21538. *
  21539. * @private
  21540. * @name delete
  21541. * @memberOf MapCache
  21542. * @param {string} key The key of the value to remove.
  21543. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21544. */
  21545. function mapCacheDelete(key) {
  21546. var result = _getMapData(this, key)['delete'](key);
  21547. this.size -= result ? 1 : 0;
  21548. return result;
  21549. }
  21550. var _mapCacheDelete = mapCacheDelete;
  21551. /**
  21552. * Gets the map value for `key`.
  21553. *
  21554. * @private
  21555. * @name get
  21556. * @memberOf MapCache
  21557. * @param {string} key The key of the value to get.
  21558. * @returns {*} Returns the entry value.
  21559. */
  21560. function mapCacheGet(key) {
  21561. return _getMapData(this, key).get(key);
  21562. }
  21563. var _mapCacheGet = mapCacheGet;
  21564. /**
  21565. * Checks if a map value for `key` exists.
  21566. *
  21567. * @private
  21568. * @name has
  21569. * @memberOf MapCache
  21570. * @param {string} key The key of the entry to check.
  21571. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21572. */
  21573. function mapCacheHas(key) {
  21574. return _getMapData(this, key).has(key);
  21575. }
  21576. var _mapCacheHas = mapCacheHas;
  21577. /**
  21578. * Sets the map `key` to `value`.
  21579. *
  21580. * @private
  21581. * @name set
  21582. * @memberOf MapCache
  21583. * @param {string} key The key of the value to set.
  21584. * @param {*} value The value to set.
  21585. * @returns {Object} Returns the map cache instance.
  21586. */
  21587. function mapCacheSet(key, value) {
  21588. var data = _getMapData(this, key),
  21589. size = data.size;
  21590. data.set(key, value);
  21591. this.size += data.size == size ? 0 : 1;
  21592. return this;
  21593. }
  21594. var _mapCacheSet = mapCacheSet;
  21595. /**
  21596. * Creates a map cache object to store key-value pairs.
  21597. *
  21598. * @private
  21599. * @constructor
  21600. * @param {Array} [entries] The key-value pairs to cache.
  21601. */
  21602. function MapCache(entries) {
  21603. var index = -1,
  21604. length = entries == null ? 0 : entries.length;
  21605. this.clear();
  21606. while (++index < length) {
  21607. var entry = entries[index];
  21608. this.set(entry[0], entry[1]);
  21609. }
  21610. } // Add methods to `MapCache`.
  21611. MapCache.prototype.clear = _mapCacheClear;
  21612. MapCache.prototype['delete'] = _mapCacheDelete;
  21613. MapCache.prototype.get = _mapCacheGet;
  21614. MapCache.prototype.has = _mapCacheHas;
  21615. MapCache.prototype.set = _mapCacheSet;
  21616. var _MapCache = MapCache;
  21617. /** Used as the size to enable large array optimizations. */
  21618. var LARGE_ARRAY_SIZE$1 = 200;
  21619. /**
  21620. * Sets the stack `key` to `value`.
  21621. *
  21622. * @private
  21623. * @name set
  21624. * @memberOf Stack
  21625. * @param {string} key The key of the value to set.
  21626. * @param {*} value The value to set.
  21627. * @returns {Object} Returns the stack cache instance.
  21628. */
  21629. function stackSet(key, value) {
  21630. var data = this.__data__;
  21631. if (data instanceof _ListCache) {
  21632. var pairs = data.__data__;
  21633. if (!_Map || pairs.length < LARGE_ARRAY_SIZE$1 - 1) {
  21634. pairs.push([key, value]);
  21635. this.size = ++data.size;
  21636. return this;
  21637. }
  21638. data = this.__data__ = new _MapCache(pairs);
  21639. }
  21640. data.set(key, value);
  21641. this.size = data.size;
  21642. return this;
  21643. }
  21644. var _stackSet = stackSet;
  21645. /**
  21646. * Creates a stack cache object to store key-value pairs.
  21647. *
  21648. * @private
  21649. * @constructor
  21650. * @param {Array} [entries] The key-value pairs to cache.
  21651. */
  21652. function Stack(entries) {
  21653. var data = this.__data__ = new _ListCache(entries);
  21654. this.size = data.size;
  21655. } // Add methods to `Stack`.
  21656. Stack.prototype.clear = _stackClear;
  21657. Stack.prototype['delete'] = _stackDelete;
  21658. Stack.prototype.get = _stackGet;
  21659. Stack.prototype.has = _stackHas;
  21660. Stack.prototype.set = _stackSet;
  21661. var _Stack = Stack;
  21662. /** Used to stand-in for `undefined` hash values. */
  21663. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  21664. /**
  21665. * Adds `value` to the array cache.
  21666. *
  21667. * @private
  21668. * @name add
  21669. * @memberOf SetCache
  21670. * @alias push
  21671. * @param {*} value The value to cache.
  21672. * @returns {Object} Returns the cache instance.
  21673. */
  21674. function setCacheAdd(value) {
  21675. this.__data__.set(value, HASH_UNDEFINED);
  21676. return this;
  21677. }
  21678. var _setCacheAdd = setCacheAdd;
  21679. /**
  21680. * Checks if `value` is in the array cache.
  21681. *
  21682. * @private
  21683. * @name has
  21684. * @memberOf SetCache
  21685. * @param {*} value The value to search for.
  21686. * @returns {number} Returns `true` if `value` is found, else `false`.
  21687. */
  21688. function setCacheHas(value) {
  21689. return this.__data__.has(value);
  21690. }
  21691. var _setCacheHas = setCacheHas;
  21692. /**
  21693. *
  21694. * Creates an array cache object to store unique values.
  21695. *
  21696. * @private
  21697. * @constructor
  21698. * @param {Array} [values] The values to cache.
  21699. */
  21700. function SetCache(values) {
  21701. var index = -1,
  21702. length = values == null ? 0 : values.length;
  21703. this.__data__ = new _MapCache();
  21704. while (++index < length) {
  21705. this.add(values[index]);
  21706. }
  21707. } // Add methods to `SetCache`.
  21708. SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
  21709. SetCache.prototype.has = _setCacheHas;
  21710. var _SetCache = SetCache;
  21711. /**
  21712. * A specialized version of `_.some` for arrays without support for iteratee
  21713. * shorthands.
  21714. *
  21715. * @private
  21716. * @param {Array} [array] The array to iterate over.
  21717. * @param {Function} predicate The function invoked per iteration.
  21718. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21719. * else `false`.
  21720. */
  21721. function arraySome(array, predicate) {
  21722. var index = -1,
  21723. length = array == null ? 0 : array.length;
  21724. while (++index < length) {
  21725. if (predicate(array[index], index, array)) {
  21726. return true;
  21727. }
  21728. }
  21729. return false;
  21730. }
  21731. var _arraySome = arraySome;
  21732. /**
  21733. * Checks if a `cache` value for `key` exists.
  21734. *
  21735. * @private
  21736. * @param {Object} cache The cache to query.
  21737. * @param {string} key The key of the entry to check.
  21738. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21739. */
  21740. function cacheHas(cache, key) {
  21741. return cache.has(key);
  21742. }
  21743. var _cacheHas = cacheHas;
  21744. /** Used to compose bitmasks for value comparisons. */
  21745. var COMPARE_PARTIAL_FLAG$5 = 1,
  21746. COMPARE_UNORDERED_FLAG$3 = 2;
  21747. /**
  21748. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21749. * partial deep comparisons.
  21750. *
  21751. * @private
  21752. * @param {Array} array The array to compare.
  21753. * @param {Array} other The other array to compare.
  21754. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21755. * @param {Function} customizer The function to customize comparisons.
  21756. * @param {Function} equalFunc The function to determine equivalents of values.
  21757. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21758. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21759. */
  21760. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21761. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
  21762. arrLength = array.length,
  21763. othLength = other.length;
  21764. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21765. return false;
  21766. } // Check that cyclic values are equal.
  21767. var arrStacked = stack.get(array);
  21768. var othStacked = stack.get(other);
  21769. if (arrStacked && othStacked) {
  21770. return arrStacked == other && othStacked == array;
  21771. }
  21772. var index = -1,
  21773. result = true,
  21774. seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new _SetCache() : undefined;
  21775. stack.set(array, other);
  21776. stack.set(other, array); // Ignore non-index properties.
  21777. while (++index < arrLength) {
  21778. var arrValue = array[index],
  21779. othValue = other[index];
  21780. if (customizer) {
  21781. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  21782. }
  21783. if (compared !== undefined) {
  21784. if (compared) {
  21785. continue;
  21786. }
  21787. result = false;
  21788. break;
  21789. } // Recursively compare arrays (susceptible to call stack limits).
  21790. if (seen) {
  21791. if (!_arraySome(other, function (othValue, othIndex) {
  21792. if (!_cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  21793. return seen.push(othIndex);
  21794. }
  21795. })) {
  21796. result = false;
  21797. break;
  21798. }
  21799. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  21800. result = false;
  21801. break;
  21802. }
  21803. }
  21804. stack['delete'](array);
  21805. stack['delete'](other);
  21806. return result;
  21807. }
  21808. var _equalArrays = equalArrays;
  21809. /** Built-in value references. */
  21810. var Uint8Array = _root.Uint8Array;
  21811. var _Uint8Array = Uint8Array;
  21812. /**
  21813. * Converts `map` to its key-value pairs.
  21814. *
  21815. * @private
  21816. * @param {Object} map The map to convert.
  21817. * @returns {Array} Returns the key-value pairs.
  21818. */
  21819. function mapToArray(map) {
  21820. var index = -1,
  21821. result = Array(map.size);
  21822. map.forEach(function (value, key) {
  21823. result[++index] = [key, value];
  21824. });
  21825. return result;
  21826. }
  21827. var _mapToArray = mapToArray;
  21828. /**
  21829. * Converts `set` to an array of its values.
  21830. *
  21831. * @private
  21832. * @param {Object} set The set to convert.
  21833. * @returns {Array} Returns the values.
  21834. */
  21835. function setToArray(set) {
  21836. var index = -1,
  21837. result = Array(set.size);
  21838. set.forEach(function (value) {
  21839. result[++index] = value;
  21840. });
  21841. return result;
  21842. }
  21843. var _setToArray = setToArray;
  21844. /** Used to compose bitmasks for value comparisons. */
  21845. var COMPARE_PARTIAL_FLAG$4 = 1,
  21846. COMPARE_UNORDERED_FLAG$2 = 2;
  21847. /** `Object#toString` result references. */
  21848. var boolTag$1 = '[object Boolean]',
  21849. dateTag$1 = '[object Date]',
  21850. errorTag$1 = '[object Error]',
  21851. mapTag$2 = '[object Map]',
  21852. numberTag$1 = '[object Number]',
  21853. regexpTag$1 = '[object RegExp]',
  21854. setTag$2 = '[object Set]',
  21855. stringTag$1 = '[object String]',
  21856. symbolTag$1 = '[object Symbol]';
  21857. var arrayBufferTag$1 = '[object ArrayBuffer]',
  21858. dataViewTag$2 = '[object DataView]';
  21859. /** Used to convert symbols to primitives and strings. */
  21860. var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
  21861. symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
  21862. /**
  21863. * A specialized version of `baseIsEqualDeep` for comparing objects of
  21864. * the same `toStringTag`.
  21865. *
  21866. * **Note:** This function only supports comparing values with tags of
  21867. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  21868. *
  21869. * @private
  21870. * @param {Object} object The object to compare.
  21871. * @param {Object} other The other object to compare.
  21872. * @param {string} tag The `toStringTag` of the objects to compare.
  21873. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21874. * @param {Function} customizer The function to customize comparisons.
  21875. * @param {Function} equalFunc The function to determine equivalents of values.
  21876. * @param {Object} stack Tracks traversed `object` and `other` objects.
  21877. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  21878. */
  21879. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  21880. switch (tag) {
  21881. case dataViewTag$2:
  21882. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  21883. return false;
  21884. }
  21885. object = object.buffer;
  21886. other = other.buffer;
  21887. case arrayBufferTag$1:
  21888. if (object.byteLength != other.byteLength || !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
  21889. return false;
  21890. }
  21891. return true;
  21892. case boolTag$1:
  21893. case dateTag$1:
  21894. case numberTag$1:
  21895. // Coerce booleans to `1` or `0` and dates to milliseconds.
  21896. // Invalid dates are coerced to `NaN`.
  21897. return eq_1(+object, +other);
  21898. case errorTag$1:
  21899. return object.name == other.name && object.message == other.message;
  21900. case regexpTag$1:
  21901. case stringTag$1:
  21902. // Coerce regexes to strings and treat strings, primitives and objects,
  21903. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  21904. // for more details.
  21905. return object == other + '';
  21906. case mapTag$2:
  21907. var convert = _mapToArray;
  21908. case setTag$2:
  21909. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
  21910. convert || (convert = _setToArray);
  21911. if (object.size != other.size && !isPartial) {
  21912. return false;
  21913. } // Assume cyclic values are equal.
  21914. var stacked = stack.get(object);
  21915. if (stacked) {
  21916. return stacked == other;
  21917. }
  21918. bitmask |= COMPARE_UNORDERED_FLAG$2; // Recursively compare objects (susceptible to call stack limits).
  21919. stack.set(object, other);
  21920. var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  21921. stack['delete'](object);
  21922. return result;
  21923. case symbolTag$1:
  21924. if (symbolValueOf) {
  21925. return symbolValueOf.call(object) == symbolValueOf.call(other);
  21926. }
  21927. }
  21928. return false;
  21929. }
  21930. var _equalByTag = equalByTag;
  21931. /**
  21932. * Appends the elements of `values` to `array`.
  21933. *
  21934. * @private
  21935. * @param {Array} array The array to modify.
  21936. * @param {Array} values The values to append.
  21937. * @returns {Array} Returns `array`.
  21938. */
  21939. function arrayPush(array, values) {
  21940. var index = -1,
  21941. length = values.length,
  21942. offset = array.length;
  21943. while (++index < length) {
  21944. array[offset + index] = values[index];
  21945. }
  21946. return array;
  21947. }
  21948. var _arrayPush = arrayPush;
  21949. /**
  21950. * Checks if `value` is classified as an `Array` object.
  21951. *
  21952. * @static
  21953. * @memberOf _
  21954. * @since 0.1.0
  21955. * @category Lang
  21956. * @param {*} value The value to check.
  21957. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  21958. * @example
  21959. *
  21960. * _.isArray([1, 2, 3]);
  21961. * // => true
  21962. *
  21963. * _.isArray(document.body.children);
  21964. * // => false
  21965. *
  21966. * _.isArray('abc');
  21967. * // => false
  21968. *
  21969. * _.isArray(_.noop);
  21970. * // => false
  21971. */
  21972. var isArray = Array.isArray;
  21973. var isArray_1 = isArray;
  21974. /**
  21975. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  21976. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  21977. * symbols of `object`.
  21978. *
  21979. * @private
  21980. * @param {Object} object The object to query.
  21981. * @param {Function} keysFunc The function to get the keys of `object`.
  21982. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  21983. * @returns {Array} Returns the array of property names and symbols.
  21984. */
  21985. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  21986. var result = keysFunc(object);
  21987. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  21988. }
  21989. var _baseGetAllKeys = baseGetAllKeys;
  21990. /**
  21991. * A specialized version of `_.filter` for arrays without support for
  21992. * iteratee shorthands.
  21993. *
  21994. * @private
  21995. * @param {Array} [array] The array to iterate over.
  21996. * @param {Function} predicate The function invoked per iteration.
  21997. * @returns {Array} Returns the new filtered array.
  21998. */
  21999. function arrayFilter(array, predicate) {
  22000. var index = -1,
  22001. length = array == null ? 0 : array.length,
  22002. resIndex = 0,
  22003. result = [];
  22004. while (++index < length) {
  22005. var value = array[index];
  22006. if (predicate(value, index, array)) {
  22007. result[resIndex++] = value;
  22008. }
  22009. }
  22010. return result;
  22011. }
  22012. var _arrayFilter = arrayFilter;
  22013. /**
  22014. * This method returns a new empty array.
  22015. *
  22016. * @static
  22017. * @memberOf _
  22018. * @since 4.13.0
  22019. * @category Util
  22020. * @returns {Array} Returns the new empty array.
  22021. * @example
  22022. *
  22023. * var arrays = _.times(2, _.stubArray);
  22024. *
  22025. * console.log(arrays);
  22026. * // => [[], []]
  22027. *
  22028. * console.log(arrays[0] === arrays[1]);
  22029. * // => false
  22030. */
  22031. function stubArray() {
  22032. return [];
  22033. }
  22034. var stubArray_1 = stubArray;
  22035. /** Used for built-in method references. */
  22036. var objectProto$6 = Object.prototype;
  22037. /** Built-in value references. */
  22038. var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
  22039. /* Built-in method references for those with the same name as other `lodash` methods. */
  22040. var nativeGetSymbols = Object.getOwnPropertySymbols;
  22041. /**
  22042. * Creates an array of the own enumerable symbols of `object`.
  22043. *
  22044. * @private
  22045. * @param {Object} object The object to query.
  22046. * @returns {Array} Returns the array of symbols.
  22047. */
  22048. var getSymbols = !nativeGetSymbols ? stubArray_1 : function (object) {
  22049. if (object == null) {
  22050. return [];
  22051. }
  22052. object = Object(object);
  22053. return _arrayFilter(nativeGetSymbols(object), function (symbol) {
  22054. return propertyIsEnumerable$1.call(object, symbol);
  22055. });
  22056. };
  22057. var _getSymbols = getSymbols;
  22058. /**
  22059. * The base implementation of `_.times` without support for iteratee shorthands
  22060. * or max array length checks.
  22061. *
  22062. * @private
  22063. * @param {number} n The number of times to invoke `iteratee`.
  22064. * @param {Function} iteratee The function invoked per iteration.
  22065. * @returns {Array} Returns the array of results.
  22066. */
  22067. function baseTimes(n, iteratee) {
  22068. var index = -1,
  22069. result = Array(n);
  22070. while (++index < n) {
  22071. result[index] = iteratee(index);
  22072. }
  22073. return result;
  22074. }
  22075. var _baseTimes = baseTimes;
  22076. /**
  22077. * Checks if `value` is object-like. A value is object-like if it's not `null`
  22078. * and has a `typeof` result of "object".
  22079. *
  22080. * @static
  22081. * @memberOf _
  22082. * @since 4.0.0
  22083. * @category Lang
  22084. * @param {*} value The value to check.
  22085. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  22086. * @example
  22087. *
  22088. * _.isObjectLike({});
  22089. * // => true
  22090. *
  22091. * _.isObjectLike([1, 2, 3]);
  22092. * // => true
  22093. *
  22094. * _.isObjectLike(_.noop);
  22095. * // => false
  22096. *
  22097. * _.isObjectLike(null);
  22098. * // => false
  22099. */
  22100. function isObjectLike(value) {
  22101. return value != null && typeof value == 'object';
  22102. }
  22103. var isObjectLike_1 = isObjectLike;
  22104. /** `Object#toString` result references. */
  22105. var argsTag$2 = '[object Arguments]';
  22106. /**
  22107. * The base implementation of `_.isArguments`.
  22108. *
  22109. * @private
  22110. * @param {*} value The value to check.
  22111. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  22112. */
  22113. function baseIsArguments(value) {
  22114. return isObjectLike_1(value) && _baseGetTag(value) == argsTag$2;
  22115. }
  22116. var _baseIsArguments = baseIsArguments;
  22117. /** Used for built-in method references. */
  22118. var objectProto$5 = Object.prototype;
  22119. /** Used to check objects for own properties. */
  22120. var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
  22121. /** Built-in value references. */
  22122. var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
  22123. /**
  22124. * Checks if `value` is likely an `arguments` object.
  22125. *
  22126. * @static
  22127. * @memberOf _
  22128. * @since 0.1.0
  22129. * @category Lang
  22130. * @param {*} value The value to check.
  22131. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  22132. * else `false`.
  22133. * @example
  22134. *
  22135. * _.isArguments(function() { return arguments; }());
  22136. * // => true
  22137. *
  22138. * _.isArguments([1, 2, 3]);
  22139. * // => false
  22140. */
  22141. var isArguments = _baseIsArguments(function () {
  22142. return arguments;
  22143. }()) ? _baseIsArguments : function (value) {
  22144. return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  22145. };
  22146. var isArguments_1 = isArguments;
  22147. /**
  22148. * This method returns `false`.
  22149. *
  22150. * @static
  22151. * @memberOf _
  22152. * @since 4.13.0
  22153. * @category Util
  22154. * @returns {boolean} Returns `false`.
  22155. * @example
  22156. *
  22157. * _.times(2, _.stubFalse);
  22158. * // => [false, false]
  22159. */
  22160. function stubFalse() {
  22161. return false;
  22162. }
  22163. var stubFalse_1 = stubFalse;
  22164. var isBuffer_1 = createCommonjsModule(function (module, exports) {
  22165. /** Detect free variable `exports`. */
  22166. var freeExports = exports && !exports.nodeType && exports;
  22167. /** Detect free variable `module`. */
  22168. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  22169. /** Detect the popular CommonJS extension `module.exports`. */
  22170. var moduleExports = freeModule && freeModule.exports === freeExports;
  22171. /** Built-in value references. */
  22172. var Buffer = moduleExports ? _root.Buffer : undefined;
  22173. /* Built-in method references for those with the same name as other `lodash` methods. */
  22174. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  22175. /**
  22176. * Checks if `value` is a buffer.
  22177. *
  22178. * @static
  22179. * @memberOf _
  22180. * @since 4.3.0
  22181. * @category Lang
  22182. * @param {*} value The value to check.
  22183. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  22184. * @example
  22185. *
  22186. * _.isBuffer(new Buffer(2));
  22187. * // => true
  22188. *
  22189. * _.isBuffer(new Uint8Array(2));
  22190. * // => false
  22191. */
  22192. var isBuffer = nativeIsBuffer || stubFalse_1;
  22193. module.exports = isBuffer;
  22194. });
  22195. /** Used as references for various `Number` constants. */
  22196. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  22197. /** Used to detect unsigned integer values. */
  22198. var reIsUint = /^(?:0|[1-9]\d*)$/;
  22199. /**
  22200. * Checks if `value` is a valid array-like index.
  22201. *
  22202. * @private
  22203. * @param {*} value The value to check.
  22204. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22205. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22206. */
  22207. function isIndex(value, length) {
  22208. var type = typeof value;
  22209. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  22210. return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  22211. }
  22212. var _isIndex = isIndex;
  22213. /** Used as references for various `Number` constants. */
  22214. var MAX_SAFE_INTEGER = 9007199254740991;
  22215. /**
  22216. * Checks if `value` is a valid array-like length.
  22217. *
  22218. * **Note:** This method is loosely based on
  22219. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  22220. *
  22221. * @static
  22222. * @memberOf _
  22223. * @since 4.0.0
  22224. * @category Lang
  22225. * @param {*} value The value to check.
  22226. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  22227. * @example
  22228. *
  22229. * _.isLength(3);
  22230. * // => true
  22231. *
  22232. * _.isLength(Number.MIN_VALUE);
  22233. * // => false
  22234. *
  22235. * _.isLength(Infinity);
  22236. * // => false
  22237. *
  22238. * _.isLength('3');
  22239. * // => false
  22240. */
  22241. function isLength(value) {
  22242. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  22243. }
  22244. var isLength_1 = isLength;
  22245. /** `Object#toString` result references. */
  22246. var argsTag$1 = '[object Arguments]',
  22247. arrayTag$1 = '[object Array]',
  22248. boolTag = '[object Boolean]',
  22249. dateTag = '[object Date]',
  22250. errorTag = '[object Error]',
  22251. funcTag = '[object Function]',
  22252. mapTag$1 = '[object Map]',
  22253. numberTag = '[object Number]',
  22254. objectTag$2 = '[object Object]',
  22255. regexpTag = '[object RegExp]',
  22256. setTag$1 = '[object Set]',
  22257. stringTag = '[object String]',
  22258. weakMapTag$1 = '[object WeakMap]';
  22259. var arrayBufferTag = '[object ArrayBuffer]',
  22260. dataViewTag$1 = '[object DataView]',
  22261. float32Tag = '[object Float32Array]',
  22262. float64Tag = '[object Float64Array]',
  22263. int8Tag = '[object Int8Array]',
  22264. int16Tag = '[object Int16Array]',
  22265. int32Tag = '[object Int32Array]',
  22266. uint8Tag = '[object Uint8Array]',
  22267. uint8ClampedTag = '[object Uint8ClampedArray]',
  22268. uint16Tag = '[object Uint16Array]',
  22269. uint32Tag = '[object Uint32Array]';
  22270. /** Used to identify `toStringTag` values of typed arrays. */
  22271. var typedArrayTags = {};
  22272. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  22273. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
  22274. /**
  22275. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  22276. *
  22277. * @private
  22278. * @param {*} value The value to check.
  22279. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  22280. */
  22281. function baseIsTypedArray(value) {
  22282. return isObjectLike_1(value) && isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  22283. }
  22284. var _baseIsTypedArray = baseIsTypedArray;
  22285. /**
  22286. * The base implementation of `_.unary` without support for storing metadata.
  22287. *
  22288. * @private
  22289. * @param {Function} func The function to cap arguments for.
  22290. * @returns {Function} Returns the new capped function.
  22291. */
  22292. function baseUnary(func) {
  22293. return function (value) {
  22294. return func(value);
  22295. };
  22296. }
  22297. var _baseUnary = baseUnary;
  22298. var _nodeUtil = createCommonjsModule(function (module, exports) {
  22299. /** Detect free variable `exports`. */
  22300. var freeExports = exports && !exports.nodeType && exports;
  22301. /** Detect free variable `module`. */
  22302. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  22303. /** Detect the popular CommonJS extension `module.exports`. */
  22304. var moduleExports = freeModule && freeModule.exports === freeExports;
  22305. /** Detect free variable `process` from Node.js. */
  22306. var freeProcess = moduleExports && _freeGlobal.process;
  22307. /** Used to access faster Node.js helpers. */
  22308. var nodeUtil = function () {
  22309. try {
  22310. // Use `util.types` for Node.js 10+.
  22311. var types = freeModule && freeModule.require && freeModule.require('util').types;
  22312. if (types) {
  22313. return types;
  22314. } // Legacy `process.binding('util')` for Node.js < 10.
  22315. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  22316. } catch (e) {}
  22317. }();
  22318. module.exports = nodeUtil;
  22319. });
  22320. /* Node.js helper references. */
  22321. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  22322. /**
  22323. * Checks if `value` is classified as a typed array.
  22324. *
  22325. * @static
  22326. * @memberOf _
  22327. * @since 3.0.0
  22328. * @category Lang
  22329. * @param {*} value The value to check.
  22330. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  22331. * @example
  22332. *
  22333. * _.isTypedArray(new Uint8Array);
  22334. * // => true
  22335. *
  22336. * _.isTypedArray([]);
  22337. * // => false
  22338. */
  22339. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  22340. var isTypedArray_1 = isTypedArray;
  22341. /** Used for built-in method references. */
  22342. var objectProto$4 = Object.prototype;
  22343. /** Used to check objects for own properties. */
  22344. var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
  22345. /**
  22346. * Creates an array of the enumerable property names of the array-like `value`.
  22347. *
  22348. * @private
  22349. * @param {*} value The value to query.
  22350. * @param {boolean} inherited Specify returning inherited property names.
  22351. * @returns {Array} Returns the array of property names.
  22352. */
  22353. function arrayLikeKeys(value, inherited) {
  22354. var isArr = isArray_1(value),
  22355. isArg = !isArr && isArguments_1(value),
  22356. isBuff = !isArr && !isArg && isBuffer_1(value),
  22357. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  22358. skipIndexes = isArr || isArg || isBuff || isType,
  22359. result = skipIndexes ? _baseTimes(value.length, String) : [],
  22360. length = result.length;
  22361. for (var key in value) {
  22362. if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
  22363. key == 'length' || isBuff && (key == 'offset' || key == 'parent') || isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
  22364. _isIndex(key, length)))) {
  22365. result.push(key);
  22366. }
  22367. }
  22368. return result;
  22369. }
  22370. var _arrayLikeKeys = arrayLikeKeys;
  22371. /** Used for built-in method references. */
  22372. var objectProto$3 = Object.prototype;
  22373. /**
  22374. * Checks if `value` is likely a prototype object.
  22375. *
  22376. * @private
  22377. * @param {*} value The value to check.
  22378. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22379. */
  22380. function isPrototype(value) {
  22381. var Ctor = value && value.constructor,
  22382. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$3;
  22383. return value === proto;
  22384. }
  22385. var _isPrototype = isPrototype;
  22386. /**
  22387. * Creates a unary function that invokes `func` with its argument transformed.
  22388. *
  22389. * @private
  22390. * @param {Function} func The function to wrap.
  22391. * @param {Function} transform The argument transform.
  22392. * @returns {Function} Returns the new function.
  22393. */
  22394. function overArg(func, transform) {
  22395. return function (arg) {
  22396. return func(transform(arg));
  22397. };
  22398. }
  22399. var _overArg = overArg;
  22400. /* Built-in method references for those with the same name as other `lodash` methods. */
  22401. var nativeKeys = _overArg(Object.keys, Object);
  22402. var _nativeKeys = nativeKeys;
  22403. /** Used for built-in method references. */
  22404. var objectProto$2 = Object.prototype;
  22405. /** Used to check objects for own properties. */
  22406. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  22407. /**
  22408. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  22409. *
  22410. * @private
  22411. * @param {Object} object The object to query.
  22412. * @returns {Array} Returns the array of property names.
  22413. */
  22414. function baseKeys(object) {
  22415. if (!_isPrototype(object)) {
  22416. return _nativeKeys(object);
  22417. }
  22418. var result = [];
  22419. for (var key in Object(object)) {
  22420. if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
  22421. result.push(key);
  22422. }
  22423. }
  22424. return result;
  22425. }
  22426. var _baseKeys = baseKeys;
  22427. /**
  22428. * Checks if `value` is array-like. A value is considered array-like if it's
  22429. * not a function and has a `value.length` that's an integer greater than or
  22430. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  22431. *
  22432. * @static
  22433. * @memberOf _
  22434. * @since 4.0.0
  22435. * @category Lang
  22436. * @param {*} value The value to check.
  22437. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  22438. * @example
  22439. *
  22440. * _.isArrayLike([1, 2, 3]);
  22441. * // => true
  22442. *
  22443. * _.isArrayLike(document.body.children);
  22444. * // => true
  22445. *
  22446. * _.isArrayLike('abc');
  22447. * // => true
  22448. *
  22449. * _.isArrayLike(_.noop);
  22450. * // => false
  22451. */
  22452. function isArrayLike(value) {
  22453. return value != null && isLength_1(value.length) && !isFunction_1(value);
  22454. }
  22455. var isArrayLike_1 = isArrayLike;
  22456. /**
  22457. * Creates an array of the own enumerable property names of `object`.
  22458. *
  22459. * **Note:** Non-object values are coerced to objects. See the
  22460. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22461. * for more details.
  22462. *
  22463. * @static
  22464. * @since 0.1.0
  22465. * @memberOf _
  22466. * @category Object
  22467. * @param {Object} object The object to query.
  22468. * @returns {Array} Returns the array of property names.
  22469. * @example
  22470. *
  22471. * function Foo() {
  22472. * this.a = 1;
  22473. * this.b = 2;
  22474. * }
  22475. *
  22476. * Foo.prototype.c = 3;
  22477. *
  22478. * _.keys(new Foo);
  22479. * // => ['a', 'b'] (iteration order is not guaranteed)
  22480. *
  22481. * _.keys('hi');
  22482. * // => ['0', '1']
  22483. */
  22484. function keys(object) {
  22485. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  22486. }
  22487. var keys_1 = keys;
  22488. /**
  22489. * Creates an array of own enumerable property names and symbols of `object`.
  22490. *
  22491. * @private
  22492. * @param {Object} object The object to query.
  22493. * @returns {Array} Returns the array of property names and symbols.
  22494. */
  22495. function getAllKeys(object) {
  22496. return _baseGetAllKeys(object, keys_1, _getSymbols);
  22497. }
  22498. var _getAllKeys = getAllKeys;
  22499. /** Used to compose bitmasks for value comparisons. */
  22500. var COMPARE_PARTIAL_FLAG$3 = 1;
  22501. /** Used for built-in method references. */
  22502. var objectProto$1 = Object.prototype;
  22503. /** Used to check objects for own properties. */
  22504. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  22505. /**
  22506. * A specialized version of `baseIsEqualDeep` for objects with support for
  22507. * partial deep comparisons.
  22508. *
  22509. * @private
  22510. * @param {Object} object The object to compare.
  22511. * @param {Object} other The other object to compare.
  22512. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22513. * @param {Function} customizer The function to customize comparisons.
  22514. * @param {Function} equalFunc The function to determine equivalents of values.
  22515. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22516. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22517. */
  22518. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22519. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
  22520. objProps = _getAllKeys(object),
  22521. objLength = objProps.length,
  22522. othProps = _getAllKeys(other),
  22523. othLength = othProps.length;
  22524. if (objLength != othLength && !isPartial) {
  22525. return false;
  22526. }
  22527. var index = objLength;
  22528. while (index--) {
  22529. var key = objProps[index];
  22530. if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
  22531. return false;
  22532. }
  22533. } // Check that cyclic values are equal.
  22534. var objStacked = stack.get(object);
  22535. var othStacked = stack.get(other);
  22536. if (objStacked && othStacked) {
  22537. return objStacked == other && othStacked == object;
  22538. }
  22539. var result = true;
  22540. stack.set(object, other);
  22541. stack.set(other, object);
  22542. var skipCtor = isPartial;
  22543. while (++index < objLength) {
  22544. key = objProps[index];
  22545. var objValue = object[key],
  22546. othValue = other[key];
  22547. if (customizer) {
  22548. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  22549. } // Recursively compare objects (susceptible to call stack limits).
  22550. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
  22551. result = false;
  22552. break;
  22553. }
  22554. skipCtor || (skipCtor = key == 'constructor');
  22555. }
  22556. if (result && !skipCtor) {
  22557. var objCtor = object.constructor,
  22558. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  22559. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22560. result = false;
  22561. }
  22562. }
  22563. stack['delete'](object);
  22564. stack['delete'](other);
  22565. return result;
  22566. }
  22567. var _equalObjects = equalObjects;
  22568. /* Built-in method references that are verified to be native. */
  22569. var DataView = _getNative(_root, 'DataView');
  22570. var _DataView = DataView;
  22571. /* Built-in method references that are verified to be native. */
  22572. var Promise$1 = _getNative(_root, 'Promise');
  22573. var _Promise = Promise$1;
  22574. /* Built-in method references that are verified to be native. */
  22575. var Set$1 = _getNative(_root, 'Set');
  22576. var _Set = Set$1;
  22577. /* Built-in method references that are verified to be native. */
  22578. var WeakMap$1 = _getNative(_root, 'WeakMap');
  22579. var _WeakMap = WeakMap$1;
  22580. /** `Object#toString` result references. */
  22581. var mapTag = '[object Map]',
  22582. objectTag$1 = '[object Object]',
  22583. promiseTag = '[object Promise]',
  22584. setTag = '[object Set]',
  22585. weakMapTag = '[object WeakMap]';
  22586. var dataViewTag = '[object DataView]';
  22587. /** Used to detect maps, sets, and weakmaps. */
  22588. var dataViewCtorString = _toSource(_DataView),
  22589. mapCtorString = _toSource(_Map),
  22590. promiseCtorString = _toSource(_Promise),
  22591. setCtorString = _toSource(_Set),
  22592. weakMapCtorString = _toSource(_WeakMap);
  22593. /**
  22594. * Gets the `toStringTag` of `value`.
  22595. *
  22596. * @private
  22597. * @param {*} value The value to query.
  22598. * @returns {string} Returns the `toStringTag`.
  22599. */
  22600. var getTag = _baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22601. if (_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag || _Map && getTag(new _Map()) != mapTag || _Promise && getTag(_Promise.resolve()) != promiseTag || _Set && getTag(new _Set()) != setTag || _WeakMap && getTag(new _WeakMap()) != weakMapTag) {
  22602. getTag = function (value) {
  22603. var result = _baseGetTag(value),
  22604. Ctor = result == objectTag$1 ? value.constructor : undefined,
  22605. ctorString = Ctor ? _toSource(Ctor) : '';
  22606. if (ctorString) {
  22607. switch (ctorString) {
  22608. case dataViewCtorString:
  22609. return dataViewTag;
  22610. case mapCtorString:
  22611. return mapTag;
  22612. case promiseCtorString:
  22613. return promiseTag;
  22614. case setCtorString:
  22615. return setTag;
  22616. case weakMapCtorString:
  22617. return weakMapTag;
  22618. }
  22619. }
  22620. return result;
  22621. };
  22622. }
  22623. var _getTag = getTag;
  22624. /** Used to compose bitmasks for value comparisons. */
  22625. var COMPARE_PARTIAL_FLAG$2 = 1;
  22626. /** `Object#toString` result references. */
  22627. var argsTag = '[object Arguments]',
  22628. arrayTag = '[object Array]',
  22629. objectTag = '[object Object]';
  22630. /** Used for built-in method references. */
  22631. var objectProto = Object.prototype;
  22632. /** Used to check objects for own properties. */
  22633. var hasOwnProperty = objectProto.hasOwnProperty;
  22634. /**
  22635. * A specialized version of `baseIsEqual` for arrays and objects which performs
  22636. * deep comparisons and tracks traversed objects enabling objects with circular
  22637. * references to be compared.
  22638. *
  22639. * @private
  22640. * @param {Object} object The object to compare.
  22641. * @param {Object} other The other object to compare.
  22642. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22643. * @param {Function} customizer The function to customize comparisons.
  22644. * @param {Function} equalFunc The function to determine equivalents of values.
  22645. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  22646. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22647. */
  22648. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  22649. var objIsArr = isArray_1(object),
  22650. othIsArr = isArray_1(other),
  22651. objTag = objIsArr ? arrayTag : _getTag(object),
  22652. othTag = othIsArr ? arrayTag : _getTag(other);
  22653. objTag = objTag == argsTag ? objectTag : objTag;
  22654. othTag = othTag == argsTag ? objectTag : othTag;
  22655. var objIsObj = objTag == objectTag,
  22656. othIsObj = othTag == objectTag,
  22657. isSameTag = objTag == othTag;
  22658. if (isSameTag && isBuffer_1(object)) {
  22659. if (!isBuffer_1(other)) {
  22660. return false;
  22661. }
  22662. objIsArr = true;
  22663. objIsObj = false;
  22664. }
  22665. if (isSameTag && !objIsObj) {
  22666. stack || (stack = new _Stack());
  22667. return objIsArr || isTypedArray_1(object) ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  22668. }
  22669. if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
  22670. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  22671. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  22672. if (objIsWrapped || othIsWrapped) {
  22673. var objUnwrapped = objIsWrapped ? object.value() : object,
  22674. othUnwrapped = othIsWrapped ? other.value() : other;
  22675. stack || (stack = new _Stack());
  22676. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  22677. }
  22678. }
  22679. if (!isSameTag) {
  22680. return false;
  22681. }
  22682. stack || (stack = new _Stack());
  22683. return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  22684. }
  22685. var _baseIsEqualDeep = baseIsEqualDeep;
  22686. /**
  22687. * The base implementation of `_.isEqual` which supports partial comparisons
  22688. * and tracks traversed objects.
  22689. *
  22690. * @private
  22691. * @param {*} value The value to compare.
  22692. * @param {*} other The other value to compare.
  22693. * @param {boolean} bitmask The bitmask flags.
  22694. * 1 - Unordered comparison
  22695. * 2 - Partial comparison
  22696. * @param {Function} [customizer] The function to customize comparisons.
  22697. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  22698. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  22699. */
  22700. function baseIsEqual(value, other, bitmask, customizer, stack) {
  22701. if (value === other) {
  22702. return true;
  22703. }
  22704. if (value == null || other == null || !isObjectLike_1(value) && !isObjectLike_1(other)) {
  22705. return value !== value && other !== other;
  22706. }
  22707. return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  22708. }
  22709. var _baseIsEqual = baseIsEqual;
  22710. /** Used to compose bitmasks for value comparisons. */
  22711. var COMPARE_PARTIAL_FLAG$1 = 1,
  22712. COMPARE_UNORDERED_FLAG$1 = 2;
  22713. /**
  22714. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  22715. *
  22716. * @private
  22717. * @param {Object} object The object to inspect.
  22718. * @param {Object} source The object of property values to match.
  22719. * @param {Array} matchData The property names, values, and compare flags to match.
  22720. * @param {Function} [customizer] The function to customize comparisons.
  22721. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  22722. */
  22723. function baseIsMatch(object, source, matchData, customizer) {
  22724. var index = matchData.length,
  22725. length = index,
  22726. noCustomizer = !customizer;
  22727. if (object == null) {
  22728. return !length;
  22729. }
  22730. object = Object(object);
  22731. while (index--) {
  22732. var data = matchData[index];
  22733. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  22734. return false;
  22735. }
  22736. }
  22737. while (++index < length) {
  22738. data = matchData[index];
  22739. var key = data[0],
  22740. objValue = object[key],
  22741. srcValue = data[1];
  22742. if (noCustomizer && data[2]) {
  22743. if (objValue === undefined && !(key in object)) {
  22744. return false;
  22745. }
  22746. } else {
  22747. var stack = new _Stack();
  22748. if (customizer) {
  22749. var result = customizer(objValue, srcValue, key, object, source, stack);
  22750. }
  22751. if (!(result === undefined ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
  22752. return false;
  22753. }
  22754. }
  22755. }
  22756. return true;
  22757. }
  22758. var _baseIsMatch = baseIsMatch;
  22759. /**
  22760. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22761. *
  22762. * @private
  22763. * @param {*} value The value to check.
  22764. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22765. * equality comparisons, else `false`.
  22766. */
  22767. function isStrictComparable(value) {
  22768. return value === value && !isObject_1(value);
  22769. }
  22770. var _isStrictComparable = isStrictComparable;
  22771. /**
  22772. * Gets the property names, values, and compare flags of `object`.
  22773. *
  22774. * @private
  22775. * @param {Object} object The object to query.
  22776. * @returns {Array} Returns the match data of `object`.
  22777. */
  22778. function getMatchData(object) {
  22779. var result = keys_1(object),
  22780. length = result.length;
  22781. while (length--) {
  22782. var key = result[length],
  22783. value = object[key];
  22784. result[length] = [key, value, _isStrictComparable(value)];
  22785. }
  22786. return result;
  22787. }
  22788. var _getMatchData = getMatchData;
  22789. /**
  22790. * A specialized version of `matchesProperty` for source values suitable
  22791. * for strict equality comparisons, i.e. `===`.
  22792. *
  22793. * @private
  22794. * @param {string} key The key of the property to get.
  22795. * @param {*} srcValue The value to match.
  22796. * @returns {Function} Returns the new spec function.
  22797. */
  22798. function matchesStrictComparable(key, srcValue) {
  22799. return function (object) {
  22800. if (object == null) {
  22801. return false;
  22802. }
  22803. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  22804. };
  22805. }
  22806. var _matchesStrictComparable = matchesStrictComparable;
  22807. /**
  22808. * The base implementation of `_.matches` which doesn't clone `source`.
  22809. *
  22810. * @private
  22811. * @param {Object} source The object of property values to match.
  22812. * @returns {Function} Returns the new spec function.
  22813. */
  22814. function baseMatches(source) {
  22815. var matchData = _getMatchData(source);
  22816. if (matchData.length == 1 && matchData[0][2]) {
  22817. return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
  22818. }
  22819. return function (object) {
  22820. return object === source || _baseIsMatch(object, source, matchData);
  22821. };
  22822. }
  22823. var _baseMatches = baseMatches;
  22824. /** `Object#toString` result references. */
  22825. var symbolTag = '[object Symbol]';
  22826. /**
  22827. * Checks if `value` is classified as a `Symbol` primitive or object.
  22828. *
  22829. * @static
  22830. * @memberOf _
  22831. * @since 4.0.0
  22832. * @category Lang
  22833. * @param {*} value The value to check.
  22834. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  22835. * @example
  22836. *
  22837. * _.isSymbol(Symbol.iterator);
  22838. * // => true
  22839. *
  22840. * _.isSymbol('abc');
  22841. * // => false
  22842. */
  22843. function isSymbol(value) {
  22844. return typeof value == 'symbol' || isObjectLike_1(value) && _baseGetTag(value) == symbolTag;
  22845. }
  22846. var isSymbol_1 = isSymbol;
  22847. /** Used to match property names within property paths. */
  22848. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  22849. reIsPlainProp = /^\w*$/;
  22850. /**
  22851. * Checks if `value` is a property name and not a property path.
  22852. *
  22853. * @private
  22854. * @param {*} value The value to check.
  22855. * @param {Object} [object] The object to query keys on.
  22856. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22857. */
  22858. function isKey(value, object) {
  22859. if (isArray_1(value)) {
  22860. return false;
  22861. }
  22862. var type = typeof value;
  22863. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol_1(value)) {
  22864. return true;
  22865. }
  22866. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  22867. }
  22868. var _isKey = isKey;
  22869. /** Error message constants. */
  22870. var FUNC_ERROR_TEXT = 'Expected a function';
  22871. /**
  22872. * Creates a function that memoizes the result of `func`. If `resolver` is
  22873. * provided, it determines the cache key for storing the result based on the
  22874. * arguments provided to the memoized function. By default, the first argument
  22875. * provided to the memoized function is used as the map cache key. The `func`
  22876. * is invoked with the `this` binding of the memoized function.
  22877. *
  22878. * **Note:** The cache is exposed as the `cache` property on the memoized
  22879. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  22880. * constructor with one whose instances implement the
  22881. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  22882. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  22883. *
  22884. * @static
  22885. * @memberOf _
  22886. * @since 0.1.0
  22887. * @category Function
  22888. * @param {Function} func The function to have its output memoized.
  22889. * @param {Function} [resolver] The function to resolve the cache key.
  22890. * @returns {Function} Returns the new memoized function.
  22891. * @example
  22892. *
  22893. * var object = { 'a': 1, 'b': 2 };
  22894. * var other = { 'c': 3, 'd': 4 };
  22895. *
  22896. * var values = _.memoize(_.values);
  22897. * values(object);
  22898. * // => [1, 2]
  22899. *
  22900. * values(other);
  22901. * // => [3, 4]
  22902. *
  22903. * object.a = 2;
  22904. * values(object);
  22905. * // => [1, 2]
  22906. *
  22907. * // Modify the result cache.
  22908. * values.cache.set(object, ['a', 'b']);
  22909. * values(object);
  22910. * // => ['a', 'b']
  22911. *
  22912. * // Replace `_.memoize.Cache`.
  22913. * _.memoize.Cache = WeakMap;
  22914. */
  22915. function memoize(func, resolver) {
  22916. if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
  22917. throw new TypeError(FUNC_ERROR_TEXT);
  22918. }
  22919. var memoized = function () {
  22920. var args = arguments,
  22921. key = resolver ? resolver.apply(this, args) : args[0],
  22922. cache = memoized.cache;
  22923. if (cache.has(key)) {
  22924. return cache.get(key);
  22925. }
  22926. var result = func.apply(this, args);
  22927. memoized.cache = cache.set(key, result) || cache;
  22928. return result;
  22929. };
  22930. memoized.cache = new (memoize.Cache || _MapCache)();
  22931. return memoized;
  22932. } // Expose `MapCache`.
  22933. memoize.Cache = _MapCache;
  22934. var memoize_1 = memoize;
  22935. /** Used as the maximum memoize cache size. */
  22936. var MAX_MEMOIZE_SIZE = 500;
  22937. /**
  22938. * A specialized version of `_.memoize` which clears the memoized function's
  22939. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22940. *
  22941. * @private
  22942. * @param {Function} func The function to have its output memoized.
  22943. * @returns {Function} Returns the new memoized function.
  22944. */
  22945. function memoizeCapped(func) {
  22946. var result = memoize_1(func, function (key) {
  22947. if (cache.size === MAX_MEMOIZE_SIZE) {
  22948. cache.clear();
  22949. }
  22950. return key;
  22951. });
  22952. var cache = result.cache;
  22953. return result;
  22954. }
  22955. var _memoizeCapped = memoizeCapped;
  22956. /** Used to match property names within property paths. */
  22957. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  22958. /** Used to match backslashes in property paths. */
  22959. var reEscapeChar = /\\(\\)?/g;
  22960. /**
  22961. * Converts `string` to a property path array.
  22962. *
  22963. * @private
  22964. * @param {string} string The string to convert.
  22965. * @returns {Array} Returns the property path array.
  22966. */
  22967. var stringToPath = _memoizeCapped(function (string) {
  22968. var result = [];
  22969. if (string.charCodeAt(0) === 46
  22970. /* . */
  22971. ) {
  22972. result.push('');
  22973. }
  22974. string.replace(rePropName, function (match, number, quote, subString) {
  22975. result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
  22976. });
  22977. return result;
  22978. });
  22979. var _stringToPath = stringToPath;
  22980. /**
  22981. * A specialized version of `_.map` for arrays without support for iteratee
  22982. * shorthands.
  22983. *
  22984. * @private
  22985. * @param {Array} [array] The array to iterate over.
  22986. * @param {Function} iteratee The function invoked per iteration.
  22987. * @returns {Array} Returns the new mapped array.
  22988. */
  22989. function arrayMap(array, iteratee) {
  22990. var index = -1,
  22991. length = array == null ? 0 : array.length,
  22992. result = Array(length);
  22993. while (++index < length) {
  22994. result[index] = iteratee(array[index], index, array);
  22995. }
  22996. return result;
  22997. }
  22998. var _arrayMap = arrayMap;
  22999. /** Used as references for various `Number` constants. */
  23000. var INFINITY$2 = 1 / 0;
  23001. /** Used to convert symbols to primitives and strings. */
  23002. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  23003. symbolToString = symbolProto ? symbolProto.toString : undefined;
  23004. /**
  23005. * The base implementation of `_.toString` which doesn't convert nullish
  23006. * values to empty strings.
  23007. *
  23008. * @private
  23009. * @param {*} value The value to process.
  23010. * @returns {string} Returns the string.
  23011. */
  23012. function baseToString(value) {
  23013. // Exit early for strings to avoid a performance hit in some environments.
  23014. if (typeof value == 'string') {
  23015. return value;
  23016. }
  23017. if (isArray_1(value)) {
  23018. // Recursively convert values (susceptible to call stack limits).
  23019. return _arrayMap(value, baseToString) + '';
  23020. }
  23021. if (isSymbol_1(value)) {
  23022. return symbolToString ? symbolToString.call(value) : '';
  23023. }
  23024. var result = value + '';
  23025. return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result;
  23026. }
  23027. var _baseToString = baseToString;
  23028. /**
  23029. * Converts `value` to a string. An empty string is returned for `null`
  23030. * and `undefined` values. The sign of `-0` is preserved.
  23031. *
  23032. * @static
  23033. * @memberOf _
  23034. * @since 4.0.0
  23035. * @category Lang
  23036. * @param {*} value The value to convert.
  23037. * @returns {string} Returns the converted string.
  23038. * @example
  23039. *
  23040. * _.toString(null);
  23041. * // => ''
  23042. *
  23043. * _.toString(-0);
  23044. * // => '-0'
  23045. *
  23046. * _.toString([1, 2, 3]);
  23047. * // => '1,2,3'
  23048. */
  23049. function toString(value) {
  23050. return value == null ? '' : _baseToString(value);
  23051. }
  23052. var toString_1 = toString;
  23053. /**
  23054. * Casts `value` to a path array if it's not one.
  23055. *
  23056. * @private
  23057. * @param {*} value The value to inspect.
  23058. * @param {Object} [object] The object to query keys on.
  23059. * @returns {Array} Returns the cast property path array.
  23060. */
  23061. function castPath(value, object) {
  23062. if (isArray_1(value)) {
  23063. return value;
  23064. }
  23065. return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
  23066. }
  23067. var _castPath = castPath;
  23068. /** Used as references for various `Number` constants. */
  23069. var INFINITY$1 = 1 / 0;
  23070. /**
  23071. * Converts `value` to a string key if it's not a string or symbol.
  23072. *
  23073. * @private
  23074. * @param {*} value The value to inspect.
  23075. * @returns {string|symbol} Returns the key.
  23076. */
  23077. function toKey(value) {
  23078. if (typeof value == 'string' || isSymbol_1(value)) {
  23079. return value;
  23080. }
  23081. var result = value + '';
  23082. return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
  23083. }
  23084. var _toKey = toKey;
  23085. /**
  23086. * The base implementation of `_.get` without support for default values.
  23087. *
  23088. * @private
  23089. * @param {Object} object The object to query.
  23090. * @param {Array|string} path The path of the property to get.
  23091. * @returns {*} Returns the resolved value.
  23092. */
  23093. function baseGet(object, path) {
  23094. path = _castPath(path, object);
  23095. var index = 0,
  23096. length = path.length;
  23097. while (object != null && index < length) {
  23098. object = object[_toKey(path[index++])];
  23099. }
  23100. return index && index == length ? object : undefined;
  23101. }
  23102. var _baseGet = baseGet;
  23103. /**
  23104. * Gets the value at `path` of `object`. If the resolved value is
  23105. * `undefined`, the `defaultValue` is returned in its place.
  23106. *
  23107. * @static
  23108. * @memberOf _
  23109. * @since 3.7.0
  23110. * @category Object
  23111. * @param {Object} object The object to query.
  23112. * @param {Array|string} path The path of the property to get.
  23113. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  23114. * @returns {*} Returns the resolved value.
  23115. * @example
  23116. *
  23117. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  23118. *
  23119. * _.get(object, 'a[0].b.c');
  23120. * // => 3
  23121. *
  23122. * _.get(object, ['a', '0', 'b', 'c']);
  23123. * // => 3
  23124. *
  23125. * _.get(object, 'a.b.c', 'default');
  23126. * // => 'default'
  23127. */
  23128. function get(object, path, defaultValue) {
  23129. var result = object == null ? undefined : _baseGet(object, path);
  23130. return result === undefined ? defaultValue : result;
  23131. }
  23132. var get_1 = get;
  23133. /**
  23134. * The base implementation of `_.hasIn` without support for deep paths.
  23135. *
  23136. * @private
  23137. * @param {Object} [object] The object to query.
  23138. * @param {Array|string} key The key to check.
  23139. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  23140. */
  23141. function baseHasIn(object, key) {
  23142. return object != null && key in Object(object);
  23143. }
  23144. var _baseHasIn = baseHasIn;
  23145. /**
  23146. * Checks if `path` exists on `object`.
  23147. *
  23148. * @private
  23149. * @param {Object} object The object to query.
  23150. * @param {Array|string} path The path to check.
  23151. * @param {Function} hasFunc The function to check properties.
  23152. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23153. */
  23154. function hasPath(object, path, hasFunc) {
  23155. path = _castPath(path, object);
  23156. var index = -1,
  23157. length = path.length,
  23158. result = false;
  23159. while (++index < length) {
  23160. var key = _toKey(path[index]);
  23161. if (!(result = object != null && hasFunc(object, key))) {
  23162. break;
  23163. }
  23164. object = object[key];
  23165. }
  23166. if (result || ++index != length) {
  23167. return result;
  23168. }
  23169. length = object == null ? 0 : object.length;
  23170. return !!length && isLength_1(length) && _isIndex(key, length) && (isArray_1(object) || isArguments_1(object));
  23171. }
  23172. var _hasPath = hasPath;
  23173. /**
  23174. * Checks if `path` is a direct or inherited property of `object`.
  23175. *
  23176. * @static
  23177. * @memberOf _
  23178. * @since 4.0.0
  23179. * @category Object
  23180. * @param {Object} object The object to query.
  23181. * @param {Array|string} path The path to check.
  23182. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23183. * @example
  23184. *
  23185. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  23186. *
  23187. * _.hasIn(object, 'a');
  23188. * // => true
  23189. *
  23190. * _.hasIn(object, 'a.b');
  23191. * // => true
  23192. *
  23193. * _.hasIn(object, ['a', 'b']);
  23194. * // => true
  23195. *
  23196. * _.hasIn(object, 'b');
  23197. * // => false
  23198. */
  23199. function hasIn(object, path) {
  23200. return object != null && _hasPath(object, path, _baseHasIn);
  23201. }
  23202. var hasIn_1 = hasIn;
  23203. /** Used to compose bitmasks for value comparisons. */
  23204. var COMPARE_PARTIAL_FLAG = 1,
  23205. COMPARE_UNORDERED_FLAG = 2;
  23206. /**
  23207. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  23208. *
  23209. * @private
  23210. * @param {string} path The path of the property to get.
  23211. * @param {*} srcValue The value to match.
  23212. * @returns {Function} Returns the new spec function.
  23213. */
  23214. function baseMatchesProperty(path, srcValue) {
  23215. if (_isKey(path) && _isStrictComparable(srcValue)) {
  23216. return _matchesStrictComparable(_toKey(path), srcValue);
  23217. }
  23218. return function (object) {
  23219. var objValue = get_1(object, path);
  23220. return objValue === undefined && objValue === srcValue ? hasIn_1(object, path) : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  23221. };
  23222. }
  23223. var _baseMatchesProperty = baseMatchesProperty;
  23224. /**
  23225. * This method returns the first argument it receives.
  23226. *
  23227. * @static
  23228. * @since 0.1.0
  23229. * @memberOf _
  23230. * @category Util
  23231. * @param {*} value Any value.
  23232. * @returns {*} Returns `value`.
  23233. * @example
  23234. *
  23235. * var object = { 'a': 1 };
  23236. *
  23237. * console.log(_.identity(object) === object);
  23238. * // => true
  23239. */
  23240. function identity$2(value) {
  23241. return value;
  23242. }
  23243. var identity_1 = identity$2;
  23244. /**
  23245. * The base implementation of `_.property` without support for deep paths.
  23246. *
  23247. * @private
  23248. * @param {string} key The key of the property to get.
  23249. * @returns {Function} Returns the new accessor function.
  23250. */
  23251. function baseProperty(key) {
  23252. return function (object) {
  23253. return object == null ? undefined : object[key];
  23254. };
  23255. }
  23256. var _baseProperty = baseProperty;
  23257. /**
  23258. * A specialized version of `baseProperty` which supports deep paths.
  23259. *
  23260. * @private
  23261. * @param {Array|string} path The path of the property to get.
  23262. * @returns {Function} Returns the new accessor function.
  23263. */
  23264. function basePropertyDeep(path) {
  23265. return function (object) {
  23266. return _baseGet(object, path);
  23267. };
  23268. }
  23269. var _basePropertyDeep = basePropertyDeep;
  23270. /**
  23271. * Creates a function that returns the value at `path` of a given object.
  23272. *
  23273. * @static
  23274. * @memberOf _
  23275. * @since 2.4.0
  23276. * @category Util
  23277. * @param {Array|string} path The path of the property to get.
  23278. * @returns {Function} Returns the new accessor function.
  23279. * @example
  23280. *
  23281. * var objects = [
  23282. * { 'a': { 'b': 2 } },
  23283. * { 'a': { 'b': 1 } }
  23284. * ];
  23285. *
  23286. * _.map(objects, _.property('a.b'));
  23287. * // => [2, 1]
  23288. *
  23289. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  23290. * // => [1, 2]
  23291. */
  23292. function property$1(path) {
  23293. return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
  23294. }
  23295. var property_1 = property$1;
  23296. /**
  23297. * The base implementation of `_.iteratee`.
  23298. *
  23299. * @private
  23300. * @param {*} [value=_.identity] The value to convert to an iteratee.
  23301. * @returns {Function} Returns the iteratee.
  23302. */
  23303. function baseIteratee(value) {
  23304. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  23305. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  23306. if (typeof value == 'function') {
  23307. return value;
  23308. }
  23309. if (value == null) {
  23310. return identity_1;
  23311. }
  23312. if (typeof value == 'object') {
  23313. return isArray_1(value) ? _baseMatchesProperty(value[0], value[1]) : _baseMatches(value);
  23314. }
  23315. return property_1(value);
  23316. }
  23317. var _baseIteratee = baseIteratee;
  23318. /**
  23319. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  23320. * support for iteratee shorthands.
  23321. *
  23322. * @private
  23323. * @param {Array} array The array to inspect.
  23324. * @param {Function} predicate The function invoked per iteration.
  23325. * @param {number} fromIndex The index to search from.
  23326. * @param {boolean} [fromRight] Specify iterating from right to left.
  23327. * @returns {number} Returns the index of the matched value, else `-1`.
  23328. */
  23329. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  23330. var length = array.length,
  23331. index = fromIndex + (fromRight ? 1 : -1);
  23332. while (fromRight ? index-- : ++index < length) {
  23333. if (predicate(array[index], index, array)) {
  23334. return index;
  23335. }
  23336. }
  23337. return -1;
  23338. }
  23339. var _baseFindIndex = baseFindIndex;
  23340. /**
  23341. * The base implementation of `_.isNaN` without support for number objects.
  23342. *
  23343. * @private
  23344. * @param {*} value The value to check.
  23345. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  23346. */
  23347. function baseIsNaN(value) {
  23348. return value !== value;
  23349. }
  23350. var _baseIsNaN = baseIsNaN;
  23351. /**
  23352. * A specialized version of `_.indexOf` which performs strict equality
  23353. * comparisons of values, i.e. `===`.
  23354. *
  23355. * @private
  23356. * @param {Array} array The array to inspect.
  23357. * @param {*} value The value to search for.
  23358. * @param {number} fromIndex The index to search from.
  23359. * @returns {number} Returns the index of the matched value, else `-1`.
  23360. */
  23361. function strictIndexOf(array, value, fromIndex) {
  23362. var index = fromIndex - 1,
  23363. length = array.length;
  23364. while (++index < length) {
  23365. if (array[index] === value) {
  23366. return index;
  23367. }
  23368. }
  23369. return -1;
  23370. }
  23371. var _strictIndexOf = strictIndexOf;
  23372. /**
  23373. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  23374. *
  23375. * @private
  23376. * @param {Array} array The array to inspect.
  23377. * @param {*} value The value to search for.
  23378. * @param {number} fromIndex The index to search from.
  23379. * @returns {number} Returns the index of the matched value, else `-1`.
  23380. */
  23381. function baseIndexOf(array, value, fromIndex) {
  23382. return value === value ? _strictIndexOf(array, value, fromIndex) : _baseFindIndex(array, _baseIsNaN, fromIndex);
  23383. }
  23384. var _baseIndexOf = baseIndexOf;
  23385. /**
  23386. * A specialized version of `_.includes` for arrays without support for
  23387. * specifying an index to search from.
  23388. *
  23389. * @private
  23390. * @param {Array} [array] The array to inspect.
  23391. * @param {*} target The value to search for.
  23392. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  23393. */
  23394. function arrayIncludes(array, value) {
  23395. var length = array == null ? 0 : array.length;
  23396. return !!length && _baseIndexOf(array, value, 0) > -1;
  23397. }
  23398. var _arrayIncludes = arrayIncludes;
  23399. /**
  23400. * This function is like `arrayIncludes` except that it accepts a comparator.
  23401. *
  23402. * @private
  23403. * @param {Array} [array] The array to inspect.
  23404. * @param {*} target The value to search for.
  23405. * @param {Function} comparator The comparator invoked per element.
  23406. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  23407. */
  23408. function arrayIncludesWith(array, value, comparator) {
  23409. var index = -1,
  23410. length = array == null ? 0 : array.length;
  23411. while (++index < length) {
  23412. if (comparator(value, array[index])) {
  23413. return true;
  23414. }
  23415. }
  23416. return false;
  23417. }
  23418. var _arrayIncludesWith = arrayIncludesWith;
  23419. /**
  23420. * This method returns `undefined`.
  23421. *
  23422. * @static
  23423. * @memberOf _
  23424. * @since 2.3.0
  23425. * @category Util
  23426. * @example
  23427. *
  23428. * _.times(2, _.noop);
  23429. * // => [undefined, undefined]
  23430. */
  23431. function noop$1() {// No operation performed.
  23432. }
  23433. var noop_1 = noop$1;
  23434. /** Used as references for various `Number` constants. */
  23435. var INFINITY = 1 / 0;
  23436. /**
  23437. * Creates a set object of `values`.
  23438. *
  23439. * @private
  23440. * @param {Array} values The values to add to the set.
  23441. * @returns {Object} Returns the new set.
  23442. */
  23443. var createSet = !(_Set && 1 / _setToArray(new _Set([, -0]))[1] == INFINITY) ? noop_1 : function (values) {
  23444. return new _Set(values);
  23445. };
  23446. var _createSet = createSet;
  23447. /** Used as the size to enable large array optimizations. */
  23448. var LARGE_ARRAY_SIZE = 200;
  23449. /**
  23450. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  23451. *
  23452. * @private
  23453. * @param {Array} array The array to inspect.
  23454. * @param {Function} [iteratee] The iteratee invoked per element.
  23455. * @param {Function} [comparator] The comparator invoked per element.
  23456. * @returns {Array} Returns the new duplicate free array.
  23457. */
  23458. function baseUniq(array, iteratee, comparator) {
  23459. var index = -1,
  23460. includes = _arrayIncludes,
  23461. length = array.length,
  23462. isCommon = true,
  23463. result = [],
  23464. seen = result;
  23465. if (comparator) {
  23466. isCommon = false;
  23467. includes = _arrayIncludesWith;
  23468. } else if (length >= LARGE_ARRAY_SIZE) {
  23469. var set = iteratee ? null : _createSet(array);
  23470. if (set) {
  23471. return _setToArray(set);
  23472. }
  23473. isCommon = false;
  23474. includes = _cacheHas;
  23475. seen = new _SetCache();
  23476. } else {
  23477. seen = iteratee ? [] : result;
  23478. }
  23479. outer: while (++index < length) {
  23480. var value = array[index],
  23481. computed = iteratee ? iteratee(value) : value;
  23482. value = comparator || value !== 0 ? value : 0;
  23483. if (isCommon && computed === computed) {
  23484. var seenIndex = seen.length;
  23485. while (seenIndex--) {
  23486. if (seen[seenIndex] === computed) {
  23487. continue outer;
  23488. }
  23489. }
  23490. if (iteratee) {
  23491. seen.push(computed);
  23492. }
  23493. result.push(value);
  23494. } else if (!includes(seen, computed, comparator)) {
  23495. if (seen !== result) {
  23496. seen.push(computed);
  23497. }
  23498. result.push(value);
  23499. }
  23500. }
  23501. return result;
  23502. }
  23503. var _baseUniq = baseUniq;
  23504. /**
  23505. * This method is like `_.uniq` except that it accepts `iteratee` which is
  23506. * invoked for each element in `array` to generate the criterion by which
  23507. * uniqueness is computed. The order of result values is determined by the
  23508. * order they occur in the array. The iteratee is invoked with one argument:
  23509. * (value).
  23510. *
  23511. * @static
  23512. * @memberOf _
  23513. * @since 4.0.0
  23514. * @category Array
  23515. * @param {Array} array The array to inspect.
  23516. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23517. * @returns {Array} Returns the new duplicate free array.
  23518. * @example
  23519. *
  23520. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  23521. * // => [2.1, 1.2]
  23522. *
  23523. * // The `_.property` iteratee shorthand.
  23524. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  23525. * // => [{ 'x': 1 }, { 'x': 2 }]
  23526. */
  23527. function uniqBy(array, iteratee) {
  23528. return array && array.length ? _baseUniq(array, _baseIteratee(iteratee)) : [];
  23529. }
  23530. var uniqBy_1 = uniqBy;
  23531. /**
  23532. * A specialized version of `baseAggregator` for arrays.
  23533. *
  23534. * @private
  23535. * @param {Array} [array] The array to iterate over.
  23536. * @param {Function} setter The function to set `accumulator` values.
  23537. * @param {Function} iteratee The iteratee to transform keys.
  23538. * @param {Object} accumulator The initial aggregated object.
  23539. * @returns {Function} Returns `accumulator`.
  23540. */
  23541. function arrayAggregator(array, setter, iteratee, accumulator) {
  23542. var index = -1,
  23543. length = array == null ? 0 : array.length;
  23544. while (++index < length) {
  23545. var value = array[index];
  23546. setter(accumulator, value, iteratee(value), array);
  23547. }
  23548. return accumulator;
  23549. }
  23550. var _arrayAggregator = arrayAggregator;
  23551. /**
  23552. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  23553. *
  23554. * @private
  23555. * @param {boolean} [fromRight] Specify iterating from right to left.
  23556. * @returns {Function} Returns the new base function.
  23557. */
  23558. function createBaseFor(fromRight) {
  23559. return function (object, iteratee, keysFunc) {
  23560. var index = -1,
  23561. iterable = Object(object),
  23562. props = keysFunc(object),
  23563. length = props.length;
  23564. while (length--) {
  23565. var key = props[fromRight ? length : ++index];
  23566. if (iteratee(iterable[key], key, iterable) === false) {
  23567. break;
  23568. }
  23569. }
  23570. return object;
  23571. };
  23572. }
  23573. var _createBaseFor = createBaseFor;
  23574. /**
  23575. * The base implementation of `baseForOwn` which iterates over `object`
  23576. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  23577. * Iteratee functions may exit iteration early by explicitly returning `false`.
  23578. *
  23579. * @private
  23580. * @param {Object} object The object to iterate over.
  23581. * @param {Function} iteratee The function invoked per iteration.
  23582. * @param {Function} keysFunc The function to get the keys of `object`.
  23583. * @returns {Object} Returns `object`.
  23584. */
  23585. var baseFor = _createBaseFor();
  23586. var _baseFor = baseFor;
  23587. /**
  23588. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  23589. *
  23590. * @private
  23591. * @param {Object} object The object to iterate over.
  23592. * @param {Function} iteratee The function invoked per iteration.
  23593. * @returns {Object} Returns `object`.
  23594. */
  23595. function baseForOwn(object, iteratee) {
  23596. return object && _baseFor(object, iteratee, keys_1);
  23597. }
  23598. var _baseForOwn = baseForOwn;
  23599. /**
  23600. * Creates a `baseEach` or `baseEachRight` function.
  23601. *
  23602. * @private
  23603. * @param {Function} eachFunc The function to iterate over a collection.
  23604. * @param {boolean} [fromRight] Specify iterating from right to left.
  23605. * @returns {Function} Returns the new base function.
  23606. */
  23607. function createBaseEach(eachFunc, fromRight) {
  23608. return function (collection, iteratee) {
  23609. if (collection == null) {
  23610. return collection;
  23611. }
  23612. if (!isArrayLike_1(collection)) {
  23613. return eachFunc(collection, iteratee);
  23614. }
  23615. var length = collection.length,
  23616. index = fromRight ? length : -1,
  23617. iterable = Object(collection);
  23618. while (fromRight ? index-- : ++index < length) {
  23619. if (iteratee(iterable[index], index, iterable) === false) {
  23620. break;
  23621. }
  23622. }
  23623. return collection;
  23624. };
  23625. }
  23626. var _createBaseEach = createBaseEach;
  23627. /**
  23628. * The base implementation of `_.forEach` without support for iteratee shorthands.
  23629. *
  23630. * @private
  23631. * @param {Array|Object} collection The collection to iterate over.
  23632. * @param {Function} iteratee The function invoked per iteration.
  23633. * @returns {Array|Object} Returns `collection`.
  23634. */
  23635. var baseEach = _createBaseEach(_baseForOwn);
  23636. var _baseEach = baseEach;
  23637. /**
  23638. * Aggregates elements of `collection` on `accumulator` with keys transformed
  23639. * by `iteratee` and values set by `setter`.
  23640. *
  23641. * @private
  23642. * @param {Array|Object} collection The collection to iterate over.
  23643. * @param {Function} setter The function to set `accumulator` values.
  23644. * @param {Function} iteratee The iteratee to transform keys.
  23645. * @param {Object} accumulator The initial aggregated object.
  23646. * @returns {Function} Returns `accumulator`.
  23647. */
  23648. function baseAggregator(collection, setter, iteratee, accumulator) {
  23649. _baseEach(collection, function (value, key, collection) {
  23650. setter(accumulator, value, iteratee(value), collection);
  23651. });
  23652. return accumulator;
  23653. }
  23654. var _baseAggregator = baseAggregator;
  23655. /**
  23656. * Creates a function like `_.groupBy`.
  23657. *
  23658. * @private
  23659. * @param {Function} setter The function to set accumulator values.
  23660. * @param {Function} [initializer] The accumulator object initializer.
  23661. * @returns {Function} Returns the new aggregator function.
  23662. */
  23663. function createAggregator(setter, initializer) {
  23664. return function (collection, iteratee) {
  23665. var func = isArray_1(collection) ? _arrayAggregator : _baseAggregator,
  23666. accumulator = initializer ? initializer() : {};
  23667. return func(collection, setter, _baseIteratee(iteratee), accumulator);
  23668. };
  23669. }
  23670. var _createAggregator = createAggregator;
  23671. /**
  23672. * Creates an array of elements split into two groups, the first of which
  23673. * contains elements `predicate` returns truthy for, the second of which
  23674. * contains elements `predicate` returns falsey for. The predicate is
  23675. * invoked with one argument: (value).
  23676. *
  23677. * @static
  23678. * @memberOf _
  23679. * @since 3.0.0
  23680. * @category Collection
  23681. * @param {Array|Object} collection The collection to iterate over.
  23682. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23683. * @returns {Array} Returns the array of grouped elements.
  23684. * @example
  23685. *
  23686. * var users = [
  23687. * { 'user': 'barney', 'age': 36, 'active': false },
  23688. * { 'user': 'fred', 'age': 40, 'active': true },
  23689. * { 'user': 'pebbles', 'age': 1, 'active': false }
  23690. * ];
  23691. *
  23692. * _.partition(users, function(o) { return o.active; });
  23693. * // => objects for [['fred'], ['barney', 'pebbles']]
  23694. *
  23695. * // The `_.matches` iteratee shorthand.
  23696. * _.partition(users, { 'age': 1, 'active': false });
  23697. * // => objects for [['pebbles'], ['barney', 'fred']]
  23698. *
  23699. * // The `_.matchesProperty` iteratee shorthand.
  23700. * _.partition(users, ['active', false]);
  23701. * // => objects for [['barney', 'pebbles'], ['fred']]
  23702. *
  23703. * // The `_.property` iteratee shorthand.
  23704. * _.partition(users, 'active');
  23705. * // => objects for [['fred'], ['barney', 'pebbles']]
  23706. */
  23707. var partition = _createAggregator(function (result, value, key) {
  23708. result[key ? 0 : 1].push(value);
  23709. }, function () {
  23710. return [[], []];
  23711. });
  23712. var partition_1 = partition;
  23713. var arrayUnion = (...arguments_) => {
  23714. return [...new Set([].concat(...arguments_))];
  23715. };
  23716. /*
  23717. * merge2
  23718. * https://github.com/teambition/merge2
  23719. *
  23720. * Copyright (c) 2014-2020 Teambition
  23721. * Licensed under the MIT license.
  23722. */
  23723. const PassThrough = stream_1__default['default'].PassThrough;
  23724. const slice = Array.prototype.slice;
  23725. var merge2_1 = merge2;
  23726. function merge2() {
  23727. const streamsQueue = [];
  23728. const args = slice.call(arguments);
  23729. let merging = false;
  23730. let options = args[args.length - 1];
  23731. if (options && !Array.isArray(options) && options.pipe == null) {
  23732. args.pop();
  23733. } else {
  23734. options = {};
  23735. }
  23736. const doEnd = options.end !== false;
  23737. const doPipeError = options.pipeError === true;
  23738. if (options.objectMode == null) {
  23739. options.objectMode = true;
  23740. }
  23741. if (options.highWaterMark == null) {
  23742. options.highWaterMark = 64 * 1024;
  23743. }
  23744. const mergedStream = PassThrough(options);
  23745. function addStream() {
  23746. for (let i = 0, len = arguments.length; i < len; i++) {
  23747. streamsQueue.push(pauseStreams(arguments[i], options));
  23748. }
  23749. mergeStream();
  23750. return this;
  23751. }
  23752. function mergeStream() {
  23753. if (merging) {
  23754. return;
  23755. }
  23756. merging = true;
  23757. let streams = streamsQueue.shift();
  23758. if (!streams) {
  23759. process.nextTick(endStream);
  23760. return;
  23761. }
  23762. if (!Array.isArray(streams)) {
  23763. streams = [streams];
  23764. }
  23765. let pipesCount = streams.length + 1;
  23766. function next() {
  23767. if (--pipesCount > 0) {
  23768. return;
  23769. }
  23770. merging = false;
  23771. mergeStream();
  23772. }
  23773. function pipe(stream) {
  23774. function onend() {
  23775. stream.removeListener('merge2UnpipeEnd', onend);
  23776. stream.removeListener('end', onend);
  23777. if (doPipeError) {
  23778. stream.removeListener('error', onerror);
  23779. }
  23780. next();
  23781. }
  23782. function onerror(err) {
  23783. mergedStream.emit('error', err);
  23784. } // skip ended stream
  23785. if (stream._readableState.endEmitted) {
  23786. return next();
  23787. }
  23788. stream.on('merge2UnpipeEnd', onend);
  23789. stream.on('end', onend);
  23790. if (doPipeError) {
  23791. stream.on('error', onerror);
  23792. }
  23793. stream.pipe(mergedStream, {
  23794. end: false
  23795. }); // compatible for old stream
  23796. stream.resume();
  23797. }
  23798. for (let i = 0; i < streams.length; i++) {
  23799. pipe(streams[i]);
  23800. }
  23801. next();
  23802. }
  23803. function endStream() {
  23804. merging = false; // emit 'queueDrain' when all streams merged.
  23805. mergedStream.emit('queueDrain');
  23806. if (doEnd) {
  23807. mergedStream.end();
  23808. }
  23809. }
  23810. mergedStream.setMaxListeners(0);
  23811. mergedStream.add = addStream;
  23812. mergedStream.on('unpipe', function (stream) {
  23813. stream.emit('merge2UnpipeEnd');
  23814. });
  23815. if (args.length) {
  23816. addStream.apply(null, args);
  23817. }
  23818. return mergedStream;
  23819. } // check and pause streams for pipe.
  23820. function pauseStreams(streams, options) {
  23821. if (!Array.isArray(streams)) {
  23822. // Backwards-compat with old-style streams
  23823. if (!streams._readableState && streams.pipe) {
  23824. streams = streams.pipe(PassThrough(options));
  23825. }
  23826. if (!streams._readableState || !streams.pause || !streams.pipe) {
  23827. throw new Error('Only readable stream can be merged.');
  23828. }
  23829. streams.pause();
  23830. } else {
  23831. for (let i = 0, len = streams.length; i < len; i++) {
  23832. streams[i] = pauseStreams(streams[i], options);
  23833. }
  23834. }
  23835. return streams;
  23836. }
  23837. var array$1 = createCommonjsModule(function (module, exports) {
  23838. Object.defineProperty(exports, "__esModule", {
  23839. value: true
  23840. });
  23841. exports.splitWhen = exports.flatten = void 0;
  23842. function flatten(items) {
  23843. return items.reduce((collection, item) => [].concat(collection, item), []);
  23844. }
  23845. exports.flatten = flatten;
  23846. function splitWhen(items, predicate) {
  23847. const result = [[]];
  23848. let groupIndex = 0;
  23849. for (const item of items) {
  23850. if (predicate(item)) {
  23851. groupIndex++;
  23852. result[groupIndex] = [];
  23853. } else {
  23854. result[groupIndex].push(item);
  23855. }
  23856. }
  23857. return result;
  23858. }
  23859. exports.splitWhen = splitWhen;
  23860. });
  23861. var errno = createCommonjsModule(function (module, exports) {
  23862. Object.defineProperty(exports, "__esModule", {
  23863. value: true
  23864. });
  23865. exports.isEnoentCodeError = void 0;
  23866. function isEnoentCodeError(error) {
  23867. return error.code === 'ENOENT';
  23868. }
  23869. exports.isEnoentCodeError = isEnoentCodeError;
  23870. });
  23871. var fs$1 = createCommonjsModule(function (module, exports) {
  23872. Object.defineProperty(exports, "__esModule", {
  23873. value: true
  23874. });
  23875. exports.createDirentFromStats = void 0;
  23876. class DirentFromStats {
  23877. constructor(name, stats) {
  23878. this.name = name;
  23879. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  23880. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  23881. this.isDirectory = stats.isDirectory.bind(stats);
  23882. this.isFIFO = stats.isFIFO.bind(stats);
  23883. this.isFile = stats.isFile.bind(stats);
  23884. this.isSocket = stats.isSocket.bind(stats);
  23885. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  23886. }
  23887. }
  23888. function createDirentFromStats(name, stats) {
  23889. return new DirentFromStats(name, stats);
  23890. }
  23891. exports.createDirentFromStats = createDirentFromStats;
  23892. });
  23893. var path_1 = createCommonjsModule(function (module, exports) {
  23894. Object.defineProperty(exports, "__esModule", {
  23895. value: true
  23896. });
  23897. exports.removeLeadingDotSegment = exports.escape = exports.makeAbsolute = exports.unixify = void 0;
  23898. const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
  23899. const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
  23900. /**
  23901. * Designed to work only with simple paths: `dir\\file`.
  23902. */
  23903. function unixify(filepath) {
  23904. return filepath.replace(/\\/g, '/');
  23905. }
  23906. exports.unixify = unixify;
  23907. function makeAbsolute(cwd, filepath) {
  23908. return path__default['default'].resolve(cwd, filepath);
  23909. }
  23910. exports.makeAbsolute = makeAbsolute;
  23911. function escape(pattern) {
  23912. return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  23913. }
  23914. exports.escape = escape;
  23915. function removeLeadingDotSegment(entry) {
  23916. // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
  23917. // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
  23918. if (entry.charAt(0) === '.') {
  23919. const secondCharactery = entry.charAt(1);
  23920. if (secondCharactery === '/' || secondCharactery === '\\') {
  23921. return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
  23922. }
  23923. }
  23924. return entry;
  23925. }
  23926. exports.removeLeadingDotSegment = removeLeadingDotSegment;
  23927. });
  23928. /*!
  23929. * is-extglob <https://github.com/jonschlinkert/is-extglob>
  23930. *
  23931. * Copyright (c) 2014-2016, Jon Schlinkert.
  23932. * Licensed under the MIT License.
  23933. */
  23934. var isExtglob = function isExtglob(str) {
  23935. if (typeof str !== 'string' || str === '') {
  23936. return false;
  23937. }
  23938. var match;
  23939. while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
  23940. if (match[2]) return true;
  23941. str = str.slice(match.index + match[0].length);
  23942. }
  23943. return false;
  23944. };
  23945. /*!
  23946. * is-glob <https://github.com/jonschlinkert/is-glob>
  23947. *
  23948. * Copyright (c) 2014-2017, Jon Schlinkert.
  23949. * Released under the MIT License.
  23950. */
  23951. var chars$1 = {
  23952. '{': '}',
  23953. '(': ')',
  23954. '[': ']'
  23955. };
  23956. var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
  23957. var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
  23958. var isGlob = function isGlob(str, options) {
  23959. if (typeof str !== 'string' || str === '') {
  23960. return false;
  23961. }
  23962. if (isExtglob(str)) {
  23963. return true;
  23964. }
  23965. var regex = strictRegex;
  23966. var match; // optionally relax regex
  23967. if (options && options.strict === false) {
  23968. regex = relaxedRegex;
  23969. }
  23970. while (match = regex.exec(str)) {
  23971. if (match[2]) return true;
  23972. var idx = match.index + match[0].length; // if an open bracket/brace/paren is escaped,
  23973. // set the index to the next closing character
  23974. var open = match[1];
  23975. var close = open ? chars$1[open] : null;
  23976. if (open && close) {
  23977. var n = str.indexOf(close, idx);
  23978. if (n !== -1) {
  23979. idx = n + 1;
  23980. }
  23981. }
  23982. str = str.slice(idx);
  23983. }
  23984. return false;
  23985. };
  23986. var pathPosixDirname = path__default['default'].posix.dirname;
  23987. var isWin32 = os__default['default'].platform() === 'win32';
  23988. var slash$1 = '/';
  23989. var backslash = /\\/g;
  23990. var enclosure = /[\{\[].*[\}\]]$/;
  23991. var globby$1 = /(^|[^\\])([\{\[]|\([^\)]+$)/;
  23992. var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
  23993. /**
  23994. * @param {string} str
  23995. * @param {Object} opts
  23996. * @param {boolean} [opts.flipBackslashes=true]
  23997. * @returns {string}
  23998. */
  23999. var globParent = function globParent(str, opts) {
  24000. var options = Object.assign({
  24001. flipBackslashes: true
  24002. }, opts); // flip windows path separators
  24003. if (options.flipBackslashes && isWin32 && str.indexOf(slash$1) < 0) {
  24004. str = str.replace(backslash, slash$1);
  24005. } // special case for strings ending in enclosure containing path separator
  24006. if (enclosure.test(str)) {
  24007. str += slash$1;
  24008. } // preserves full path in case of trailing path separator
  24009. str += 'a'; // remove path parts that are globby
  24010. do {
  24011. str = pathPosixDirname(str);
  24012. } while (isGlob(str) || globby$1.test(str)); // remove escape chars and return result
  24013. return str.replace(escaped, '$1');
  24014. };
  24015. var utils$a = createCommonjsModule(function (module, exports) {
  24016. exports.isInteger = num => {
  24017. if (typeof num === 'number') {
  24018. return Number.isInteger(num);
  24019. }
  24020. if (typeof num === 'string' && num.trim() !== '') {
  24021. return Number.isInteger(Number(num));
  24022. }
  24023. return false;
  24024. };
  24025. /**
  24026. * Find a node of the given type
  24027. */
  24028. exports.find = (node, type) => node.nodes.find(node => node.type === type);
  24029. /**
  24030. * Find a node of the given type
  24031. */
  24032. exports.exceedsLimit = (min, max, step = 1, limit) => {
  24033. if (limit === false) return false;
  24034. if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
  24035. return (Number(max) - Number(min)) / Number(step) >= limit;
  24036. };
  24037. /**
  24038. * Escape the given node with '\\' before node.value
  24039. */
  24040. exports.escapeNode = (block, n = 0, type) => {
  24041. let node = block.nodes[n];
  24042. if (!node) return;
  24043. if (type && node.type === type || node.type === 'open' || node.type === 'close') {
  24044. if (node.escaped !== true) {
  24045. node.value = '\\' + node.value;
  24046. node.escaped = true;
  24047. }
  24048. }
  24049. };
  24050. /**
  24051. * Returns true if the given brace node should be enclosed in literal braces
  24052. */
  24053. exports.encloseBrace = node => {
  24054. if (node.type !== 'brace') return false;
  24055. if (node.commas >> 0 + node.ranges >> 0 === 0) {
  24056. node.invalid = true;
  24057. return true;
  24058. }
  24059. return false;
  24060. };
  24061. /**
  24062. * Returns true if a brace node is invalid.
  24063. */
  24064. exports.isInvalidBrace = block => {
  24065. if (block.type !== 'brace') return false;
  24066. if (block.invalid === true || block.dollar) return true;
  24067. if (block.commas >> 0 + block.ranges >> 0 === 0) {
  24068. block.invalid = true;
  24069. return true;
  24070. }
  24071. if (block.open !== true || block.close !== true) {
  24072. block.invalid = true;
  24073. return true;
  24074. }
  24075. return false;
  24076. };
  24077. /**
  24078. * Returns true if a node is an open or close node
  24079. */
  24080. exports.isOpenOrClose = node => {
  24081. if (node.type === 'open' || node.type === 'close') {
  24082. return true;
  24083. }
  24084. return node.open === true || node.close === true;
  24085. };
  24086. /**
  24087. * Reduce an array of text nodes.
  24088. */
  24089. exports.reduce = nodes => nodes.reduce((acc, node) => {
  24090. if (node.type === 'text') acc.push(node.value);
  24091. if (node.type === 'range') node.type = 'text';
  24092. return acc;
  24093. }, []);
  24094. /**
  24095. * Flatten an array
  24096. */
  24097. exports.flatten = (...args) => {
  24098. const result = [];
  24099. const flat = arr => {
  24100. for (let i = 0; i < arr.length; i++) {
  24101. let ele = arr[i];
  24102. Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
  24103. }
  24104. return result;
  24105. };
  24106. flat(args);
  24107. return result;
  24108. };
  24109. });
  24110. var stringify$2 = (ast, options = {}) => {
  24111. let stringify = (node, parent = {}) => {
  24112. let invalidBlock = options.escapeInvalid && utils$a.isInvalidBrace(parent);
  24113. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  24114. let output = '';
  24115. if (node.value) {
  24116. if ((invalidBlock || invalidNode) && utils$a.isOpenOrClose(node)) {
  24117. return '\\' + node.value;
  24118. }
  24119. return node.value;
  24120. }
  24121. if (node.value) {
  24122. return node.value;
  24123. }
  24124. if (node.nodes) {
  24125. for (let child of node.nodes) {
  24126. output += stringify(child);
  24127. }
  24128. }
  24129. return output;
  24130. };
  24131. return stringify(ast);
  24132. };
  24133. /*!
  24134. * is-number <https://github.com/jonschlinkert/is-number>
  24135. *
  24136. * Copyright (c) 2014-present, Jon Schlinkert.
  24137. * Released under the MIT License.
  24138. */
  24139. var isNumber$1 = function (num) {
  24140. if (typeof num === 'number') {
  24141. return num - num === 0;
  24142. }
  24143. if (typeof num === 'string' && num.trim() !== '') {
  24144. return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
  24145. }
  24146. return false;
  24147. };
  24148. const toRegexRange = (min, max, options) => {
  24149. if (isNumber$1(min) === false) {
  24150. throw new TypeError('toRegexRange: expected the first argument to be a number');
  24151. }
  24152. if (max === void 0 || min === max) {
  24153. return String(min);
  24154. }
  24155. if (isNumber$1(max) === false) {
  24156. throw new TypeError('toRegexRange: expected the second argument to be a number.');
  24157. }
  24158. let opts = Object.assign({
  24159. relaxZeros: true
  24160. }, options);
  24161. if (typeof opts.strictZeros === 'boolean') {
  24162. opts.relaxZeros = opts.strictZeros === false;
  24163. }
  24164. let relax = String(opts.relaxZeros);
  24165. let shorthand = String(opts.shorthand);
  24166. let capture = String(opts.capture);
  24167. let wrap = String(opts.wrap);
  24168. let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
  24169. if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
  24170. return toRegexRange.cache[cacheKey].result;
  24171. }
  24172. let a = Math.min(min, max);
  24173. let b = Math.max(min, max);
  24174. if (Math.abs(a - b) === 1) {
  24175. let result = min + '|' + max;
  24176. if (opts.capture) {
  24177. return `(${result})`;
  24178. }
  24179. if (opts.wrap === false) {
  24180. return result;
  24181. }
  24182. return `(?:${result})`;
  24183. }
  24184. let isPadded = hasPadding(min) || hasPadding(max);
  24185. let state = {
  24186. min,
  24187. max,
  24188. a,
  24189. b
  24190. };
  24191. let positives = [];
  24192. let negatives = [];
  24193. if (isPadded) {
  24194. state.isPadded = isPadded;
  24195. state.maxLen = String(state.max).length;
  24196. }
  24197. if (a < 0) {
  24198. let newMin = b < 0 ? Math.abs(b) : 1;
  24199. negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
  24200. a = state.a = 0;
  24201. }
  24202. if (b >= 0) {
  24203. positives = splitToPatterns(a, b, state, opts);
  24204. }
  24205. state.negatives = negatives;
  24206. state.positives = positives;
  24207. state.result = collatePatterns(negatives, positives);
  24208. if (opts.capture === true) {
  24209. state.result = `(${state.result})`;
  24210. } else if (opts.wrap !== false && positives.length + negatives.length > 1) {
  24211. state.result = `(?:${state.result})`;
  24212. }
  24213. toRegexRange.cache[cacheKey] = state;
  24214. return state.result;
  24215. };
  24216. function collatePatterns(neg, pos, options) {
  24217. let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
  24218. let onlyPositive = filterPatterns(pos, neg, '', false) || [];
  24219. let intersected = filterPatterns(neg, pos, '-?', true) || [];
  24220. let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
  24221. return subpatterns.join('|');
  24222. }
  24223. function splitToRanges(min, max) {
  24224. let nines = 1;
  24225. let zeros = 1;
  24226. let stop = countNines(min, nines);
  24227. let stops = new Set([max]);
  24228. while (min <= stop && stop <= max) {
  24229. stops.add(stop);
  24230. nines += 1;
  24231. stop = countNines(min, nines);
  24232. }
  24233. stop = countZeros(max + 1, zeros) - 1;
  24234. while (min < stop && stop <= max) {
  24235. stops.add(stop);
  24236. zeros += 1;
  24237. stop = countZeros(max + 1, zeros) - 1;
  24238. }
  24239. stops = [...stops];
  24240. stops.sort(compare);
  24241. return stops;
  24242. }
  24243. /**
  24244. * Convert a range to a regex pattern
  24245. * @param {Number} `start`
  24246. * @param {Number} `stop`
  24247. * @return {String}
  24248. */
  24249. function rangeToPattern(start, stop, options) {
  24250. if (start === stop) {
  24251. return {
  24252. pattern: start,
  24253. count: [],
  24254. digits: 0
  24255. };
  24256. }
  24257. let zipped = zip(start, stop);
  24258. let digits = zipped.length;
  24259. let pattern = '';
  24260. let count = 0;
  24261. for (let i = 0; i < digits; i++) {
  24262. let [startDigit, stopDigit] = zipped[i];
  24263. if (startDigit === stopDigit) {
  24264. pattern += startDigit;
  24265. } else if (startDigit !== '0' || stopDigit !== '9') {
  24266. pattern += toCharacterClass(startDigit, stopDigit);
  24267. } else {
  24268. count++;
  24269. }
  24270. }
  24271. if (count) {
  24272. pattern += options.shorthand === true ? '\\d' : '[0-9]';
  24273. }
  24274. return {
  24275. pattern,
  24276. count: [count],
  24277. digits
  24278. };
  24279. }
  24280. function splitToPatterns(min, max, tok, options) {
  24281. let ranges = splitToRanges(min, max);
  24282. let tokens = [];
  24283. let start = min;
  24284. let prev;
  24285. for (let i = 0; i < ranges.length; i++) {
  24286. let max = ranges[i];
  24287. let obj = rangeToPattern(String(start), String(max), options);
  24288. let zeros = '';
  24289. if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
  24290. if (prev.count.length > 1) {
  24291. prev.count.pop();
  24292. }
  24293. prev.count.push(obj.count[0]);
  24294. prev.string = prev.pattern + toQuantifier(prev.count);
  24295. start = max + 1;
  24296. continue;
  24297. }
  24298. if (tok.isPadded) {
  24299. zeros = padZeros(max, tok, options);
  24300. }
  24301. obj.string = zeros + obj.pattern + toQuantifier(obj.count);
  24302. tokens.push(obj);
  24303. start = max + 1;
  24304. prev = obj;
  24305. }
  24306. return tokens;
  24307. }
  24308. function filterPatterns(arr, comparison, prefix, intersection, options) {
  24309. let result = [];
  24310. for (let ele of arr) {
  24311. let {
  24312. string
  24313. } = ele; // only push if _both_ are negative...
  24314. if (!intersection && !contains(comparison, 'string', string)) {
  24315. result.push(prefix + string);
  24316. } // or _both_ are positive
  24317. if (intersection && contains(comparison, 'string', string)) {
  24318. result.push(prefix + string);
  24319. }
  24320. }
  24321. return result;
  24322. }
  24323. /**
  24324. * Zip strings
  24325. */
  24326. function zip(a, b) {
  24327. let arr = [];
  24328. for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
  24329. return arr;
  24330. }
  24331. function compare(a, b) {
  24332. return a > b ? 1 : b > a ? -1 : 0;
  24333. }
  24334. function contains(arr, key, val) {
  24335. return arr.some(ele => ele[key] === val);
  24336. }
  24337. function countNines(min, len) {
  24338. return Number(String(min).slice(0, -len) + '9'.repeat(len));
  24339. }
  24340. function countZeros(integer, zeros) {
  24341. return integer - integer % Math.pow(10, zeros);
  24342. }
  24343. function toQuantifier(digits) {
  24344. let [start = 0, stop = ''] = digits;
  24345. if (stop || start > 1) {
  24346. return `{${start + (stop ? ',' + stop : '')}}`;
  24347. }
  24348. return '';
  24349. }
  24350. function toCharacterClass(a, b, options) {
  24351. return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
  24352. }
  24353. function hasPadding(str) {
  24354. return /^-?(0+)\d/.test(str);
  24355. }
  24356. function padZeros(value, tok, options) {
  24357. if (!tok.isPadded) {
  24358. return value;
  24359. }
  24360. let diff = Math.abs(tok.maxLen - String(value).length);
  24361. let relax = options.relaxZeros !== false;
  24362. switch (diff) {
  24363. case 0:
  24364. return '';
  24365. case 1:
  24366. return relax ? '0?' : '0';
  24367. case 2:
  24368. return relax ? '0{0,2}' : '00';
  24369. default:
  24370. {
  24371. return relax ? `0{0,${diff}}` : `0{${diff}}`;
  24372. }
  24373. }
  24374. }
  24375. /**
  24376. * Cache
  24377. */
  24378. toRegexRange.cache = {};
  24379. toRegexRange.clearCache = () => toRegexRange.cache = {};
  24380. /**
  24381. * Expose `toRegexRange`
  24382. */
  24383. var toRegexRange_1 = toRegexRange;
  24384. const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  24385. const transform = toNumber => {
  24386. return value => toNumber === true ? Number(value) : String(value);
  24387. };
  24388. const isValidValue = value => {
  24389. return typeof value === 'number' || typeof value === 'string' && value !== '';
  24390. };
  24391. const isNumber = num => Number.isInteger(+num);
  24392. const zeros = input => {
  24393. let value = `${input}`;
  24394. let index = -1;
  24395. if (value[0] === '-') value = value.slice(1);
  24396. if (value === '0') return false;
  24397. while (value[++index] === '0');
  24398. return index > 0;
  24399. };
  24400. const stringify$1 = (start, end, options) => {
  24401. if (typeof start === 'string' || typeof end === 'string') {
  24402. return true;
  24403. }
  24404. return options.stringify === true;
  24405. };
  24406. const pad = (input, maxLength, toNumber) => {
  24407. if (maxLength > 0) {
  24408. let dash = input[0] === '-' ? '-' : '';
  24409. if (dash) input = input.slice(1);
  24410. input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
  24411. }
  24412. if (toNumber === false) {
  24413. return String(input);
  24414. }
  24415. return input;
  24416. };
  24417. const toMaxLen = (input, maxLength) => {
  24418. let negative = input[0] === '-' ? '-' : '';
  24419. if (negative) {
  24420. input = input.slice(1);
  24421. maxLength--;
  24422. }
  24423. while (input.length < maxLength) input = '0' + input;
  24424. return negative ? '-' + input : input;
  24425. };
  24426. const toSequence = (parts, options) => {
  24427. parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  24428. parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  24429. let prefix = options.capture ? '' : '?:';
  24430. let positives = '';
  24431. let negatives = '';
  24432. let result;
  24433. if (parts.positives.length) {
  24434. positives = parts.positives.join('|');
  24435. }
  24436. if (parts.negatives.length) {
  24437. negatives = `-(${prefix}${parts.negatives.join('|')})`;
  24438. }
  24439. if (positives && negatives) {
  24440. result = `${positives}|${negatives}`;
  24441. } else {
  24442. result = positives || negatives;
  24443. }
  24444. if (options.wrap) {
  24445. return `(${prefix}${result})`;
  24446. }
  24447. return result;
  24448. };
  24449. const toRange = (a, b, isNumbers, options) => {
  24450. if (isNumbers) {
  24451. return toRegexRange_1(a, b, Object.assign({
  24452. wrap: false
  24453. }, options));
  24454. }
  24455. let start = String.fromCharCode(a);
  24456. if (a === b) return start;
  24457. let stop = String.fromCharCode(b);
  24458. return `[${start}-${stop}]`;
  24459. };
  24460. const toRegex = (start, end, options) => {
  24461. if (Array.isArray(start)) {
  24462. let wrap = options.wrap === true;
  24463. let prefix = options.capture ? '' : '?:';
  24464. return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
  24465. }
  24466. return toRegexRange_1(start, end, options);
  24467. };
  24468. const rangeError = (...args) => {
  24469. return new RangeError('Invalid range arguments: ' + util__default['default'].inspect(...args));
  24470. };
  24471. const invalidRange = (start, end, options) => {
  24472. if (options.strictRanges === true) throw rangeError([start, end]);
  24473. return [];
  24474. };
  24475. const invalidStep = (step, options) => {
  24476. if (options.strictRanges === true) {
  24477. throw new TypeError(`Expected step "${step}" to be a number`);
  24478. }
  24479. return [];
  24480. };
  24481. const fillNumbers = (start, end, step = 1, options = {}) => {
  24482. let a = Number(start);
  24483. let b = Number(end);
  24484. if (!Number.isInteger(a) || !Number.isInteger(b)) {
  24485. if (options.strictRanges === true) throw rangeError([start, end]);
  24486. return [];
  24487. } // fix negative zero
  24488. if (a === 0) a = 0;
  24489. if (b === 0) b = 0;
  24490. let descending = a > b;
  24491. let startString = String(start);
  24492. let endString = String(end);
  24493. let stepString = String(step);
  24494. step = Math.max(Math.abs(step), 1);
  24495. let padded = zeros(startString) || zeros(endString) || zeros(stepString);
  24496. let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
  24497. let toNumber = padded === false && stringify$1(start, end, options) === false;
  24498. let format = options.transform || transform(toNumber);
  24499. if (options.toRegex && step === 1) {
  24500. return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
  24501. }
  24502. let parts = {
  24503. negatives: [],
  24504. positives: []
  24505. };
  24506. let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
  24507. let range = [];
  24508. let index = 0;
  24509. while (descending ? a >= b : a <= b) {
  24510. if (options.toRegex === true && step > 1) {
  24511. push(a);
  24512. } else {
  24513. range.push(pad(format(a, index), maxLen, toNumber));
  24514. }
  24515. a = descending ? a - step : a + step;
  24516. index++;
  24517. }
  24518. if (options.toRegex === true) {
  24519. return step > 1 ? toSequence(parts, options) : toRegex(range, null, Object.assign({
  24520. wrap: false
  24521. }, options));
  24522. }
  24523. return range;
  24524. };
  24525. const fillLetters = (start, end, step = 1, options = {}) => {
  24526. if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
  24527. return invalidRange(start, end, options);
  24528. }
  24529. let format = options.transform || (val => String.fromCharCode(val));
  24530. let a = `${start}`.charCodeAt(0);
  24531. let b = `${end}`.charCodeAt(0);
  24532. let descending = a > b;
  24533. let min = Math.min(a, b);
  24534. let max = Math.max(a, b);
  24535. if (options.toRegex && step === 1) {
  24536. return toRange(min, max, false, options);
  24537. }
  24538. let range = [];
  24539. let index = 0;
  24540. while (descending ? a >= b : a <= b) {
  24541. range.push(format(a, index));
  24542. a = descending ? a - step : a + step;
  24543. index++;
  24544. }
  24545. if (options.toRegex === true) {
  24546. return toRegex(range, null, {
  24547. wrap: false,
  24548. options
  24549. });
  24550. }
  24551. return range;
  24552. };
  24553. const fill$9 = (start, end, step, options = {}) => {
  24554. if (end == null && isValidValue(start)) {
  24555. return [start];
  24556. }
  24557. if (!isValidValue(start) || !isValidValue(end)) {
  24558. return invalidRange(start, end, options);
  24559. }
  24560. if (typeof step === 'function') {
  24561. return fill$9(start, end, 1, {
  24562. transform: step
  24563. });
  24564. }
  24565. if (isObject$1(step)) {
  24566. return fill$9(start, end, 0, step);
  24567. }
  24568. let opts = Object.assign({}, options);
  24569. if (opts.capture === true) opts.wrap = true;
  24570. step = step || opts.step || 1;
  24571. if (!isNumber(step)) {
  24572. if (step != null && !isObject$1(step)) return invalidStep(step, opts);
  24573. return fill$9(start, end, 1, step);
  24574. }
  24575. if (isNumber(start) && isNumber(end)) {
  24576. return fillNumbers(start, end, step, opts);
  24577. }
  24578. return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
  24579. };
  24580. var fillRange = fill$9;
  24581. const compile = (ast, options = {}) => {
  24582. let walk = (node, parent = {}) => {
  24583. let invalidBlock = utils$a.isInvalidBrace(parent);
  24584. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  24585. let invalid = invalidBlock === true || invalidNode === true;
  24586. let prefix = options.escapeInvalid === true ? '\\' : '';
  24587. let output = '';
  24588. if (node.isOpen === true) {
  24589. return prefix + node.value;
  24590. }
  24591. if (node.isClose === true) {
  24592. return prefix + node.value;
  24593. }
  24594. if (node.type === 'open') {
  24595. return invalid ? prefix + node.value : '(';
  24596. }
  24597. if (node.type === 'close') {
  24598. return invalid ? prefix + node.value : ')';
  24599. }
  24600. if (node.type === 'comma') {
  24601. return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
  24602. }
  24603. if (node.value) {
  24604. return node.value;
  24605. }
  24606. if (node.nodes && node.ranges > 0) {
  24607. let args = utils$a.reduce(node.nodes);
  24608. let range = fillRange(...args, Object.assign(Object.assign({}, options), {}, {
  24609. wrap: false,
  24610. toRegex: true
  24611. }));
  24612. if (range.length !== 0) {
  24613. return args.length > 1 && range.length > 1 ? `(${range})` : range;
  24614. }
  24615. }
  24616. if (node.nodes) {
  24617. for (let child of node.nodes) {
  24618. output += walk(child, node);
  24619. }
  24620. }
  24621. return output;
  24622. };
  24623. return walk(ast);
  24624. };
  24625. var compile_1 = compile;
  24626. const append = (queue = '', stash = '', enclose = false) => {
  24627. let result = [];
  24628. queue = [].concat(queue);
  24629. stash = [].concat(stash);
  24630. if (!stash.length) return queue;
  24631. if (!queue.length) {
  24632. return enclose ? utils$a.flatten(stash).map(ele => `{${ele}}`) : stash;
  24633. }
  24634. for (let item of queue) {
  24635. if (Array.isArray(item)) {
  24636. for (let value of item) {
  24637. result.push(append(value, stash, enclose));
  24638. }
  24639. } else {
  24640. for (let ele of stash) {
  24641. if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
  24642. result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
  24643. }
  24644. }
  24645. }
  24646. return utils$a.flatten(result);
  24647. };
  24648. const expand = (ast, options = {}) => {
  24649. let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
  24650. let walk = (node, parent = {}) => {
  24651. node.queue = [];
  24652. let p = parent;
  24653. let q = parent.queue;
  24654. while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
  24655. p = p.parent;
  24656. q = p.queue;
  24657. }
  24658. if (node.invalid || node.dollar) {
  24659. q.push(append(q.pop(), stringify$2(node, options)));
  24660. return;
  24661. }
  24662. if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
  24663. q.push(append(q.pop(), ['{}']));
  24664. return;
  24665. }
  24666. if (node.nodes && node.ranges > 0) {
  24667. let args = utils$a.reduce(node.nodes);
  24668. if (utils$a.exceedsLimit(...args, options.step, rangeLimit)) {
  24669. throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
  24670. }
  24671. let range = fillRange(...args, options);
  24672. if (range.length === 0) {
  24673. range = stringify$2(node, options);
  24674. }
  24675. q.push(append(q.pop(), range));
  24676. node.nodes = [];
  24677. return;
  24678. }
  24679. let enclose = utils$a.encloseBrace(node);
  24680. let queue = node.queue;
  24681. let block = node;
  24682. while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
  24683. block = block.parent;
  24684. queue = block.queue;
  24685. }
  24686. for (let i = 0; i < node.nodes.length; i++) {
  24687. let child = node.nodes[i];
  24688. if (child.type === 'comma' && node.type === 'brace') {
  24689. if (i === 1) queue.push('');
  24690. queue.push('');
  24691. continue;
  24692. }
  24693. if (child.type === 'close') {
  24694. q.push(append(q.pop(), queue, enclose));
  24695. continue;
  24696. }
  24697. if (child.value && child.type !== 'open') {
  24698. queue.push(append(queue.pop(), child.value));
  24699. continue;
  24700. }
  24701. if (child.nodes) {
  24702. walk(child, node);
  24703. }
  24704. }
  24705. return queue;
  24706. };
  24707. return utils$a.flatten(walk(ast));
  24708. };
  24709. var expand_1 = expand;
  24710. var constants$2 = {
  24711. MAX_LENGTH: 1024 * 64,
  24712. // Digits
  24713. CHAR_0: '0',
  24714. /* 0 */
  24715. CHAR_9: '9',
  24716. /* 9 */
  24717. // Alphabet chars.
  24718. CHAR_UPPERCASE_A: 'A',
  24719. /* A */
  24720. CHAR_LOWERCASE_A: 'a',
  24721. /* a */
  24722. CHAR_UPPERCASE_Z: 'Z',
  24723. /* Z */
  24724. CHAR_LOWERCASE_Z: 'z',
  24725. /* z */
  24726. CHAR_LEFT_PARENTHESES: '(',
  24727. /* ( */
  24728. CHAR_RIGHT_PARENTHESES: ')',
  24729. /* ) */
  24730. CHAR_ASTERISK: '*',
  24731. /* * */
  24732. // Non-alphabetic chars.
  24733. CHAR_AMPERSAND: '&',
  24734. /* & */
  24735. CHAR_AT: '@',
  24736. /* @ */
  24737. CHAR_BACKSLASH: '\\',
  24738. /* \ */
  24739. CHAR_BACKTICK: '`',
  24740. /* ` */
  24741. CHAR_CARRIAGE_RETURN: '\r',
  24742. /* \r */
  24743. CHAR_CIRCUMFLEX_ACCENT: '^',
  24744. /* ^ */
  24745. CHAR_COLON: ':',
  24746. /* : */
  24747. CHAR_COMMA: ',',
  24748. /* , */
  24749. CHAR_DOLLAR: '$',
  24750. /* . */
  24751. CHAR_DOT: '.',
  24752. /* . */
  24753. CHAR_DOUBLE_QUOTE: '"',
  24754. /* " */
  24755. CHAR_EQUAL: '=',
  24756. /* = */
  24757. CHAR_EXCLAMATION_MARK: '!',
  24758. /* ! */
  24759. CHAR_FORM_FEED: '\f',
  24760. /* \f */
  24761. CHAR_FORWARD_SLASH: '/',
  24762. /* / */
  24763. CHAR_HASH: '#',
  24764. /* # */
  24765. CHAR_HYPHEN_MINUS: '-',
  24766. /* - */
  24767. CHAR_LEFT_ANGLE_BRACKET: '<',
  24768. /* < */
  24769. CHAR_LEFT_CURLY_BRACE: '{',
  24770. /* { */
  24771. CHAR_LEFT_SQUARE_BRACKET: '[',
  24772. /* [ */
  24773. CHAR_LINE_FEED: '\n',
  24774. /* \n */
  24775. CHAR_NO_BREAK_SPACE: '\u00A0',
  24776. /* \u00A0 */
  24777. CHAR_PERCENT: '%',
  24778. /* % */
  24779. CHAR_PLUS: '+',
  24780. /* + */
  24781. CHAR_QUESTION_MARK: '?',
  24782. /* ? */
  24783. CHAR_RIGHT_ANGLE_BRACKET: '>',
  24784. /* > */
  24785. CHAR_RIGHT_CURLY_BRACE: '}',
  24786. /* } */
  24787. CHAR_RIGHT_SQUARE_BRACKET: ']',
  24788. /* ] */
  24789. CHAR_SEMICOLON: ';',
  24790. /* ; */
  24791. CHAR_SINGLE_QUOTE: '\'',
  24792. /* ' */
  24793. CHAR_SPACE: ' ',
  24794. /* */
  24795. CHAR_TAB: '\t',
  24796. /* \t */
  24797. CHAR_UNDERSCORE: '_',
  24798. /* _ */
  24799. CHAR_VERTICAL_LINE: '|',
  24800. /* | */
  24801. CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
  24802. /* \uFEFF */
  24803. };
  24804. /**
  24805. * Constants
  24806. */
  24807. const {
  24808. MAX_LENGTH: MAX_LENGTH$1,
  24809. CHAR_BACKSLASH,
  24810. /* \ */
  24811. CHAR_BACKTICK,
  24812. /* ` */
  24813. CHAR_COMMA: CHAR_COMMA$1,
  24814. /* , */
  24815. CHAR_DOT: CHAR_DOT$1,
  24816. /* . */
  24817. CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1,
  24818. /* ( */
  24819. CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1,
  24820. /* ) */
  24821. CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1,
  24822. /* { */
  24823. CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1,
  24824. /* } */
  24825. CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1,
  24826. /* [ */
  24827. CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1,
  24828. /* ] */
  24829. CHAR_DOUBLE_QUOTE,
  24830. /* " */
  24831. CHAR_SINGLE_QUOTE,
  24832. /* ' */
  24833. CHAR_NO_BREAK_SPACE,
  24834. CHAR_ZERO_WIDTH_NOBREAK_SPACE
  24835. } = constants$2;
  24836. /**
  24837. * parse
  24838. */
  24839. const parse$3 = (input, options = {}) => {
  24840. if (typeof input !== 'string') {
  24841. throw new TypeError('Expected a string');
  24842. }
  24843. let opts = options || {};
  24844. let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
  24845. if (input.length > max) {
  24846. throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
  24847. }
  24848. let ast = {
  24849. type: 'root',
  24850. input,
  24851. nodes: []
  24852. };
  24853. let stack = [ast];
  24854. let block = ast;
  24855. let prev = ast;
  24856. let brackets = 0;
  24857. let length = input.length;
  24858. let index = 0;
  24859. let depth = 0;
  24860. let value;
  24861. /**
  24862. * Helpers
  24863. */
  24864. const advance = () => input[index++];
  24865. const push = node => {
  24866. if (node.type === 'text' && prev.type === 'dot') {
  24867. prev.type = 'text';
  24868. }
  24869. if (prev && prev.type === 'text' && node.type === 'text') {
  24870. prev.value += node.value;
  24871. return;
  24872. }
  24873. block.nodes.push(node);
  24874. node.parent = block;
  24875. node.prev = prev;
  24876. prev = node;
  24877. return node;
  24878. };
  24879. push({
  24880. type: 'bos'
  24881. });
  24882. while (index < length) {
  24883. block = stack[stack.length - 1];
  24884. value = advance();
  24885. /**
  24886. * Invalid chars
  24887. */
  24888. if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
  24889. continue;
  24890. }
  24891. /**
  24892. * Escaped chars
  24893. */
  24894. if (value === CHAR_BACKSLASH) {
  24895. push({
  24896. type: 'text',
  24897. value: (options.keepEscaping ? value : '') + advance()
  24898. });
  24899. continue;
  24900. }
  24901. /**
  24902. * Right square bracket (literal): ']'
  24903. */
  24904. if (value === CHAR_RIGHT_SQUARE_BRACKET$1) {
  24905. push({
  24906. type: 'text',
  24907. value: '\\' + value
  24908. });
  24909. continue;
  24910. }
  24911. /**
  24912. * Left square bracket: '['
  24913. */
  24914. if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
  24915. brackets++;
  24916. let next;
  24917. while (index < length && (next = advance())) {
  24918. value += next;
  24919. if (next === CHAR_LEFT_SQUARE_BRACKET$1) {
  24920. brackets++;
  24921. continue;
  24922. }
  24923. if (next === CHAR_BACKSLASH) {
  24924. value += advance();
  24925. continue;
  24926. }
  24927. if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
  24928. brackets--;
  24929. if (brackets === 0) {
  24930. break;
  24931. }
  24932. }
  24933. }
  24934. push({
  24935. type: 'text',
  24936. value
  24937. });
  24938. continue;
  24939. }
  24940. /**
  24941. * Parentheses
  24942. */
  24943. if (value === CHAR_LEFT_PARENTHESES$1) {
  24944. block = push({
  24945. type: 'paren',
  24946. nodes: []
  24947. });
  24948. stack.push(block);
  24949. push({
  24950. type: 'text',
  24951. value
  24952. });
  24953. continue;
  24954. }
  24955. if (value === CHAR_RIGHT_PARENTHESES$1) {
  24956. if (block.type !== 'paren') {
  24957. push({
  24958. type: 'text',
  24959. value
  24960. });
  24961. continue;
  24962. }
  24963. block = stack.pop();
  24964. push({
  24965. type: 'text',
  24966. value
  24967. });
  24968. block = stack[stack.length - 1];
  24969. continue;
  24970. }
  24971. /**
  24972. * Quotes: '|"|`
  24973. */
  24974. if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
  24975. let open = value;
  24976. let next;
  24977. if (options.keepQuotes !== true) {
  24978. value = '';
  24979. }
  24980. while (index < length && (next = advance())) {
  24981. if (next === CHAR_BACKSLASH) {
  24982. value += next + advance();
  24983. continue;
  24984. }
  24985. if (next === open) {
  24986. if (options.keepQuotes === true) value += next;
  24987. break;
  24988. }
  24989. value += next;
  24990. }
  24991. push({
  24992. type: 'text',
  24993. value
  24994. });
  24995. continue;
  24996. }
  24997. /**
  24998. * Left curly brace: '{'
  24999. */
  25000. if (value === CHAR_LEFT_CURLY_BRACE$1) {
  25001. depth++;
  25002. let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
  25003. let brace = {
  25004. type: 'brace',
  25005. open: true,
  25006. close: false,
  25007. dollar,
  25008. depth,
  25009. commas: 0,
  25010. ranges: 0,
  25011. nodes: []
  25012. };
  25013. block = push(brace);
  25014. stack.push(block);
  25015. push({
  25016. type: 'open',
  25017. value
  25018. });
  25019. continue;
  25020. }
  25021. /**
  25022. * Right curly brace: '}'
  25023. */
  25024. if (value === CHAR_RIGHT_CURLY_BRACE$1) {
  25025. if (block.type !== 'brace') {
  25026. push({
  25027. type: 'text',
  25028. value
  25029. });
  25030. continue;
  25031. }
  25032. let type = 'close';
  25033. block = stack.pop();
  25034. block.close = true;
  25035. push({
  25036. type,
  25037. value
  25038. });
  25039. depth--;
  25040. block = stack[stack.length - 1];
  25041. continue;
  25042. }
  25043. /**
  25044. * Comma: ','
  25045. */
  25046. if (value === CHAR_COMMA$1 && depth > 0) {
  25047. if (block.ranges > 0) {
  25048. block.ranges = 0;
  25049. let open = block.nodes.shift();
  25050. block.nodes = [open, {
  25051. type: 'text',
  25052. value: stringify$2(block)
  25053. }];
  25054. }
  25055. push({
  25056. type: 'comma',
  25057. value
  25058. });
  25059. block.commas++;
  25060. continue;
  25061. }
  25062. /**
  25063. * Dot: '.'
  25064. */
  25065. if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
  25066. let siblings = block.nodes;
  25067. if (depth === 0 || siblings.length === 0) {
  25068. push({
  25069. type: 'text',
  25070. value
  25071. });
  25072. continue;
  25073. }
  25074. if (prev.type === 'dot') {
  25075. block.range = [];
  25076. prev.value += value;
  25077. prev.type = 'range';
  25078. if (block.nodes.length !== 3 && block.nodes.length !== 5) {
  25079. block.invalid = true;
  25080. block.ranges = 0;
  25081. prev.type = 'text';
  25082. continue;
  25083. }
  25084. block.ranges++;
  25085. block.args = [];
  25086. continue;
  25087. }
  25088. if (prev.type === 'range') {
  25089. siblings.pop();
  25090. let before = siblings[siblings.length - 1];
  25091. before.value += prev.value + value;
  25092. prev = before;
  25093. block.ranges--;
  25094. continue;
  25095. }
  25096. push({
  25097. type: 'dot',
  25098. value
  25099. });
  25100. continue;
  25101. }
  25102. /**
  25103. * Text
  25104. */
  25105. push({
  25106. type: 'text',
  25107. value
  25108. });
  25109. } // Mark imbalanced braces and brackets as invalid
  25110. do {
  25111. block = stack.pop();
  25112. if (block.type !== 'root') {
  25113. block.nodes.forEach(node => {
  25114. if (!node.nodes) {
  25115. if (node.type === 'open') node.isOpen = true;
  25116. if (node.type === 'close') node.isClose = true;
  25117. if (!node.nodes) node.type = 'text';
  25118. node.invalid = true;
  25119. }
  25120. }); // get the location of the block on parent.nodes (block's siblings)
  25121. let parent = stack[stack.length - 1];
  25122. let index = parent.nodes.indexOf(block); // replace the (invalid) block with it's nodes
  25123. parent.nodes.splice(index, 1, ...block.nodes);
  25124. }
  25125. } while (stack.length > 0);
  25126. push({
  25127. type: 'eos'
  25128. });
  25129. return ast;
  25130. };
  25131. var parse_1$3 = parse$3;
  25132. /**
  25133. * Expand the given pattern or create a regex-compatible string.
  25134. *
  25135. * ```js
  25136. * const braces = require('braces');
  25137. * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
  25138. * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
  25139. * ```
  25140. * @param {String} `str`
  25141. * @param {Object} `options`
  25142. * @return {String}
  25143. * @api public
  25144. */
  25145. const braces = (input, options = {}) => {
  25146. let output = [];
  25147. if (Array.isArray(input)) {
  25148. for (let pattern of input) {
  25149. let result = braces.create(pattern, options);
  25150. if (Array.isArray(result)) {
  25151. output.push(...result);
  25152. } else {
  25153. output.push(result);
  25154. }
  25155. }
  25156. } else {
  25157. output = [].concat(braces.create(input, options));
  25158. }
  25159. if (options && options.expand === true && options.nodupes === true) {
  25160. output = [...new Set(output)];
  25161. }
  25162. return output;
  25163. };
  25164. /**
  25165. * Parse the given `str` with the given `options`.
  25166. *
  25167. * ```js
  25168. * // braces.parse(pattern, [, options]);
  25169. * const ast = braces.parse('a/{b,c}/d');
  25170. * console.log(ast);
  25171. * ```
  25172. * @param {String} pattern Brace pattern to parse
  25173. * @param {Object} options
  25174. * @return {Object} Returns an AST
  25175. * @api public
  25176. */
  25177. braces.parse = (input, options = {}) => parse_1$3(input, options);
  25178. /**
  25179. * Creates a braces string from an AST, or an AST node.
  25180. *
  25181. * ```js
  25182. * const braces = require('braces');
  25183. * let ast = braces.parse('foo/{a,b}/bar');
  25184. * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
  25185. * ```
  25186. * @param {String} `input` Brace pattern or AST.
  25187. * @param {Object} `options`
  25188. * @return {Array} Returns an array of expanded values.
  25189. * @api public
  25190. */
  25191. braces.stringify = (input, options = {}) => {
  25192. if (typeof input === 'string') {
  25193. return stringify$2(braces.parse(input, options), options);
  25194. }
  25195. return stringify$2(input, options);
  25196. };
  25197. /**
  25198. * Compiles a brace pattern into a regex-compatible, optimized string.
  25199. * This method is called by the main [braces](#braces) function by default.
  25200. *
  25201. * ```js
  25202. * const braces = require('braces');
  25203. * console.log(braces.compile('a/{b,c}/d'));
  25204. * //=> ['a/(b|c)/d']
  25205. * ```
  25206. * @param {String} `input` Brace pattern or AST.
  25207. * @param {Object} `options`
  25208. * @return {Array} Returns an array of expanded values.
  25209. * @api public
  25210. */
  25211. braces.compile = (input, options = {}) => {
  25212. if (typeof input === 'string') {
  25213. input = braces.parse(input, options);
  25214. }
  25215. return compile_1(input, options);
  25216. };
  25217. /**
  25218. * Expands a brace pattern into an array. This method is called by the
  25219. * main [braces](#braces) function when `options.expand` is true. Before
  25220. * using this method it's recommended that you read the [performance notes](#performance))
  25221. * and advantages of using [.compile](#compile) instead.
  25222. *
  25223. * ```js
  25224. * const braces = require('braces');
  25225. * console.log(braces.expand('a/{b,c}/d'));
  25226. * //=> ['a/b/d', 'a/c/d'];
  25227. * ```
  25228. * @param {String} `pattern` Brace pattern
  25229. * @param {Object} `options`
  25230. * @return {Array} Returns an array of expanded values.
  25231. * @api public
  25232. */
  25233. braces.expand = (input, options = {}) => {
  25234. if (typeof input === 'string') {
  25235. input = braces.parse(input, options);
  25236. }
  25237. let result = expand_1(input, options); // filter out empty strings if specified
  25238. if (options.noempty === true) {
  25239. result = result.filter(Boolean);
  25240. } // filter out duplicates if specified
  25241. if (options.nodupes === true) {
  25242. result = [...new Set(result)];
  25243. }
  25244. return result;
  25245. };
  25246. /**
  25247. * Processes a brace pattern and returns either an expanded array
  25248. * (if `options.expand` is true), a highly optimized regex-compatible string.
  25249. * This method is called by the main [braces](#braces) function.
  25250. *
  25251. * ```js
  25252. * const braces = require('braces');
  25253. * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
  25254. * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
  25255. * ```
  25256. * @param {String} `pattern` Brace pattern
  25257. * @param {Object} `options`
  25258. * @return {Array} Returns an array of expanded values.
  25259. * @api public
  25260. */
  25261. braces.create = (input, options = {}) => {
  25262. if (input === '' || input.length < 3) {
  25263. return [input];
  25264. }
  25265. return options.expand !== true ? braces.compile(input, options) : braces.expand(input, options);
  25266. };
  25267. /**
  25268. * Expose "braces"
  25269. */
  25270. var braces_1 = braces;
  25271. const WIN_SLASH = '\\\\/';
  25272. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  25273. /**
  25274. * Posix glob regex
  25275. */
  25276. const DOT_LITERAL = '\\.';
  25277. const PLUS_LITERAL = '\\+';
  25278. const QMARK_LITERAL = '\\?';
  25279. const SLASH_LITERAL = '\\/';
  25280. const ONE_CHAR = '(?=.)';
  25281. const QMARK = '[^/]';
  25282. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  25283. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  25284. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  25285. const NO_DOT = `(?!${DOT_LITERAL})`;
  25286. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  25287. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  25288. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  25289. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  25290. const STAR = `${QMARK}*?`;
  25291. const POSIX_CHARS = {
  25292. DOT_LITERAL,
  25293. PLUS_LITERAL,
  25294. QMARK_LITERAL,
  25295. SLASH_LITERAL,
  25296. ONE_CHAR,
  25297. QMARK,
  25298. END_ANCHOR,
  25299. DOTS_SLASH,
  25300. NO_DOT,
  25301. NO_DOTS,
  25302. NO_DOT_SLASH,
  25303. NO_DOTS_SLASH,
  25304. QMARK_NO_DOT,
  25305. STAR,
  25306. START_ANCHOR
  25307. };
  25308. /**
  25309. * Windows glob regex
  25310. */
  25311. const WINDOWS_CHARS = Object.assign(Object.assign({}, POSIX_CHARS), {}, {
  25312. SLASH_LITERAL: `[${WIN_SLASH}]`,
  25313. QMARK: WIN_NO_SLASH,
  25314. STAR: `${WIN_NO_SLASH}*?`,
  25315. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  25316. NO_DOT: `(?!${DOT_LITERAL})`,
  25317. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  25318. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  25319. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  25320. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  25321. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  25322. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
  25323. });
  25324. /**
  25325. * POSIX Bracket Regex
  25326. */
  25327. const POSIX_REGEX_SOURCE$1 = {
  25328. alnum: 'a-zA-Z0-9',
  25329. alpha: 'a-zA-Z',
  25330. ascii: '\\x00-\\x7F',
  25331. blank: ' \\t',
  25332. cntrl: '\\x00-\\x1F\\x7F',
  25333. digit: '0-9',
  25334. graph: '\\x21-\\x7E',
  25335. lower: 'a-z',
  25336. print: '\\x20-\\x7E ',
  25337. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  25338. space: ' \\t\\r\\n\\v\\f',
  25339. upper: 'A-Z',
  25340. word: 'A-Za-z0-9_',
  25341. xdigit: 'A-Fa-f0-9'
  25342. };
  25343. var constants$1 = {
  25344. MAX_LENGTH: 1024 * 64,
  25345. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  25346. // regular expressions
  25347. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  25348. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  25349. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  25350. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  25351. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  25352. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  25353. // Replace globs with equivalent patterns to reduce parsing time.
  25354. REPLACEMENTS: {
  25355. '***': '*',
  25356. '**/**': '**',
  25357. '**/**/**': '**'
  25358. },
  25359. // Digits
  25360. CHAR_0: 48,
  25361. /* 0 */
  25362. CHAR_9: 57,
  25363. /* 9 */
  25364. // Alphabet chars.
  25365. CHAR_UPPERCASE_A: 65,
  25366. /* A */
  25367. CHAR_LOWERCASE_A: 97,
  25368. /* a */
  25369. CHAR_UPPERCASE_Z: 90,
  25370. /* Z */
  25371. CHAR_LOWERCASE_Z: 122,
  25372. /* z */
  25373. CHAR_LEFT_PARENTHESES: 40,
  25374. /* ( */
  25375. CHAR_RIGHT_PARENTHESES: 41,
  25376. /* ) */
  25377. CHAR_ASTERISK: 42,
  25378. /* * */
  25379. // Non-alphabetic chars.
  25380. CHAR_AMPERSAND: 38,
  25381. /* & */
  25382. CHAR_AT: 64,
  25383. /* @ */
  25384. CHAR_BACKWARD_SLASH: 92,
  25385. /* \ */
  25386. CHAR_CARRIAGE_RETURN: 13,
  25387. /* \r */
  25388. CHAR_CIRCUMFLEX_ACCENT: 94,
  25389. /* ^ */
  25390. CHAR_COLON: 58,
  25391. /* : */
  25392. CHAR_COMMA: 44,
  25393. /* , */
  25394. CHAR_DOT: 46,
  25395. /* . */
  25396. CHAR_DOUBLE_QUOTE: 34,
  25397. /* " */
  25398. CHAR_EQUAL: 61,
  25399. /* = */
  25400. CHAR_EXCLAMATION_MARK: 33,
  25401. /* ! */
  25402. CHAR_FORM_FEED: 12,
  25403. /* \f */
  25404. CHAR_FORWARD_SLASH: 47,
  25405. /* / */
  25406. CHAR_GRAVE_ACCENT: 96,
  25407. /* ` */
  25408. CHAR_HASH: 35,
  25409. /* # */
  25410. CHAR_HYPHEN_MINUS: 45,
  25411. /* - */
  25412. CHAR_LEFT_ANGLE_BRACKET: 60,
  25413. /* < */
  25414. CHAR_LEFT_CURLY_BRACE: 123,
  25415. /* { */
  25416. CHAR_LEFT_SQUARE_BRACKET: 91,
  25417. /* [ */
  25418. CHAR_LINE_FEED: 10,
  25419. /* \n */
  25420. CHAR_NO_BREAK_SPACE: 160,
  25421. /* \u00A0 */
  25422. CHAR_PERCENT: 37,
  25423. /* % */
  25424. CHAR_PLUS: 43,
  25425. /* + */
  25426. CHAR_QUESTION_MARK: 63,
  25427. /* ? */
  25428. CHAR_RIGHT_ANGLE_BRACKET: 62,
  25429. /* > */
  25430. CHAR_RIGHT_CURLY_BRACE: 125,
  25431. /* } */
  25432. CHAR_RIGHT_SQUARE_BRACKET: 93,
  25433. /* ] */
  25434. CHAR_SEMICOLON: 59,
  25435. /* ; */
  25436. CHAR_SINGLE_QUOTE: 39,
  25437. /* ' */
  25438. CHAR_SPACE: 32,
  25439. /* */
  25440. CHAR_TAB: 9,
  25441. /* \t */
  25442. CHAR_UNDERSCORE: 95,
  25443. /* _ */
  25444. CHAR_VERTICAL_LINE: 124,
  25445. /* | */
  25446. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
  25447. /* \uFEFF */
  25448. SEP: path__default['default'].sep,
  25449. /**
  25450. * Create EXTGLOB_CHARS
  25451. */
  25452. extglobChars(chars) {
  25453. return {
  25454. '!': {
  25455. type: 'negate',
  25456. open: '(?:(?!(?:',
  25457. close: `))${chars.STAR})`
  25458. },
  25459. '?': {
  25460. type: 'qmark',
  25461. open: '(?:',
  25462. close: ')?'
  25463. },
  25464. '+': {
  25465. type: 'plus',
  25466. open: '(?:',
  25467. close: ')+'
  25468. },
  25469. '*': {
  25470. type: 'star',
  25471. open: '(?:',
  25472. close: ')*'
  25473. },
  25474. '@': {
  25475. type: 'at',
  25476. open: '(?:',
  25477. close: ')'
  25478. }
  25479. };
  25480. },
  25481. /**
  25482. * Create GLOB_CHARS
  25483. */
  25484. globChars(win32) {
  25485. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  25486. }
  25487. };
  25488. var utils$9 = createCommonjsModule(function (module, exports) {
  25489. const win32 = process.platform === 'win32';
  25490. const {
  25491. REGEX_BACKSLASH,
  25492. REGEX_REMOVE_BACKSLASH,
  25493. REGEX_SPECIAL_CHARS,
  25494. REGEX_SPECIAL_CHARS_GLOBAL
  25495. } = constants$1;
  25496. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  25497. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  25498. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  25499. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  25500. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  25501. exports.removeBackslashes = str => {
  25502. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  25503. return match === '\\' ? '' : match;
  25504. });
  25505. };
  25506. exports.supportsLookbehinds = () => {
  25507. const segs = process.version.slice(1).split('.').map(Number);
  25508. if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
  25509. return true;
  25510. }
  25511. return false;
  25512. };
  25513. exports.isWindows = options => {
  25514. if (options && typeof options.windows === 'boolean') {
  25515. return options.windows;
  25516. }
  25517. return win32 === true || path__default['default'].sep === '\\';
  25518. };
  25519. exports.escapeLast = (input, char, lastIdx) => {
  25520. const idx = input.lastIndexOf(char, lastIdx);
  25521. if (idx === -1) return input;
  25522. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  25523. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  25524. };
  25525. exports.removePrefix = (input, state = {}) => {
  25526. let output = input;
  25527. if (output.startsWith('./')) {
  25528. output = output.slice(2);
  25529. state.prefix = './';
  25530. }
  25531. return output;
  25532. };
  25533. exports.wrapOutput = (input, state = {}, options = {}) => {
  25534. const prepend = options.contains ? '' : '^';
  25535. const append = options.contains ? '' : '$';
  25536. let output = `${prepend}(?:${input})${append}`;
  25537. if (state.negated === true) {
  25538. output = `(?:^(?!${output}).*$)`;
  25539. }
  25540. return output;
  25541. };
  25542. });
  25543. const {
  25544. CHAR_ASTERISK,
  25545. /* * */
  25546. CHAR_AT,
  25547. /* @ */
  25548. CHAR_BACKWARD_SLASH,
  25549. /* \ */
  25550. CHAR_COMMA,
  25551. /* , */
  25552. CHAR_DOT,
  25553. /* . */
  25554. CHAR_EXCLAMATION_MARK,
  25555. /* ! */
  25556. CHAR_FORWARD_SLASH,
  25557. /* / */
  25558. CHAR_LEFT_CURLY_BRACE,
  25559. /* { */
  25560. CHAR_LEFT_PARENTHESES,
  25561. /* ( */
  25562. CHAR_LEFT_SQUARE_BRACKET,
  25563. /* [ */
  25564. CHAR_PLUS,
  25565. /* + */
  25566. CHAR_QUESTION_MARK,
  25567. /* ? */
  25568. CHAR_RIGHT_CURLY_BRACE,
  25569. /* } */
  25570. CHAR_RIGHT_PARENTHESES,
  25571. /* ) */
  25572. CHAR_RIGHT_SQUARE_BRACKET
  25573. /* ] */
  25574. } = constants$1;
  25575. const isPathSeparator = code => {
  25576. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  25577. };
  25578. const depth = token => {
  25579. if (token.isPrefix !== true) {
  25580. token.depth = token.isGlobstar ? Infinity : 1;
  25581. }
  25582. };
  25583. /**
  25584. * Quickly scans a glob pattern and returns an object with a handful of
  25585. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  25586. * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
  25587. * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
  25588. *
  25589. * ```js
  25590. * const pm = require('picomatch');
  25591. * console.log(pm.scan('foo/bar/*.js'));
  25592. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  25593. * ```
  25594. * @param {String} `str`
  25595. * @param {Object} `options`
  25596. * @return {Object} Returns an object with tokens and regex source string.
  25597. * @api public
  25598. */
  25599. const scan = (input, options) => {
  25600. const opts = options || {};
  25601. const length = input.length - 1;
  25602. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  25603. const slashes = [];
  25604. const tokens = [];
  25605. const parts = [];
  25606. let str = input;
  25607. let index = -1;
  25608. let start = 0;
  25609. let lastIndex = 0;
  25610. let isBrace = false;
  25611. let isBracket = false;
  25612. let isGlob = false;
  25613. let isExtglob = false;
  25614. let isGlobstar = false;
  25615. let braceEscaped = false;
  25616. let backslashes = false;
  25617. let negated = false;
  25618. let negatedExtglob = false;
  25619. let finished = false;
  25620. let braces = 0;
  25621. let prev;
  25622. let code;
  25623. let token = {
  25624. value: '',
  25625. depth: 0,
  25626. isGlob: false
  25627. };
  25628. const eos = () => index >= length;
  25629. const peek = () => str.charCodeAt(index + 1);
  25630. const advance = () => {
  25631. prev = code;
  25632. return str.charCodeAt(++index);
  25633. };
  25634. while (index < length) {
  25635. code = advance();
  25636. let next;
  25637. if (code === CHAR_BACKWARD_SLASH) {
  25638. backslashes = token.backslashes = true;
  25639. code = advance();
  25640. if (code === CHAR_LEFT_CURLY_BRACE) {
  25641. braceEscaped = true;
  25642. }
  25643. continue;
  25644. }
  25645. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  25646. braces++;
  25647. while (eos() !== true && (code = advance())) {
  25648. if (code === CHAR_BACKWARD_SLASH) {
  25649. backslashes = token.backslashes = true;
  25650. advance();
  25651. continue;
  25652. }
  25653. if (code === CHAR_LEFT_CURLY_BRACE) {
  25654. braces++;
  25655. continue;
  25656. }
  25657. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  25658. isBrace = token.isBrace = true;
  25659. isGlob = token.isGlob = true;
  25660. finished = true;
  25661. if (scanToEnd === true) {
  25662. continue;
  25663. }
  25664. break;
  25665. }
  25666. if (braceEscaped !== true && code === CHAR_COMMA) {
  25667. isBrace = token.isBrace = true;
  25668. isGlob = token.isGlob = true;
  25669. finished = true;
  25670. if (scanToEnd === true) {
  25671. continue;
  25672. }
  25673. break;
  25674. }
  25675. if (code === CHAR_RIGHT_CURLY_BRACE) {
  25676. braces--;
  25677. if (braces === 0) {
  25678. braceEscaped = false;
  25679. isBrace = token.isBrace = true;
  25680. finished = true;
  25681. break;
  25682. }
  25683. }
  25684. }
  25685. if (scanToEnd === true) {
  25686. continue;
  25687. }
  25688. break;
  25689. }
  25690. if (code === CHAR_FORWARD_SLASH) {
  25691. slashes.push(index);
  25692. tokens.push(token);
  25693. token = {
  25694. value: '',
  25695. depth: 0,
  25696. isGlob: false
  25697. };
  25698. if (finished === true) continue;
  25699. if (prev === CHAR_DOT && index === start + 1) {
  25700. start += 2;
  25701. continue;
  25702. }
  25703. lastIndex = index + 1;
  25704. continue;
  25705. }
  25706. if (opts.noext !== true) {
  25707. const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
  25708. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  25709. isGlob = token.isGlob = true;
  25710. isExtglob = token.isExtglob = true;
  25711. finished = true;
  25712. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  25713. negatedExtglob = true;
  25714. }
  25715. if (scanToEnd === true) {
  25716. while (eos() !== true && (code = advance())) {
  25717. if (code === CHAR_BACKWARD_SLASH) {
  25718. backslashes = token.backslashes = true;
  25719. code = advance();
  25720. continue;
  25721. }
  25722. if (code === CHAR_RIGHT_PARENTHESES) {
  25723. isGlob = token.isGlob = true;
  25724. finished = true;
  25725. break;
  25726. }
  25727. }
  25728. continue;
  25729. }
  25730. break;
  25731. }
  25732. }
  25733. if (code === CHAR_ASTERISK) {
  25734. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  25735. isGlob = token.isGlob = true;
  25736. finished = true;
  25737. if (scanToEnd === true) {
  25738. continue;
  25739. }
  25740. break;
  25741. }
  25742. if (code === CHAR_QUESTION_MARK) {
  25743. isGlob = token.isGlob = true;
  25744. finished = true;
  25745. if (scanToEnd === true) {
  25746. continue;
  25747. }
  25748. break;
  25749. }
  25750. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  25751. while (eos() !== true && (next = advance())) {
  25752. if (next === CHAR_BACKWARD_SLASH) {
  25753. backslashes = token.backslashes = true;
  25754. advance();
  25755. continue;
  25756. }
  25757. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  25758. isBracket = token.isBracket = true;
  25759. isGlob = token.isGlob = true;
  25760. finished = true;
  25761. break;
  25762. }
  25763. }
  25764. if (scanToEnd === true) {
  25765. continue;
  25766. }
  25767. break;
  25768. }
  25769. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  25770. negated = token.negated = true;
  25771. start++;
  25772. continue;
  25773. }
  25774. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  25775. isGlob = token.isGlob = true;
  25776. if (scanToEnd === true) {
  25777. while (eos() !== true && (code = advance())) {
  25778. if (code === CHAR_LEFT_PARENTHESES) {
  25779. backslashes = token.backslashes = true;
  25780. code = advance();
  25781. continue;
  25782. }
  25783. if (code === CHAR_RIGHT_PARENTHESES) {
  25784. finished = true;
  25785. break;
  25786. }
  25787. }
  25788. continue;
  25789. }
  25790. break;
  25791. }
  25792. if (isGlob === true) {
  25793. finished = true;
  25794. if (scanToEnd === true) {
  25795. continue;
  25796. }
  25797. break;
  25798. }
  25799. }
  25800. if (opts.noext === true) {
  25801. isExtglob = false;
  25802. isGlob = false;
  25803. }
  25804. let base = str;
  25805. let prefix = '';
  25806. let glob = '';
  25807. if (start > 0) {
  25808. prefix = str.slice(0, start);
  25809. str = str.slice(start);
  25810. lastIndex -= start;
  25811. }
  25812. if (base && isGlob === true && lastIndex > 0) {
  25813. base = str.slice(0, lastIndex);
  25814. glob = str.slice(lastIndex);
  25815. } else if (isGlob === true) {
  25816. base = '';
  25817. glob = str;
  25818. } else {
  25819. base = str;
  25820. }
  25821. if (base && base !== '' && base !== '/' && base !== str) {
  25822. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  25823. base = base.slice(0, -1);
  25824. }
  25825. }
  25826. if (opts.unescape === true) {
  25827. if (glob) glob = utils$9.removeBackslashes(glob);
  25828. if (base && backslashes === true) {
  25829. base = utils$9.removeBackslashes(base);
  25830. }
  25831. }
  25832. const state = {
  25833. prefix,
  25834. input,
  25835. start,
  25836. base,
  25837. glob,
  25838. isBrace,
  25839. isBracket,
  25840. isGlob,
  25841. isExtglob,
  25842. isGlobstar,
  25843. negated,
  25844. negatedExtglob
  25845. };
  25846. if (opts.tokens === true) {
  25847. state.maxDepth = 0;
  25848. if (!isPathSeparator(code)) {
  25849. tokens.push(token);
  25850. }
  25851. state.tokens = tokens;
  25852. }
  25853. if (opts.parts === true || opts.tokens === true) {
  25854. let prevIndex;
  25855. for (let idx = 0; idx < slashes.length; idx++) {
  25856. const n = prevIndex ? prevIndex + 1 : start;
  25857. const i = slashes[idx];
  25858. const value = input.slice(n, i);
  25859. if (opts.tokens) {
  25860. if (idx === 0 && start !== 0) {
  25861. tokens[idx].isPrefix = true;
  25862. tokens[idx].value = prefix;
  25863. } else {
  25864. tokens[idx].value = value;
  25865. }
  25866. depth(tokens[idx]);
  25867. state.maxDepth += tokens[idx].depth;
  25868. }
  25869. if (idx !== 0 || value !== '') {
  25870. parts.push(value);
  25871. }
  25872. prevIndex = i;
  25873. }
  25874. if (prevIndex && prevIndex + 1 < input.length) {
  25875. const value = input.slice(prevIndex + 1);
  25876. parts.push(value);
  25877. if (opts.tokens) {
  25878. tokens[tokens.length - 1].value = value;
  25879. depth(tokens[tokens.length - 1]);
  25880. state.maxDepth += tokens[tokens.length - 1].depth;
  25881. }
  25882. }
  25883. state.slashes = slashes;
  25884. state.parts = parts;
  25885. }
  25886. return state;
  25887. };
  25888. var scan_1 = scan;
  25889. /**
  25890. * Constants
  25891. */
  25892. const {
  25893. MAX_LENGTH,
  25894. POSIX_REGEX_SOURCE,
  25895. REGEX_NON_SPECIAL_CHARS,
  25896. REGEX_SPECIAL_CHARS_BACKREF,
  25897. REPLACEMENTS
  25898. } = constants$1;
  25899. /**
  25900. * Helpers
  25901. */
  25902. const expandRange = (args, options) => {
  25903. if (typeof options.expandRange === 'function') {
  25904. return options.expandRange(...args, options);
  25905. }
  25906. args.sort();
  25907. const value = `[${args.join('-')}]`;
  25908. try {
  25909. /* eslint-disable-next-line no-new */
  25910. new RegExp(value);
  25911. } catch (ex) {
  25912. return args.map(v => utils$9.escapeRegex(v)).join('..');
  25913. }
  25914. return value;
  25915. };
  25916. /**
  25917. * Create the message for a syntax error
  25918. */
  25919. const syntaxError$1 = (type, char) => {
  25920. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  25921. };
  25922. /**
  25923. * Parse the given input string.
  25924. * @param {String} input
  25925. * @param {Object} options
  25926. * @return {Object}
  25927. */
  25928. const parse$2 = (input, options) => {
  25929. if (typeof input !== 'string') {
  25930. throw new TypeError('Expected a string');
  25931. }
  25932. input = REPLACEMENTS[input] || input;
  25933. const opts = Object.assign({}, options);
  25934. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  25935. let len = input.length;
  25936. if (len > max) {
  25937. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  25938. }
  25939. const bos = {
  25940. type: 'bos',
  25941. value: '',
  25942. output: opts.prepend || ''
  25943. };
  25944. const tokens = [bos];
  25945. const capture = opts.capture ? '' : '?:';
  25946. const win32 = utils$9.isWindows(options); // create constants based on platform, for windows or posix
  25947. const PLATFORM_CHARS = constants$1.globChars(win32);
  25948. const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
  25949. const {
  25950. DOT_LITERAL,
  25951. PLUS_LITERAL,
  25952. SLASH_LITERAL,
  25953. ONE_CHAR,
  25954. DOTS_SLASH,
  25955. NO_DOT,
  25956. NO_DOT_SLASH,
  25957. NO_DOTS_SLASH,
  25958. QMARK,
  25959. QMARK_NO_DOT,
  25960. STAR,
  25961. START_ANCHOR
  25962. } = PLATFORM_CHARS;
  25963. const globstar = opts => {
  25964. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  25965. };
  25966. const nodot = opts.dot ? '' : NO_DOT;
  25967. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  25968. let star = opts.bash === true ? globstar(opts) : STAR;
  25969. if (opts.capture) {
  25970. star = `(${star})`;
  25971. } // minimatch options support
  25972. if (typeof opts.noext === 'boolean') {
  25973. opts.noextglob = opts.noext;
  25974. }
  25975. const state = {
  25976. input,
  25977. index: -1,
  25978. start: 0,
  25979. dot: opts.dot === true,
  25980. consumed: '',
  25981. output: '',
  25982. prefix: '',
  25983. backtrack: false,
  25984. negated: false,
  25985. brackets: 0,
  25986. braces: 0,
  25987. parens: 0,
  25988. quotes: 0,
  25989. globstar: false,
  25990. tokens
  25991. };
  25992. input = utils$9.removePrefix(input, state);
  25993. len = input.length;
  25994. const extglobs = [];
  25995. const braces = [];
  25996. const stack = [];
  25997. let prev = bos;
  25998. let value;
  25999. /**
  26000. * Tokenizing helpers
  26001. */
  26002. const eos = () => state.index === len - 1;
  26003. const peek = state.peek = (n = 1) => input[state.index + n];
  26004. const advance = state.advance = () => input[++state.index] || '';
  26005. const remaining = () => input.slice(state.index + 1);
  26006. const consume = (value = '', num = 0) => {
  26007. state.consumed += value;
  26008. state.index += num;
  26009. };
  26010. const append = token => {
  26011. state.output += token.output != null ? token.output : token.value;
  26012. consume(token.value);
  26013. };
  26014. const negate = () => {
  26015. let count = 1;
  26016. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  26017. advance();
  26018. state.start++;
  26019. count++;
  26020. }
  26021. if (count % 2 === 0) {
  26022. return false;
  26023. }
  26024. state.negated = true;
  26025. state.start++;
  26026. return true;
  26027. };
  26028. const increment = type => {
  26029. state[type]++;
  26030. stack.push(type);
  26031. };
  26032. const decrement = type => {
  26033. state[type]--;
  26034. stack.pop();
  26035. };
  26036. /**
  26037. * Push tokens onto the tokens array. This helper speeds up
  26038. * tokenizing by 1) helping us avoid backtracking as much as possible,
  26039. * and 2) helping us avoid creating extra tokens when consecutive
  26040. * characters are plain text. This improves performance and simplifies
  26041. * lookbehinds.
  26042. */
  26043. const push = tok => {
  26044. if (prev.type === 'globstar') {
  26045. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  26046. const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren');
  26047. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  26048. state.output = state.output.slice(0, -prev.output.length);
  26049. prev.type = 'star';
  26050. prev.value = '*';
  26051. prev.output = star;
  26052. state.output += prev.output;
  26053. }
  26054. }
  26055. if (extglobs.length && tok.type !== 'paren') {
  26056. extglobs[extglobs.length - 1].inner += tok.value;
  26057. }
  26058. if (tok.value || tok.output) append(tok);
  26059. if (prev && prev.type === 'text' && tok.type === 'text') {
  26060. prev.value += tok.value;
  26061. prev.output = (prev.output || '') + tok.value;
  26062. return;
  26063. }
  26064. tok.prev = prev;
  26065. tokens.push(tok);
  26066. prev = tok;
  26067. };
  26068. const extglobOpen = (type, value) => {
  26069. const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, {
  26070. conditions: 1,
  26071. inner: ''
  26072. });
  26073. token.prev = prev;
  26074. token.parens = state.parens;
  26075. token.output = state.output;
  26076. const output = (opts.capture ? '(' : '') + token.open;
  26077. increment('parens');
  26078. push({
  26079. type,
  26080. value,
  26081. output: state.output ? '' : ONE_CHAR
  26082. });
  26083. push({
  26084. type: 'paren',
  26085. extglob: true,
  26086. value: advance(),
  26087. output
  26088. });
  26089. extglobs.push(token);
  26090. };
  26091. const extglobClose = token => {
  26092. let output = token.close + (opts.capture ? ')' : '');
  26093. let rest;
  26094. if (token.type === 'negate') {
  26095. let extglobStar = star;
  26096. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  26097. extglobStar = globstar(opts);
  26098. }
  26099. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  26100. output = token.close = `)$))${extglobStar}`;
  26101. }
  26102. if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  26103. output = token.close = `)${rest})${extglobStar})`;
  26104. }
  26105. if (token.prev.type === 'bos') {
  26106. state.negatedExtglob = true;
  26107. }
  26108. }
  26109. push({
  26110. type: 'paren',
  26111. extglob: true,
  26112. value,
  26113. output
  26114. });
  26115. decrement('parens');
  26116. };
  26117. /**
  26118. * Fast paths
  26119. */
  26120. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  26121. let backslashes = false;
  26122. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  26123. if (first === '\\') {
  26124. backslashes = true;
  26125. return m;
  26126. }
  26127. if (first === '?') {
  26128. if (esc) {
  26129. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  26130. }
  26131. if (index === 0) {
  26132. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  26133. }
  26134. return QMARK.repeat(chars.length);
  26135. }
  26136. if (first === '.') {
  26137. return DOT_LITERAL.repeat(chars.length);
  26138. }
  26139. if (first === '*') {
  26140. if (esc) {
  26141. return esc + first + (rest ? star : '');
  26142. }
  26143. return star;
  26144. }
  26145. return esc ? m : `\\${m}`;
  26146. });
  26147. if (backslashes === true) {
  26148. if (opts.unescape === true) {
  26149. output = output.replace(/\\/g, '');
  26150. } else {
  26151. output = output.replace(/\\+/g, m => {
  26152. return m.length % 2 === 0 ? '\\\\' : m ? '\\' : '';
  26153. });
  26154. }
  26155. }
  26156. if (output === input && opts.contains === true) {
  26157. state.output = input;
  26158. return state;
  26159. }
  26160. state.output = utils$9.wrapOutput(output, state, options);
  26161. return state;
  26162. }
  26163. /**
  26164. * Tokenize input until we reach end-of-string
  26165. */
  26166. while (!eos()) {
  26167. value = advance();
  26168. if (value === '\u0000') {
  26169. continue;
  26170. }
  26171. /**
  26172. * Escaped characters
  26173. */
  26174. if (value === '\\') {
  26175. const next = peek();
  26176. if (next === '/' && opts.bash !== true) {
  26177. continue;
  26178. }
  26179. if (next === '.' || next === ';') {
  26180. continue;
  26181. }
  26182. if (!next) {
  26183. value += '\\';
  26184. push({
  26185. type: 'text',
  26186. value
  26187. });
  26188. continue;
  26189. } // collapse slashes to reduce potential for exploits
  26190. const match = /^\\+/.exec(remaining());
  26191. let slashes = 0;
  26192. if (match && match[0].length > 2) {
  26193. slashes = match[0].length;
  26194. state.index += slashes;
  26195. if (slashes % 2 !== 0) {
  26196. value += '\\';
  26197. }
  26198. }
  26199. if (opts.unescape === true) {
  26200. value = advance();
  26201. } else {
  26202. value += advance();
  26203. }
  26204. if (state.brackets === 0) {
  26205. push({
  26206. type: 'text',
  26207. value
  26208. });
  26209. continue;
  26210. }
  26211. }
  26212. /**
  26213. * If we're inside a regex character class, continue
  26214. * until we reach the closing bracket.
  26215. */
  26216. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  26217. if (opts.posix !== false && value === ':') {
  26218. const inner = prev.value.slice(1);
  26219. if (inner.includes('[')) {
  26220. prev.posix = true;
  26221. if (inner.includes(':')) {
  26222. const idx = prev.value.lastIndexOf('[');
  26223. const pre = prev.value.slice(0, idx);
  26224. const rest = prev.value.slice(idx + 2);
  26225. const posix = POSIX_REGEX_SOURCE[rest];
  26226. if (posix) {
  26227. prev.value = pre + posix;
  26228. state.backtrack = true;
  26229. advance();
  26230. if (!bos.output && tokens.indexOf(prev) === 1) {
  26231. bos.output = ONE_CHAR;
  26232. }
  26233. continue;
  26234. }
  26235. }
  26236. }
  26237. }
  26238. if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') {
  26239. value = `\\${value}`;
  26240. }
  26241. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  26242. value = `\\${value}`;
  26243. }
  26244. if (opts.posix === true && value === '!' && prev.value === '[') {
  26245. value = '^';
  26246. }
  26247. prev.value += value;
  26248. append({
  26249. value
  26250. });
  26251. continue;
  26252. }
  26253. /**
  26254. * If we're inside a quoted string, continue
  26255. * until we reach the closing double quote.
  26256. */
  26257. if (state.quotes === 1 && value !== '"') {
  26258. value = utils$9.escapeRegex(value);
  26259. prev.value += value;
  26260. append({
  26261. value
  26262. });
  26263. continue;
  26264. }
  26265. /**
  26266. * Double quotes
  26267. */
  26268. if (value === '"') {
  26269. state.quotes = state.quotes === 1 ? 0 : 1;
  26270. if (opts.keepQuotes === true) {
  26271. push({
  26272. type: 'text',
  26273. value
  26274. });
  26275. }
  26276. continue;
  26277. }
  26278. /**
  26279. * Parentheses
  26280. */
  26281. if (value === '(') {
  26282. increment('parens');
  26283. push({
  26284. type: 'paren',
  26285. value
  26286. });
  26287. continue;
  26288. }
  26289. if (value === ')') {
  26290. if (state.parens === 0 && opts.strictBrackets === true) {
  26291. throw new SyntaxError(syntaxError$1('opening', '('));
  26292. }
  26293. const extglob = extglobs[extglobs.length - 1];
  26294. if (extglob && state.parens === extglob.parens + 1) {
  26295. extglobClose(extglobs.pop());
  26296. continue;
  26297. }
  26298. push({
  26299. type: 'paren',
  26300. value,
  26301. output: state.parens ? ')' : '\\)'
  26302. });
  26303. decrement('parens');
  26304. continue;
  26305. }
  26306. /**
  26307. * Square brackets
  26308. */
  26309. if (value === '[') {
  26310. if (opts.nobracket === true || !remaining().includes(']')) {
  26311. if (opts.nobracket !== true && opts.strictBrackets === true) {
  26312. throw new SyntaxError(syntaxError$1('closing', ']'));
  26313. }
  26314. value = `\\${value}`;
  26315. } else {
  26316. increment('brackets');
  26317. }
  26318. push({
  26319. type: 'bracket',
  26320. value
  26321. });
  26322. continue;
  26323. }
  26324. if (value === ']') {
  26325. if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) {
  26326. push({
  26327. type: 'text',
  26328. value,
  26329. output: `\\${value}`
  26330. });
  26331. continue;
  26332. }
  26333. if (state.brackets === 0) {
  26334. if (opts.strictBrackets === true) {
  26335. throw new SyntaxError(syntaxError$1('opening', '['));
  26336. }
  26337. push({
  26338. type: 'text',
  26339. value,
  26340. output: `\\${value}`
  26341. });
  26342. continue;
  26343. }
  26344. decrement('brackets');
  26345. const prevValue = prev.value.slice(1);
  26346. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  26347. value = `/${value}`;
  26348. }
  26349. prev.value += value;
  26350. append({
  26351. value
  26352. }); // when literal brackets are explicitly disabled
  26353. // assume we should match with a regex character class
  26354. if (opts.literalBrackets === false || utils$9.hasRegexChars(prevValue)) {
  26355. continue;
  26356. }
  26357. const escaped = utils$9.escapeRegex(prev.value);
  26358. state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled
  26359. // assume we should escape the brackets to match literal characters
  26360. if (opts.literalBrackets === true) {
  26361. state.output += escaped;
  26362. prev.value = escaped;
  26363. continue;
  26364. } // when the user specifies nothing, try to match both
  26365. prev.value = `(${capture}${escaped}|${prev.value})`;
  26366. state.output += prev.value;
  26367. continue;
  26368. }
  26369. /**
  26370. * Braces
  26371. */
  26372. if (value === '{' && opts.nobrace !== true) {
  26373. increment('braces');
  26374. const open = {
  26375. type: 'brace',
  26376. value,
  26377. output: '(',
  26378. outputIndex: state.output.length,
  26379. tokensIndex: state.tokens.length
  26380. };
  26381. braces.push(open);
  26382. push(open);
  26383. continue;
  26384. }
  26385. if (value === '}') {
  26386. const brace = braces[braces.length - 1];
  26387. if (opts.nobrace === true || !brace) {
  26388. push({
  26389. type: 'text',
  26390. value,
  26391. output: value
  26392. });
  26393. continue;
  26394. }
  26395. let output = ')';
  26396. if (brace.dots === true) {
  26397. const arr = tokens.slice();
  26398. const range = [];
  26399. for (let i = arr.length - 1; i >= 0; i--) {
  26400. tokens.pop();
  26401. if (arr[i].type === 'brace') {
  26402. break;
  26403. }
  26404. if (arr[i].type !== 'dots') {
  26405. range.unshift(arr[i].value);
  26406. }
  26407. }
  26408. output = expandRange(range, opts);
  26409. state.backtrack = true;
  26410. }
  26411. if (brace.comma !== true && brace.dots !== true) {
  26412. const out = state.output.slice(0, brace.outputIndex);
  26413. const toks = state.tokens.slice(brace.tokensIndex);
  26414. brace.value = brace.output = '\\{';
  26415. value = output = '\\}';
  26416. state.output = out;
  26417. for (const t of toks) {
  26418. state.output += t.output || t.value;
  26419. }
  26420. }
  26421. push({
  26422. type: 'brace',
  26423. value,
  26424. output
  26425. });
  26426. decrement('braces');
  26427. braces.pop();
  26428. continue;
  26429. }
  26430. /**
  26431. * Pipes
  26432. */
  26433. if (value === '|') {
  26434. if (extglobs.length > 0) {
  26435. extglobs[extglobs.length - 1].conditions++;
  26436. }
  26437. push({
  26438. type: 'text',
  26439. value
  26440. });
  26441. continue;
  26442. }
  26443. /**
  26444. * Commas
  26445. */
  26446. if (value === ',') {
  26447. let output = value;
  26448. const brace = braces[braces.length - 1];
  26449. if (brace && stack[stack.length - 1] === 'braces') {
  26450. brace.comma = true;
  26451. output = '|';
  26452. }
  26453. push({
  26454. type: 'comma',
  26455. value,
  26456. output
  26457. });
  26458. continue;
  26459. }
  26460. /**
  26461. * Slashes
  26462. */
  26463. if (value === '/') {
  26464. // if the beginning of the glob is "./", advance the start
  26465. // to the current index, and don't add the "./" characters
  26466. // to the state. This greatly simplifies lookbehinds when
  26467. // checking for BOS characters like "!" and "." (not "./")
  26468. if (prev.type === 'dot' && state.index === state.start + 1) {
  26469. state.start = state.index + 1;
  26470. state.consumed = '';
  26471. state.output = '';
  26472. tokens.pop();
  26473. prev = bos; // reset "prev" to the first token
  26474. continue;
  26475. }
  26476. push({
  26477. type: 'slash',
  26478. value,
  26479. output: SLASH_LITERAL
  26480. });
  26481. continue;
  26482. }
  26483. /**
  26484. * Dots
  26485. */
  26486. if (value === '.') {
  26487. if (state.braces > 0 && prev.type === 'dot') {
  26488. if (prev.value === '.') prev.output = DOT_LITERAL;
  26489. const brace = braces[braces.length - 1];
  26490. prev.type = 'dots';
  26491. prev.output += value;
  26492. prev.value += value;
  26493. brace.dots = true;
  26494. continue;
  26495. }
  26496. if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  26497. push({
  26498. type: 'text',
  26499. value,
  26500. output: DOT_LITERAL
  26501. });
  26502. continue;
  26503. }
  26504. push({
  26505. type: 'dot',
  26506. value,
  26507. output: DOT_LITERAL
  26508. });
  26509. continue;
  26510. }
  26511. /**
  26512. * Question marks
  26513. */
  26514. if (value === '?') {
  26515. const isGroup = prev && prev.value === '(';
  26516. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  26517. extglobOpen('qmark', value);
  26518. continue;
  26519. }
  26520. if (prev && prev.type === 'paren') {
  26521. const next = peek();
  26522. let output = value;
  26523. if (next === '<' && !utils$9.supportsLookbehinds()) {
  26524. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  26525. }
  26526. if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) {
  26527. output = `\\${value}`;
  26528. }
  26529. push({
  26530. type: 'text',
  26531. value,
  26532. output
  26533. });
  26534. continue;
  26535. }
  26536. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  26537. push({
  26538. type: 'qmark',
  26539. value,
  26540. output: QMARK_NO_DOT
  26541. });
  26542. continue;
  26543. }
  26544. push({
  26545. type: 'qmark',
  26546. value,
  26547. output: QMARK
  26548. });
  26549. continue;
  26550. }
  26551. /**
  26552. * Exclamation
  26553. */
  26554. if (value === '!') {
  26555. if (opts.noextglob !== true && peek() === '(') {
  26556. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  26557. extglobOpen('negate', value);
  26558. continue;
  26559. }
  26560. }
  26561. if (opts.nonegate !== true && state.index === 0) {
  26562. negate();
  26563. continue;
  26564. }
  26565. }
  26566. /**
  26567. * Plus
  26568. */
  26569. if (value === '+') {
  26570. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  26571. extglobOpen('plus', value);
  26572. continue;
  26573. }
  26574. if (prev && prev.value === '(' || opts.regex === false) {
  26575. push({
  26576. type: 'plus',
  26577. value,
  26578. output: PLUS_LITERAL
  26579. });
  26580. continue;
  26581. }
  26582. if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) {
  26583. push({
  26584. type: 'plus',
  26585. value
  26586. });
  26587. continue;
  26588. }
  26589. push({
  26590. type: 'plus',
  26591. value: PLUS_LITERAL
  26592. });
  26593. continue;
  26594. }
  26595. /**
  26596. * Plain text
  26597. */
  26598. if (value === '@') {
  26599. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  26600. push({
  26601. type: 'at',
  26602. extglob: true,
  26603. value,
  26604. output: ''
  26605. });
  26606. continue;
  26607. }
  26608. push({
  26609. type: 'text',
  26610. value
  26611. });
  26612. continue;
  26613. }
  26614. /**
  26615. * Plain text
  26616. */
  26617. if (value !== '*') {
  26618. if (value === '$' || value === '^') {
  26619. value = `\\${value}`;
  26620. }
  26621. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  26622. if (match) {
  26623. value += match[0];
  26624. state.index += match[0].length;
  26625. }
  26626. push({
  26627. type: 'text',
  26628. value
  26629. });
  26630. continue;
  26631. }
  26632. /**
  26633. * Stars
  26634. */
  26635. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  26636. prev.type = 'star';
  26637. prev.star = true;
  26638. prev.value += value;
  26639. prev.output = star;
  26640. state.backtrack = true;
  26641. state.globstar = true;
  26642. consume(value);
  26643. continue;
  26644. }
  26645. let rest = remaining();
  26646. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  26647. extglobOpen('star', value);
  26648. continue;
  26649. }
  26650. if (prev.type === 'star') {
  26651. if (opts.noglobstar === true) {
  26652. consume(value);
  26653. continue;
  26654. }
  26655. const prior = prev.prev;
  26656. const before = prior.prev;
  26657. const isStart = prior.type === 'slash' || prior.type === 'bos';
  26658. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  26659. if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) {
  26660. push({
  26661. type: 'star',
  26662. value,
  26663. output: ''
  26664. });
  26665. continue;
  26666. }
  26667. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  26668. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  26669. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  26670. push({
  26671. type: 'star',
  26672. value,
  26673. output: ''
  26674. });
  26675. continue;
  26676. } // strip consecutive `/**/`
  26677. while (rest.slice(0, 3) === '/**') {
  26678. const after = input[state.index + 4];
  26679. if (after && after !== '/') {
  26680. break;
  26681. }
  26682. rest = rest.slice(3);
  26683. consume('/**', 3);
  26684. }
  26685. if (prior.type === 'bos' && eos()) {
  26686. prev.type = 'globstar';
  26687. prev.value += value;
  26688. prev.output = globstar(opts);
  26689. state.output = prev.output;
  26690. state.globstar = true;
  26691. consume(value);
  26692. continue;
  26693. }
  26694. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  26695. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  26696. prior.output = `(?:${prior.output}`;
  26697. prev.type = 'globstar';
  26698. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  26699. prev.value += value;
  26700. state.globstar = true;
  26701. state.output += prior.output + prev.output;
  26702. consume(value);
  26703. continue;
  26704. }
  26705. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  26706. const end = rest[1] !== void 0 ? '|$' : '';
  26707. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  26708. prior.output = `(?:${prior.output}`;
  26709. prev.type = 'globstar';
  26710. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  26711. prev.value += value;
  26712. state.output += prior.output + prev.output;
  26713. state.globstar = true;
  26714. consume(value + advance());
  26715. push({
  26716. type: 'slash',
  26717. value: '/',
  26718. output: ''
  26719. });
  26720. continue;
  26721. }
  26722. if (prior.type === 'bos' && rest[0] === '/') {
  26723. prev.type = 'globstar';
  26724. prev.value += value;
  26725. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  26726. state.output = prev.output;
  26727. state.globstar = true;
  26728. consume(value + advance());
  26729. push({
  26730. type: 'slash',
  26731. value: '/',
  26732. output: ''
  26733. });
  26734. continue;
  26735. } // remove single star from output
  26736. state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar
  26737. prev.type = 'globstar';
  26738. prev.output = globstar(opts);
  26739. prev.value += value; // reset output with globstar
  26740. state.output += prev.output;
  26741. state.globstar = true;
  26742. consume(value);
  26743. continue;
  26744. }
  26745. const token = {
  26746. type: 'star',
  26747. value,
  26748. output: star
  26749. };
  26750. if (opts.bash === true) {
  26751. token.output = '.*?';
  26752. if (prev.type === 'bos' || prev.type === 'slash') {
  26753. token.output = nodot + token.output;
  26754. }
  26755. push(token);
  26756. continue;
  26757. }
  26758. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  26759. token.output = value;
  26760. push(token);
  26761. continue;
  26762. }
  26763. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  26764. if (prev.type === 'dot') {
  26765. state.output += NO_DOT_SLASH;
  26766. prev.output += NO_DOT_SLASH;
  26767. } else if (opts.dot === true) {
  26768. state.output += NO_DOTS_SLASH;
  26769. prev.output += NO_DOTS_SLASH;
  26770. } else {
  26771. state.output += nodot;
  26772. prev.output += nodot;
  26773. }
  26774. if (peek() !== '*') {
  26775. state.output += ONE_CHAR;
  26776. prev.output += ONE_CHAR;
  26777. }
  26778. }
  26779. push(token);
  26780. }
  26781. while (state.brackets > 0) {
  26782. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ']'));
  26783. state.output = utils$9.escapeLast(state.output, '[');
  26784. decrement('brackets');
  26785. }
  26786. while (state.parens > 0) {
  26787. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ')'));
  26788. state.output = utils$9.escapeLast(state.output, '(');
  26789. decrement('parens');
  26790. }
  26791. while (state.braces > 0) {
  26792. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', '}'));
  26793. state.output = utils$9.escapeLast(state.output, '{');
  26794. decrement('braces');
  26795. }
  26796. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  26797. push({
  26798. type: 'maybe_slash',
  26799. value: '',
  26800. output: `${SLASH_LITERAL}?`
  26801. });
  26802. } // rebuild the output if we had to backtrack at any point
  26803. if (state.backtrack === true) {
  26804. state.output = '';
  26805. for (const token of state.tokens) {
  26806. state.output += token.output != null ? token.output : token.value;
  26807. if (token.suffix) {
  26808. state.output += token.suffix;
  26809. }
  26810. }
  26811. }
  26812. return state;
  26813. };
  26814. /**
  26815. * Fast paths for creating regular expressions for common glob patterns.
  26816. * This can significantly speed up processing and has very little downside
  26817. * impact when none of the fast paths match.
  26818. */
  26819. parse$2.fastpaths = (input, options) => {
  26820. const opts = Object.assign({}, options);
  26821. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  26822. const len = input.length;
  26823. if (len > max) {
  26824. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  26825. }
  26826. input = REPLACEMENTS[input] || input;
  26827. const win32 = utils$9.isWindows(options); // create constants based on platform, for windows or posix
  26828. const {
  26829. DOT_LITERAL,
  26830. SLASH_LITERAL,
  26831. ONE_CHAR,
  26832. DOTS_SLASH,
  26833. NO_DOT,
  26834. NO_DOTS,
  26835. NO_DOTS_SLASH,
  26836. STAR,
  26837. START_ANCHOR
  26838. } = constants$1.globChars(win32);
  26839. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  26840. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  26841. const capture = opts.capture ? '' : '?:';
  26842. const state = {
  26843. negated: false,
  26844. prefix: ''
  26845. };
  26846. let star = opts.bash === true ? '.*?' : STAR;
  26847. if (opts.capture) {
  26848. star = `(${star})`;
  26849. }
  26850. const globstar = opts => {
  26851. if (opts.noglobstar === true) return star;
  26852. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  26853. };
  26854. const create = str => {
  26855. switch (str) {
  26856. case '*':
  26857. return `${nodot}${ONE_CHAR}${star}`;
  26858. case '.*':
  26859. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  26860. case '*.*':
  26861. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  26862. case '*/*':
  26863. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  26864. case '**':
  26865. return nodot + globstar(opts);
  26866. case '**/*':
  26867. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  26868. case '**/*.*':
  26869. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  26870. case '**/.*':
  26871. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  26872. default:
  26873. {
  26874. const match = /^(.*?)\.(\w+)$/.exec(str);
  26875. if (!match) return;
  26876. const source = create(match[1]);
  26877. if (!source) return;
  26878. return source + DOT_LITERAL + match[2];
  26879. }
  26880. }
  26881. };
  26882. const output = utils$9.removePrefix(input, state);
  26883. let source = create(output);
  26884. if (source && opts.strictSlashes !== true) {
  26885. source += `${SLASH_LITERAL}?`;
  26886. }
  26887. return source;
  26888. };
  26889. var parse_1$2 = parse$2;
  26890. const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
  26891. /**
  26892. * Creates a matcher function from one or more glob patterns. The
  26893. * returned function takes a string to match as its first argument,
  26894. * and returns true if the string is a match. The returned matcher
  26895. * function also takes a boolean as the second argument that, when true,
  26896. * returns an object with additional information.
  26897. *
  26898. * ```js
  26899. * const picomatch = require('picomatch');
  26900. * // picomatch(glob[, options]);
  26901. *
  26902. * const isMatch = picomatch('*.!(*a)');
  26903. * console.log(isMatch('a.a')); //=> false
  26904. * console.log(isMatch('a.b')); //=> true
  26905. * ```
  26906. * @name picomatch
  26907. * @param {String|Array} `globs` One or more glob patterns.
  26908. * @param {Object=} `options`
  26909. * @return {Function=} Returns a matcher function.
  26910. * @api public
  26911. */
  26912. const picomatch$1 = (glob, options, returnState = false) => {
  26913. if (Array.isArray(glob)) {
  26914. const fns = glob.map(input => picomatch$1(input, options, returnState));
  26915. const arrayMatcher = str => {
  26916. for (const isMatch of fns) {
  26917. const state = isMatch(str);
  26918. if (state) return state;
  26919. }
  26920. return false;
  26921. };
  26922. return arrayMatcher;
  26923. }
  26924. const isState = isObject(glob) && glob.tokens && glob.input;
  26925. if (glob === '' || typeof glob !== 'string' && !isState) {
  26926. throw new TypeError('Expected pattern to be a non-empty string');
  26927. }
  26928. const opts = options || {};
  26929. const posix = utils$9.isWindows(options);
  26930. const regex = isState ? picomatch$1.compileRe(glob, options) : picomatch$1.makeRe(glob, options, false, true);
  26931. const state = regex.state;
  26932. delete regex.state;
  26933. let isIgnored = () => false;
  26934. if (opts.ignore) {
  26935. const ignoreOpts = Object.assign(Object.assign({}, options), {}, {
  26936. ignore: null,
  26937. onMatch: null,
  26938. onResult: null
  26939. });
  26940. isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
  26941. }
  26942. const matcher = (input, returnObject = false) => {
  26943. const {
  26944. isMatch,
  26945. match,
  26946. output
  26947. } = picomatch$1.test(input, regex, options, {
  26948. glob,
  26949. posix
  26950. });
  26951. const result = {
  26952. glob,
  26953. state,
  26954. regex,
  26955. posix,
  26956. input,
  26957. output,
  26958. match,
  26959. isMatch
  26960. };
  26961. if (typeof opts.onResult === 'function') {
  26962. opts.onResult(result);
  26963. }
  26964. if (isMatch === false) {
  26965. result.isMatch = false;
  26966. return returnObject ? result : false;
  26967. }
  26968. if (isIgnored(input)) {
  26969. if (typeof opts.onIgnore === 'function') {
  26970. opts.onIgnore(result);
  26971. }
  26972. result.isMatch = false;
  26973. return returnObject ? result : false;
  26974. }
  26975. if (typeof opts.onMatch === 'function') {
  26976. opts.onMatch(result);
  26977. }
  26978. return returnObject ? result : true;
  26979. };
  26980. if (returnState) {
  26981. matcher.state = state;
  26982. }
  26983. return matcher;
  26984. };
  26985. /**
  26986. * Test `input` with the given `regex`. This is used by the main
  26987. * `picomatch()` function to test the input string.
  26988. *
  26989. * ```js
  26990. * const picomatch = require('picomatch');
  26991. * // picomatch.test(input, regex[, options]);
  26992. *
  26993. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  26994. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  26995. * ```
  26996. * @param {String} `input` String to test.
  26997. * @param {RegExp} `regex`
  26998. * @return {Object} Returns an object with matching info.
  26999. * @api public
  27000. */
  27001. picomatch$1.test = (input, regex, options, {
  27002. glob,
  27003. posix
  27004. } = {}) => {
  27005. if (typeof input !== 'string') {
  27006. throw new TypeError('Expected input to be a string');
  27007. }
  27008. if (input === '') {
  27009. return {
  27010. isMatch: false,
  27011. output: ''
  27012. };
  27013. }
  27014. const opts = options || {};
  27015. const format = opts.format || (posix ? utils$9.toPosixSlashes : null);
  27016. let match = input === glob;
  27017. let output = match && format ? format(input) : input;
  27018. if (match === false) {
  27019. output = format ? format(input) : input;
  27020. match = output === glob;
  27021. }
  27022. if (match === false || opts.capture === true) {
  27023. if (opts.matchBase === true || opts.basename === true) {
  27024. match = picomatch$1.matchBase(input, regex, options, posix);
  27025. } else {
  27026. match = regex.exec(output);
  27027. }
  27028. }
  27029. return {
  27030. isMatch: Boolean(match),
  27031. match,
  27032. output
  27033. };
  27034. };
  27035. /**
  27036. * Match the basename of a filepath.
  27037. *
  27038. * ```js
  27039. * const picomatch = require('picomatch');
  27040. * // picomatch.matchBase(input, glob[, options]);
  27041. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  27042. * ```
  27043. * @param {String} `input` String to test.
  27044. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  27045. * @return {Boolean}
  27046. * @api public
  27047. */
  27048. picomatch$1.matchBase = (input, glob, options, posix = utils$9.isWindows(options)) => {
  27049. const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
  27050. return regex.test(path__default['default'].basename(input));
  27051. };
  27052. /**
  27053. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  27054. *
  27055. * ```js
  27056. * const picomatch = require('picomatch');
  27057. * // picomatch.isMatch(string, patterns[, options]);
  27058. *
  27059. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  27060. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  27061. * ```
  27062. * @param {String|Array} str The string to test.
  27063. * @param {String|Array} patterns One or more glob patterns to use for matching.
  27064. * @param {Object} [options] See available [options](#options).
  27065. * @return {Boolean} Returns true if any patterns match `str`
  27066. * @api public
  27067. */
  27068. picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
  27069. /**
  27070. * Parse a glob pattern to create the source string for a regular
  27071. * expression.
  27072. *
  27073. * ```js
  27074. * const picomatch = require('picomatch');
  27075. * const result = picomatch.parse(pattern[, options]);
  27076. * ```
  27077. * @param {String} `pattern`
  27078. * @param {Object} `options`
  27079. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  27080. * @api public
  27081. */
  27082. picomatch$1.parse = (pattern, options) => {
  27083. if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
  27084. return parse_1$2(pattern, Object.assign(Object.assign({}, options), {}, {
  27085. fastpaths: false
  27086. }));
  27087. };
  27088. /**
  27089. * Scan a glob pattern to separate the pattern into segments.
  27090. *
  27091. * ```js
  27092. * const picomatch = require('picomatch');
  27093. * // picomatch.scan(input[, options]);
  27094. *
  27095. * const result = picomatch.scan('!./foo/*.js');
  27096. * console.log(result);
  27097. * { prefix: '!./',
  27098. * input: '!./foo/*.js',
  27099. * start: 3,
  27100. * base: 'foo',
  27101. * glob: '*.js',
  27102. * isBrace: false,
  27103. * isBracket: false,
  27104. * isGlob: true,
  27105. * isExtglob: false,
  27106. * isGlobstar: false,
  27107. * negated: true }
  27108. * ```
  27109. * @param {String} `input` Glob pattern to scan.
  27110. * @param {Object} `options`
  27111. * @return {Object} Returns an object with
  27112. * @api public
  27113. */
  27114. picomatch$1.scan = (input, options) => scan_1(input, options);
  27115. /**
  27116. * Compile a regular expression from the `state` object returned by the
  27117. * [parse()](#parse) method.
  27118. *
  27119. * @param {Object} `state`
  27120. * @param {Object} `options`
  27121. * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
  27122. * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  27123. * @return {RegExp}
  27124. * @api public
  27125. */
  27126. picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
  27127. if (returnOutput === true) {
  27128. return state.output;
  27129. }
  27130. const opts = options || {};
  27131. const prepend = opts.contains ? '' : '^';
  27132. const append = opts.contains ? '' : '$';
  27133. let source = `${prepend}(?:${state.output})${append}`;
  27134. if (state && state.negated === true) {
  27135. source = `^(?!${source}).*$`;
  27136. }
  27137. const regex = picomatch$1.toRegex(source, options);
  27138. if (returnState === true) {
  27139. regex.state = state;
  27140. }
  27141. return regex;
  27142. };
  27143. /**
  27144. * Create a regular expression from a parsed glob pattern.
  27145. *
  27146. * ```js
  27147. * const picomatch = require('picomatch');
  27148. * const state = picomatch.parse('*.js');
  27149. * // picomatch.compileRe(state[, options]);
  27150. *
  27151. * console.log(picomatch.compileRe(state));
  27152. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  27153. * ```
  27154. * @param {String} `state` The object returned from the `.parse` method.
  27155. * @param {Object} `options`
  27156. * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
  27157. * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  27158. * @return {RegExp} Returns a regex created from the given pattern.
  27159. * @api public
  27160. */
  27161. picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  27162. if (!input || typeof input !== 'string') {
  27163. throw new TypeError('Expected a non-empty string');
  27164. }
  27165. let parsed = {
  27166. negated: false,
  27167. fastpaths: true
  27168. };
  27169. if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  27170. parsed.output = parse_1$2.fastpaths(input, options);
  27171. }
  27172. if (!parsed.output) {
  27173. parsed = parse_1$2(input, options);
  27174. }
  27175. return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
  27176. };
  27177. /**
  27178. * Create a regular expression from the given regex source string.
  27179. *
  27180. * ```js
  27181. * const picomatch = require('picomatch');
  27182. * // picomatch.toRegex(source[, options]);
  27183. *
  27184. * const { output } = picomatch.parse('*.js');
  27185. * console.log(picomatch.toRegex(output));
  27186. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  27187. * ```
  27188. * @param {String} `source` Regular expression source string.
  27189. * @param {Object} `options`
  27190. * @return {RegExp}
  27191. * @api public
  27192. */
  27193. picomatch$1.toRegex = (source, options) => {
  27194. try {
  27195. const opts = options || {};
  27196. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  27197. } catch (err) {
  27198. if (options && options.debug === true) throw err;
  27199. return /$^/;
  27200. }
  27201. };
  27202. /**
  27203. * Picomatch constants.
  27204. * @return {Object}
  27205. */
  27206. picomatch$1.constants = constants$1;
  27207. /**
  27208. * Expose "picomatch"
  27209. */
  27210. var picomatch_1 = picomatch$1;
  27211. var picomatch = picomatch_1;
  27212. const isEmptyString = val => val === '' || val === './';
  27213. /**
  27214. * Returns an array of strings that match one or more glob patterns.
  27215. *
  27216. * ```js
  27217. * const mm = require('micromatch');
  27218. * // mm(list, patterns[, options]);
  27219. *
  27220. * console.log(mm(['a.js', 'a.txt'], ['*.js']));
  27221. * //=> [ 'a.js' ]
  27222. * ```
  27223. * @param {String|Array<string>} `list` List of strings to match.
  27224. * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
  27225. * @param {Object} `options` See available [options](#options)
  27226. * @return {Array} Returns an array of matches
  27227. * @summary false
  27228. * @api public
  27229. */
  27230. const micromatch = (list, patterns, options) => {
  27231. patterns = [].concat(patterns);
  27232. list = [].concat(list);
  27233. let omit = new Set();
  27234. let keep = new Set();
  27235. let items = new Set();
  27236. let negatives = 0;
  27237. let onResult = state => {
  27238. items.add(state.output);
  27239. if (options && options.onResult) {
  27240. options.onResult(state);
  27241. }
  27242. };
  27243. for (let i = 0; i < patterns.length; i++) {
  27244. let isMatch = picomatch(String(patterns[i]), Object.assign(Object.assign({}, options), {}, {
  27245. onResult
  27246. }), true);
  27247. let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
  27248. if (negated) negatives++;
  27249. for (let item of list) {
  27250. let matched = isMatch(item, true);
  27251. let match = negated ? !matched.isMatch : matched.isMatch;
  27252. if (!match) continue;
  27253. if (negated) {
  27254. omit.add(matched.output);
  27255. } else {
  27256. omit.delete(matched.output);
  27257. keep.add(matched.output);
  27258. }
  27259. }
  27260. }
  27261. let result = negatives === patterns.length ? [...items] : [...keep];
  27262. let matches = result.filter(item => !omit.has(item));
  27263. if (options && matches.length === 0) {
  27264. if (options.failglob === true) {
  27265. throw new Error(`No matches found for "${patterns.join(', ')}"`);
  27266. }
  27267. if (options.nonull === true || options.nullglob === true) {
  27268. return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
  27269. }
  27270. }
  27271. return matches;
  27272. };
  27273. /**
  27274. * Backwards compatibility
  27275. */
  27276. micromatch.match = micromatch;
  27277. /**
  27278. * Returns a matcher function from the given glob `pattern` and `options`.
  27279. * The returned function takes a string to match as its only argument and returns
  27280. * true if the string is a match.
  27281. *
  27282. * ```js
  27283. * const mm = require('micromatch');
  27284. * // mm.matcher(pattern[, options]);
  27285. *
  27286. * const isMatch = mm.matcher('*.!(*a)');
  27287. * console.log(isMatch('a.a')); //=> false
  27288. * console.log(isMatch('a.b')); //=> true
  27289. * ```
  27290. * @param {String} `pattern` Glob pattern
  27291. * @param {Object} `options`
  27292. * @return {Function} Returns a matcher function.
  27293. * @api public
  27294. */
  27295. micromatch.matcher = (pattern, options) => picomatch(pattern, options);
  27296. /**
  27297. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  27298. *
  27299. * ```js
  27300. * const mm = require('micromatch');
  27301. * // mm.isMatch(string, patterns[, options]);
  27302. *
  27303. * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
  27304. * console.log(mm.isMatch('a.a', 'b.*')); //=> false
  27305. * ```
  27306. * @param {String} `str` The string to test.
  27307. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  27308. * @param {Object} `[options]` See available [options](#options).
  27309. * @return {Boolean} Returns true if any patterns match `str`
  27310. * @api public
  27311. */
  27312. micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
  27313. /**
  27314. * Backwards compatibility
  27315. */
  27316. micromatch.any = micromatch.isMatch;
  27317. /**
  27318. * Returns a list of strings that _**do not match any**_ of the given `patterns`.
  27319. *
  27320. * ```js
  27321. * const mm = require('micromatch');
  27322. * // mm.not(list, patterns[, options]);
  27323. *
  27324. * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
  27325. * //=> ['b.b', 'c.c']
  27326. * ```
  27327. * @param {Array} `list` Array of strings to match.
  27328. * @param {String|Array} `patterns` One or more glob pattern to use for matching.
  27329. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27330. * @return {Array} Returns an array of strings that **do not match** the given patterns.
  27331. * @api public
  27332. */
  27333. micromatch.not = (list, patterns, options = {}) => {
  27334. patterns = [].concat(patterns).map(String);
  27335. let result = new Set();
  27336. let items = [];
  27337. let onResult = state => {
  27338. if (options.onResult) options.onResult(state);
  27339. items.push(state.output);
  27340. };
  27341. let matches = micromatch(list, patterns, Object.assign(Object.assign({}, options), {}, {
  27342. onResult
  27343. }));
  27344. for (let item of items) {
  27345. if (!matches.includes(item)) {
  27346. result.add(item);
  27347. }
  27348. }
  27349. return [...result];
  27350. };
  27351. /**
  27352. * Returns true if the given `string` contains the given pattern. Similar
  27353. * to [.isMatch](#isMatch) but the pattern can match any part of the string.
  27354. *
  27355. * ```js
  27356. * var mm = require('micromatch');
  27357. * // mm.contains(string, pattern[, options]);
  27358. *
  27359. * console.log(mm.contains('aa/bb/cc', '*b'));
  27360. * //=> true
  27361. * console.log(mm.contains('aa/bb/cc', '*d'));
  27362. * //=> false
  27363. * ```
  27364. * @param {String} `str` The string to match.
  27365. * @param {String|Array} `patterns` Glob pattern to use for matching.
  27366. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27367. * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
  27368. * @api public
  27369. */
  27370. micromatch.contains = (str, pattern, options) => {
  27371. if (typeof str !== 'string') {
  27372. throw new TypeError(`Expected a string: "${util__default['default'].inspect(str)}"`);
  27373. }
  27374. if (Array.isArray(pattern)) {
  27375. return pattern.some(p => micromatch.contains(str, p, options));
  27376. }
  27377. if (typeof pattern === 'string') {
  27378. if (isEmptyString(str) || isEmptyString(pattern)) {
  27379. return false;
  27380. }
  27381. if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) {
  27382. return true;
  27383. }
  27384. }
  27385. return micromatch.isMatch(str, pattern, Object.assign(Object.assign({}, options), {}, {
  27386. contains: true
  27387. }));
  27388. };
  27389. /**
  27390. * Filter the keys of the given object with the given `glob` pattern
  27391. * and `options`. Does not attempt to match nested keys. If you need this feature,
  27392. * use [glob-object][] instead.
  27393. *
  27394. * ```js
  27395. * const mm = require('micromatch');
  27396. * // mm.matchKeys(object, patterns[, options]);
  27397. *
  27398. * const obj = { aa: 'a', ab: 'b', ac: 'c' };
  27399. * console.log(mm.matchKeys(obj, '*b'));
  27400. * //=> { ab: 'b' }
  27401. * ```
  27402. * @param {Object} `object` The object with keys to filter.
  27403. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  27404. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27405. * @return {Object} Returns an object with only keys that match the given patterns.
  27406. * @api public
  27407. */
  27408. micromatch.matchKeys = (obj, patterns, options) => {
  27409. if (!utils$9.isObject(obj)) {
  27410. throw new TypeError('Expected the first argument to be an object');
  27411. }
  27412. let keys = micromatch(Object.keys(obj), patterns, options);
  27413. let res = {};
  27414. for (let key of keys) res[key] = obj[key];
  27415. return res;
  27416. };
  27417. /**
  27418. * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
  27419. *
  27420. * ```js
  27421. * const mm = require('micromatch');
  27422. * // mm.some(list, patterns[, options]);
  27423. *
  27424. * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  27425. * // true
  27426. * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
  27427. * // false
  27428. * ```
  27429. * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
  27430. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  27431. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27432. * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
  27433. * @api public
  27434. */
  27435. micromatch.some = (list, patterns, options) => {
  27436. let items = [].concat(list);
  27437. for (let pattern of [].concat(patterns)) {
  27438. let isMatch = picomatch(String(pattern), options);
  27439. if (items.some(item => isMatch(item))) {
  27440. return true;
  27441. }
  27442. }
  27443. return false;
  27444. };
  27445. /**
  27446. * Returns true if every string in the given `list` matches
  27447. * any of the given glob `patterns`.
  27448. *
  27449. * ```js
  27450. * const mm = require('micromatch');
  27451. * // mm.every(list, patterns[, options]);
  27452. *
  27453. * console.log(mm.every('foo.js', ['foo.js']));
  27454. * // true
  27455. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
  27456. * // true
  27457. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  27458. * // false
  27459. * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
  27460. * // false
  27461. * ```
  27462. * @param {String|Array} `list` The string or array of strings to test.
  27463. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  27464. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27465. * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
  27466. * @api public
  27467. */
  27468. micromatch.every = (list, patterns, options) => {
  27469. let items = [].concat(list);
  27470. for (let pattern of [].concat(patterns)) {
  27471. let isMatch = picomatch(String(pattern), options);
  27472. if (!items.every(item => isMatch(item))) {
  27473. return false;
  27474. }
  27475. }
  27476. return true;
  27477. };
  27478. /**
  27479. * Returns true if **all** of the given `patterns` match
  27480. * the specified string.
  27481. *
  27482. * ```js
  27483. * const mm = require('micromatch');
  27484. * // mm.all(string, patterns[, options]);
  27485. *
  27486. * console.log(mm.all('foo.js', ['foo.js']));
  27487. * // true
  27488. *
  27489. * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
  27490. * // false
  27491. *
  27492. * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
  27493. * // true
  27494. *
  27495. * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
  27496. * // true
  27497. * ```
  27498. * @param {String|Array} `str` The string to test.
  27499. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  27500. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27501. * @return {Boolean} Returns true if any patterns match `str`
  27502. * @api public
  27503. */
  27504. micromatch.all = (str, patterns, options) => {
  27505. if (typeof str !== 'string') {
  27506. throw new TypeError(`Expected a string: "${util__default['default'].inspect(str)}"`);
  27507. }
  27508. return [].concat(patterns).every(p => picomatch(p, options)(str));
  27509. };
  27510. /**
  27511. * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
  27512. *
  27513. * ```js
  27514. * const mm = require('micromatch');
  27515. * // mm.capture(pattern, string[, options]);
  27516. *
  27517. * console.log(mm.capture('test/*.js', 'test/foo.js'));
  27518. * //=> ['foo']
  27519. * console.log(mm.capture('test/*.js', 'foo/bar.css'));
  27520. * //=> null
  27521. * ```
  27522. * @param {String} `glob` Glob pattern to use for matching.
  27523. * @param {String} `input` String to match
  27524. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  27525. * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
  27526. * @api public
  27527. */
  27528. micromatch.capture = (glob, input, options) => {
  27529. let posix = utils$9.isWindows(options);
  27530. let regex = picomatch.makeRe(String(glob), Object.assign(Object.assign({}, options), {}, {
  27531. capture: true
  27532. }));
  27533. let match = regex.exec(posix ? utils$9.toPosixSlashes(input) : input);
  27534. if (match) {
  27535. return match.slice(1).map(v => v === void 0 ? '' : v);
  27536. }
  27537. };
  27538. /**
  27539. * Create a regular expression from the given glob `pattern`.
  27540. *
  27541. * ```js
  27542. * const mm = require('micromatch');
  27543. * // mm.makeRe(pattern[, options]);
  27544. *
  27545. * console.log(mm.makeRe('*.js'));
  27546. * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
  27547. * ```
  27548. * @param {String} `pattern` A glob pattern to convert to regex.
  27549. * @param {Object} `options`
  27550. * @return {RegExp} Returns a regex created from the given pattern.
  27551. * @api public
  27552. */
  27553. micromatch.makeRe = (...args) => picomatch.makeRe(...args);
  27554. /**
  27555. * Scan a glob pattern to separate the pattern into segments. Used
  27556. * by the [split](#split) method.
  27557. *
  27558. * ```js
  27559. * const mm = require('micromatch');
  27560. * const state = mm.scan(pattern[, options]);
  27561. * ```
  27562. * @param {String} `pattern`
  27563. * @param {Object} `options`
  27564. * @return {Object} Returns an object with
  27565. * @api public
  27566. */
  27567. micromatch.scan = (...args) => picomatch.scan(...args);
  27568. /**
  27569. * Parse a glob pattern to create the source string for a regular
  27570. * expression.
  27571. *
  27572. * ```js
  27573. * const mm = require('micromatch');
  27574. * const state = mm(pattern[, options]);
  27575. * ```
  27576. * @param {String} `glob`
  27577. * @param {Object} `options`
  27578. * @return {Object} Returns an object with useful properties and output to be used as regex source string.
  27579. * @api public
  27580. */
  27581. micromatch.parse = (patterns, options) => {
  27582. let res = [];
  27583. for (let pattern of [].concat(patterns || [])) {
  27584. for (let str of braces_1(String(pattern), options)) {
  27585. res.push(picomatch.parse(str, options));
  27586. }
  27587. }
  27588. return res;
  27589. };
  27590. /**
  27591. * Process the given brace `pattern`.
  27592. *
  27593. * ```js
  27594. * const { braces } = require('micromatch');
  27595. * console.log(braces('foo/{a,b,c}/bar'));
  27596. * //=> [ 'foo/(a|b|c)/bar' ]
  27597. *
  27598. * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
  27599. * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
  27600. * ```
  27601. * @param {String} `pattern` String with brace pattern to process.
  27602. * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
  27603. * @return {Array}
  27604. * @api public
  27605. */
  27606. micromatch.braces = (pattern, options) => {
  27607. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  27608. if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
  27609. return [pattern];
  27610. }
  27611. return braces_1(pattern, options);
  27612. };
  27613. /**
  27614. * Expand braces
  27615. */
  27616. micromatch.braceExpand = (pattern, options) => {
  27617. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  27618. return micromatch.braces(pattern, Object.assign(Object.assign({}, options), {}, {
  27619. expand: true
  27620. }));
  27621. };
  27622. /**
  27623. * Expose micromatch
  27624. */
  27625. var micromatch_1 = micromatch;
  27626. var pattern = createCommonjsModule(function (module, exports) {
  27627. Object.defineProperty(exports, "__esModule", {
  27628. value: true
  27629. });
  27630. exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
  27631. const GLOBSTAR = '**';
  27632. const ESCAPE_SYMBOL = '\\';
  27633. const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
  27634. const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
  27635. const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
  27636. const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
  27637. const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
  27638. function isStaticPattern(pattern, options = {}) {
  27639. return !isDynamicPattern(pattern, options);
  27640. }
  27641. exports.isStaticPattern = isStaticPattern;
  27642. function isDynamicPattern(pattern, options = {}) {
  27643. /**
  27644. * A special case with an empty string is necessary for matching patterns that start with a forward slash.
  27645. * An empty string cannot be a dynamic pattern.
  27646. * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
  27647. */
  27648. if (pattern === '') {
  27649. return false;
  27650. }
  27651. /**
  27652. * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
  27653. * filepath directly (without read directory).
  27654. */
  27655. if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
  27656. return true;
  27657. }
  27658. if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
  27659. return true;
  27660. }
  27661. if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
  27662. return true;
  27663. }
  27664. if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
  27665. return true;
  27666. }
  27667. return false;
  27668. }
  27669. exports.isDynamicPattern = isDynamicPattern;
  27670. function convertToPositivePattern(pattern) {
  27671. return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
  27672. }
  27673. exports.convertToPositivePattern = convertToPositivePattern;
  27674. function convertToNegativePattern(pattern) {
  27675. return '!' + pattern;
  27676. }
  27677. exports.convertToNegativePattern = convertToNegativePattern;
  27678. function isNegativePattern(pattern) {
  27679. return pattern.startsWith('!') && pattern[1] !== '(';
  27680. }
  27681. exports.isNegativePattern = isNegativePattern;
  27682. function isPositivePattern(pattern) {
  27683. return !isNegativePattern(pattern);
  27684. }
  27685. exports.isPositivePattern = isPositivePattern;
  27686. function getNegativePatterns(patterns) {
  27687. return patterns.filter(isNegativePattern);
  27688. }
  27689. exports.getNegativePatterns = getNegativePatterns;
  27690. function getPositivePatterns(patterns) {
  27691. return patterns.filter(isPositivePattern);
  27692. }
  27693. exports.getPositivePatterns = getPositivePatterns;
  27694. /**
  27695. * Returns patterns that can be applied inside the current directory.
  27696. *
  27697. * @example
  27698. * // ['./*', '*', 'a/*']
  27699. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  27700. */
  27701. function getPatternsInsideCurrentDirectory(patterns) {
  27702. return patterns.filter(pattern => !isPatternRelatedToParentDirectory(pattern));
  27703. }
  27704. exports.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
  27705. /**
  27706. * Returns patterns to be expanded relative to (outside) the current directory.
  27707. *
  27708. * @example
  27709. * // ['../*', './../*']
  27710. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  27711. */
  27712. function getPatternsOutsideCurrentDirectory(patterns) {
  27713. return patterns.filter(isPatternRelatedToParentDirectory);
  27714. }
  27715. exports.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
  27716. function isPatternRelatedToParentDirectory(pattern) {
  27717. return pattern.startsWith('..') || pattern.startsWith('./..');
  27718. }
  27719. exports.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
  27720. function getBaseDirectory(pattern) {
  27721. return globParent(pattern, {
  27722. flipBackslashes: false
  27723. });
  27724. }
  27725. exports.getBaseDirectory = getBaseDirectory;
  27726. function hasGlobStar(pattern) {
  27727. return pattern.includes(GLOBSTAR);
  27728. }
  27729. exports.hasGlobStar = hasGlobStar;
  27730. function endsWithSlashGlobStar(pattern) {
  27731. return pattern.endsWith('/' + GLOBSTAR);
  27732. }
  27733. exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
  27734. function isAffectDepthOfReadingPattern(pattern) {
  27735. const basename = path__default['default'].basename(pattern);
  27736. return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
  27737. }
  27738. exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
  27739. function expandPatternsWithBraceExpansion(patterns) {
  27740. return patterns.reduce((collection, pattern) => {
  27741. return collection.concat(expandBraceExpansion(pattern));
  27742. }, []);
  27743. }
  27744. exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
  27745. function expandBraceExpansion(pattern) {
  27746. return micromatch_1.braces(pattern, {
  27747. expand: true,
  27748. nodupes: true
  27749. });
  27750. }
  27751. exports.expandBraceExpansion = expandBraceExpansion;
  27752. function getPatternParts(pattern, options) {
  27753. let {
  27754. parts
  27755. } = micromatch_1.scan(pattern, Object.assign(Object.assign({}, options), {
  27756. parts: true
  27757. }));
  27758. /**
  27759. * The scan method returns an empty array in some cases.
  27760. * See micromatch/picomatch#58 for more details.
  27761. */
  27762. if (parts.length === 0) {
  27763. parts = [pattern];
  27764. }
  27765. /**
  27766. * The scan method does not return an empty part for the pattern with a forward slash.
  27767. * This is another part of micromatch/picomatch#58.
  27768. */
  27769. if (parts[0].startsWith('/')) {
  27770. parts[0] = parts[0].slice(1);
  27771. parts.unshift('');
  27772. }
  27773. return parts;
  27774. }
  27775. exports.getPatternParts = getPatternParts;
  27776. function makeRe(pattern, options) {
  27777. return micromatch_1.makeRe(pattern, options);
  27778. }
  27779. exports.makeRe = makeRe;
  27780. function convertPatternsToRe(patterns, options) {
  27781. return patterns.map(pattern => makeRe(pattern, options));
  27782. }
  27783. exports.convertPatternsToRe = convertPatternsToRe;
  27784. function matchAny(entry, patternsRe) {
  27785. return patternsRe.some(patternRe => patternRe.test(entry));
  27786. }
  27787. exports.matchAny = matchAny;
  27788. });
  27789. var stream$4 = createCommonjsModule(function (module, exports) {
  27790. Object.defineProperty(exports, "__esModule", {
  27791. value: true
  27792. });
  27793. exports.merge = void 0;
  27794. function merge(streams) {
  27795. const mergedStream = merge2_1(streams);
  27796. streams.forEach(stream => {
  27797. stream.once('error', error => mergedStream.emit('error', error));
  27798. });
  27799. mergedStream.once('close', () => propagateCloseEventToSources(streams));
  27800. mergedStream.once('end', () => propagateCloseEventToSources(streams));
  27801. return mergedStream;
  27802. }
  27803. exports.merge = merge;
  27804. function propagateCloseEventToSources(streams) {
  27805. streams.forEach(stream => stream.emit('close'));
  27806. }
  27807. });
  27808. var string = createCommonjsModule(function (module, exports) {
  27809. Object.defineProperty(exports, "__esModule", {
  27810. value: true
  27811. });
  27812. exports.isEmpty = exports.isString = void 0;
  27813. function isString(input) {
  27814. return typeof input === 'string';
  27815. }
  27816. exports.isString = isString;
  27817. function isEmpty(input) {
  27818. return input === '';
  27819. }
  27820. exports.isEmpty = isEmpty;
  27821. });
  27822. var utils$8 = createCommonjsModule(function (module, exports) {
  27823. Object.defineProperty(exports, "__esModule", {
  27824. value: true
  27825. });
  27826. exports.string = exports.stream = exports.pattern = exports.path = exports.fs = exports.errno = exports.array = void 0;
  27827. exports.array = array$1;
  27828. exports.errno = errno;
  27829. exports.fs = fs$1;
  27830. exports.path = path_1;
  27831. exports.pattern = pattern;
  27832. exports.stream = stream$4;
  27833. exports.string = string;
  27834. });
  27835. var tasks = createCommonjsModule(function (module, exports) {
  27836. Object.defineProperty(exports, "__esModule", {
  27837. value: true
  27838. });
  27839. exports.convertPatternGroupToTask = exports.convertPatternGroupsToTasks = exports.groupPatternsByBaseDirectory = exports.getNegativePatternsAsPositive = exports.getPositivePatterns = exports.convertPatternsToTasks = exports.generate = void 0;
  27840. function generate(patterns, settings) {
  27841. const positivePatterns = getPositivePatterns(patterns);
  27842. const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
  27843. const staticPatterns = positivePatterns.filter(pattern => utils$8.pattern.isStaticPattern(pattern, settings));
  27844. const dynamicPatterns = positivePatterns.filter(pattern => utils$8.pattern.isDynamicPattern(pattern, settings));
  27845. const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns,
  27846. /* dynamic */
  27847. false);
  27848. const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns,
  27849. /* dynamic */
  27850. true);
  27851. return staticTasks.concat(dynamicTasks);
  27852. }
  27853. exports.generate = generate;
  27854. /**
  27855. * Returns tasks grouped by basic pattern directories.
  27856. *
  27857. * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
  27858. * This is necessary because directory traversal starts at the base directory and goes deeper.
  27859. */
  27860. function convertPatternsToTasks(positive, negative, dynamic) {
  27861. const tasks = [];
  27862. const patternsOutsideCurrentDirectory = utils$8.pattern.getPatternsOutsideCurrentDirectory(positive);
  27863. const patternsInsideCurrentDirectory = utils$8.pattern.getPatternsInsideCurrentDirectory(positive);
  27864. const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
  27865. const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
  27866. tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
  27867. /*
  27868. * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
  27869. * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
  27870. */
  27871. if ('.' in insideCurrentDirectoryGroup) {
  27872. tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
  27873. } else {
  27874. tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
  27875. }
  27876. return tasks;
  27877. }
  27878. exports.convertPatternsToTasks = convertPatternsToTasks;
  27879. function getPositivePatterns(patterns) {
  27880. return utils$8.pattern.getPositivePatterns(patterns);
  27881. }
  27882. exports.getPositivePatterns = getPositivePatterns;
  27883. function getNegativePatternsAsPositive(patterns, ignore) {
  27884. const negative = utils$8.pattern.getNegativePatterns(patterns).concat(ignore);
  27885. const positive = negative.map(utils$8.pattern.convertToPositivePattern);
  27886. return positive;
  27887. }
  27888. exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
  27889. function groupPatternsByBaseDirectory(patterns) {
  27890. const group = {};
  27891. return patterns.reduce((collection, pattern) => {
  27892. const base = utils$8.pattern.getBaseDirectory(pattern);
  27893. if (base in collection) {
  27894. collection[base].push(pattern);
  27895. } else {
  27896. collection[base] = [pattern];
  27897. }
  27898. return collection;
  27899. }, group);
  27900. }
  27901. exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
  27902. function convertPatternGroupsToTasks(positive, negative, dynamic) {
  27903. return Object.keys(positive).map(base => {
  27904. return convertPatternGroupToTask(base, positive[base], negative, dynamic);
  27905. });
  27906. }
  27907. exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
  27908. function convertPatternGroupToTask(base, positive, negative, dynamic) {
  27909. return {
  27910. dynamic,
  27911. positive,
  27912. negative,
  27913. base,
  27914. patterns: [].concat(positive, negative.map(utils$8.pattern.convertToNegativePattern))
  27915. };
  27916. }
  27917. exports.convertPatternGroupToTask = convertPatternGroupToTask;
  27918. });
  27919. var async$4 = createCommonjsModule(function (module, exports) {
  27920. Object.defineProperty(exports, "__esModule", {
  27921. value: true
  27922. });
  27923. exports.read = void 0;
  27924. function read(path, settings, callback) {
  27925. settings.fs.lstat(path, (lstatError, lstat) => {
  27926. if (lstatError !== null) {
  27927. callFailureCallback(callback, lstatError);
  27928. return;
  27929. }
  27930. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  27931. callSuccessCallback(callback, lstat);
  27932. return;
  27933. }
  27934. settings.fs.stat(path, (statError, stat) => {
  27935. if (statError !== null) {
  27936. if (settings.throwErrorOnBrokenSymbolicLink) {
  27937. callFailureCallback(callback, statError);
  27938. return;
  27939. }
  27940. callSuccessCallback(callback, lstat);
  27941. return;
  27942. }
  27943. if (settings.markSymbolicLink) {
  27944. stat.isSymbolicLink = () => true;
  27945. }
  27946. callSuccessCallback(callback, stat);
  27947. });
  27948. });
  27949. }
  27950. exports.read = read;
  27951. function callFailureCallback(callback, error) {
  27952. callback(error);
  27953. }
  27954. function callSuccessCallback(callback, result) {
  27955. callback(null, result);
  27956. }
  27957. });
  27958. var sync$8 = createCommonjsModule(function (module, exports) {
  27959. Object.defineProperty(exports, "__esModule", {
  27960. value: true
  27961. });
  27962. exports.read = void 0;
  27963. function read(path, settings) {
  27964. const lstat = settings.fs.lstatSync(path);
  27965. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  27966. return lstat;
  27967. }
  27968. try {
  27969. const stat = settings.fs.statSync(path);
  27970. if (settings.markSymbolicLink) {
  27971. stat.isSymbolicLink = () => true;
  27972. }
  27973. return stat;
  27974. } catch (error) {
  27975. if (!settings.throwErrorOnBrokenSymbolicLink) {
  27976. return lstat;
  27977. }
  27978. throw error;
  27979. }
  27980. }
  27981. exports.read = read;
  27982. });
  27983. var fs_1$1 = createCommonjsModule(function (module, exports) {
  27984. Object.defineProperty(exports, "__esModule", {
  27985. value: true
  27986. });
  27987. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  27988. exports.FILE_SYSTEM_ADAPTER = {
  27989. lstat: fs__default['default'].lstat,
  27990. stat: fs__default['default'].stat,
  27991. lstatSync: fs__default['default'].lstatSync,
  27992. statSync: fs__default['default'].statSync
  27993. };
  27994. function createFileSystemAdapter(fsMethods) {
  27995. if (fsMethods === undefined) {
  27996. return exports.FILE_SYSTEM_ADAPTER;
  27997. }
  27998. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  27999. }
  28000. exports.createFileSystemAdapter = createFileSystemAdapter;
  28001. });
  28002. class Settings$2 {
  28003. constructor(_options = {}) {
  28004. this._options = _options;
  28005. this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
  28006. this.fs = fs_1$1.createFileSystemAdapter(this._options.fs);
  28007. this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
  28008. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  28009. }
  28010. _getValue(option, value) {
  28011. return option !== null && option !== void 0 ? option : value;
  28012. }
  28013. }
  28014. var _default$l = Settings$2;
  28015. var settings$3 = /*#__PURE__*/Object.defineProperty({
  28016. default: _default$l
  28017. }, '__esModule', {
  28018. value: true
  28019. });
  28020. var out$3 = createCommonjsModule(function (module, exports) {
  28021. Object.defineProperty(exports, "__esModule", {
  28022. value: true
  28023. });
  28024. exports.statSync = exports.stat = exports.Settings = void 0;
  28025. exports.Settings = settings$3.default;
  28026. function stat(path, optionsOrSettingsOrCallback, callback) {
  28027. if (typeof optionsOrSettingsOrCallback === 'function') {
  28028. async$4.read(path, getSettings(), optionsOrSettingsOrCallback);
  28029. return;
  28030. }
  28031. async$4.read(path, getSettings(optionsOrSettingsOrCallback), callback);
  28032. }
  28033. exports.stat = stat;
  28034. function statSync(path, optionsOrSettings) {
  28035. const settings = getSettings(optionsOrSettings);
  28036. return sync$8.read(path, settings);
  28037. }
  28038. exports.statSync = statSync;
  28039. function getSettings(settingsOrOptions = {}) {
  28040. if (settingsOrOptions instanceof settings$3.default) {
  28041. return settingsOrOptions;
  28042. }
  28043. return new settings$3.default(settingsOrOptions);
  28044. }
  28045. });
  28046. /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  28047. let promise$1;
  28048. var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : global) // reuse resolved promise, and allocate it lazily
  28049. : cb => (promise$1 || (promise$1 = Promise.resolve())).then(cb).catch(err => setTimeout(() => {
  28050. throw err;
  28051. }, 0));
  28052. /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  28053. var runParallel_1 = runParallel;
  28054. function runParallel(tasks, cb) {
  28055. let results, pending, keys;
  28056. let isSync = true;
  28057. if (Array.isArray(tasks)) {
  28058. results = [];
  28059. pending = tasks.length;
  28060. } else {
  28061. keys = Object.keys(tasks);
  28062. results = {};
  28063. pending = keys.length;
  28064. }
  28065. function done(err) {
  28066. function end() {
  28067. if (cb) cb(err, results);
  28068. cb = null;
  28069. }
  28070. if (isSync) queueMicrotask_1(end);else end();
  28071. }
  28072. function each(i, err, result) {
  28073. results[i] = result;
  28074. if (--pending === 0 || err) {
  28075. done(err);
  28076. }
  28077. }
  28078. if (!pending) {
  28079. // empty
  28080. done(null);
  28081. } else if (keys) {
  28082. // object
  28083. keys.forEach(function (key) {
  28084. tasks[key](function (err, result) {
  28085. each(key, err, result);
  28086. });
  28087. });
  28088. } else {
  28089. // array
  28090. tasks.forEach(function (task, i) {
  28091. task(function (err, result) {
  28092. each(i, err, result);
  28093. });
  28094. });
  28095. }
  28096. isSync = false;
  28097. }
  28098. var constants = createCommonjsModule(function (module, exports) {
  28099. Object.defineProperty(exports, "__esModule", {
  28100. value: true
  28101. });
  28102. exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
  28103. const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
  28104. if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) {
  28105. throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);
  28106. }
  28107. const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
  28108. const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
  28109. const SUPPORTED_MAJOR_VERSION = 10;
  28110. const SUPPORTED_MINOR_VERSION = 10;
  28111. const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
  28112. const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
  28113. /**
  28114. * IS `true` for Node.js 10.10 and greater.
  28115. */
  28116. exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
  28117. });
  28118. var fs = createCommonjsModule(function (module, exports) {
  28119. Object.defineProperty(exports, "__esModule", {
  28120. value: true
  28121. });
  28122. exports.createDirentFromStats = void 0;
  28123. class DirentFromStats {
  28124. constructor(name, stats) {
  28125. this.name = name;
  28126. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  28127. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  28128. this.isDirectory = stats.isDirectory.bind(stats);
  28129. this.isFIFO = stats.isFIFO.bind(stats);
  28130. this.isFile = stats.isFile.bind(stats);
  28131. this.isSocket = stats.isSocket.bind(stats);
  28132. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  28133. }
  28134. }
  28135. function createDirentFromStats(name, stats) {
  28136. return new DirentFromStats(name, stats);
  28137. }
  28138. exports.createDirentFromStats = createDirentFromStats;
  28139. });
  28140. var utils$7 = createCommonjsModule(function (module, exports) {
  28141. Object.defineProperty(exports, "__esModule", {
  28142. value: true
  28143. });
  28144. exports.fs = void 0;
  28145. exports.fs = fs;
  28146. });
  28147. var common$1 = createCommonjsModule(function (module, exports) {
  28148. Object.defineProperty(exports, "__esModule", {
  28149. value: true
  28150. });
  28151. exports.joinPathSegments = void 0;
  28152. function joinPathSegments(a, b, separator) {
  28153. /**
  28154. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  28155. */
  28156. if (a.endsWith(separator)) {
  28157. return a + b;
  28158. }
  28159. return a + separator + b;
  28160. }
  28161. exports.joinPathSegments = joinPathSegments;
  28162. });
  28163. var async$3 = createCommonjsModule(function (module, exports) {
  28164. Object.defineProperty(exports, "__esModule", {
  28165. value: true
  28166. });
  28167. exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
  28168. function read(directory, settings, callback) {
  28169. if (!settings.stats && constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  28170. readdirWithFileTypes(directory, settings, callback);
  28171. return;
  28172. }
  28173. readdir(directory, settings, callback);
  28174. }
  28175. exports.read = read;
  28176. function readdirWithFileTypes(directory, settings, callback) {
  28177. settings.fs.readdir(directory, {
  28178. withFileTypes: true
  28179. }, (readdirError, dirents) => {
  28180. if (readdirError !== null) {
  28181. callFailureCallback(callback, readdirError);
  28182. return;
  28183. }
  28184. const entries = dirents.map(dirent => ({
  28185. dirent,
  28186. name: dirent.name,
  28187. path: common$1.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  28188. }));
  28189. if (!settings.followSymbolicLinks) {
  28190. callSuccessCallback(callback, entries);
  28191. return;
  28192. }
  28193. const tasks = entries.map(entry => makeRplTaskEntry(entry, settings));
  28194. runParallel_1(tasks, (rplError, rplEntries) => {
  28195. if (rplError !== null) {
  28196. callFailureCallback(callback, rplError);
  28197. return;
  28198. }
  28199. callSuccessCallback(callback, rplEntries);
  28200. });
  28201. });
  28202. }
  28203. exports.readdirWithFileTypes = readdirWithFileTypes;
  28204. function makeRplTaskEntry(entry, settings) {
  28205. return done => {
  28206. if (!entry.dirent.isSymbolicLink()) {
  28207. done(null, entry);
  28208. return;
  28209. }
  28210. settings.fs.stat(entry.path, (statError, stats) => {
  28211. if (statError !== null) {
  28212. if (settings.throwErrorOnBrokenSymbolicLink) {
  28213. done(statError);
  28214. return;
  28215. }
  28216. done(null, entry);
  28217. return;
  28218. }
  28219. entry.dirent = utils$7.fs.createDirentFromStats(entry.name, stats);
  28220. done(null, entry);
  28221. });
  28222. };
  28223. }
  28224. function readdir(directory, settings, callback) {
  28225. settings.fs.readdir(directory, (readdirError, names) => {
  28226. if (readdirError !== null) {
  28227. callFailureCallback(callback, readdirError);
  28228. return;
  28229. }
  28230. const tasks = names.map(name => {
  28231. const path = common$1.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  28232. return done => {
  28233. out$3.stat(path, settings.fsStatSettings, (error, stats) => {
  28234. if (error !== null) {
  28235. done(error);
  28236. return;
  28237. }
  28238. const entry = {
  28239. name,
  28240. path,
  28241. dirent: utils$7.fs.createDirentFromStats(name, stats)
  28242. };
  28243. if (settings.stats) {
  28244. entry.stats = stats;
  28245. }
  28246. done(null, entry);
  28247. });
  28248. };
  28249. });
  28250. runParallel_1(tasks, (rplError, entries) => {
  28251. if (rplError !== null) {
  28252. callFailureCallback(callback, rplError);
  28253. return;
  28254. }
  28255. callSuccessCallback(callback, entries);
  28256. });
  28257. });
  28258. }
  28259. exports.readdir = readdir;
  28260. function callFailureCallback(callback, error) {
  28261. callback(error);
  28262. }
  28263. function callSuccessCallback(callback, result) {
  28264. callback(null, result);
  28265. }
  28266. });
  28267. var sync$7 = createCommonjsModule(function (module, exports) {
  28268. Object.defineProperty(exports, "__esModule", {
  28269. value: true
  28270. });
  28271. exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
  28272. function read(directory, settings) {
  28273. if (!settings.stats && constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  28274. return readdirWithFileTypes(directory, settings);
  28275. }
  28276. return readdir(directory, settings);
  28277. }
  28278. exports.read = read;
  28279. function readdirWithFileTypes(directory, settings) {
  28280. const dirents = settings.fs.readdirSync(directory, {
  28281. withFileTypes: true
  28282. });
  28283. return dirents.map(dirent => {
  28284. const entry = {
  28285. dirent,
  28286. name: dirent.name,
  28287. path: common$1.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  28288. };
  28289. if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
  28290. try {
  28291. const stats = settings.fs.statSync(entry.path);
  28292. entry.dirent = utils$7.fs.createDirentFromStats(entry.name, stats);
  28293. } catch (error) {
  28294. if (settings.throwErrorOnBrokenSymbolicLink) {
  28295. throw error;
  28296. }
  28297. }
  28298. }
  28299. return entry;
  28300. });
  28301. }
  28302. exports.readdirWithFileTypes = readdirWithFileTypes;
  28303. function readdir(directory, settings) {
  28304. const names = settings.fs.readdirSync(directory);
  28305. return names.map(name => {
  28306. const entryPath = common$1.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  28307. const stats = out$3.statSync(entryPath, settings.fsStatSettings);
  28308. const entry = {
  28309. name,
  28310. path: entryPath,
  28311. dirent: utils$7.fs.createDirentFromStats(name, stats)
  28312. };
  28313. if (settings.stats) {
  28314. entry.stats = stats;
  28315. }
  28316. return entry;
  28317. });
  28318. }
  28319. exports.readdir = readdir;
  28320. });
  28321. var fs_1 = createCommonjsModule(function (module, exports) {
  28322. Object.defineProperty(exports, "__esModule", {
  28323. value: true
  28324. });
  28325. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  28326. exports.FILE_SYSTEM_ADAPTER = {
  28327. lstat: fs__default['default'].lstat,
  28328. stat: fs__default['default'].stat,
  28329. lstatSync: fs__default['default'].lstatSync,
  28330. statSync: fs__default['default'].statSync,
  28331. readdir: fs__default['default'].readdir,
  28332. readdirSync: fs__default['default'].readdirSync
  28333. };
  28334. function createFileSystemAdapter(fsMethods) {
  28335. if (fsMethods === undefined) {
  28336. return exports.FILE_SYSTEM_ADAPTER;
  28337. }
  28338. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  28339. }
  28340. exports.createFileSystemAdapter = createFileSystemAdapter;
  28341. });
  28342. class Settings$1 {
  28343. constructor(_options = {}) {
  28344. this._options = _options;
  28345. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
  28346. this.fs = fs_1.createFileSystemAdapter(this._options.fs);
  28347. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path__default['default'].sep);
  28348. this.stats = this._getValue(this._options.stats, false);
  28349. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  28350. this.fsStatSettings = new out$3.Settings({
  28351. followSymbolicLink: this.followSymbolicLinks,
  28352. fs: this.fs,
  28353. throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
  28354. });
  28355. }
  28356. _getValue(option, value) {
  28357. return option !== null && option !== void 0 ? option : value;
  28358. }
  28359. }
  28360. var _default$k = Settings$1;
  28361. var settings$2 = /*#__PURE__*/Object.defineProperty({
  28362. default: _default$k
  28363. }, '__esModule', {
  28364. value: true
  28365. });
  28366. var out$2 = createCommonjsModule(function (module, exports) {
  28367. Object.defineProperty(exports, "__esModule", {
  28368. value: true
  28369. });
  28370. exports.Settings = exports.scandirSync = exports.scandir = void 0;
  28371. exports.Settings = settings$2.default;
  28372. function scandir(path, optionsOrSettingsOrCallback, callback) {
  28373. if (typeof optionsOrSettingsOrCallback === 'function') {
  28374. async$3.read(path, getSettings(), optionsOrSettingsOrCallback);
  28375. return;
  28376. }
  28377. async$3.read(path, getSettings(optionsOrSettingsOrCallback), callback);
  28378. }
  28379. exports.scandir = scandir;
  28380. function scandirSync(path, optionsOrSettings) {
  28381. const settings = getSettings(optionsOrSettings);
  28382. return sync$7.read(path, settings);
  28383. }
  28384. exports.scandirSync = scandirSync;
  28385. function getSettings(settingsOrOptions = {}) {
  28386. if (settingsOrOptions instanceof settings$2.default) {
  28387. return settingsOrOptions;
  28388. }
  28389. return new settings$2.default(settingsOrOptions);
  28390. }
  28391. });
  28392. function reusify(Constructor) {
  28393. var head = new Constructor();
  28394. var tail = head;
  28395. function get() {
  28396. var current = head;
  28397. if (current.next) {
  28398. head = current.next;
  28399. } else {
  28400. head = new Constructor();
  28401. tail = head;
  28402. }
  28403. current.next = null;
  28404. return current;
  28405. }
  28406. function release(obj) {
  28407. tail.next = obj;
  28408. tail = obj;
  28409. }
  28410. return {
  28411. get: get,
  28412. release: release
  28413. };
  28414. }
  28415. var reusify_1 = reusify;
  28416. /* eslint-disable no-var */
  28417. function fastqueue(context, worker, concurrency) {
  28418. if (typeof context === 'function') {
  28419. concurrency = worker;
  28420. worker = context;
  28421. context = null;
  28422. }
  28423. if (concurrency < 1) {
  28424. throw new Error('fastqueue concurrency must be greater than 1');
  28425. }
  28426. var cache = reusify_1(Task);
  28427. var queueHead = null;
  28428. var queueTail = null;
  28429. var _running = 0;
  28430. var errorHandler = null;
  28431. var self = {
  28432. push: push,
  28433. drain: noop,
  28434. saturated: noop,
  28435. pause: pause,
  28436. paused: false,
  28437. concurrency: concurrency,
  28438. running: running,
  28439. resume: resume,
  28440. idle: idle,
  28441. length: length,
  28442. getQueue: getQueue,
  28443. unshift: unshift,
  28444. empty: noop,
  28445. kill: kill,
  28446. killAndDrain: killAndDrain,
  28447. error: error
  28448. };
  28449. return self;
  28450. function running() {
  28451. return _running;
  28452. }
  28453. function pause() {
  28454. self.paused = true;
  28455. }
  28456. function length() {
  28457. var current = queueHead;
  28458. var counter = 0;
  28459. while (current) {
  28460. current = current.next;
  28461. counter++;
  28462. }
  28463. return counter;
  28464. }
  28465. function getQueue() {
  28466. var current = queueHead;
  28467. var tasks = [];
  28468. while (current) {
  28469. tasks.push(current.value);
  28470. current = current.next;
  28471. }
  28472. return tasks;
  28473. }
  28474. function resume() {
  28475. if (!self.paused) return;
  28476. self.paused = false;
  28477. for (var i = 0; i < self.concurrency; i++) {
  28478. _running++;
  28479. release();
  28480. }
  28481. }
  28482. function idle() {
  28483. return _running === 0 && self.length() === 0;
  28484. }
  28485. function push(value, done) {
  28486. var current = cache.get();
  28487. current.context = context;
  28488. current.release = release;
  28489. current.value = value;
  28490. current.callback = done || noop;
  28491. current.errorHandler = errorHandler;
  28492. if (_running === self.concurrency || self.paused) {
  28493. if (queueTail) {
  28494. queueTail.next = current;
  28495. queueTail = current;
  28496. } else {
  28497. queueHead = current;
  28498. queueTail = current;
  28499. self.saturated();
  28500. }
  28501. } else {
  28502. _running++;
  28503. worker.call(context, current.value, current.worked);
  28504. }
  28505. }
  28506. function unshift(value, done) {
  28507. var current = cache.get();
  28508. current.context = context;
  28509. current.release = release;
  28510. current.value = value;
  28511. current.callback = done || noop;
  28512. if (_running === self.concurrency || self.paused) {
  28513. if (queueHead) {
  28514. current.next = queueHead;
  28515. queueHead = current;
  28516. } else {
  28517. queueHead = current;
  28518. queueTail = current;
  28519. self.saturated();
  28520. }
  28521. } else {
  28522. _running++;
  28523. worker.call(context, current.value, current.worked);
  28524. }
  28525. }
  28526. function release(holder) {
  28527. if (holder) {
  28528. cache.release(holder);
  28529. }
  28530. var next = queueHead;
  28531. if (next) {
  28532. if (!self.paused) {
  28533. if (queueTail === queueHead) {
  28534. queueTail = null;
  28535. }
  28536. queueHead = next.next;
  28537. next.next = null;
  28538. worker.call(context, next.value, next.worked);
  28539. if (queueTail === null) {
  28540. self.empty();
  28541. }
  28542. } else {
  28543. _running--;
  28544. }
  28545. } else if (--_running === 0) {
  28546. self.drain();
  28547. }
  28548. }
  28549. function kill() {
  28550. queueHead = null;
  28551. queueTail = null;
  28552. self.drain = noop;
  28553. }
  28554. function killAndDrain() {
  28555. queueHead = null;
  28556. queueTail = null;
  28557. self.drain();
  28558. self.drain = noop;
  28559. }
  28560. function error(handler) {
  28561. errorHandler = handler;
  28562. }
  28563. }
  28564. function noop() {}
  28565. function Task() {
  28566. this.value = null;
  28567. this.callback = noop;
  28568. this.next = null;
  28569. this.release = noop;
  28570. this.context = null;
  28571. this.errorHandler = null;
  28572. var self = this;
  28573. this.worked = function worked(err, result) {
  28574. var callback = self.callback;
  28575. var errorHandler = self.errorHandler;
  28576. var val = self.value;
  28577. self.value = null;
  28578. self.callback = noop;
  28579. if (self.errorHandler) {
  28580. errorHandler(err, val);
  28581. }
  28582. callback.call(self.context, err, result);
  28583. self.release(self);
  28584. };
  28585. }
  28586. function queueAsPromised(context, worker, concurrency) {
  28587. if (typeof context === 'function') {
  28588. concurrency = worker;
  28589. worker = context;
  28590. context = null;
  28591. }
  28592. function asyncWrapper(arg, cb) {
  28593. worker.call(this, arg).then(function (res) {
  28594. cb(null, res);
  28595. }, cb);
  28596. }
  28597. var queue = fastqueue(context, asyncWrapper, concurrency);
  28598. var pushCb = queue.push;
  28599. var unshiftCb = queue.unshift;
  28600. queue.push = push;
  28601. queue.unshift = unshift;
  28602. return queue;
  28603. function push(value) {
  28604. var p = new Promise(function (resolve, reject) {
  28605. pushCb(value, function (err, result) {
  28606. if (err) {
  28607. reject(err);
  28608. return;
  28609. }
  28610. resolve(result);
  28611. });
  28612. }); // Let's fork the promise chain to
  28613. // make the error bubble up to the user but
  28614. // not lead to a unhandledRejection
  28615. p.catch(noop);
  28616. return p;
  28617. }
  28618. function unshift(value) {
  28619. var p = new Promise(function (resolve, reject) {
  28620. unshiftCb(value, function (err, result) {
  28621. if (err) {
  28622. reject(err);
  28623. return;
  28624. }
  28625. resolve(result);
  28626. });
  28627. }); // Let's fork the promise chain to
  28628. // make the error bubble up to the user but
  28629. // not lead to a unhandledRejection
  28630. p.catch(noop);
  28631. return p;
  28632. }
  28633. }
  28634. var queue = fastqueue;
  28635. var promise = queueAsPromised;
  28636. queue.promise = promise;
  28637. var common = createCommonjsModule(function (module, exports) {
  28638. Object.defineProperty(exports, "__esModule", {
  28639. value: true
  28640. });
  28641. exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0;
  28642. function isFatalError(settings, error) {
  28643. if (settings.errorFilter === null) {
  28644. return true;
  28645. }
  28646. return !settings.errorFilter(error);
  28647. }
  28648. exports.isFatalError = isFatalError;
  28649. function isAppliedFilter(filter, value) {
  28650. return filter === null || filter(value);
  28651. }
  28652. exports.isAppliedFilter = isAppliedFilter;
  28653. function replacePathSegmentSeparator(filepath, separator) {
  28654. return filepath.split(/[/\\]/).join(separator);
  28655. }
  28656. exports.replacePathSegmentSeparator = replacePathSegmentSeparator;
  28657. function joinPathSegments(a, b, separator) {
  28658. if (a === '') {
  28659. return b;
  28660. }
  28661. /**
  28662. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  28663. */
  28664. if (a.endsWith(separator)) {
  28665. return a + b;
  28666. }
  28667. return a + separator + b;
  28668. }
  28669. exports.joinPathSegments = joinPathSegments;
  28670. });
  28671. class Reader$1 {
  28672. constructor(_root, _settings) {
  28673. this._root = _root;
  28674. this._settings = _settings;
  28675. this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
  28676. }
  28677. }
  28678. var _default$j = Reader$1;
  28679. var reader$1 = /*#__PURE__*/Object.defineProperty({
  28680. default: _default$j
  28681. }, '__esModule', {
  28682. value: true
  28683. });
  28684. class AsyncReader extends reader$1.default {
  28685. constructor(_root, _settings) {
  28686. super(_root, _settings);
  28687. this._settings = _settings;
  28688. this._scandir = out$2.scandir;
  28689. this._emitter = new events_1__default['default'].EventEmitter();
  28690. this._queue = queue(this._worker.bind(this), this._settings.concurrency);
  28691. this._isFatalError = false;
  28692. this._isDestroyed = false;
  28693. this._queue.drain = () => {
  28694. if (!this._isFatalError) {
  28695. this._emitter.emit('end');
  28696. }
  28697. };
  28698. }
  28699. read() {
  28700. this._isFatalError = false;
  28701. this._isDestroyed = false;
  28702. setImmediate(() => {
  28703. this._pushToQueue(this._root, this._settings.basePath);
  28704. });
  28705. return this._emitter;
  28706. }
  28707. get isDestroyed() {
  28708. return this._isDestroyed;
  28709. }
  28710. destroy() {
  28711. if (this._isDestroyed) {
  28712. throw new Error('The reader is already destroyed');
  28713. }
  28714. this._isDestroyed = true;
  28715. this._queue.killAndDrain();
  28716. }
  28717. onEntry(callback) {
  28718. this._emitter.on('entry', callback);
  28719. }
  28720. onError(callback) {
  28721. this._emitter.once('error', callback);
  28722. }
  28723. onEnd(callback) {
  28724. this._emitter.once('end', callback);
  28725. }
  28726. _pushToQueue(directory, base) {
  28727. const queueItem = {
  28728. directory,
  28729. base
  28730. };
  28731. this._queue.push(queueItem, error => {
  28732. if (error !== null) {
  28733. this._handleError(error);
  28734. }
  28735. });
  28736. }
  28737. _worker(item, done) {
  28738. this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
  28739. if (error !== null) {
  28740. done(error, undefined);
  28741. return;
  28742. }
  28743. for (const entry of entries) {
  28744. this._handleEntry(entry, item.base);
  28745. }
  28746. done(null, undefined);
  28747. });
  28748. }
  28749. _handleError(error) {
  28750. if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
  28751. return;
  28752. }
  28753. this._isFatalError = true;
  28754. this._isDestroyed = true;
  28755. this._emitter.emit('error', error);
  28756. }
  28757. _handleEntry(entry, base) {
  28758. if (this._isDestroyed || this._isFatalError) {
  28759. return;
  28760. }
  28761. const fullpath = entry.path;
  28762. if (base !== undefined) {
  28763. entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  28764. }
  28765. if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
  28766. this._emitEntry(entry);
  28767. }
  28768. if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
  28769. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  28770. }
  28771. }
  28772. _emitEntry(entry) {
  28773. this._emitter.emit('entry', entry);
  28774. }
  28775. }
  28776. var _default$i = AsyncReader;
  28777. var async$2 = /*#__PURE__*/Object.defineProperty({
  28778. default: _default$i
  28779. }, '__esModule', {
  28780. value: true
  28781. });
  28782. class AsyncProvider {
  28783. constructor(_root, _settings) {
  28784. this._root = _root;
  28785. this._settings = _settings;
  28786. this._reader = new async$2.default(this._root, this._settings);
  28787. this._storage = [];
  28788. }
  28789. read(callback) {
  28790. this._reader.onError(error => {
  28791. callFailureCallback(callback, error);
  28792. });
  28793. this._reader.onEntry(entry => {
  28794. this._storage.push(entry);
  28795. });
  28796. this._reader.onEnd(() => {
  28797. callSuccessCallback(callback, this._storage);
  28798. });
  28799. this._reader.read();
  28800. }
  28801. }
  28802. var _default$h = AsyncProvider;
  28803. function callFailureCallback(callback, error) {
  28804. callback(error);
  28805. }
  28806. function callSuccessCallback(callback, entries) {
  28807. callback(null, entries);
  28808. }
  28809. var async$1 = /*#__PURE__*/Object.defineProperty({
  28810. default: _default$h
  28811. }, '__esModule', {
  28812. value: true
  28813. });
  28814. class StreamProvider {
  28815. constructor(_root, _settings) {
  28816. this._root = _root;
  28817. this._settings = _settings;
  28818. this._reader = new async$2.default(this._root, this._settings);
  28819. this._stream = new stream_1__default['default'].Readable({
  28820. objectMode: true,
  28821. read: () => {},
  28822. destroy: () => {
  28823. if (!this._reader.isDestroyed) {
  28824. this._reader.destroy();
  28825. }
  28826. }
  28827. });
  28828. }
  28829. read() {
  28830. this._reader.onError(error => {
  28831. this._stream.emit('error', error);
  28832. });
  28833. this._reader.onEntry(entry => {
  28834. this._stream.push(entry);
  28835. });
  28836. this._reader.onEnd(() => {
  28837. this._stream.push(null);
  28838. });
  28839. this._reader.read();
  28840. return this._stream;
  28841. }
  28842. }
  28843. var _default$g = StreamProvider;
  28844. var stream$3 = /*#__PURE__*/Object.defineProperty({
  28845. default: _default$g
  28846. }, '__esModule', {
  28847. value: true
  28848. });
  28849. class SyncReader extends reader$1.default {
  28850. constructor() {
  28851. super(...arguments);
  28852. this._scandir = out$2.scandirSync;
  28853. this._storage = [];
  28854. this._queue = new Set();
  28855. }
  28856. read() {
  28857. this._pushToQueue(this._root, this._settings.basePath);
  28858. this._handleQueue();
  28859. return this._storage;
  28860. }
  28861. _pushToQueue(directory, base) {
  28862. this._queue.add({
  28863. directory,
  28864. base
  28865. });
  28866. }
  28867. _handleQueue() {
  28868. for (const item of this._queue.values()) {
  28869. this._handleDirectory(item.directory, item.base);
  28870. }
  28871. }
  28872. _handleDirectory(directory, base) {
  28873. try {
  28874. const entries = this._scandir(directory, this._settings.fsScandirSettings);
  28875. for (const entry of entries) {
  28876. this._handleEntry(entry, base);
  28877. }
  28878. } catch (error) {
  28879. this._handleError(error);
  28880. }
  28881. }
  28882. _handleError(error) {
  28883. if (!common.isFatalError(this._settings, error)) {
  28884. return;
  28885. }
  28886. throw error;
  28887. }
  28888. _handleEntry(entry, base) {
  28889. const fullpath = entry.path;
  28890. if (base !== undefined) {
  28891. entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  28892. }
  28893. if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
  28894. this._pushToStorage(entry);
  28895. }
  28896. if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
  28897. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  28898. }
  28899. }
  28900. _pushToStorage(entry) {
  28901. this._storage.push(entry);
  28902. }
  28903. }
  28904. var _default$f = SyncReader;
  28905. var sync$6 = /*#__PURE__*/Object.defineProperty({
  28906. default: _default$f
  28907. }, '__esModule', {
  28908. value: true
  28909. });
  28910. class SyncProvider {
  28911. constructor(_root, _settings) {
  28912. this._root = _root;
  28913. this._settings = _settings;
  28914. this._reader = new sync$6.default(this._root, this._settings);
  28915. }
  28916. read() {
  28917. return this._reader.read();
  28918. }
  28919. }
  28920. var _default$e = SyncProvider;
  28921. var sync$5 = /*#__PURE__*/Object.defineProperty({
  28922. default: _default$e
  28923. }, '__esModule', {
  28924. value: true
  28925. });
  28926. class Settings {
  28927. constructor(_options = {}) {
  28928. this._options = _options;
  28929. this.basePath = this._getValue(this._options.basePath, undefined);
  28930. this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
  28931. this.deepFilter = this._getValue(this._options.deepFilter, null);
  28932. this.entryFilter = this._getValue(this._options.entryFilter, null);
  28933. this.errorFilter = this._getValue(this._options.errorFilter, null);
  28934. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path__default['default'].sep);
  28935. this.fsScandirSettings = new out$2.Settings({
  28936. followSymbolicLinks: this._options.followSymbolicLinks,
  28937. fs: this._options.fs,
  28938. pathSegmentSeparator: this._options.pathSegmentSeparator,
  28939. stats: this._options.stats,
  28940. throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
  28941. });
  28942. }
  28943. _getValue(option, value) {
  28944. return option !== null && option !== void 0 ? option : value;
  28945. }
  28946. }
  28947. var _default$d = Settings;
  28948. var settings$1 = /*#__PURE__*/Object.defineProperty({
  28949. default: _default$d
  28950. }, '__esModule', {
  28951. value: true
  28952. });
  28953. var out$1 = createCommonjsModule(function (module, exports) {
  28954. Object.defineProperty(exports, "__esModule", {
  28955. value: true
  28956. });
  28957. exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0;
  28958. exports.Settings = settings$1.default;
  28959. function walk(directory, optionsOrSettingsOrCallback, callback) {
  28960. if (typeof optionsOrSettingsOrCallback === 'function') {
  28961. new async$1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
  28962. return;
  28963. }
  28964. new async$1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
  28965. }
  28966. exports.walk = walk;
  28967. function walkSync(directory, optionsOrSettings) {
  28968. const settings = getSettings(optionsOrSettings);
  28969. const provider = new sync$5.default(directory, settings);
  28970. return provider.read();
  28971. }
  28972. exports.walkSync = walkSync;
  28973. function walkStream(directory, optionsOrSettings) {
  28974. const settings = getSettings(optionsOrSettings);
  28975. const provider = new stream$3.default(directory, settings);
  28976. return provider.read();
  28977. }
  28978. exports.walkStream = walkStream;
  28979. function getSettings(settingsOrOptions = {}) {
  28980. if (settingsOrOptions instanceof settings$1.default) {
  28981. return settingsOrOptions;
  28982. }
  28983. return new settings$1.default(settingsOrOptions);
  28984. }
  28985. });
  28986. class Reader {
  28987. constructor(_settings) {
  28988. this._settings = _settings;
  28989. this._fsStatSettings = new out$3.Settings({
  28990. followSymbolicLink: this._settings.followSymbolicLinks,
  28991. fs: this._settings.fs,
  28992. throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
  28993. });
  28994. }
  28995. _getFullEntryPath(filepath) {
  28996. return path__default['default'].resolve(this._settings.cwd, filepath);
  28997. }
  28998. _makeEntry(stats, pattern) {
  28999. const entry = {
  29000. name: pattern,
  29001. path: pattern,
  29002. dirent: utils$8.fs.createDirentFromStats(pattern, stats)
  29003. };
  29004. if (this._settings.stats) {
  29005. entry.stats = stats;
  29006. }
  29007. return entry;
  29008. }
  29009. _isFatalError(error) {
  29010. return !utils$8.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
  29011. }
  29012. }
  29013. var _default$c = Reader;
  29014. var reader = /*#__PURE__*/Object.defineProperty({
  29015. default: _default$c
  29016. }, '__esModule', {
  29017. value: true
  29018. });
  29019. class ReaderStream extends reader.default {
  29020. constructor() {
  29021. super(...arguments);
  29022. this._walkStream = out$1.walkStream;
  29023. this._stat = out$3.stat;
  29024. }
  29025. dynamic(root, options) {
  29026. return this._walkStream(root, options);
  29027. }
  29028. static(patterns, options) {
  29029. const filepaths = patterns.map(this._getFullEntryPath, this);
  29030. const stream = new stream_1__default['default'].PassThrough({
  29031. objectMode: true
  29032. });
  29033. stream._write = (index, _enc, done) => {
  29034. return this._getEntry(filepaths[index], patterns[index], options).then(entry => {
  29035. if (entry !== null && options.entryFilter(entry)) {
  29036. stream.push(entry);
  29037. }
  29038. if (index === filepaths.length - 1) {
  29039. stream.end();
  29040. }
  29041. done();
  29042. }).catch(done);
  29043. };
  29044. for (let i = 0; i < filepaths.length; i++) {
  29045. stream.write(i);
  29046. }
  29047. return stream;
  29048. }
  29049. _getEntry(filepath, pattern, options) {
  29050. return this._getStat(filepath).then(stats => this._makeEntry(stats, pattern)).catch(error => {
  29051. if (options.errorFilter(error)) {
  29052. return null;
  29053. }
  29054. throw error;
  29055. });
  29056. }
  29057. _getStat(filepath) {
  29058. return new Promise((resolve, reject) => {
  29059. this._stat(filepath, this._fsStatSettings, (error, stats) => {
  29060. return error === null ? resolve(stats) : reject(error);
  29061. });
  29062. });
  29063. }
  29064. }
  29065. var _default$b = ReaderStream;
  29066. var stream$2 = /*#__PURE__*/Object.defineProperty({
  29067. default: _default$b
  29068. }, '__esModule', {
  29069. value: true
  29070. });
  29071. class Matcher {
  29072. constructor(_patterns, _settings, _micromatchOptions) {
  29073. this._patterns = _patterns;
  29074. this._settings = _settings;
  29075. this._micromatchOptions = _micromatchOptions;
  29076. this._storage = [];
  29077. this._fillStorage();
  29078. }
  29079. _fillStorage() {
  29080. /**
  29081. * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
  29082. * So, before expand patterns with brace expansion into separated patterns.
  29083. */
  29084. const patterns = utils$8.pattern.expandPatternsWithBraceExpansion(this._patterns);
  29085. for (const pattern of patterns) {
  29086. const segments = this._getPatternSegments(pattern);
  29087. const sections = this._splitSegmentsIntoSections(segments);
  29088. this._storage.push({
  29089. complete: sections.length <= 1,
  29090. pattern,
  29091. segments,
  29092. sections
  29093. });
  29094. }
  29095. }
  29096. _getPatternSegments(pattern) {
  29097. const parts = utils$8.pattern.getPatternParts(pattern, this._micromatchOptions);
  29098. return parts.map(part => {
  29099. const dynamic = utils$8.pattern.isDynamicPattern(part, this._settings);
  29100. if (!dynamic) {
  29101. return {
  29102. dynamic: false,
  29103. pattern: part
  29104. };
  29105. }
  29106. return {
  29107. dynamic: true,
  29108. pattern: part,
  29109. patternRe: utils$8.pattern.makeRe(part, this._micromatchOptions)
  29110. };
  29111. });
  29112. }
  29113. _splitSegmentsIntoSections(segments) {
  29114. return utils$8.array.splitWhen(segments, segment => segment.dynamic && utils$8.pattern.hasGlobStar(segment.pattern));
  29115. }
  29116. }
  29117. var _default$a = Matcher;
  29118. var matcher = /*#__PURE__*/Object.defineProperty({
  29119. default: _default$a
  29120. }, '__esModule', {
  29121. value: true
  29122. });
  29123. class PartialMatcher extends matcher.default {
  29124. match(filepath) {
  29125. const parts = filepath.split('/');
  29126. const levels = parts.length;
  29127. const patterns = this._storage.filter(info => !info.complete || info.segments.length > levels);
  29128. for (const pattern of patterns) {
  29129. const section = pattern.sections[0];
  29130. /**
  29131. * In this case, the pattern has a globstar and we must read all directories unconditionally,
  29132. * but only if the level has reached the end of the first group.
  29133. *
  29134. * fixtures/{a,b}/**
  29135. * ^ true/false ^ always true
  29136. */
  29137. if (!pattern.complete && levels > section.length) {
  29138. return true;
  29139. }
  29140. const match = parts.every((part, index) => {
  29141. const segment = pattern.segments[index];
  29142. if (segment.dynamic && segment.patternRe.test(part)) {
  29143. return true;
  29144. }
  29145. if (!segment.dynamic && segment.pattern === part) {
  29146. return true;
  29147. }
  29148. return false;
  29149. });
  29150. if (match) {
  29151. return true;
  29152. }
  29153. }
  29154. return false;
  29155. }
  29156. }
  29157. var _default$9 = PartialMatcher;
  29158. var partial = /*#__PURE__*/Object.defineProperty({
  29159. default: _default$9
  29160. }, '__esModule', {
  29161. value: true
  29162. });
  29163. class DeepFilter {
  29164. constructor(_settings, _micromatchOptions) {
  29165. this._settings = _settings;
  29166. this._micromatchOptions = _micromatchOptions;
  29167. }
  29168. getFilter(basePath, positive, negative) {
  29169. const matcher = this._getMatcher(positive);
  29170. const negativeRe = this._getNegativePatternsRe(negative);
  29171. return entry => this._filter(basePath, entry, matcher, negativeRe);
  29172. }
  29173. _getMatcher(patterns) {
  29174. return new partial.default(patterns, this._settings, this._micromatchOptions);
  29175. }
  29176. _getNegativePatternsRe(patterns) {
  29177. const affectDepthOfReadingPatterns = patterns.filter(utils$8.pattern.isAffectDepthOfReadingPattern);
  29178. return utils$8.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
  29179. }
  29180. _filter(basePath, entry, matcher, negativeRe) {
  29181. if (this._isSkippedByDeep(basePath, entry.path)) {
  29182. return false;
  29183. }
  29184. if (this._isSkippedSymbolicLink(entry)) {
  29185. return false;
  29186. }
  29187. const filepath = utils$8.path.removeLeadingDotSegment(entry.path);
  29188. if (this._isSkippedByPositivePatterns(filepath, matcher)) {
  29189. return false;
  29190. }
  29191. return this._isSkippedByNegativePatterns(filepath, negativeRe);
  29192. }
  29193. _isSkippedByDeep(basePath, entryPath) {
  29194. /**
  29195. * Avoid unnecessary depth calculations when it doesn't matter.
  29196. */
  29197. if (this._settings.deep === Infinity) {
  29198. return false;
  29199. }
  29200. return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
  29201. }
  29202. _getEntryLevel(basePath, entryPath) {
  29203. const entryPathDepth = entryPath.split('/').length;
  29204. if (basePath === '') {
  29205. return entryPathDepth;
  29206. }
  29207. const basePathDepth = basePath.split('/').length;
  29208. return entryPathDepth - basePathDepth;
  29209. }
  29210. _isSkippedSymbolicLink(entry) {
  29211. return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
  29212. }
  29213. _isSkippedByPositivePatterns(entryPath, matcher) {
  29214. return !this._settings.baseNameMatch && !matcher.match(entryPath);
  29215. }
  29216. _isSkippedByNegativePatterns(entryPath, patternsRe) {
  29217. return !utils$8.pattern.matchAny(entryPath, patternsRe);
  29218. }
  29219. }
  29220. var _default$8 = DeepFilter;
  29221. var deep = /*#__PURE__*/Object.defineProperty({
  29222. default: _default$8
  29223. }, '__esModule', {
  29224. value: true
  29225. });
  29226. class EntryFilter {
  29227. constructor(_settings, _micromatchOptions) {
  29228. this._settings = _settings;
  29229. this._micromatchOptions = _micromatchOptions;
  29230. this.index = new Map();
  29231. }
  29232. getFilter(positive, negative) {
  29233. const positiveRe = utils$8.pattern.convertPatternsToRe(positive, this._micromatchOptions);
  29234. const negativeRe = utils$8.pattern.convertPatternsToRe(negative, this._micromatchOptions);
  29235. return entry => this._filter(entry, positiveRe, negativeRe);
  29236. }
  29237. _filter(entry, positiveRe, negativeRe) {
  29238. if (this._settings.unique && this._isDuplicateEntry(entry)) {
  29239. return false;
  29240. }
  29241. if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
  29242. return false;
  29243. }
  29244. if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
  29245. return false;
  29246. }
  29247. const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
  29248. const isMatched = this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe);
  29249. if (this._settings.unique && isMatched) {
  29250. this._createIndexRecord(entry);
  29251. }
  29252. return isMatched;
  29253. }
  29254. _isDuplicateEntry(entry) {
  29255. return this.index.has(entry.path);
  29256. }
  29257. _createIndexRecord(entry) {
  29258. this.index.set(entry.path, undefined);
  29259. }
  29260. _onlyFileFilter(entry) {
  29261. return this._settings.onlyFiles && !entry.dirent.isFile();
  29262. }
  29263. _onlyDirectoryFilter(entry) {
  29264. return this._settings.onlyDirectories && !entry.dirent.isDirectory();
  29265. }
  29266. _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
  29267. if (!this._settings.absolute) {
  29268. return false;
  29269. }
  29270. const fullpath = utils$8.path.makeAbsolute(this._settings.cwd, entryPath);
  29271. return utils$8.pattern.matchAny(fullpath, patternsRe);
  29272. }
  29273. _isMatchToPatterns(entryPath, patternsRe) {
  29274. const filepath = utils$8.path.removeLeadingDotSegment(entryPath);
  29275. return utils$8.pattern.matchAny(filepath, patternsRe);
  29276. }
  29277. }
  29278. var _default$7 = EntryFilter;
  29279. var entry$1 = /*#__PURE__*/Object.defineProperty({
  29280. default: _default$7
  29281. }, '__esModule', {
  29282. value: true
  29283. });
  29284. class ErrorFilter {
  29285. constructor(_settings) {
  29286. this._settings = _settings;
  29287. }
  29288. getFilter() {
  29289. return error => this._isNonFatalError(error);
  29290. }
  29291. _isNonFatalError(error) {
  29292. return utils$8.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
  29293. }
  29294. }
  29295. var _default$6 = ErrorFilter;
  29296. var error$1 = /*#__PURE__*/Object.defineProperty({
  29297. default: _default$6
  29298. }, '__esModule', {
  29299. value: true
  29300. });
  29301. class EntryTransformer {
  29302. constructor(_settings) {
  29303. this._settings = _settings;
  29304. }
  29305. getTransformer() {
  29306. return entry => this._transform(entry);
  29307. }
  29308. _transform(entry) {
  29309. let filepath = entry.path;
  29310. if (this._settings.absolute) {
  29311. filepath = utils$8.path.makeAbsolute(this._settings.cwd, filepath);
  29312. filepath = utils$8.path.unixify(filepath);
  29313. }
  29314. if (this._settings.markDirectories && entry.dirent.isDirectory()) {
  29315. filepath += '/';
  29316. }
  29317. if (!this._settings.objectMode) {
  29318. return filepath;
  29319. }
  29320. return Object.assign(Object.assign({}, entry), {
  29321. path: filepath
  29322. });
  29323. }
  29324. }
  29325. var _default$5 = EntryTransformer;
  29326. var entry = /*#__PURE__*/Object.defineProperty({
  29327. default: _default$5
  29328. }, '__esModule', {
  29329. value: true
  29330. });
  29331. class Provider {
  29332. constructor(_settings) {
  29333. this._settings = _settings;
  29334. this.errorFilter = new error$1.default(this._settings);
  29335. this.entryFilter = new entry$1.default(this._settings, this._getMicromatchOptions());
  29336. this.deepFilter = new deep.default(this._settings, this._getMicromatchOptions());
  29337. this.entryTransformer = new entry.default(this._settings);
  29338. }
  29339. _getRootDirectory(task) {
  29340. return path__default['default'].resolve(this._settings.cwd, task.base);
  29341. }
  29342. _getReaderOptions(task) {
  29343. const basePath = task.base === '.' ? '' : task.base;
  29344. return {
  29345. basePath,
  29346. pathSegmentSeparator: '/',
  29347. concurrency: this._settings.concurrency,
  29348. deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
  29349. entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
  29350. errorFilter: this.errorFilter.getFilter(),
  29351. followSymbolicLinks: this._settings.followSymbolicLinks,
  29352. fs: this._settings.fs,
  29353. stats: this._settings.stats,
  29354. throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
  29355. transform: this.entryTransformer.getTransformer()
  29356. };
  29357. }
  29358. _getMicromatchOptions() {
  29359. return {
  29360. dot: this._settings.dot,
  29361. matchBase: this._settings.baseNameMatch,
  29362. nobrace: !this._settings.braceExpansion,
  29363. nocase: !this._settings.caseSensitiveMatch,
  29364. noext: !this._settings.extglob,
  29365. noglobstar: !this._settings.globstar,
  29366. posix: true,
  29367. strictSlashes: false
  29368. };
  29369. }
  29370. }
  29371. var _default$4 = Provider;
  29372. var provider = /*#__PURE__*/Object.defineProperty({
  29373. default: _default$4
  29374. }, '__esModule', {
  29375. value: true
  29376. });
  29377. class ProviderAsync extends provider.default {
  29378. constructor() {
  29379. super(...arguments);
  29380. this._reader = new stream$2.default(this._settings);
  29381. }
  29382. read(task) {
  29383. const root = this._getRootDirectory(task);
  29384. const options = this._getReaderOptions(task);
  29385. const entries = [];
  29386. return new Promise((resolve, reject) => {
  29387. const stream = this.api(root, task, options);
  29388. stream.once('error', reject);
  29389. stream.on('data', entry => entries.push(options.transform(entry)));
  29390. stream.once('end', () => resolve(entries));
  29391. });
  29392. }
  29393. api(root, task, options) {
  29394. if (task.dynamic) {
  29395. return this._reader.dynamic(root, options);
  29396. }
  29397. return this._reader.static(task.patterns, options);
  29398. }
  29399. }
  29400. var _default$3 = ProviderAsync;
  29401. var async = /*#__PURE__*/Object.defineProperty({
  29402. default: _default$3
  29403. }, '__esModule', {
  29404. value: true
  29405. });
  29406. class ProviderStream extends provider.default {
  29407. constructor() {
  29408. super(...arguments);
  29409. this._reader = new stream$2.default(this._settings);
  29410. }
  29411. read(task) {
  29412. const root = this._getRootDirectory(task);
  29413. const options = this._getReaderOptions(task);
  29414. const source = this.api(root, task, options);
  29415. const destination = new stream_1__default['default'].Readable({
  29416. objectMode: true,
  29417. read: () => {}
  29418. });
  29419. source.once('error', error => destination.emit('error', error)).on('data', entry => destination.emit('data', options.transform(entry))).once('end', () => destination.emit('end'));
  29420. destination.once('close', () => source.destroy());
  29421. return destination;
  29422. }
  29423. api(root, task, options) {
  29424. if (task.dynamic) {
  29425. return this._reader.dynamic(root, options);
  29426. }
  29427. return this._reader.static(task.patterns, options);
  29428. }
  29429. }
  29430. var _default$2 = ProviderStream;
  29431. var stream$1 = /*#__PURE__*/Object.defineProperty({
  29432. default: _default$2
  29433. }, '__esModule', {
  29434. value: true
  29435. });
  29436. class ReaderSync extends reader.default {
  29437. constructor() {
  29438. super(...arguments);
  29439. this._walkSync = out$1.walkSync;
  29440. this._statSync = out$3.statSync;
  29441. }
  29442. dynamic(root, options) {
  29443. return this._walkSync(root, options);
  29444. }
  29445. static(patterns, options) {
  29446. const entries = [];
  29447. for (const pattern of patterns) {
  29448. const filepath = this._getFullEntryPath(pattern);
  29449. const entry = this._getEntry(filepath, pattern, options);
  29450. if (entry === null || !options.entryFilter(entry)) {
  29451. continue;
  29452. }
  29453. entries.push(entry);
  29454. }
  29455. return entries;
  29456. }
  29457. _getEntry(filepath, pattern, options) {
  29458. try {
  29459. const stats = this._getStat(filepath);
  29460. return this._makeEntry(stats, pattern);
  29461. } catch (error) {
  29462. if (options.errorFilter(error)) {
  29463. return null;
  29464. }
  29465. throw error;
  29466. }
  29467. }
  29468. _getStat(filepath) {
  29469. return this._statSync(filepath, this._fsStatSettings);
  29470. }
  29471. }
  29472. var _default$1 = ReaderSync;
  29473. var sync$4 = /*#__PURE__*/Object.defineProperty({
  29474. default: _default$1
  29475. }, '__esModule', {
  29476. value: true
  29477. });
  29478. class ProviderSync extends provider.default {
  29479. constructor() {
  29480. super(...arguments);
  29481. this._reader = new sync$4.default(this._settings);
  29482. }
  29483. read(task) {
  29484. const root = this._getRootDirectory(task);
  29485. const options = this._getReaderOptions(task);
  29486. const entries = this.api(root, task, options);
  29487. return entries.map(options.transform);
  29488. }
  29489. api(root, task, options) {
  29490. if (task.dynamic) {
  29491. return this._reader.dynamic(root, options);
  29492. }
  29493. return this._reader.static(task.patterns, options);
  29494. }
  29495. }
  29496. var _default = ProviderSync;
  29497. var sync$3 = /*#__PURE__*/Object.defineProperty({
  29498. default: _default
  29499. }, '__esModule', {
  29500. value: true
  29501. });
  29502. var settings = createCommonjsModule(function (module, exports) {
  29503. Object.defineProperty(exports, "__esModule", {
  29504. value: true
  29505. });
  29506. exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
  29507. /**
  29508. * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
  29509. * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
  29510. */
  29511. const CPU_COUNT = Math.max(os__default['default'].cpus().length, 1);
  29512. exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
  29513. lstat: fs__default['default'].lstat,
  29514. lstatSync: fs__default['default'].lstatSync,
  29515. stat: fs__default['default'].stat,
  29516. statSync: fs__default['default'].statSync,
  29517. readdir: fs__default['default'].readdir,
  29518. readdirSync: fs__default['default'].readdirSync
  29519. };
  29520. class Settings {
  29521. constructor(_options = {}) {
  29522. this._options = _options;
  29523. this.absolute = this._getValue(this._options.absolute, false);
  29524. this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
  29525. this.braceExpansion = this._getValue(this._options.braceExpansion, true);
  29526. this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
  29527. this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
  29528. this.cwd = this._getValue(this._options.cwd, process.cwd());
  29529. this.deep = this._getValue(this._options.deep, Infinity);
  29530. this.dot = this._getValue(this._options.dot, false);
  29531. this.extglob = this._getValue(this._options.extglob, true);
  29532. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
  29533. this.fs = this._getFileSystemMethods(this._options.fs);
  29534. this.globstar = this._getValue(this._options.globstar, true);
  29535. this.ignore = this._getValue(this._options.ignore, []);
  29536. this.markDirectories = this._getValue(this._options.markDirectories, false);
  29537. this.objectMode = this._getValue(this._options.objectMode, false);
  29538. this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
  29539. this.onlyFiles = this._getValue(this._options.onlyFiles, true);
  29540. this.stats = this._getValue(this._options.stats, false);
  29541. this.suppressErrors = this._getValue(this._options.suppressErrors, false);
  29542. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
  29543. this.unique = this._getValue(this._options.unique, true);
  29544. if (this.onlyDirectories) {
  29545. this.onlyFiles = false;
  29546. }
  29547. if (this.stats) {
  29548. this.objectMode = true;
  29549. }
  29550. }
  29551. _getValue(option, value) {
  29552. return option === undefined ? value : option;
  29553. }
  29554. _getFileSystemMethods(methods = {}) {
  29555. return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
  29556. }
  29557. }
  29558. exports.default = Settings;
  29559. });
  29560. async function FastGlob(source, options) {
  29561. assertPatternsInput$1(source);
  29562. const works = getWorks(source, async.default, options);
  29563. const result = await Promise.all(works);
  29564. return utils$8.array.flatten(result);
  29565. } // https://github.com/typescript-eslint/typescript-eslint/issues/60
  29566. // eslint-disable-next-line no-redeclare
  29567. (function (FastGlob) {
  29568. function sync(source, options) {
  29569. assertPatternsInput$1(source);
  29570. const works = getWorks(source, sync$3.default, options);
  29571. return utils$8.array.flatten(works);
  29572. }
  29573. FastGlob.sync = sync;
  29574. function stream(source, options) {
  29575. assertPatternsInput$1(source);
  29576. const works = getWorks(source, stream$1.default, options);
  29577. /**
  29578. * The stream returned by the provider cannot work with an asynchronous iterator.
  29579. * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
  29580. * This affects performance (+25%). I don't see best solution right now.
  29581. */
  29582. return utils$8.stream.merge(works);
  29583. }
  29584. FastGlob.stream = stream;
  29585. function generateTasks(source, options) {
  29586. assertPatternsInput$1(source);
  29587. const patterns = [].concat(source);
  29588. const settings$1 = new settings.default(options);
  29589. return tasks.generate(patterns, settings$1);
  29590. }
  29591. FastGlob.generateTasks = generateTasks;
  29592. function isDynamicPattern(source, options) {
  29593. assertPatternsInput$1(source);
  29594. const settings$1 = new settings.default(options);
  29595. return utils$8.pattern.isDynamicPattern(source, settings$1);
  29596. }
  29597. FastGlob.isDynamicPattern = isDynamicPattern;
  29598. function escapePath(source) {
  29599. assertPatternsInput$1(source);
  29600. return utils$8.path.escape(source);
  29601. }
  29602. FastGlob.escapePath = escapePath;
  29603. })(FastGlob || (FastGlob = {}));
  29604. function getWorks(source, _Provider, options) {
  29605. const patterns = [].concat(source);
  29606. const settings$1 = new settings.default(options);
  29607. const tasks$1 = tasks.generate(patterns, settings$1);
  29608. const provider = new _Provider(settings$1);
  29609. return tasks$1.map(provider.read, provider);
  29610. }
  29611. function assertPatternsInput$1(input) {
  29612. const source = [].concat(input);
  29613. const isValidSource = source.every(item => utils$8.string.isString(item) && !utils$8.string.isEmpty(item));
  29614. if (!isValidSource) {
  29615. throw new TypeError('Patterns must be a string (non empty) or an array of strings');
  29616. }
  29617. }
  29618. var out = FastGlob;
  29619. const {
  29620. promisify: promisify$1
  29621. } = util__default['default'];
  29622. async function isType(fsStatType, statsMethodName, filePath) {
  29623. if (typeof filePath !== 'string') {
  29624. throw new TypeError(`Expected a string, got ${typeof filePath}`);
  29625. }
  29626. try {
  29627. const stats = await promisify$1(fs__default['default'][fsStatType])(filePath);
  29628. return stats[statsMethodName]();
  29629. } catch (error) {
  29630. if (error.code === 'ENOENT') {
  29631. return false;
  29632. }
  29633. throw error;
  29634. }
  29635. }
  29636. function isTypeSync(fsStatType, statsMethodName, filePath) {
  29637. if (typeof filePath !== 'string') {
  29638. throw new TypeError(`Expected a string, got ${typeof filePath}`);
  29639. }
  29640. try {
  29641. return fs__default['default'][fsStatType](filePath)[statsMethodName]();
  29642. } catch (error) {
  29643. if (error.code === 'ENOENT') {
  29644. return false;
  29645. }
  29646. throw error;
  29647. }
  29648. }
  29649. var isFile = isType.bind(null, 'stat', 'isFile');
  29650. var isDirectory$1 = isType.bind(null, 'stat', 'isDirectory');
  29651. var isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
  29652. var isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
  29653. var isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
  29654. var isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
  29655. var pathType = {
  29656. isFile: isFile,
  29657. isDirectory: isDirectory$1,
  29658. isSymlink: isSymlink,
  29659. isFileSync: isFileSync,
  29660. isDirectorySync: isDirectorySync,
  29661. isSymlinkSync: isSymlinkSync
  29662. };
  29663. const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
  29664. const getPath = (filepath, cwd) => {
  29665. const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
  29666. return path__default['default'].isAbsolute(pth) ? pth : path__default['default'].join(cwd, pth);
  29667. };
  29668. const addExtensions = (file, extensions) => {
  29669. if (path__default['default'].extname(file)) {
  29670. return `**/${file}`;
  29671. }
  29672. return `**/${file}.${getExtensions(extensions)}`;
  29673. };
  29674. const getGlob = (directory, options) => {
  29675. if (options.files && !Array.isArray(options.files)) {
  29676. throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
  29677. }
  29678. if (options.extensions && !Array.isArray(options.extensions)) {
  29679. throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
  29680. }
  29681. if (options.files && options.extensions) {
  29682. return options.files.map(x => path__default['default'].posix.join(directory, addExtensions(x, options.extensions)));
  29683. }
  29684. if (options.files) {
  29685. return options.files.map(x => path__default['default'].posix.join(directory, `**/${x}`));
  29686. }
  29687. if (options.extensions) {
  29688. return [path__default['default'].posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
  29689. }
  29690. return [path__default['default'].posix.join(directory, '**')];
  29691. };
  29692. var dirGlob = async (input, options) => {
  29693. options = Object.assign({
  29694. cwd: process.cwd()
  29695. }, options);
  29696. if (typeof options.cwd !== 'string') {
  29697. throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
  29698. }
  29699. const globs = await Promise.all([].concat(input).map(async x => {
  29700. const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
  29701. return isDirectory ? getGlob(x, options) : x;
  29702. }));
  29703. return [].concat.apply([], globs); // eslint-disable-line prefer-spread
  29704. };
  29705. var sync$2 = (input, options) => {
  29706. options = Object.assign({
  29707. cwd: process.cwd()
  29708. }, options);
  29709. if (typeof options.cwd !== 'string') {
  29710. throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
  29711. }
  29712. const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
  29713. return [].concat.apply([], globs); // eslint-disable-line prefer-spread
  29714. };
  29715. dirGlob.sync = sync$2;
  29716. // A simple implementation of make-array
  29717. function makeArray(subject) {
  29718. return Array.isArray(subject) ? subject : [subject];
  29719. }
  29720. const EMPTY = '';
  29721. const SPACE = ' ';
  29722. const ESCAPE = '\\';
  29723. const REGEX_TEST_BLANK_LINE = /^\s+$/;
  29724. const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  29725. const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
  29726. const REGEX_SPLITALL_CRLF = /\r?\n/g; // /foo,
  29727. // ./foo,
  29728. // ../foo,
  29729. // .
  29730. // ..
  29731. const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
  29732. const SLASH = '/';
  29733. const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  29734. /* istanbul ignore next */
  29735. : 'node-ignore';
  29736. const define = (object, key, value) => Object.defineProperty(object, key, {
  29737. value
  29738. });
  29739. const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
  29740. // The cases are complicated, see test cases for details
  29741. const sanitizeRange = range => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
  29742. // fatal for JavaScript regular expression, so eliminate it.
  29743. : EMPTY); // See fixtures #59
  29744. const cleanRangeBackSlash = slashes => {
  29745. const {
  29746. length
  29747. } = slashes;
  29748. return slashes.slice(0, length - length % 2);
  29749. }; // > If the pattern ends with a slash,
  29750. // > it is removed for the purpose of the following description,
  29751. // > but it would only find a match with a directory.
  29752. // > In other words, foo/ will match a directory foo and paths underneath it,
  29753. // > but will not match a regular file or a symbolic link foo
  29754. // > (this is consistent with the way how pathspec works in general in Git).
  29755. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  29756. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  29757. // you could use option `mark: true` with `glob`
  29758. // '`foo/`' should not continue with the '`..`'
  29759. const REPLACERS = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  29760. [// (a\ ) -> (a )
  29761. // (a ) -> (a)
  29762. // (a \ ) -> (a )
  29763. /\\?\s+$/, match => match.indexOf('\\') === 0 ? SPACE : EMPTY], // replace (\ ) with ' '
  29764. [/\\\s/g, () => SPACE], // Escape metacharacters
  29765. // which is written down by users but means special for regular expressions.
  29766. // > There are 12 characters with special meanings:
  29767. // > - the backslash \,
  29768. // > - the caret ^,
  29769. // > - the dollar sign $,
  29770. // > - the period or dot .,
  29771. // > - the vertical bar or pipe symbol |,
  29772. // > - the question mark ?,
  29773. // > - the asterisk or star *,
  29774. // > - the plus sign +,
  29775. // > - the opening parenthesis (,
  29776. // > - the closing parenthesis ),
  29777. // > - and the opening square bracket [,
  29778. // > - the opening curly brace {,
  29779. // > These special characters are often called "metacharacters".
  29780. [/[\\$.|*+(){^]/g, match => `\\${match}`], [// > a question mark (?) matches a single character
  29781. /(?!\\)\?/g, () => '[^/]'], // leading slash
  29782. [// > A leading slash matches the beginning of the pathname.
  29783. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  29784. // A leading slash matches the beginning of the pathname
  29785. /^\//, () => '^'], // replace special metacharacter slash after the leading slash
  29786. [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
  29787. // > For example, "**/foo" matches file or directory "foo" anywhere,
  29788. // > the same as pattern "foo".
  29789. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  29790. // > under directory "foo".
  29791. // Notice that the '*'s have been replaced as '\\*'
  29792. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  29793. () => '^(?:.*\\/)?'], // starting
  29794. [// there will be no leading '/'
  29795. // (which has been replaced by section "leading slash")
  29796. // If starts with '**', adding a '^' to the regular expression also works
  29797. /^(?=[^^])/, function startingReplacer() {
  29798. // If has a slash `/` at the beginning or middle
  29799. return !/\/(?!$)/.test(this) // > Prior to 2.22.1
  29800. // > If the pattern does not contain a slash /,
  29801. // > Git treats it as a shell glob pattern
  29802. // Actually, if there is only a trailing slash,
  29803. // git also treats it as a shell glob pattern
  29804. // After 2.22.1 (compatible but clearer)
  29805. // > If there is a separator at the beginning or middle (or both)
  29806. // > of the pattern, then the pattern is relative to the directory
  29807. // > level of the particular .gitignore file itself.
  29808. // > Otherwise the pattern may also match at any level below
  29809. // > the .gitignore level.
  29810. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
  29811. // > consumption by fnmatch(3)
  29812. : '^';
  29813. }], // two globstars
  29814. [// Use lookahead assertions so that we could match more than one `'/**'`
  29815. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  29816. // should not use '*', or it will be replaced by the next replacer
  29817. // Check if it is not the last `'/**'`
  29818. (_, index, str) => index + 6 < str.length // case: /**/
  29819. // > A slash followed by two consecutive asterisks then a slash matches
  29820. // > zero or more directories.
  29821. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  29822. // '/**/'
  29823. ? '(?:\\/[^\\/]+)*' // case: /**
  29824. // > A trailing `"/**"` matches everything inside.
  29825. // #21: everything inside but it should not include the current folder
  29826. : '\\/.+'], // intermediate wildcards
  29827. [// Never replace escaped '*'
  29828. // ignore rule '\*' will match the path '*'
  29829. // 'abc.*/' -> go
  29830. // 'abc.*' -> skip this rule
  29831. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  29832. // '*.js' doesn't match 'abc'
  29833. (_, p1) => `${p1}[^\\/]*`], [// unescape, revert step 3 except for back slash
  29834. // For example, if a user escape a '\\*',
  29835. // after step 3, the result will be '\\\\\\*'
  29836. /\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE], [// '\\\\' -> '\\'
  29837. /\\\\/g, () => ESCAPE], [// > The range notation, e.g. [a-zA-Z],
  29838. // > can be used to match one of the characters in a range.
  29839. // `\` is escaped by step 3
  29840. /(\\)?\[([^\]/]*?)(\\*)($|\])/g, (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE // '\\[bar]' -> '\\\\[bar\\]'
  29841. ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === ']' ? endEscape.length % 2 === 0 // A normal case, and it is a range notation
  29842. // '[bar]'
  29843. // '[bar\\\\]'
  29844. ? `[${sanitizeRange(range)}${endEscape}]` // Invalid range notaton
  29845. // '[bar\\]' -> '[bar\\\\]'
  29846. : '[]' : '[]'], // ending
  29847. [// 'js' will not match 'js.'
  29848. // 'ab' will not match 'abc'
  29849. /(?:[^*])$/, // WTF!
  29850. // https://git-scm.com/docs/gitignore
  29851. // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
  29852. // which re-fixes #24, #38
  29853. // > If there is a separator at the end of the pattern then the pattern
  29854. // > will only match directories, otherwise the pattern can match both
  29855. // > files and directories.
  29856. // 'js*' will not match 'a.js'
  29857. // 'js/' will not match 'a.js'
  29858. // 'js' will match 'a.js' and 'a.js/'
  29859. match => /\/$/.test(match) // foo/ will not match 'foo'
  29860. ? `${match}$` // foo matches 'foo' and 'foo/'
  29861. : `${match}(?=$|\\/$)`], // trailing wildcard
  29862. [/(\^|\\\/)?\\\*$/, (_, p1) => {
  29863. const prefix = p1 // '\^':
  29864. // '/*' does not match EMPTY
  29865. // '/*' does not match everything
  29866. // '\\\/':
  29867. // 'abc/*' does not match 'abc/'
  29868. ? `${p1}[^/]+` // 'a*' matches 'a'
  29869. // 'a*' matches 'aa'
  29870. : '[^/]*';
  29871. return `${prefix}(?=$|\\/$)`;
  29872. }]]; // A simple cache, because an ignore rule only has only one certain meaning
  29873. const regexCache = Object.create(null); // @param {pattern}
  29874. const makeRegex = (pattern, negative, ignorecase) => {
  29875. const r = regexCache[pattern];
  29876. if (r) {
  29877. return r;
  29878. } // const replacers = negative
  29879. // ? NEGATIVE_REPLACERS
  29880. // : POSITIVE_REPLACERS
  29881. const source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
  29882. return regexCache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  29883. };
  29884. const isString = subject => typeof subject === 'string'; // > A blank line matches no files, so it can serve as a separator for readability.
  29885. const checkPattern = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  29886. && pattern.indexOf('#') !== 0;
  29887. const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
  29888. class IgnoreRule {
  29889. constructor(origin, pattern, negative, regex) {
  29890. this.origin = origin;
  29891. this.pattern = pattern;
  29892. this.negative = negative;
  29893. this.regex = regex;
  29894. }
  29895. }
  29896. const createRule = (pattern, ignorecase) => {
  29897. const origin = pattern;
  29898. let negative = false; // > An optional prefix "!" which negates the pattern;
  29899. if (pattern.indexOf('!') === 0) {
  29900. negative = true;
  29901. pattern = pattern.substr(1);
  29902. }
  29903. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
  29904. // > begin with a literal "!", for example, `"\!important!.txt"`.
  29905. .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
  29906. // > begin with a hash.
  29907. .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
  29908. const regex = makeRegex(pattern, negative, ignorecase);
  29909. return new IgnoreRule(origin, pattern, negative, regex);
  29910. };
  29911. const throwError = (message, Ctor) => {
  29912. throw new Ctor(message);
  29913. };
  29914. const checkPath = (path, originalPath, doThrow) => {
  29915. if (!isString(path)) {
  29916. return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
  29917. } // We don't know if we should ignore EMPTY, so throw
  29918. if (!path) {
  29919. return doThrow(`path must not be empty`, TypeError);
  29920. } // Check if it is a relative path
  29921. if (checkPath.isNotRelative(path)) {
  29922. const r = '`path.relative()`d';
  29923. return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
  29924. }
  29925. return true;
  29926. };
  29927. const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
  29928. checkPath.isNotRelative = isNotRelative;
  29929. checkPath.convert = p => p;
  29930. class Ignore {
  29931. constructor({
  29932. ignorecase = true
  29933. } = {}) {
  29934. this._rules = [];
  29935. this._ignorecase = ignorecase;
  29936. define(this, KEY_IGNORE, true);
  29937. this._initCache();
  29938. }
  29939. _initCache() {
  29940. this._ignoreCache = Object.create(null);
  29941. this._testCache = Object.create(null);
  29942. }
  29943. _addPattern(pattern) {
  29944. // #32
  29945. if (pattern && pattern[KEY_IGNORE]) {
  29946. this._rules = this._rules.concat(pattern._rules);
  29947. this._added = true;
  29948. return;
  29949. }
  29950. if (checkPattern(pattern)) {
  29951. const rule = createRule(pattern, this._ignorecase);
  29952. this._added = true;
  29953. this._rules.push(rule);
  29954. }
  29955. } // @param {Array<string> | string | Ignore} pattern
  29956. add(pattern) {
  29957. this._added = false;
  29958. makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  29959. // making the behavior changed.
  29960. if (this._added) {
  29961. this._initCache();
  29962. }
  29963. return this;
  29964. } // legacy
  29965. addPattern(pattern) {
  29966. return this.add(pattern);
  29967. } // | ignored : unignored
  29968. // negative | 0:0 | 0:1 | 1:0 | 1:1
  29969. // -------- | ------- | ------- | ------- | --------
  29970. // 0 | TEST | TEST | SKIP | X
  29971. // 1 | TESTIF | SKIP | TEST | X
  29972. // - SKIP: always skip
  29973. // - TEST: always test
  29974. // - TESTIF: only test if checkUnignored
  29975. // - X: that never happen
  29976. // @param {boolean} whether should check if the path is unignored,
  29977. // setting `checkUnignored` to `false` could reduce additional
  29978. // path matching.
  29979. // @returns {TestResult} true if a file is ignored
  29980. _testOne(path, checkUnignored) {
  29981. let ignored = false;
  29982. let unignored = false;
  29983. this._rules.forEach(rule => {
  29984. const {
  29985. negative
  29986. } = rule;
  29987. if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
  29988. return;
  29989. }
  29990. const matched = rule.regex.test(path);
  29991. if (matched) {
  29992. ignored = !negative;
  29993. unignored = negative;
  29994. }
  29995. });
  29996. return {
  29997. ignored,
  29998. unignored
  29999. };
  30000. } // @returns {TestResult}
  30001. _test(originalPath, cache, checkUnignored, slices) {
  30002. const path = originalPath // Supports nullable path
  30003. && checkPath.convert(originalPath);
  30004. checkPath(path, originalPath, throwError);
  30005. return this._t(path, cache, checkUnignored, slices);
  30006. }
  30007. _t(path, cache, checkUnignored, slices) {
  30008. if (path in cache) {
  30009. return cache[path];
  30010. }
  30011. if (!slices) {
  30012. // path/to/a.js
  30013. // ['path', 'to', 'a.js']
  30014. slices = path.split(SLASH);
  30015. }
  30016. slices.pop(); // If the path has no parent directory, just test it
  30017. if (!slices.length) {
  30018. return cache[path] = this._testOne(path, checkUnignored);
  30019. }
  30020. const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices); // If the path contains a parent directory, check the parent first
  30021. return cache[path] = parent.ignored // > It is not possible to re-include a file if a parent directory of
  30022. // > that file is excluded.
  30023. ? parent : this._testOne(path, checkUnignored);
  30024. }
  30025. ignores(path) {
  30026. return this._test(path, this._ignoreCache, false).ignored;
  30027. }
  30028. createFilter() {
  30029. return path => !this.ignores(path);
  30030. }
  30031. filter(paths) {
  30032. return makeArray(paths).filter(this.createFilter());
  30033. } // @returns {TestResult}
  30034. test(path) {
  30035. return this._test(path, this._testCache, true);
  30036. }
  30037. }
  30038. const factory = options => new Ignore(options);
  30039. const returnFalse = () => false;
  30040. const isPathValid = path => checkPath(path && checkPath.convert(path), path, returnFalse);
  30041. factory.isPathValid = isPathValid; // Fixes typescript
  30042. factory.default = factory;
  30043. var ignore = factory; // Windows
  30044. // --------------------------------------------------------------
  30045. /* istanbul ignore if */
  30046. if ( // Detect `process` so that it can run in browsers.
  30047. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  30048. /* eslint no-control-regex: "off" */
  30049. const makePosix = str => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, '/');
  30050. checkPath.convert = makePosix; // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
  30051. // 'd:\\foo'
  30052. const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
  30053. checkPath.isNotRelative = path => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
  30054. }
  30055. var slash = path => {
  30056. const isExtendedLengthPath = /^\\\\\?\\/.test(path);
  30057. const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
  30058. if (isExtendedLengthPath || hasNonAscii) {
  30059. return path;
  30060. }
  30061. return path.replace(/\\/g, '/');
  30062. };
  30063. const {
  30064. promisify
  30065. } = util__default['default'];
  30066. const DEFAULT_IGNORE = ['**/node_modules/**', '**/flow-typed/**', '**/coverage/**', '**/.git'];
  30067. const readFileP = promisify(fs__default['default'].readFile);
  30068. const mapGitIgnorePatternTo = base => ignore => {
  30069. if (ignore.startsWith('!')) {
  30070. return '!' + path__default['default'].posix.join(base, ignore.slice(1));
  30071. }
  30072. return path__default['default'].posix.join(base, ignore);
  30073. };
  30074. const parseGitIgnore = (content, options) => {
  30075. const base = slash(path__default['default'].relative(options.cwd, path__default['default'].dirname(options.fileName)));
  30076. return content.split(/\r?\n/).filter(Boolean).filter(line => !line.startsWith('#')).map(mapGitIgnorePatternTo(base));
  30077. };
  30078. const reduceIgnore = files => {
  30079. const ignores = ignore();
  30080. for (const file of files) {
  30081. ignores.add(parseGitIgnore(file.content, {
  30082. cwd: file.cwd,
  30083. fileName: file.filePath
  30084. }));
  30085. }
  30086. return ignores;
  30087. };
  30088. const ensureAbsolutePathForCwd = (cwd, p) => {
  30089. cwd = slash(cwd);
  30090. if (path__default['default'].isAbsolute(p)) {
  30091. if (slash(p).startsWith(cwd)) {
  30092. return p;
  30093. }
  30094. throw new Error(`Path ${p} is not in cwd ${cwd}`);
  30095. }
  30096. return path__default['default'].join(cwd, p);
  30097. };
  30098. const getIsIgnoredPredecate = (ignores, cwd) => {
  30099. return p => ignores.ignores(slash(path__default['default'].relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p))));
  30100. };
  30101. const getFile = async (file, cwd) => {
  30102. const filePath = path__default['default'].join(cwd, file);
  30103. const content = await readFileP(filePath, 'utf8');
  30104. return {
  30105. cwd,
  30106. filePath,
  30107. content
  30108. };
  30109. };
  30110. const getFileSync = (file, cwd) => {
  30111. const filePath = path__default['default'].join(cwd, file);
  30112. const content = fs__default['default'].readFileSync(filePath, 'utf8');
  30113. return {
  30114. cwd,
  30115. filePath,
  30116. content
  30117. };
  30118. };
  30119. const normalizeOptions = ({
  30120. ignore = [],
  30121. cwd = slash(process.cwd())
  30122. } = {}) => {
  30123. return {
  30124. ignore,
  30125. cwd
  30126. };
  30127. };
  30128. var gitignore = async options => {
  30129. options = normalizeOptions(options);
  30130. const paths = await out('**/.gitignore', {
  30131. ignore: DEFAULT_IGNORE.concat(options.ignore),
  30132. cwd: options.cwd
  30133. });
  30134. const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
  30135. const ignores = reduceIgnore(files);
  30136. return getIsIgnoredPredecate(ignores, options.cwd);
  30137. };
  30138. var sync$1 = options => {
  30139. options = normalizeOptions(options);
  30140. const paths = out.sync('**/.gitignore', {
  30141. ignore: DEFAULT_IGNORE.concat(options.ignore),
  30142. cwd: options.cwd
  30143. });
  30144. const files = paths.map(file => getFileSync(file, options.cwd));
  30145. const ignores = reduceIgnore(files);
  30146. return getIsIgnoredPredecate(ignores, options.cwd);
  30147. };
  30148. gitignore.sync = sync$1;
  30149. const {
  30150. Transform
  30151. } = stream_1__default['default'];
  30152. class ObjectTransform extends Transform {
  30153. constructor() {
  30154. super({
  30155. objectMode: true
  30156. });
  30157. }
  30158. }
  30159. class FilterStream$1 extends ObjectTransform {
  30160. constructor(filter) {
  30161. super();
  30162. this._filter = filter;
  30163. }
  30164. _transform(data, encoding, callback) {
  30165. if (this._filter(data)) {
  30166. this.push(data);
  30167. }
  30168. callback();
  30169. }
  30170. }
  30171. class UniqueStream$1 extends ObjectTransform {
  30172. constructor() {
  30173. super();
  30174. this._pushed = new Set();
  30175. }
  30176. _transform(data, encoding, callback) {
  30177. if (!this._pushed.has(data)) {
  30178. this.push(data);
  30179. this._pushed.add(data);
  30180. }
  30181. callback();
  30182. }
  30183. }
  30184. var streamUtils = {
  30185. FilterStream: FilterStream$1,
  30186. UniqueStream: UniqueStream$1
  30187. };
  30188. const {
  30189. FilterStream,
  30190. UniqueStream
  30191. } = streamUtils;
  30192. const DEFAULT_FILTER = () => false;
  30193. const isNegative = pattern => pattern[0] === '!';
  30194. const assertPatternsInput = patterns => {
  30195. if (!patterns.every(pattern => typeof pattern === 'string')) {
  30196. throw new TypeError('Patterns must be a string or an array of strings');
  30197. }
  30198. };
  30199. const checkCwdOption = (options = {}) => {
  30200. if (!options.cwd) {
  30201. return;
  30202. }
  30203. let stat;
  30204. try {
  30205. stat = fs__default['default'].statSync(options.cwd);
  30206. } catch {
  30207. return;
  30208. }
  30209. if (!stat.isDirectory()) {
  30210. throw new Error('The `cwd` option must be a path to a directory');
  30211. }
  30212. };
  30213. const getPathString = p => p.stats instanceof fs__default['default'].Stats ? p.path : p;
  30214. const generateGlobTasks = (patterns, taskOptions) => {
  30215. patterns = arrayUnion([].concat(patterns));
  30216. assertPatternsInput(patterns);
  30217. checkCwdOption(taskOptions);
  30218. const globTasks = [];
  30219. taskOptions = Object.assign({
  30220. ignore: [],
  30221. expandDirectories: true
  30222. }, taskOptions);
  30223. for (const [index, pattern] of patterns.entries()) {
  30224. if (isNegative(pattern)) {
  30225. continue;
  30226. }
  30227. const ignore = patterns.slice(index).filter(pattern => isNegative(pattern)).map(pattern => pattern.slice(1));
  30228. const options = Object.assign(Object.assign({}, taskOptions), {}, {
  30229. ignore: taskOptions.ignore.concat(ignore)
  30230. });
  30231. globTasks.push({
  30232. pattern,
  30233. options
  30234. });
  30235. }
  30236. return globTasks;
  30237. };
  30238. const globDirs = (task, fn) => {
  30239. let options = {};
  30240. if (task.options.cwd) {
  30241. options.cwd = task.options.cwd;
  30242. }
  30243. if (Array.isArray(task.options.expandDirectories)) {
  30244. options = Object.assign(Object.assign({}, options), {}, {
  30245. files: task.options.expandDirectories
  30246. });
  30247. } else if (typeof task.options.expandDirectories === 'object') {
  30248. options = Object.assign(Object.assign({}, options), task.options.expandDirectories);
  30249. }
  30250. return fn(task.pattern, options);
  30251. };
  30252. const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern];
  30253. const getFilterSync = options => {
  30254. return options && options.gitignore ? gitignore.sync({
  30255. cwd: options.cwd,
  30256. ignore: options.ignore
  30257. }) : DEFAULT_FILTER;
  30258. };
  30259. const globToTask = task => glob => {
  30260. const {
  30261. options
  30262. } = task;
  30263. if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
  30264. options.ignore = dirGlob.sync(options.ignore);
  30265. }
  30266. return {
  30267. pattern: glob,
  30268. options
  30269. };
  30270. };
  30271. var globby = async (patterns, options) => {
  30272. const globTasks = generateGlobTasks(patterns, options);
  30273. const getFilter = async () => {
  30274. return options && options.gitignore ? gitignore({
  30275. cwd: options.cwd,
  30276. ignore: options.ignore
  30277. }) : DEFAULT_FILTER;
  30278. };
  30279. const getTasks = async () => {
  30280. const tasks = await Promise.all(globTasks.map(async task => {
  30281. const globs = await getPattern(task, dirGlob);
  30282. return Promise.all(globs.map(globToTask(task)));
  30283. }));
  30284. return arrayUnion(...tasks);
  30285. };
  30286. const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
  30287. const paths = await Promise.all(tasks.map(task => out(task.pattern, task.options)));
  30288. return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_)));
  30289. };
  30290. var sync = (patterns, options) => {
  30291. const globTasks = generateGlobTasks(patterns, options);
  30292. const tasks = [];
  30293. for (const task of globTasks) {
  30294. const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
  30295. tasks.push(...newTask);
  30296. }
  30297. const filter = getFilterSync(options);
  30298. let matches = [];
  30299. for (const task of tasks) {
  30300. matches = arrayUnion(matches, out.sync(task.pattern, task.options));
  30301. }
  30302. return matches.filter(path_ => !filter(path_));
  30303. };
  30304. var stream = (patterns, options) => {
  30305. const globTasks = generateGlobTasks(patterns, options);
  30306. const tasks = [];
  30307. for (const task of globTasks) {
  30308. const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
  30309. tasks.push(...newTask);
  30310. }
  30311. const filter = getFilterSync(options);
  30312. const filterStream = new FilterStream(p => !filter(p));
  30313. const uniqueStream = new UniqueStream();
  30314. return merge2_1(tasks.map(task => out.stream(task.pattern, task.options))).pipe(filterStream).pipe(uniqueStream);
  30315. };
  30316. var generateGlobTasks_1 = generateGlobTasks;
  30317. var hasMagic = (patterns, options) => [].concat(patterns).some(pattern => out.isDynamicPattern(pattern, options));
  30318. var gitignore_1 = gitignore;
  30319. globby.sync = sync;
  30320. globby.stream = stream;
  30321. globby.generateGlobTasks = generateGlobTasks_1;
  30322. globby.hasMagic = hasMagic;
  30323. globby.gitignore = gitignore_1;
  30324. const _excluded = ["languageId"];
  30325. var createLanguage = function (linguistData, override) {
  30326. const {
  30327. languageId
  30328. } = linguistData,
  30329. rest = _objectWithoutProperties(linguistData, _excluded);
  30330. return Object.assign(Object.assign({
  30331. linguistLanguageId: languageId
  30332. }, rest), override(linguistData));
  30333. };
  30334. /*
  30335. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  30336. Redistribution and use in source and binary forms, with or without
  30337. modification, are permitted provided that the following conditions are met:
  30338. * Redistributions of source code must retain the above copyright
  30339. notice, this list of conditions and the following disclaimer.
  30340. * Redistributions in binary form must reproduce the above copyright
  30341. notice, this list of conditions and the following disclaimer in the
  30342. documentation and/or other materials provided with the distribution.
  30343. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  30344. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30345. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30346. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30347. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30348. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30349. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30350. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30351. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30352. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30353. */
  30354. var ast = createCommonjsModule(function (module) {
  30355. (function () {
  30356. function isExpression(node) {
  30357. if (node == null) {
  30358. return false;
  30359. }
  30360. switch (node.type) {
  30361. case 'ArrayExpression':
  30362. case 'AssignmentExpression':
  30363. case 'BinaryExpression':
  30364. case 'CallExpression':
  30365. case 'ConditionalExpression':
  30366. case 'FunctionExpression':
  30367. case 'Identifier':
  30368. case 'Literal':
  30369. case 'LogicalExpression':
  30370. case 'MemberExpression':
  30371. case 'NewExpression':
  30372. case 'ObjectExpression':
  30373. case 'SequenceExpression':
  30374. case 'ThisExpression':
  30375. case 'UnaryExpression':
  30376. case 'UpdateExpression':
  30377. return true;
  30378. }
  30379. return false;
  30380. }
  30381. function isIterationStatement(node) {
  30382. if (node == null) {
  30383. return false;
  30384. }
  30385. switch (node.type) {
  30386. case 'DoWhileStatement':
  30387. case 'ForInStatement':
  30388. case 'ForStatement':
  30389. case 'WhileStatement':
  30390. return true;
  30391. }
  30392. return false;
  30393. }
  30394. function isStatement(node) {
  30395. if (node == null) {
  30396. return false;
  30397. }
  30398. switch (node.type) {
  30399. case 'BlockStatement':
  30400. case 'BreakStatement':
  30401. case 'ContinueStatement':
  30402. case 'DebuggerStatement':
  30403. case 'DoWhileStatement':
  30404. case 'EmptyStatement':
  30405. case 'ExpressionStatement':
  30406. case 'ForInStatement':
  30407. case 'ForStatement':
  30408. case 'IfStatement':
  30409. case 'LabeledStatement':
  30410. case 'ReturnStatement':
  30411. case 'SwitchStatement':
  30412. case 'ThrowStatement':
  30413. case 'TryStatement':
  30414. case 'VariableDeclaration':
  30415. case 'WhileStatement':
  30416. case 'WithStatement':
  30417. return true;
  30418. }
  30419. return false;
  30420. }
  30421. function isSourceElement(node) {
  30422. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  30423. }
  30424. function trailingStatement(node) {
  30425. switch (node.type) {
  30426. case 'IfStatement':
  30427. if (node.alternate != null) {
  30428. return node.alternate;
  30429. }
  30430. return node.consequent;
  30431. case 'LabeledStatement':
  30432. case 'ForStatement':
  30433. case 'ForInStatement':
  30434. case 'WhileStatement':
  30435. case 'WithStatement':
  30436. return node.body;
  30437. }
  30438. return null;
  30439. }
  30440. function isProblematicIfStatement(node) {
  30441. var current;
  30442. if (node.type !== 'IfStatement') {
  30443. return false;
  30444. }
  30445. if (node.alternate == null) {
  30446. return false;
  30447. }
  30448. current = node.consequent;
  30449. do {
  30450. if (current.type === 'IfStatement') {
  30451. if (current.alternate == null) {
  30452. return true;
  30453. }
  30454. }
  30455. current = trailingStatement(current);
  30456. } while (current);
  30457. return false;
  30458. }
  30459. module.exports = {
  30460. isExpression: isExpression,
  30461. isStatement: isStatement,
  30462. isIterationStatement: isIterationStatement,
  30463. isSourceElement: isSourceElement,
  30464. isProblematicIfStatement: isProblematicIfStatement,
  30465. trailingStatement: trailingStatement
  30466. };
  30467. })();
  30468. /* vim: set sw=4 ts=4 et tw=80 : */
  30469. });
  30470. /*
  30471. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  30472. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  30473. Redistribution and use in source and binary forms, with or without
  30474. modification, are permitted provided that the following conditions are met:
  30475. * Redistributions of source code must retain the above copyright
  30476. notice, this list of conditions and the following disclaimer.
  30477. * Redistributions in binary form must reproduce the above copyright
  30478. notice, this list of conditions and the following disclaimer in the
  30479. documentation and/or other materials provided with the distribution.
  30480. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30481. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30482. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30483. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30484. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30485. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30486. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30487. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30488. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30489. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30490. */
  30491. var code = createCommonjsModule(function (module) {
  30492. (function () {
  30493. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  30494. ES5Regex = {
  30495. // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
  30496. NonAsciiIdentifierStart: /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]/,
  30497. // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
  30498. NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
  30499. };
  30500. ES6Regex = {
  30501. // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
  30502. NonAsciiIdentifierStart: /[\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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
  30503. // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
  30504. NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\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\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  30505. };
  30506. function isDecimalDigit(ch) {
  30507. return 0x30 <= ch && ch <= 0x39; // 0..9
  30508. }
  30509. function isHexDigit(ch) {
  30510. return 0x30 <= ch && ch <= 0x39 || // 0..9
  30511. 0x61 <= ch && ch <= 0x66 || // a..f
  30512. 0x41 <= ch && ch <= 0x46; // A..F
  30513. }
  30514. function isOctalDigit(ch) {
  30515. return ch >= 0x30 && ch <= 0x37; // 0..7
  30516. } // 7.2 White Space
  30517. NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  30518. function isWhiteSpace(ch) {
  30519. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  30520. } // 7.3 Line Terminators
  30521. function isLineTerminator(ch) {
  30522. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  30523. } // 7.6 Identifier Names and Identifiers
  30524. function fromCodePoint(cp) {
  30525. if (cp <= 0xFFFF) {
  30526. return String.fromCharCode(cp);
  30527. }
  30528. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  30529. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  30530. return cu1 + cu2;
  30531. }
  30532. IDENTIFIER_START = new Array(0x80);
  30533. for (ch = 0; ch < 0x80; ++ch) {
  30534. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  30535. ch >= 0x41 && ch <= 0x5A || // A..Z
  30536. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  30537. }
  30538. IDENTIFIER_PART = new Array(0x80);
  30539. for (ch = 0; ch < 0x80; ++ch) {
  30540. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  30541. ch >= 0x41 && ch <= 0x5A || // A..Z
  30542. ch >= 0x30 && ch <= 0x39 || // 0..9
  30543. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  30544. }
  30545. function isIdentifierStartES5(ch) {
  30546. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  30547. }
  30548. function isIdentifierPartES5(ch) {
  30549. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  30550. }
  30551. function isIdentifierStartES6(ch) {
  30552. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  30553. }
  30554. function isIdentifierPartES6(ch) {
  30555. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  30556. }
  30557. module.exports = {
  30558. isDecimalDigit: isDecimalDigit,
  30559. isHexDigit: isHexDigit,
  30560. isOctalDigit: isOctalDigit,
  30561. isWhiteSpace: isWhiteSpace,
  30562. isLineTerminator: isLineTerminator,
  30563. isIdentifierStartES5: isIdentifierStartES5,
  30564. isIdentifierPartES5: isIdentifierPartES5,
  30565. isIdentifierStartES6: isIdentifierStartES6,
  30566. isIdentifierPartES6: isIdentifierPartES6
  30567. };
  30568. })();
  30569. /* vim: set sw=4 ts=4 et tw=80 : */
  30570. });
  30571. /*
  30572. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  30573. Redistribution and use in source and binary forms, with or without
  30574. modification, are permitted provided that the following conditions are met:
  30575. * Redistributions of source code must retain the above copyright
  30576. notice, this list of conditions and the following disclaimer.
  30577. * Redistributions in binary form must reproduce the above copyright
  30578. notice, this list of conditions and the following disclaimer in the
  30579. documentation and/or other materials provided with the distribution.
  30580. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30581. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30582. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30583. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30584. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30585. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30586. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30587. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30588. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30589. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30590. */
  30591. var keyword = createCommonjsModule(function (module) {
  30592. (function () {
  30593. var code$1 = code;
  30594. function isStrictModeReservedWordES6(id) {
  30595. switch (id) {
  30596. case 'implements':
  30597. case 'interface':
  30598. case 'package':
  30599. case 'private':
  30600. case 'protected':
  30601. case 'public':
  30602. case 'static':
  30603. case 'let':
  30604. return true;
  30605. default:
  30606. return false;
  30607. }
  30608. }
  30609. function isKeywordES5(id, strict) {
  30610. // yield should not be treated as keyword under non-strict mode.
  30611. if (!strict && id === 'yield') {
  30612. return false;
  30613. }
  30614. return isKeywordES6(id, strict);
  30615. }
  30616. function isKeywordES6(id, strict) {
  30617. if (strict && isStrictModeReservedWordES6(id)) {
  30618. return true;
  30619. }
  30620. switch (id.length) {
  30621. case 2:
  30622. return id === 'if' || id === 'in' || id === 'do';
  30623. case 3:
  30624. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  30625. case 4:
  30626. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  30627. case 5:
  30628. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  30629. case 6:
  30630. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  30631. case 7:
  30632. return id === 'default' || id === 'finally' || id === 'extends';
  30633. case 8:
  30634. return id === 'function' || id === 'continue' || id === 'debugger';
  30635. case 10:
  30636. return id === 'instanceof';
  30637. default:
  30638. return false;
  30639. }
  30640. }
  30641. function isReservedWordES5(id, strict) {
  30642. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  30643. }
  30644. function isReservedWordES6(id, strict) {
  30645. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  30646. }
  30647. function isRestrictedWord(id) {
  30648. return id === 'eval' || id === 'arguments';
  30649. }
  30650. function isIdentifierNameES5(id) {
  30651. var i, iz, ch;
  30652. if (id.length === 0) {
  30653. return false;
  30654. }
  30655. ch = id.charCodeAt(0);
  30656. if (!code$1.isIdentifierStartES5(ch)) {
  30657. return false;
  30658. }
  30659. for (i = 1, iz = id.length; i < iz; ++i) {
  30660. ch = id.charCodeAt(i);
  30661. if (!code$1.isIdentifierPartES5(ch)) {
  30662. return false;
  30663. }
  30664. }
  30665. return true;
  30666. }
  30667. function decodeUtf16(lead, trail) {
  30668. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  30669. }
  30670. function isIdentifierNameES6(id) {
  30671. var i, iz, ch, lowCh, check;
  30672. if (id.length === 0) {
  30673. return false;
  30674. }
  30675. check = code$1.isIdentifierStartES6;
  30676. for (i = 0, iz = id.length; i < iz; ++i) {
  30677. ch = id.charCodeAt(i);
  30678. if (0xD800 <= ch && ch <= 0xDBFF) {
  30679. ++i;
  30680. if (i >= iz) {
  30681. return false;
  30682. }
  30683. lowCh = id.charCodeAt(i);
  30684. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  30685. return false;
  30686. }
  30687. ch = decodeUtf16(ch, lowCh);
  30688. }
  30689. if (!check(ch)) {
  30690. return false;
  30691. }
  30692. check = code$1.isIdentifierPartES6;
  30693. }
  30694. return true;
  30695. }
  30696. function isIdentifierES5(id, strict) {
  30697. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  30698. }
  30699. function isIdentifierES6(id, strict) {
  30700. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  30701. }
  30702. module.exports = {
  30703. isKeywordES5: isKeywordES5,
  30704. isKeywordES6: isKeywordES6,
  30705. isReservedWordES5: isReservedWordES5,
  30706. isReservedWordES6: isReservedWordES6,
  30707. isRestrictedWord: isRestrictedWord,
  30708. isIdentifierNameES5: isIdentifierNameES5,
  30709. isIdentifierNameES6: isIdentifierNameES6,
  30710. isIdentifierES5: isIdentifierES5,
  30711. isIdentifierES6: isIdentifierES6
  30712. };
  30713. })();
  30714. /* vim: set sw=4 ts=4 et tw=80 : */
  30715. });
  30716. /*
  30717. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  30718. Redistribution and use in source and binary forms, with or without
  30719. modification, are permitted provided that the following conditions are met:
  30720. * Redistributions of source code must retain the above copyright
  30721. notice, this list of conditions and the following disclaimer.
  30722. * Redistributions in binary form must reproduce the above copyright
  30723. notice, this list of conditions and the following disclaimer in the
  30724. documentation and/or other materials provided with the distribution.
  30725. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30726. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30727. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30728. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30729. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30730. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30731. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30732. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30733. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30734. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30735. */
  30736. var utils$6 = createCommonjsModule(function (module, exports) {
  30737. (function () {
  30738. exports.ast = ast;
  30739. exports.code = code;
  30740. exports.keyword = keyword;
  30741. })();
  30742. /* vim: set sw=4 ts=4 et tw=80 : */
  30743. });
  30744. const isIdentifierName = utils$6.keyword.isIdentifierNameES5;
  30745. const {
  30746. getLast: getLast$d,
  30747. hasNewline: hasNewline$7,
  30748. skipWhitespace,
  30749. isNonEmptyArray: isNonEmptyArray$h,
  30750. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$1,
  30751. getStringWidth: getStringWidth$3
  30752. } = util$5;
  30753. const {
  30754. locStart: locStart$q,
  30755. locEnd: locEnd$p,
  30756. hasSameLocStart
  30757. } = loc$6;
  30758. /**
  30759. * @typedef {import("./types/estree").Node} Node
  30760. * @typedef {import("./types/estree").TemplateLiteral} TemplateLiteral
  30761. * @typedef {import("./types/estree").Comment} Comment
  30762. * @typedef {import("./types/estree").MemberExpression} MemberExpression
  30763. * @typedef {import("./types/estree").OptionalMemberExpression} OptionalMemberExpression
  30764. * @typedef {import("./types/estree").CallExpression} CallExpression
  30765. * @typedef {import("./types/estree").OptionalCallExpression} OptionalCallExpression
  30766. * @typedef {import("./types/estree").Expression} Expression
  30767. * @typedef {import("./types/estree").Property} Property
  30768. * @typedef {import("./types/estree").ObjectTypeProperty} ObjectTypeProperty
  30769. * @typedef {import("./types/estree").TaggedTemplateExpression} TaggedTemplateExpression
  30770. * @typedef {import("./types/estree").Literal} Literal
  30771. *
  30772. * @typedef {import("../common/ast-path")} AstPath
  30773. */
  30774. // We match any whitespace except line terminators because
  30775. // Flow annotation comments cannot be split across lines. For example:
  30776. //
  30777. // (this /*
  30778. // : any */).foo = 5;
  30779. //
  30780. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  30781. // removing the newline would create a type annotation that the user did not intend
  30782. // to create.
  30783. const NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  30784. const FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
  30785. const FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
  30786. /**
  30787. * @param {Node} node
  30788. * @returns {boolean}
  30789. */
  30790. function hasFlowShorthandAnnotationComment$3(node) {
  30791. // https://flow.org/en/docs/types/comments/
  30792. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  30793. return node.extra && node.extra.parenthesized && isNonEmptyArray$h(node.trailingComments) && isBlockComment$5(node.trailingComments[0]) && FLOW_SHORTHAND_ANNOTATION.test(node.trailingComments[0].value);
  30794. }
  30795. /**
  30796. * @param {Comment[]} comments
  30797. * @returns {boolean}
  30798. */
  30799. function hasFlowAnnotationComment$2(comments) {
  30800. return isNonEmptyArray$h(comments) && isBlockComment$5(comments[0]) && FLOW_ANNOTATION.test(comments[0].value);
  30801. }
  30802. /**
  30803. * @param {Node} node
  30804. * @param {(Node) => boolean} fn
  30805. * @returns {boolean}
  30806. */
  30807. function hasNode$2(node, fn) {
  30808. if (!node || typeof node !== "object") {
  30809. return false;
  30810. }
  30811. if (Array.isArray(node)) {
  30812. return node.some(value => hasNode$2(value, fn));
  30813. }
  30814. const result = fn(node);
  30815. return typeof result === "boolean" ? result : Object.values(node).some(value => hasNode$2(value, fn));
  30816. }
  30817. /**
  30818. * @param {Node} node
  30819. * @returns {boolean}
  30820. */
  30821. function hasNakedLeftSide$3(node) {
  30822. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || isCallExpression$d(node) || isMemberExpression$a(node) || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
  30823. }
  30824. function getLeftSide$1(node) {
  30825. if (node.expressions) {
  30826. return node.expressions[0];
  30827. }
  30828. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  30829. }
  30830. function getLeftSidePathName$2(path, node) {
  30831. if (node.expressions) {
  30832. return ["expressions", 0];
  30833. }
  30834. if (node.left) {
  30835. return ["left"];
  30836. }
  30837. if (node.test) {
  30838. return ["test"];
  30839. }
  30840. if (node.object) {
  30841. return ["object"];
  30842. }
  30843. if (node.callee) {
  30844. return ["callee"];
  30845. }
  30846. if (node.tag) {
  30847. return ["tag"];
  30848. }
  30849. if (node.argument) {
  30850. return ["argument"];
  30851. }
  30852. if (node.expression) {
  30853. return ["expression"];
  30854. }
  30855. throw new Error("Unexpected node has no left side.");
  30856. }
  30857. /**
  30858. * @param {Comment} comment
  30859. * @returns {boolean}
  30860. */
  30861. function isBlockComment$5(comment) {
  30862. return comment.type === "Block" || comment.type === "CommentBlock" || // `meriyah`
  30863. comment.type === "MultiLine";
  30864. }
  30865. /**
  30866. * @param {Comment} comment
  30867. * @returns {boolean}
  30868. */
  30869. function isLineComment$3(comment) {
  30870. return comment.type === "Line" || comment.type === "CommentLine" || // `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
  30871. comment.type === "SingleLine" || comment.type === "HashbangComment" || comment.type === "HTMLOpen" || comment.type === "HTMLClose";
  30872. }
  30873. const exportDeclarationTypes = new Set(["ExportDefaultDeclaration", "ExportDefaultSpecifier", "DeclareExportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
  30874. /**
  30875. * @param {Node} node
  30876. * @returns {boolean}
  30877. */
  30878. function isExportDeclaration(node) {
  30879. return node && exportDeclarationTypes.has(node.type);
  30880. }
  30881. /**
  30882. * @param {AstPath} path
  30883. * @returns {Node | null}
  30884. */
  30885. function getParentExportDeclaration$2(path) {
  30886. const parentNode = path.getParentNode();
  30887. if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
  30888. return parentNode;
  30889. }
  30890. return null;
  30891. }
  30892. /**
  30893. * @param {Node} node
  30894. * @returns {boolean}
  30895. */
  30896. function isLiteral$3(node) {
  30897. return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
  30898. }
  30899. /**
  30900. * @param {Node} node
  30901. * @returns {boolean}
  30902. */
  30903. function isNumericLiteral$5(node) {
  30904. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  30905. }
  30906. function isSignedNumericLiteral$2(node) {
  30907. return node.type === "UnaryExpression" && (node.operator === "+" || node.operator === "-") && isNumericLiteral$5(node.argument);
  30908. }
  30909. /**
  30910. * @param {Node} node
  30911. * @returns {boolean}
  30912. */
  30913. function isStringLiteral$5(node) {
  30914. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  30915. }
  30916. /**
  30917. * @param {Node} node
  30918. * @returns {boolean}
  30919. */
  30920. function isObjectType$2(node) {
  30921. return node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || node.type === "TSMappedType";
  30922. }
  30923. /**
  30924. * @param {Node} node
  30925. * @returns {boolean}
  30926. */
  30927. function isFunctionOrArrowExpression$1(node) {
  30928. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  30929. }
  30930. /**
  30931. * @param {Node} node
  30932. * @returns {boolean}
  30933. */
  30934. function isFunctionOrArrowExpressionWithBody(node) {
  30935. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  30936. }
  30937. /**
  30938. * @param {Node} node
  30939. * @returns {boolean}
  30940. */
  30941. function isTemplateLiteral(node) {
  30942. return node.type === "TemplateLiteral";
  30943. }
  30944. /**
  30945. * Note: `inject` is used in AngularJS 1.x, `async` in Angular 2+
  30946. * example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  30947. *
  30948. * @param {CallExpression} node
  30949. * @returns {boolean}
  30950. */
  30951. function isAngularTestWrapper(node) {
  30952. return isCallExpression$d(node) && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  30953. }
  30954. /**
  30955. * @param {Node} node
  30956. * @returns {boolean}
  30957. */
  30958. function isJsxNode$7(node) {
  30959. return node.type === "JSXElement" || node.type === "JSXFragment";
  30960. }
  30961. function isTheOnlyJsxElementInMarkdown$2(options, path) {
  30962. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  30963. return false;
  30964. }
  30965. const node = path.getNode();
  30966. if (!node.expression || !isJsxNode$7(node.expression)) {
  30967. return false;
  30968. }
  30969. const parent = path.getParentNode();
  30970. return parent.type === "Program" && parent.body.length === 1;
  30971. }
  30972. function isGetterOrSetter$1(node) {
  30973. return node.kind === "get" || node.kind === "set";
  30974. } // TODO: This is a bad hack and we need a better way to distinguish between
  30975. // arrow functions and otherwise
  30976. function isFunctionNotation$1(node) {
  30977. return isGetterOrSetter$1(node) || hasSameLocStart(node, node.value);
  30978. } // Hack to differentiate between the following two which have the same ast
  30979. // type T = { method: () => void };
  30980. // type T = { method(): void };
  30981. /**
  30982. * @param {Node} node
  30983. * @returns {boolean}
  30984. */
  30985. function isObjectTypePropertyAFunction$2(node) {
  30986. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation$1(node);
  30987. } // Hack to differentiate between the following two which have the same ast
  30988. // declare function f(a): void;
  30989. // var f: (a) => void;
  30990. function isTypeAnnotationAFunction$1(node) {
  30991. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !hasSameLocStart(node, node.typeAnnotation);
  30992. }
  30993. const binaryishNodeTypes = new Set(["BinaryExpression", "LogicalExpression", "NGPipeExpression"]);
  30994. /**
  30995. * @param {Node} node
  30996. * @returns {boolean}
  30997. */
  30998. function isBinaryish$5(node) {
  30999. return binaryishNodeTypes.has(node.type);
  31000. }
  31001. /**
  31002. * @param {Node} node
  31003. * @returns {boolean}
  31004. */
  31005. function isMemberish$2(node) {
  31006. return isMemberExpression$a(node) || node.type === "BindExpression" && Boolean(node.object);
  31007. }
  31008. const simpleTypeAnnotations = new Set([// `any`
  31009. "AnyTypeAnnotation", "TSAnyKeyword", // `null`
  31010. "NullLiteralTypeAnnotation", "TSNullKeyword", // `this`
  31011. "ThisTypeAnnotation", "TSThisType", // `number`
  31012. "NumberTypeAnnotation", "TSNumberKeyword", // `void`
  31013. "VoidTypeAnnotation", "TSVoidKeyword", // `boolean`
  31014. "BooleanTypeAnnotation", "TSBooleanKeyword", // `bigint`
  31015. "BigIntTypeAnnotation", "TSBigIntKeyword", // `symbol`
  31016. "SymbolTypeAnnotation", "TSSymbolKeyword", // `string`
  31017. "StringTypeAnnotation", "TSStringKeyword", // literals
  31018. "BooleanLiteralTypeAnnotation", "StringLiteralTypeAnnotation", "BigIntLiteralTypeAnnotation", "NumberLiteralTypeAnnotation", "TSLiteralType", "TSTemplateLiteralType", // flow only, `empty`, `mixed`
  31019. "EmptyTypeAnnotation", "MixedTypeAnnotation", // typescript only, `never`, `object`, `undefined`, `unknown`
  31020. "TSNeverKeyword", "TSObjectKeyword", "TSUndefinedKeyword", "TSUnknownKeyword"]);
  31021. /**
  31022. * @param {Node} node
  31023. * @returns {boolean}
  31024. */
  31025. function isSimpleType$2(node) {
  31026. if (!node) {
  31027. return false;
  31028. }
  31029. if ((node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference") && !node.typeParameters) {
  31030. return true;
  31031. }
  31032. if (simpleTypeAnnotations.has(node.type)) {
  31033. return true;
  31034. }
  31035. return false;
  31036. }
  31037. const unitTestRe = /^(?:skip|[fx]?(?:it|describe|test))$/;
  31038. /**
  31039. * @param {{callee: MemberExpression | OptionalMemberExpression}} node
  31040. * @returns {boolean}
  31041. */
  31042. function isSkipOrOnlyBlock(node) {
  31043. return isMemberExpression$a(node.callee) && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
  31044. }
  31045. /**
  31046. * @param {CallExpression} node
  31047. * @returns {boolean}
  31048. */
  31049. function isUnitTestSetUp(node) {
  31050. const unitTestSetUpRe = /^(?:before|after)(?:Each|All)$/;
  31051. return node.callee.type === "Identifier" && unitTestSetUpRe.test(node.callee.name) && node.arguments.length === 1;
  31052. } // eg; `describe("some string", (done) => {})`
  31053. function isTestCall$3(node, parent) {
  31054. if (node.type !== "CallExpression") {
  31055. return false;
  31056. }
  31057. if (node.arguments.length === 1) {
  31058. if (isAngularTestWrapper(node) && parent && isTestCall$3(parent)) {
  31059. return isFunctionOrArrowExpression$1(node.arguments[0]);
  31060. }
  31061. if (isUnitTestSetUp(node)) {
  31062. return isAngularTestWrapper(node.arguments[0]);
  31063. }
  31064. } else if (node.arguments.length === 2 || node.arguments.length === 3) {
  31065. if ((node.callee.type === "Identifier" && unitTestRe.test(node.callee.name) || isSkipOrOnlyBlock(node)) && (isTemplateLiteral(node.arguments[0]) || isStringLiteral$5(node.arguments[0]))) {
  31066. // it("name", () => { ... }, 2500)
  31067. if (node.arguments[2] && !isNumericLiteral$5(node.arguments[2])) {
  31068. return false;
  31069. }
  31070. return (node.arguments.length === 2 ? isFunctionOrArrowExpression$1(node.arguments[1]) : isFunctionOrArrowExpressionWithBody(node.arguments[1]) && getFunctionParameters$6(node.arguments[1]).length <= 1) || isAngularTestWrapper(node.arguments[1]);
  31071. }
  31072. }
  31073. return false;
  31074. }
  31075. /**
  31076. * @param {Node} node
  31077. * @returns {boolean}
  31078. */
  31079. function isCallExpression$d(node) {
  31080. return node && (node.type === "CallExpression" || node.type === "OptionalCallExpression");
  31081. }
  31082. /**
  31083. * @param {Node} node
  31084. * @returns {boolean}
  31085. */
  31086. function isMemberExpression$a(node) {
  31087. return node && (node.type === "MemberExpression" || node.type === "OptionalMemberExpression");
  31088. }
  31089. /**
  31090. *
  31091. * @param {any} node
  31092. * @returns {boolean}
  31093. */
  31094. function isSimpleTemplateLiteral$1(node) {
  31095. let expressionsKey = "expressions";
  31096. if (node.type === "TSTemplateLiteralType") {
  31097. expressionsKey = "types";
  31098. }
  31099. const expressions = node[expressionsKey];
  31100. if (expressions.length === 0) {
  31101. return false;
  31102. }
  31103. return expressions.every(expr => {
  31104. // Disallow comments since printDocToString can't print them here
  31105. if (hasComment$j(expr)) {
  31106. return false;
  31107. } // Allow `x` and `this`
  31108. if (expr.type === "Identifier" || expr.type === "ThisExpression") {
  31109. return true;
  31110. } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
  31111. if (isMemberExpression$a(expr)) {
  31112. let head = expr;
  31113. while (isMemberExpression$a(head)) {
  31114. if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") {
  31115. return false;
  31116. }
  31117. head = head.object;
  31118. if (hasComment$j(head)) {
  31119. return false;
  31120. }
  31121. }
  31122. if (head.type === "Identifier" || head.type === "ThisExpression") {
  31123. return true;
  31124. }
  31125. return false;
  31126. }
  31127. return false;
  31128. });
  31129. }
  31130. /**
  31131. * @param {string} tokenNode
  31132. * @param {string} keyword
  31133. * @returns {string}
  31134. */
  31135. function getTypeScriptMappedTypeModifier$1(tokenNode, keyword) {
  31136. if (tokenNode === "+") {
  31137. return "+" + keyword;
  31138. }
  31139. if (tokenNode === "-") {
  31140. return "-" + keyword;
  31141. }
  31142. return keyword;
  31143. }
  31144. /**
  31145. * @param {string} text
  31146. * @param {Node} typeAnnotation
  31147. * @returns {boolean}
  31148. */
  31149. function isFlowAnnotationComment$2(text, typeAnnotation) {
  31150. const start = locStart$q(typeAnnotation);
  31151. const end = skipWhitespace(text, locEnd$p(typeAnnotation));
  31152. return end !== false && text.slice(start, start + 2) === "/*" && text.slice(end, end + 2) === "*/";
  31153. }
  31154. /**
  31155. * @param {string} text
  31156. * @param {Node} node
  31157. * @returns {boolean}
  31158. */
  31159. function hasLeadingOwnLineComment$4(text, node) {
  31160. if (isJsxNode$7(node)) {
  31161. return hasNodeIgnoreComment$1(node);
  31162. }
  31163. return hasComment$j(node, CommentCheckFlags$g.Leading, comment => hasNewline$7(text, locEnd$p(comment)));
  31164. } // Note: Quoting/unquoting numbers in TypeScript is not safe.
  31165. //
  31166. // let a = { 1: 1, 2: 2 }
  31167. // let b = { '1': 1, '2': 2 }
  31168. //
  31169. // declare let aa: keyof typeof a;
  31170. // declare let bb: keyof typeof b;
  31171. //
  31172. // aa = bb;
  31173. // ^^
  31174. // Type '"1" | "2"' is not assignable to type '1 | 2'.
  31175. // Type '"1"' is not assignable to type '1 | 2'.(2322)
  31176. //
  31177. // And in Flow, you get:
  31178. //
  31179. // const x = {
  31180. // 0: 1
  31181. // ^ Non-string literal property keys not supported. [unsupported-syntax]
  31182. // }
  31183. //
  31184. // Angular does not support unquoted numbers in expressions.
  31185. //
  31186. // So we play it safe and only unquote numbers for the JavaScript parsers.
  31187. // (Vue supports unquoted numbers in expressions, but let’s keep it simple.)
  31188. //
  31189. // Identifiers can be unquoted in more circumstances, though.
  31190. function isStringPropSafeToUnquote$1(node, options) {
  31191. return options.parser !== "json" && isStringLiteral$5(node.key) && rawText$5(node.key).slice(1, -1) === node.key.value && (isIdentifierName(node.key.value) && // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
  31192. // See https://github.com/microsoft/TypeScript/pull/20075
  31193. !((options.parser === "typescript" || options.parser === "babel-ts") && node.type === "ClassProperty") || isSimpleNumber$1(node.key.value) && String(Number(node.key.value)) === node.key.value && (options.parser === "babel" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree"));
  31194. } // Matches “simple” numbers like `123` and `2.5` but not `1_000`, `1e+100` or `0b10`.
  31195. function isSimpleNumber$1(numberString) {
  31196. return /^(?:\d+|\d+\.\d+)$/.test(numberString);
  31197. }
  31198. /**
  31199. * @param {Node} node
  31200. * @param {Node} parentNode
  31201. * @returns {boolean}
  31202. */
  31203. function isJestEachTemplateLiteral$1(node, parentNode) {
  31204. /**
  31205. * describe.each`table`(name, fn)
  31206. * describe.only.each`table`(name, fn)
  31207. * describe.skip.each`table`(name, fn)
  31208. * test.each`table`(name, fn)
  31209. * test.only.each`table`(name, fn)
  31210. * test.skip.each`table`(name, fn)
  31211. *
  31212. * Ref: https://github.com/facebook/jest/pull/6102
  31213. */
  31214. const jestEachTriggerRegex = /^[fx]?(?:describe|it|test)$/;
  31215. return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name));
  31216. }
  31217. /**
  31218. * @param {TemplateLiteral} template
  31219. * @returns {boolean}
  31220. */
  31221. function templateLiteralHasNewLines(template) {
  31222. return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
  31223. }
  31224. /**
  31225. * @param {TemplateLiteral | TaggedTemplateExpression} node
  31226. * @param {string} text
  31227. * @returns {boolean}
  31228. */
  31229. function isTemplateOnItsOwnLine$2(node, text) {
  31230. return (node.type === "TemplateLiteral" && templateLiteralHasNewLines(node) || node.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(node.quasi)) && !hasNewline$7(text, locStart$q(node), {
  31231. backwards: true
  31232. });
  31233. }
  31234. /**
  31235. * @param {Node} node
  31236. * @returns {boolean}
  31237. */
  31238. function needsHardlineAfterDanglingComment$2(node) {
  31239. if (!hasComment$j(node)) {
  31240. return false;
  31241. }
  31242. const lastDanglingComment = getLast$d(getComments$5(node, CommentCheckFlags$g.Dangling));
  31243. return lastDanglingComment && !isBlockComment$5(lastDanglingComment);
  31244. } // Logic to check for args with multiple anonymous functions. For instance,
  31245. // the following call should be split on multiple lines for readability:
  31246. // source.pipe(map((x) => x + x), filter((x) => x % 2 === 0))
  31247. function isFunctionCompositionArgs$1(args) {
  31248. if (args.length <= 1) {
  31249. return false;
  31250. }
  31251. let count = 0;
  31252. for (const arg of args) {
  31253. if (isFunctionOrArrowExpression$1(arg)) {
  31254. count += 1;
  31255. if (count > 1) {
  31256. return true;
  31257. }
  31258. } else if (isCallExpression$d(arg)) {
  31259. for (const childArg of arg.arguments) {
  31260. if (isFunctionOrArrowExpression$1(childArg)) {
  31261. return true;
  31262. }
  31263. }
  31264. }
  31265. }
  31266. return false;
  31267. } // Logic to determine if a call is a “long curried function call”.
  31268. // See https://github.com/prettier/prettier/issues/1420.
  31269. //
  31270. // `connect(a, b, c)(d)`
  31271. // In the above call expression, the second call is the parent node and the
  31272. // first call is the current node.
  31273. /**
  31274. * @param {AstPath} path
  31275. * @returns {boolean}
  31276. */
  31277. function isLongCurriedCallExpression$2(path) {
  31278. const node = path.getValue();
  31279. const parent = path.getParentNode();
  31280. return isCallExpression$d(node) && isCallExpression$d(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
  31281. }
  31282. /**
  31283. * @param {any} node
  31284. * @param {number} depth
  31285. * @returns {boolean}
  31286. */
  31287. function isSimpleCallArgument$1(node, depth) {
  31288. if (depth >= 2) {
  31289. return false;
  31290. }
  31291. const isChildSimple = child => isSimpleCallArgument$1(child, depth + 1);
  31292. const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
  31293. if (regexpPattern && getStringWidth$3(regexpPattern) > 5) {
  31294. return false;
  31295. }
  31296. if (node.type === "Literal" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "BooleanLiteral" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "Identifier" || node.type === "ThisExpression" || node.type === "Super" || node.type === "PrivateName" || node.type === "PrivateIdentifier" || node.type === "ArgumentPlaceholder" || node.type === "Import") {
  31297. return true;
  31298. }
  31299. if (node.type === "TemplateLiteral") {
  31300. return node.quasis.every(element => !element.value.raw.includes("\n")) && node.expressions.every(isChildSimple);
  31301. }
  31302. if (node.type === "ObjectExpression") {
  31303. return node.properties.every(p => !p.computed && (p.shorthand || p.value && isChildSimple(p.value)));
  31304. }
  31305. if (node.type === "ArrayExpression") {
  31306. return node.elements.every(x => x === null || isChildSimple(x));
  31307. }
  31308. if (isCallLikeExpression$2(node)) {
  31309. return (node.type === "ImportExpression" || isSimpleCallArgument$1(node.callee, depth)) && getCallArguments$5(node).every(isChildSimple);
  31310. }
  31311. if (isMemberExpression$a(node)) {
  31312. return isSimpleCallArgument$1(node.object, depth) && isSimpleCallArgument$1(node.property, depth);
  31313. }
  31314. if (node.type === "UnaryExpression" && (node.operator === "!" || node.operator === "-")) {
  31315. return isSimpleCallArgument$1(node.argument, depth);
  31316. }
  31317. if (node.type === "TSNonNullExpression") {
  31318. return isSimpleCallArgument$1(node.expression, depth);
  31319. }
  31320. return false;
  31321. }
  31322. function rawText$5(node) {
  31323. return node.extra ? node.extra.raw : node.raw;
  31324. }
  31325. function identity$1(x) {
  31326. return x;
  31327. }
  31328. function isTSXFile$1(options) {
  31329. return options.filepath && /\.tsx$/i.test(options.filepath);
  31330. }
  31331. /**
  31332. * @param {any} options
  31333. * @param {("es5" | "all")} [level]
  31334. * @returns {boolean}
  31335. */
  31336. function shouldPrintComma$b(options, level = "es5") {
  31337. return options.trailingComma === "es5" && level === "es5" || options.trailingComma === "all" && (level === "all" || level === "es5");
  31338. }
  31339. /**
  31340. * Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  31341. * holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  31342. * already necessary grouping parentheses.
  31343. *
  31344. * @param {Node} node
  31345. * @param {boolean} forbidFunctionClassAndDoExpr
  31346. * @returns {boolean}
  31347. */
  31348. function startsWithNoLookaheadToken$2(node, forbidFunctionClassAndDoExpr) {
  31349. node = getLeftMost(node);
  31350. switch (node.type) {
  31351. case "FunctionExpression":
  31352. case "ClassExpression":
  31353. case "DoExpression":
  31354. return forbidFunctionClassAndDoExpr;
  31355. case "ObjectExpression":
  31356. return true;
  31357. case "MemberExpression":
  31358. case "OptionalMemberExpression":
  31359. return startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
  31360. case "TaggedTemplateExpression":
  31361. if (node.tag.type === "FunctionExpression") {
  31362. // IIFEs are always already parenthesized
  31363. return false;
  31364. }
  31365. return startsWithNoLookaheadToken$2(node.tag, forbidFunctionClassAndDoExpr);
  31366. case "CallExpression":
  31367. case "OptionalCallExpression":
  31368. if (node.callee.type === "FunctionExpression") {
  31369. // IIFEs are always already parenthesized
  31370. return false;
  31371. }
  31372. return startsWithNoLookaheadToken$2(node.callee, forbidFunctionClassAndDoExpr);
  31373. case "ConditionalExpression":
  31374. return startsWithNoLookaheadToken$2(node.test, forbidFunctionClassAndDoExpr);
  31375. case "UpdateExpression":
  31376. return !node.prefix && startsWithNoLookaheadToken$2(node.argument, forbidFunctionClassAndDoExpr);
  31377. case "BindExpression":
  31378. return node.object && startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
  31379. case "SequenceExpression":
  31380. return startsWithNoLookaheadToken$2(node.expressions[0], forbidFunctionClassAndDoExpr);
  31381. case "TSAsExpression":
  31382. case "TSNonNullExpression":
  31383. return startsWithNoLookaheadToken$2(node.expression, forbidFunctionClassAndDoExpr);
  31384. default:
  31385. return false;
  31386. }
  31387. }
  31388. const equalityOperators = {
  31389. "==": true,
  31390. "!=": true,
  31391. "===": true,
  31392. "!==": true
  31393. };
  31394. const multiplicativeOperators = {
  31395. "*": true,
  31396. "/": true,
  31397. "%": true
  31398. };
  31399. const bitshiftOperators = {
  31400. ">>": true,
  31401. ">>>": true,
  31402. "<<": true
  31403. };
  31404. function shouldFlatten$2(parentOp, nodeOp) {
  31405. if (getPrecedence$1(nodeOp) !== getPrecedence$1(parentOp)) {
  31406. return false;
  31407. } // ** is right-associative
  31408. // x ** y ** z --> x ** (y ** z)
  31409. if (parentOp === "**") {
  31410. return false;
  31411. } // x == y == z --> (x == y) == z
  31412. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  31413. return false;
  31414. } // x * y % z --> (x * y) % z
  31415. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  31416. return false;
  31417. } // x * y / z --> (x * y) / z
  31418. // x / y * z --> (x / y) * z
  31419. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  31420. return false;
  31421. } // x << y << z --> (x << y) << z
  31422. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  31423. return false;
  31424. }
  31425. return true;
  31426. }
  31427. const PRECEDENCE = {};
  31428. for (const [i, tier] of [["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].entries()) {
  31429. for (const op of tier) {
  31430. PRECEDENCE[op] = i;
  31431. }
  31432. }
  31433. function getPrecedence$1(op) {
  31434. return PRECEDENCE[op];
  31435. }
  31436. function getLeftMost(node) {
  31437. while (node.left) {
  31438. node = node.left;
  31439. }
  31440. return node;
  31441. }
  31442. function isBitwiseOperator$1(operator) {
  31443. return Boolean(bitshiftOperators[operator]) || operator === "|" || operator === "^" || operator === "&";
  31444. }
  31445. function hasRestParameter$1(node) {
  31446. if (node.rest) {
  31447. return true;
  31448. }
  31449. const parameters = getFunctionParameters$6(node);
  31450. return parameters.length > 0 && getLast$d(parameters).type === "RestElement";
  31451. }
  31452. const functionParametersCache = new WeakMap();
  31453. function getFunctionParameters$6(node) {
  31454. if (functionParametersCache.has(node)) {
  31455. return functionParametersCache.get(node);
  31456. }
  31457. const parameters = [];
  31458. if (node.this) {
  31459. parameters.push(node.this);
  31460. } // `params` vs `parameters` - see https://github.com/babel/babel/issues/9231
  31461. if (Array.isArray(node.parameters)) {
  31462. parameters.push(...node.parameters);
  31463. } else if (Array.isArray(node.params)) {
  31464. parameters.push(...node.params);
  31465. }
  31466. if (node.rest) {
  31467. parameters.push(node.rest);
  31468. }
  31469. functionParametersCache.set(node, parameters);
  31470. return parameters;
  31471. }
  31472. function iterateFunctionParametersPath$1(path, iteratee) {
  31473. const node = path.getValue();
  31474. let index = 0;
  31475. const callback = childPath => iteratee(childPath, index++);
  31476. if (node.this) {
  31477. path.call(callback, "this");
  31478. }
  31479. if (Array.isArray(node.parameters)) {
  31480. path.each(callback, "parameters");
  31481. } else if (Array.isArray(node.params)) {
  31482. path.each(callback, "params");
  31483. }
  31484. if (node.rest) {
  31485. path.call(callback, "rest");
  31486. }
  31487. }
  31488. const callArgumentsCache = new WeakMap();
  31489. function getCallArguments$5(node) {
  31490. if (callArgumentsCache.has(node)) {
  31491. return callArgumentsCache.get(node);
  31492. }
  31493. let args = node.arguments;
  31494. if (node.type === "ImportExpression") {
  31495. args = [node.source];
  31496. if (node.attributes) {
  31497. args.push(node.attributes);
  31498. }
  31499. }
  31500. callArgumentsCache.set(node, args);
  31501. return args;
  31502. }
  31503. function iterateCallArgumentsPath$2(path, iteratee) {
  31504. const node = path.getValue();
  31505. if (node.type === "ImportExpression") {
  31506. path.call(sourcePath => iteratee(sourcePath, 0), "source");
  31507. if (node.attributes) {
  31508. path.call(sourcePath => iteratee(sourcePath, 1), "attributes");
  31509. }
  31510. } else {
  31511. path.each(iteratee, "arguments");
  31512. }
  31513. }
  31514. function isPrettierIgnoreComment$1(comment) {
  31515. return comment.value.trim() === "prettier-ignore" && !comment.unignore;
  31516. }
  31517. function hasNodeIgnoreComment$1(node) {
  31518. return node && (node.prettierIgnore || hasComment$j(node, CommentCheckFlags$g.PrettierIgnore));
  31519. }
  31520. function hasIgnoreComment$2(path) {
  31521. const node = path.getValue();
  31522. return hasNodeIgnoreComment$1(node);
  31523. }
  31524. const CommentCheckFlags$g = {
  31525. /** Check comment is a leading comment */
  31526. Leading: 1 << 1,
  31527. /** Check comment is a trailing comment */
  31528. Trailing: 1 << 2,
  31529. /** Check comment is a dangling comment */
  31530. Dangling: 1 << 3,
  31531. /** Check comment is a block comment */
  31532. Block: 1 << 4,
  31533. /** Check comment is a line comment */
  31534. Line: 1 << 5,
  31535. /** Check comment is a `prettier-ignore` comment */
  31536. PrettierIgnore: 1 << 6,
  31537. /** Check comment is the first attached comment */
  31538. First: 1 << 7,
  31539. /** Check comment is the last attached comment */
  31540. Last: 1 << 8
  31541. };
  31542. const getCommentTestFunction = (flags, fn) => {
  31543. if (typeof flags === "function") {
  31544. fn = flags;
  31545. flags = 0;
  31546. }
  31547. if (flags || fn) {
  31548. return (comment, index, comments) => !(flags & CommentCheckFlags$g.Leading && !comment.leading || flags & CommentCheckFlags$g.Trailing && !comment.trailing || flags & CommentCheckFlags$g.Dangling && (comment.leading || comment.trailing) || flags & CommentCheckFlags$g.Block && !isBlockComment$5(comment) || flags & CommentCheckFlags$g.Line && !isLineComment$3(comment) || flags & CommentCheckFlags$g.First && index !== 0 || flags & CommentCheckFlags$g.Last && index !== comments.length - 1 || flags & CommentCheckFlags$g.PrettierIgnore && !isPrettierIgnoreComment$1(comment) || fn && !fn(comment));
  31549. }
  31550. };
  31551. /**
  31552. * @param {Node} node
  31553. * @param {number | function} [flags]
  31554. * @param {function} [fn]
  31555. * @returns {boolean}
  31556. */
  31557. function hasComment$j(node, flags, fn) {
  31558. if (!node || !isNonEmptyArray$h(node.comments)) {
  31559. return false;
  31560. }
  31561. const test = getCommentTestFunction(flags, fn);
  31562. return test ? node.comments.some(test) : true;
  31563. }
  31564. /**
  31565. * @param {Node} node
  31566. * @param {number | function} [flags]
  31567. * @param {function} [fn]
  31568. * @returns {Comment[]}
  31569. */
  31570. function getComments$5(node, flags, fn) {
  31571. if (!node || !Array.isArray(node.comments)) {
  31572. return [];
  31573. }
  31574. const test = getCommentTestFunction(flags, fn);
  31575. return test ? node.comments.filter(test) : node.comments;
  31576. }
  31577. /**
  31578. * @param {Node} node
  31579. * @returns {boolean}
  31580. */
  31581. const isNextLineEmpty$c = (node, {
  31582. originalText
  31583. }) => isNextLineEmptyAfterIndex$1(originalText, locEnd$p(node));
  31584. function isCallLikeExpression$2(node) {
  31585. return isCallExpression$d(node) || node.type === "NewExpression" || node.type === "ImportExpression";
  31586. }
  31587. function isObjectProperty$6(node) {
  31588. return node && (node.type === "ObjectProperty" || node.type === "Property" && !node.method && node.kind === "init");
  31589. }
  31590. var utils$5 = {
  31591. getFunctionParameters: getFunctionParameters$6,
  31592. iterateFunctionParametersPath: iterateFunctionParametersPath$1,
  31593. getCallArguments: getCallArguments$5,
  31594. iterateCallArgumentsPath: iterateCallArgumentsPath$2,
  31595. hasRestParameter: hasRestParameter$1,
  31596. getLeftSide: getLeftSide$1,
  31597. getLeftSidePathName: getLeftSidePathName$2,
  31598. getParentExportDeclaration: getParentExportDeclaration$2,
  31599. getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier$1,
  31600. hasFlowAnnotationComment: hasFlowAnnotationComment$2,
  31601. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$3,
  31602. hasLeadingOwnLineComment: hasLeadingOwnLineComment$4,
  31603. hasNakedLeftSide: hasNakedLeftSide$3,
  31604. hasNode: hasNode$2,
  31605. hasIgnoreComment: hasIgnoreComment$2,
  31606. hasNodeIgnoreComment: hasNodeIgnoreComment$1,
  31607. identity: identity$1,
  31608. isBinaryish: isBinaryish$5,
  31609. isBlockComment: isBlockComment$5,
  31610. isCallLikeExpression: isCallLikeExpression$2,
  31611. isLineComment: isLineComment$3,
  31612. isPrettierIgnoreComment: isPrettierIgnoreComment$1,
  31613. isCallExpression: isCallExpression$d,
  31614. isMemberExpression: isMemberExpression$a,
  31615. isExportDeclaration,
  31616. isFlowAnnotationComment: isFlowAnnotationComment$2,
  31617. isFunctionCompositionArgs: isFunctionCompositionArgs$1,
  31618. isFunctionNotation: isFunctionNotation$1,
  31619. isFunctionOrArrowExpression: isFunctionOrArrowExpression$1,
  31620. isGetterOrSetter: isGetterOrSetter$1,
  31621. isJestEachTemplateLiteral: isJestEachTemplateLiteral$1,
  31622. isJsxNode: isJsxNode$7,
  31623. isLiteral: isLiteral$3,
  31624. isLongCurriedCallExpression: isLongCurriedCallExpression$2,
  31625. isSimpleCallArgument: isSimpleCallArgument$1,
  31626. isMemberish: isMemberish$2,
  31627. isNumericLiteral: isNumericLiteral$5,
  31628. isSignedNumericLiteral: isSignedNumericLiteral$2,
  31629. isObjectProperty: isObjectProperty$6,
  31630. isObjectType: isObjectType$2,
  31631. isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$2,
  31632. isSimpleType: isSimpleType$2,
  31633. isSimpleNumber: isSimpleNumber$1,
  31634. isSimpleTemplateLiteral: isSimpleTemplateLiteral$1,
  31635. isStringLiteral: isStringLiteral$5,
  31636. isStringPropSafeToUnquote: isStringPropSafeToUnquote$1,
  31637. isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$2,
  31638. isTestCall: isTestCall$3,
  31639. isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$2,
  31640. isTSXFile: isTSXFile$1,
  31641. isTypeAnnotationAFunction: isTypeAnnotationAFunction$1,
  31642. isNextLineEmpty: isNextLineEmpty$c,
  31643. needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$2,
  31644. rawText: rawText$5,
  31645. shouldPrintComma: shouldPrintComma$b,
  31646. isBitwiseOperator: isBitwiseOperator$1,
  31647. shouldFlatten: shouldFlatten$2,
  31648. startsWithNoLookaheadToken: startsWithNoLookaheadToken$2,
  31649. getPrecedence: getPrecedence$1,
  31650. hasComment: hasComment$j,
  31651. getComments: getComments$5,
  31652. CommentCheckFlags: CommentCheckFlags$g
  31653. };
  31654. const {
  31655. getStringWidth: getStringWidth$2,
  31656. getIndentSize
  31657. } = util$5;
  31658. const {
  31659. builders: {
  31660. join: join$u,
  31661. hardline: hardline$A,
  31662. softline: softline$u,
  31663. group: group$D,
  31664. indent: indent$z,
  31665. align: align$5,
  31666. lineSuffixBoundary: lineSuffixBoundary$1,
  31667. addAlignmentToDoc
  31668. },
  31669. printer: {
  31670. printDocToString: printDocToString$1
  31671. },
  31672. utils: {
  31673. mapDoc: mapDoc$3
  31674. }
  31675. } = doc;
  31676. const {
  31677. isBinaryish: isBinaryish$4,
  31678. isJestEachTemplateLiteral,
  31679. isSimpleTemplateLiteral,
  31680. hasComment: hasComment$i,
  31681. isMemberExpression: isMemberExpression$9
  31682. } = utils$5;
  31683. function printTemplateLiteral$2(path, print, options) {
  31684. const node = path.getValue();
  31685. const isTemplateLiteral = node.type === "TemplateLiteral";
  31686. if (isTemplateLiteral && isJestEachTemplateLiteral(node, path.getParentNode())) {
  31687. const printed = printJestEachTemplateLiteral(path, options, print);
  31688. if (printed) {
  31689. return printed;
  31690. }
  31691. }
  31692. let expressionsKey = "expressions";
  31693. if (node.type === "TSTemplateLiteralType") {
  31694. expressionsKey = "types";
  31695. }
  31696. const parts = [];
  31697. let expressions = path.map(print, expressionsKey);
  31698. const isSimple = isSimpleTemplateLiteral(node);
  31699. if (isSimple) {
  31700. expressions = expressions.map(doc => printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
  31701. printWidth: Number.POSITIVE_INFINITY
  31702. })).formatted);
  31703. }
  31704. parts.push(lineSuffixBoundary$1, "`");
  31705. path.each(childPath => {
  31706. const i = childPath.getName();
  31707. parts.push(print());
  31708. if (i < expressions.length) {
  31709. // For a template literal of the following form:
  31710. // `someQuery {
  31711. // ${call({
  31712. // a,
  31713. // b,
  31714. // })}
  31715. // }`
  31716. // the expression is on its own line (there is a \n in the previous
  31717. // quasi literal), therefore we want to indent the JavaScript
  31718. // expression inside at the beginning of ${ instead of the beginning
  31719. // of the `.
  31720. const {
  31721. tabWidth
  31722. } = options;
  31723. const quasi = childPath.getValue();
  31724. const indentSize = getIndentSize(quasi.value.raw, tabWidth);
  31725. let printed = expressions[i];
  31726. if (!isSimple) {
  31727. const expression = node[expressionsKey][i]; // Breaks at the template element boundaries (${ and }) are preferred to breaking
  31728. // in the middle of a MemberExpression
  31729. if (hasComment$i(expression) || isMemberExpression$9(expression) || expression.type === "ConditionalExpression" || expression.type === "SequenceExpression" || expression.type === "TSAsExpression" || isBinaryish$4(expression)) {
  31730. printed = [indent$z([softline$u, printed]), softline$u];
  31731. }
  31732. }
  31733. const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$5(Number.NEGATIVE_INFINITY, printed) : addAlignmentToDoc(printed, indentSize, tabWidth);
  31734. parts.push(group$D(["${", aligned, lineSuffixBoundary$1, "}"]));
  31735. }
  31736. }, "quasis");
  31737. parts.push("`");
  31738. return parts;
  31739. }
  31740. function printJestEachTemplateLiteral(path, options, print) {
  31741. /**
  31742. * a | b | expected
  31743. * ${1} | ${1} | ${2}
  31744. * ${1} | ${2} | ${3}
  31745. * ${2} | ${1} | ${3}
  31746. */
  31747. const node = path.getNode();
  31748. const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  31749. if (headerNames.length > 1 || headerNames.some(headerName => headerName.length > 0)) {
  31750. options.__inJestEach = true;
  31751. const expressions = path.map(print, "expressions");
  31752. options.__inJestEach = false;
  31753. const parts = [];
  31754. const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
  31755. printWidth: Number.POSITIVE_INFINITY,
  31756. endOfLine: "lf"
  31757. })).formatted + "}");
  31758. const tableBody = [{
  31759. hasLineBreak: false,
  31760. cells: []
  31761. }];
  31762. for (let i = 1; i < node.quasis.length; i++) {
  31763. const row = getLast_1(tableBody);
  31764. const correspondingExpression = stringifiedExpressions[i - 1];
  31765. row.cells.push(correspondingExpression);
  31766. if (correspondingExpression.includes("\n")) {
  31767. row.hasLineBreak = true;
  31768. }
  31769. if (node.quasis[i].value.raw.includes("\n")) {
  31770. tableBody.push({
  31771. hasLineBreak: false,
  31772. cells: []
  31773. });
  31774. }
  31775. }
  31776. const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
  31777. const maxColumnWidths = Array.from({
  31778. length: maxColumnCount
  31779. }).fill(0);
  31780. const table = [{
  31781. cells: headerNames
  31782. }, ...tableBody.filter(row => row.cells.length > 0)];
  31783. for (const {
  31784. cells
  31785. } of table.filter(row => !row.hasLineBreak)) {
  31786. for (const [index, cell] of cells.entries()) {
  31787. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  31788. }
  31789. }
  31790. parts.push(lineSuffixBoundary$1, "`", indent$z([hardline$A, join$u(hardline$A, table.map(row => join$u(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell))))))]), hardline$A, "`");
  31791. return parts;
  31792. }
  31793. }
  31794. function printTemplateExpression(path, print) {
  31795. const node = path.getValue();
  31796. let printed = print();
  31797. if (hasComment$i(node)) {
  31798. printed = group$D([indent$z([softline$u, printed]), softline$u]);
  31799. }
  31800. return ["${", printed, lineSuffixBoundary$1, "}"];
  31801. }
  31802. function printTemplateExpressions$3(path, print) {
  31803. return path.map(path => printTemplateExpression(path, print), "expressions");
  31804. }
  31805. function escapeTemplateCharacters$2(doc, raw) {
  31806. return mapDoc$3(doc, currentDoc => {
  31807. if (typeof currentDoc === "string") {
  31808. return raw ? currentDoc.replace(/(\\*)`/g, "$1$1\\`") : uncookTemplateElementValue$1(currentDoc);
  31809. }
  31810. return currentDoc;
  31811. });
  31812. }
  31813. function uncookTemplateElementValue$1(cookedValue) {
  31814. return cookedValue.replace(/([\\`]|\${)/g, "\\$1");
  31815. }
  31816. var templateLiteral = {
  31817. printTemplateLiteral: printTemplateLiteral$2,
  31818. printTemplateExpressions: printTemplateExpressions$3,
  31819. escapeTemplateCharacters: escapeTemplateCharacters$2,
  31820. uncookTemplateElementValue: uncookTemplateElementValue$1
  31821. };
  31822. const {
  31823. builders: {
  31824. indent: indent$y,
  31825. softline: softline$t,
  31826. literalline: literalline$4,
  31827. dedentToRoot: dedentToRoot$2
  31828. }
  31829. } = doc;
  31830. const {
  31831. escapeTemplateCharacters: escapeTemplateCharacters$1
  31832. } = templateLiteral;
  31833. function format$3(path, print, textToDoc) {
  31834. const node = path.getValue();
  31835. let text = node.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
  31836. const indentation = getIndentation(text);
  31837. const hasIndent = indentation !== "";
  31838. if (hasIndent) {
  31839. text = text.replace(new RegExp(`^${indentation}`, "gm"), "");
  31840. }
  31841. const doc = escapeTemplateCharacters$1(textToDoc(text, {
  31842. parser: "markdown",
  31843. __inJsTemplate: true
  31844. }, {
  31845. stripTrailingHardline: true
  31846. }), true);
  31847. return ["`", hasIndent ? indent$y([softline$t, doc]) : [literalline$4, dedentToRoot$2(doc)], softline$t, "`"];
  31848. }
  31849. function getIndentation(str) {
  31850. const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  31851. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  31852. }
  31853. var markdown = format$3;
  31854. const {
  31855. isNonEmptyArray: isNonEmptyArray$g
  31856. } = util$5;
  31857. const {
  31858. builders: {
  31859. indent: indent$x,
  31860. hardline: hardline$z,
  31861. softline: softline$s
  31862. },
  31863. utils: {
  31864. mapDoc: mapDoc$2,
  31865. replaceEndOfLine: replaceEndOfLine$1,
  31866. cleanDoc: cleanDoc$3
  31867. }
  31868. } = doc;
  31869. const {
  31870. printTemplateExpressions: printTemplateExpressions$2
  31871. } = templateLiteral;
  31872. function format$2(path, print, textToDoc) {
  31873. const node = path.getValue(); // Get full template literal with expressions replaced by placeholders
  31874. const rawQuasis = node.quasis.map(q => q.value.raw);
  31875. let placeholderID = 0;
  31876. const text = rawQuasis.reduce((prevVal, currVal, idx) => idx === 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal, "");
  31877. const doc = textToDoc(text, {
  31878. parser: "scss"
  31879. }, {
  31880. stripTrailingHardline: true
  31881. });
  31882. const expressionDocs = printTemplateExpressions$2(path, print);
  31883. return transformCssDoc(doc, node, expressionDocs);
  31884. }
  31885. function transformCssDoc(quasisDoc, parentNode, expressionDocs) {
  31886. const isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  31887. if (isEmpty) {
  31888. return "``";
  31889. }
  31890. const newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  31891. /* istanbul ignore if */
  31892. if (!newDoc) {
  31893. throw new Error("Couldn't insert all the expressions");
  31894. }
  31895. return ["`", indent$x([hardline$z, newDoc]), softline$s, "`"];
  31896. } // Search all the placeholders in the quasisDoc tree
  31897. // and replace them with the expression docs one by one
  31898. // returns a new doc with all the placeholders replaced,
  31899. // or null if it couldn't replace any expression
  31900. function replacePlaceholders(quasisDoc, expressionDocs) {
  31901. if (!isNonEmptyArray$g(expressionDocs)) {
  31902. return quasisDoc;
  31903. }
  31904. let replaceCounter = 0;
  31905. const newDoc = mapDoc$2(cleanDoc$3(quasisDoc), doc => {
  31906. if (typeof doc !== "string" || !doc.includes("@prettier-placeholder")) {
  31907. return doc;
  31908. } // When we have multiple placeholders in one line, like:
  31909. // ${Child}${Child2}:not(:first-child)
  31910. return doc.split(/@prettier-placeholder-(\d+)-id/).map((component, idx) => {
  31911. // The placeholder is always at odd indices
  31912. if (idx % 2 === 0) {
  31913. return replaceEndOfLine$1(component);
  31914. } // The component will always be a number at odd index
  31915. replaceCounter++;
  31916. return expressionDocs[component];
  31917. });
  31918. });
  31919. return expressionDocs.length === replaceCounter ? newDoc : null;
  31920. }
  31921. var css = format$2;
  31922. const {
  31923. builders: {
  31924. indent: indent$w,
  31925. join: join$t,
  31926. hardline: hardline$y
  31927. }
  31928. } = doc;
  31929. const {
  31930. escapeTemplateCharacters,
  31931. printTemplateExpressions: printTemplateExpressions$1
  31932. } = templateLiteral;
  31933. function format$1(path, print, textToDoc) {
  31934. const node = path.getValue();
  31935. const numQuasis = node.quasis.length;
  31936. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  31937. return "``";
  31938. }
  31939. const expressionDocs = printTemplateExpressions$1(path, print);
  31940. const parts = [];
  31941. for (let i = 0; i < numQuasis; i++) {
  31942. const templateElement = node.quasis[i];
  31943. const isFirst = i === 0;
  31944. const isLast = i === numQuasis - 1;
  31945. const text = templateElement.value.cooked;
  31946. const lines = text.split("\n");
  31947. const numLines = lines.length;
  31948. const expressionDoc = expressionDocs[i];
  31949. const startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  31950. const endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  31951. const commentsAndWhitespaceOnly = lines.every(line => /^\s*(?:#[^\n\r]*)?$/.test(line)); // Bail out if an interpolation occurs within a comment.
  31952. if (!isLast && /#[^\n\r]*$/.test(lines[numLines - 1])) {
  31953. return null;
  31954. }
  31955. let doc = null;
  31956. if (commentsAndWhitespaceOnly) {
  31957. doc = printGraphqlComments(lines);
  31958. } else {
  31959. doc = textToDoc(text, {
  31960. parser: "graphql"
  31961. }, {
  31962. stripTrailingHardline: true
  31963. });
  31964. }
  31965. if (doc) {
  31966. doc = escapeTemplateCharacters(doc, false);
  31967. if (!isFirst && startsWithBlankLine) {
  31968. parts.push("");
  31969. }
  31970. parts.push(doc);
  31971. if (!isLast && endsWithBlankLine) {
  31972. parts.push("");
  31973. }
  31974. } else if (!isFirst && !isLast && startsWithBlankLine) {
  31975. parts.push("");
  31976. }
  31977. if (expressionDoc) {
  31978. parts.push(expressionDoc);
  31979. }
  31980. }
  31981. return ["`", indent$w([hardline$y, join$t(hardline$y, parts)]), hardline$y, "`"];
  31982. }
  31983. function printGraphqlComments(lines) {
  31984. const parts = [];
  31985. let seenComment = false;
  31986. const array = lines.map(textLine => textLine.trim());
  31987. for (const [i, textLine] of array.entries()) {
  31988. // Lines are either whitespace only, or a comment (with potential whitespace
  31989. // around it). Drop whitespace-only lines.
  31990. if (textLine === "") {
  31991. continue;
  31992. }
  31993. if (array[i - 1] === "" && seenComment) {
  31994. // If a non-first comment is preceded by a blank (whitespace only) line,
  31995. // add in a blank line.
  31996. parts.push([hardline$y, textLine]);
  31997. } else {
  31998. parts.push(textLine);
  31999. }
  32000. seenComment = true;
  32001. } // If `lines` was whitespace only, return `null`.
  32002. return parts.length === 0 ? null : join$t(hardline$y, parts);
  32003. }
  32004. var graphql = format$1;
  32005. const {
  32006. builders: {
  32007. indent: indent$v,
  32008. line: line$y,
  32009. hardline: hardline$x,
  32010. group: group$C
  32011. },
  32012. utils: {
  32013. mapDoc: mapDoc$1
  32014. }
  32015. } = doc;
  32016. const {
  32017. printTemplateExpressions,
  32018. uncookTemplateElementValue
  32019. } = templateLiteral; // The counter is needed to distinguish nested embeds.
  32020. let htmlTemplateLiteralCounter = 0;
  32021. function format(path, print, textToDoc, options, {
  32022. parser
  32023. }) {
  32024. const node = path.getValue();
  32025. const counter = htmlTemplateLiteralCounter;
  32026. htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
  32027. const composePlaceholder = index => `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
  32028. const text = node.quasis.map((quasi, index, quasis) => index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index)).join("");
  32029. const expressionDocs = printTemplateExpressions(path, print);
  32030. if (expressionDocs.length === 0 && text.trim().length === 0) {
  32031. return "``";
  32032. }
  32033. const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
  32034. let topLevelCount = 0;
  32035. const doc = textToDoc(text, {
  32036. parser,
  32037. __onHtmlRoot(root) {
  32038. topLevelCount = root.children.length;
  32039. }
  32040. }, {
  32041. stripTrailingHardline: true
  32042. });
  32043. const contentDoc = mapDoc$1(doc, doc => {
  32044. if (typeof doc !== "string") {
  32045. return doc;
  32046. }
  32047. const parts = [];
  32048. const components = doc.split(placeholderRegex);
  32049. for (let i = 0; i < components.length; i++) {
  32050. let component = components[i];
  32051. if (i % 2 === 0) {
  32052. if (component) {
  32053. component = uncookTemplateElementValue(component);
  32054. if (options.__embeddedInHtml) {
  32055. component = component.replace(/<\/(script)\b/gi, "<\\/$1");
  32056. }
  32057. parts.push(component);
  32058. }
  32059. continue;
  32060. }
  32061. const placeholderIndex = Number(component);
  32062. parts.push(expressionDocs[placeholderIndex]);
  32063. }
  32064. return parts;
  32065. });
  32066. const leadingWhitespace = /^\s/.test(text) ? " " : "";
  32067. const trailingWhitespace = /\s$/.test(text) ? " " : "";
  32068. const linebreak = options.htmlWhitespaceSensitivity === "ignore" ? hardline$x : leadingWhitespace && trailingWhitespace ? line$y : null;
  32069. if (linebreak) {
  32070. return group$C(["`", indent$v([linebreak, group$C(contentDoc)]), linebreak, "`"]);
  32071. }
  32072. return group$C(["`", leadingWhitespace, topLevelCount > 1 ? indent$v(group$C(contentDoc)) : group$C(contentDoc), trailingWhitespace, "`"]);
  32073. }
  32074. var html$1 = format;
  32075. const {
  32076. hasComment: hasComment$h,
  32077. CommentCheckFlags: CommentCheckFlags$f,
  32078. isObjectProperty: isObjectProperty$5
  32079. } = utils$5;
  32080. function getLanguage(path) {
  32081. if (isStyledJsx(path) || isStyledComponents(path) || isCssProp(path) || isAngularComponentStyles(path)) {
  32082. return "css";
  32083. }
  32084. if (isGraphQL(path)) {
  32085. return "graphql";
  32086. }
  32087. if (isHtml(path)) {
  32088. return "html";
  32089. }
  32090. if (isAngularComponentTemplate(path)) {
  32091. return "angular";
  32092. }
  32093. if (isMarkdown(path)) {
  32094. return "markdown";
  32095. }
  32096. }
  32097. function embed$5(path, print, textToDoc, options) {
  32098. const node = path.getValue();
  32099. if (node.type !== "TemplateLiteral" || // Bail out if any of the quasis have an invalid escape sequence
  32100. // (which would make the `cooked` value be `null`)
  32101. hasInvalidCookedValue(node)) {
  32102. return;
  32103. }
  32104. const language = getLanguage(path);
  32105. if (!language) {
  32106. return;
  32107. }
  32108. if (language === "markdown") {
  32109. return markdown(path, print, textToDoc);
  32110. }
  32111. if (language === "css") {
  32112. return css(path, print, textToDoc);
  32113. }
  32114. if (language === "graphql") {
  32115. return graphql(path, print, textToDoc);
  32116. }
  32117. if (language === "html" || language === "angular") {
  32118. return html$1(path, print, textToDoc, options, {
  32119. parser: language
  32120. });
  32121. }
  32122. }
  32123. /**
  32124. * md`...`
  32125. * markdown`...`
  32126. */
  32127. function isMarkdown(path) {
  32128. const node = path.getValue();
  32129. const parent = path.getParentNode();
  32130. return parent && parent.type === "TaggedTemplateExpression" && node.quasis.length === 1 && parent.tag.type === "Identifier" && (parent.tag.name === "md" || parent.tag.name === "markdown");
  32131. }
  32132. /**
  32133. * Template literal in these contexts:
  32134. * <style jsx>{`div{color:red}`}</style>
  32135. * css``
  32136. * css.global``
  32137. * css.resolve``
  32138. */
  32139. function isStyledJsx(path) {
  32140. const node = path.getValue();
  32141. const parent = path.getParentNode();
  32142. const parentParent = path.getParentNode(1);
  32143. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(attribute => attribute.name.name === "jsx") || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
  32144. }
  32145. /**
  32146. * Angular Components can have:
  32147. * - Inline HTML template
  32148. * - Inline CSS styles
  32149. *
  32150. * ...which are both within template literals somewhere
  32151. * inside of the Component decorator factory.
  32152. *
  32153. * E.g.
  32154. * @Component({
  32155. * template: `<div>...</div>`,
  32156. * styles: [`h1 { color: blue; }`]
  32157. * })
  32158. */
  32159. function isAngularComponentStyles(path) {
  32160. return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "styles" && name === "value", ...angularComponentObjectExpressionPredicates);
  32161. }
  32162. function isAngularComponentTemplate(path) {
  32163. return path.match(node => node.type === "TemplateLiteral", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
  32164. }
  32165. const angularComponentObjectExpressionPredicates = [(node, name) => node.type === "ObjectExpression" && name === "properties", (node, name) => node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments", (node, name) => node.type === "Decorator" && name === "expression"];
  32166. /**
  32167. * styled-components template literals
  32168. */
  32169. function isStyledComponents(path) {
  32170. const parent = path.getParentNode();
  32171. if (!parent || parent.type !== "TaggedTemplateExpression") {
  32172. return false;
  32173. }
  32174. const tag = parent.tag.type === "ParenthesizedExpression" ? parent.tag.expression : parent.tag;
  32175. switch (tag.type) {
  32176. case "MemberExpression":
  32177. return (// styled.foo``
  32178. isStyledIdentifier(tag.object) || // Component.extend``
  32179. isStyledExtend(tag)
  32180. );
  32181. case "CallExpression":
  32182. return (// styled(Component)``
  32183. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && (isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
  32184. isStyledExtend(tag.callee.object)) || tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  32185. );
  32186. case "Identifier":
  32187. // css``
  32188. return tag.name === "css";
  32189. default:
  32190. return false;
  32191. }
  32192. }
  32193. /**
  32194. * JSX element with CSS prop
  32195. */
  32196. function isCssProp(path) {
  32197. const parent = path.getParentNode();
  32198. const parentParent = path.getParentNode(1);
  32199. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  32200. }
  32201. function isStyledIdentifier(node) {
  32202. return node.type === "Identifier" && node.name === "styled";
  32203. }
  32204. function isStyledExtend(node) {
  32205. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  32206. }
  32207. /*
  32208. * react-relay and graphql-tag
  32209. * graphql`...`
  32210. * graphql.experimental`...`
  32211. * gql`...`
  32212. * GraphQL comment block
  32213. *
  32214. * This intentionally excludes Relay Classic tags, as Prettier does not
  32215. * support Relay Classic formatting.
  32216. */
  32217. function isGraphQL(path) {
  32218. const node = path.getValue();
  32219. const parent = path.getParentNode();
  32220. return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
  32221. }
  32222. function hasLanguageComment(node, languageName) {
  32223. // This checks for a leading comment that is exactly `/* GraphQL */`
  32224. // In order to be in line with other implementations of this comment tag
  32225. // we will not trim the comment value and we will expect exactly one space on
  32226. // either side of the GraphQL string
  32227. // Also see ./clean.js
  32228. return hasComment$h(node, CommentCheckFlags$f.Block | CommentCheckFlags$f.Leading, ({
  32229. value
  32230. }) => value === ` ${languageName} `);
  32231. }
  32232. /**
  32233. * - html`...`
  32234. * - HTML comment block
  32235. */
  32236. function isHtml(path) {
  32237. return hasLanguageComment(path.getValue(), "HTML") || path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi");
  32238. }
  32239. function hasInvalidCookedValue({
  32240. quasis
  32241. }) {
  32242. return quasis.some(({
  32243. value: {
  32244. cooked
  32245. }
  32246. }) => cooked === null);
  32247. }
  32248. var embed_1$4 = embed$5;
  32249. const {
  32250. isBlockComment: isBlockComment$4
  32251. } = utils$5;
  32252. const ignoredProperties$4 = new Set(["range", "raw", "comments", "leadingComments", "trailingComments", "innerComments", "extra", "start", "end", "loc", "flags", "errors", "tokens"]);
  32253. const removeTemplateElementsValue = node => {
  32254. for (const templateElement of node.quasis) {
  32255. delete templateElement.value;
  32256. }
  32257. };
  32258. function clean$7(ast, newObj, parent) {
  32259. if (ast.type === "Program") {
  32260. delete newObj.sourceType;
  32261. }
  32262. if (ast.type === "BigIntLiteral" || ast.type === "BigIntLiteralTypeAnnotation") {
  32263. if (newObj.value) {
  32264. newObj.value = newObj.value.toLowerCase();
  32265. }
  32266. }
  32267. if (ast.type === "BigIntLiteral" || ast.type === "Literal") {
  32268. if (newObj.bigint) {
  32269. newObj.bigint = newObj.bigint.toLowerCase();
  32270. }
  32271. }
  32272. if (ast.type === "DecimalLiteral") {
  32273. newObj.value = Number(newObj.value);
  32274. }
  32275. if (ast.type === "Literal" && newObj.decimal) {
  32276. newObj.decimal = Number(newObj.decimal);
  32277. } // We remove extra `;` and add them when needed
  32278. if (ast.type === "EmptyStatement") {
  32279. return null;
  32280. } // We move text around, including whitespaces and add {" "}
  32281. if (ast.type === "JSXText") {
  32282. return null;
  32283. }
  32284. if (ast.type === "JSXExpressionContainer" && (ast.expression.type === "Literal" || ast.expression.type === "StringLiteral") && ast.expression.value === " ") {
  32285. return null;
  32286. } // We change {'key': value} into {key: value}.
  32287. // And {key: value} into {'key': value}.
  32288. // Also for (some) number keys.
  32289. if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "ClassMethod" || ast.type === "PropertyDefinition" || ast.type === "TSDeclareMethod" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "NumericLiteral" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
  32290. delete newObj.key;
  32291. } // Remove raw and cooked values from TemplateElement when it's CSS
  32292. // styled-jsx
  32293. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(attr => attr.name.name === "jsx")) {
  32294. for (const {
  32295. type,
  32296. expression
  32297. } of newObj.children) {
  32298. if (type === "JSXExpressionContainer" && expression.type === "TemplateLiteral") {
  32299. removeTemplateElementsValue(expression);
  32300. }
  32301. }
  32302. } // CSS template literals in css prop
  32303. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  32304. removeTemplateElementsValue(newObj.value.expression);
  32305. } // We change quotes
  32306. if (ast.type === "JSXAttribute" && ast.value && ast.value.type === "Literal" && /["']|&quot;|&apos;/.test(ast.value.value)) {
  32307. newObj.value.value = newObj.value.value.replace(/["']|&quot;|&apos;/g, '"');
  32308. } // Angular Components: Inline HTML template and Inline CSS styles
  32309. const expression = ast.expression || ast.callee;
  32310. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  32311. const astProps = ast.expression.arguments[0].properties;
  32312. for (const [index, prop] of newObj.expression.arguments[0].properties.entries()) {
  32313. switch (astProps[index].key.name) {
  32314. case "styles":
  32315. if (prop.value.type === "ArrayExpression") {
  32316. removeTemplateElementsValue(prop.value.elements[0]);
  32317. }
  32318. break;
  32319. case "template":
  32320. if (prop.value.type === "TemplateLiteral") {
  32321. removeTemplateElementsValue(prop.value);
  32322. }
  32323. break;
  32324. }
  32325. }
  32326. } // styled-components, graphql, markdown
  32327. if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
  32328. removeTemplateElementsValue(newObj.quasi);
  32329. }
  32330. if (ast.type === "TemplateLiteral") {
  32331. // This checks for a leading comment that is exactly `/* GraphQL */`
  32332. // In order to be in line with other implementations of this comment tag
  32333. // we will not trim the comment value and we will expect exactly one space on
  32334. // either side of the GraphQL string
  32335. // Also see ./embed.js
  32336. const hasLanguageComment = ast.leadingComments && ast.leadingComments.some(comment => isBlockComment$4(comment) && ["GraphQL", "HTML"].some(languageName => comment.value === ` ${languageName} `));
  32337. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql" || // TODO: check parser
  32338. // `flow` and `typescript` don't have `leadingComments`
  32339. !ast.leadingComments) {
  32340. removeTemplateElementsValue(newObj);
  32341. }
  32342. }
  32343. if (ast.type === "InterpreterDirective") {
  32344. newObj.value = newObj.value.trimEnd();
  32345. } // Prettier removes degenerate union and intersection types with only one member.
  32346. if ((ast.type === "TSIntersectionType" || ast.type === "TSUnionType") && ast.types.length === 1) {
  32347. return newObj.types[0];
  32348. }
  32349. }
  32350. clean$7.ignoredProperties = ignoredProperties$4;
  32351. var clean_1$4 = clean$7;
  32352. const detectNewline = string => {
  32353. if (typeof string !== 'string') {
  32354. throw new TypeError('Expected a string');
  32355. }
  32356. const newlines = string.match(/(?:\r?\n)/g) || [];
  32357. if (newlines.length === 0) {
  32358. return;
  32359. }
  32360. const crlf = newlines.filter(newline => newline === '\r\n').length;
  32361. const lf = newlines.length - crlf;
  32362. return crlf > lf ? '\r\n' : '\n';
  32363. };
  32364. var detectNewline_1 = detectNewline;
  32365. var graceful = string => typeof string === 'string' && detectNewline(string) || '\n';
  32366. detectNewline_1.graceful = graceful;
  32367. var extract_1 = extract$1;
  32368. var strip_1 = strip$1;
  32369. var parse_1$1 = parse$1;
  32370. var parseWithComments_1 = parseWithComments$1;
  32371. var print_1$1 = print$3;
  32372. function _os() {
  32373. const data = os__default['default'];
  32374. _os = function () {
  32375. return data;
  32376. };
  32377. return data;
  32378. }
  32379. function _detectNewline() {
  32380. const data = _interopRequireDefault(detectNewline_1);
  32381. _detectNewline = function () {
  32382. return data;
  32383. };
  32384. return data;
  32385. }
  32386. function _interopRequireDefault(obj) {
  32387. return obj && obj.__esModule ? obj : {
  32388. default: obj
  32389. };
  32390. }
  32391. /**
  32392. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  32393. *
  32394. * This source code is licensed under the MIT license found in the
  32395. * LICENSE file in the root directory of this source tree.
  32396. */
  32397. const commentEndRe = /\*\/$/;
  32398. const commentStartRe = /^\/\*\*/;
  32399. const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  32400. const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  32401. const ltrimNewlineRe = /^(\r?\n)+/;
  32402. const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  32403. const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  32404. const stringStartRe = /(\r?\n|^) *\* ?/g;
  32405. const STRING_ARRAY = [];
  32406. function extract$1(contents) {
  32407. const match = contents.match(docblockRe);
  32408. return match ? match[0].trimLeft() : '';
  32409. }
  32410. function strip$1(contents) {
  32411. const match = contents.match(docblockRe);
  32412. return match && match[0] ? contents.substring(match[0].length) : contents;
  32413. }
  32414. function parse$1(docblock) {
  32415. return parseWithComments$1(docblock).pragmas;
  32416. }
  32417. function parseWithComments$1(docblock) {
  32418. const line = (0, _detectNewline().default)(docblock) || _os().EOL;
  32419. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  32420. let prev = '';
  32421. while (prev !== docblock) {
  32422. prev = docblock;
  32423. docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
  32424. }
  32425. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  32426. const result = Object.create(null);
  32427. const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  32428. let match;
  32429. while (match = propertyRe.exec(docblock)) {
  32430. // strip linecomments from pragmas
  32431. const nextPragma = match[2].replace(lineCommentRe, '');
  32432. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  32433. result[match[1]] = STRING_ARRAY.concat(result[match[1]], nextPragma);
  32434. } else {
  32435. result[match[1]] = nextPragma;
  32436. }
  32437. }
  32438. return {
  32439. comments,
  32440. pragmas: result
  32441. };
  32442. }
  32443. function print$3({
  32444. comments = '',
  32445. pragmas = {}
  32446. }) {
  32447. const line = (0, _detectNewline().default)(comments) || _os().EOL;
  32448. const head = '/**';
  32449. const start = ' *';
  32450. const tail = ' */';
  32451. const keys = Object.keys(pragmas);
  32452. const printedObject = keys.map(key => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map(keyValue => start + ' ' + keyValue + line).join('');
  32453. if (!comments) {
  32454. if (keys.length === 0) {
  32455. return '';
  32456. }
  32457. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  32458. const value = pragmas[keys[0]];
  32459. return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
  32460. }
  32461. }
  32462. const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line;
  32463. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  32464. }
  32465. function printKeyValues(key, valueOrArray) {
  32466. return STRING_ARRAY.concat(valueOrArray).map(value => `@${key} ${value}`.trim());
  32467. }
  32468. var build = /*#__PURE__*/Object.defineProperty({
  32469. extract: extract_1,
  32470. strip: strip_1,
  32471. parse: parse_1$1,
  32472. parseWithComments: parseWithComments_1,
  32473. print: print_1$1
  32474. }, '__esModule', {
  32475. value: true
  32476. });
  32477. const {
  32478. parseWithComments,
  32479. strip,
  32480. extract,
  32481. print: print$2
  32482. } = build;
  32483. const {
  32484. getShebang
  32485. } = util$5;
  32486. const {
  32487. normalizeEndOfLine
  32488. } = endOfLine;
  32489. function parseDocBlock(text) {
  32490. const shebang = getShebang(text);
  32491. if (shebang) {
  32492. text = text.slice(shebang.length + 1);
  32493. }
  32494. const docBlock = extract(text);
  32495. const {
  32496. pragmas,
  32497. comments
  32498. } = parseWithComments(docBlock);
  32499. return {
  32500. shebang,
  32501. text,
  32502. pragmas,
  32503. comments
  32504. };
  32505. }
  32506. function hasPragma$4(text) {
  32507. const pragmas = Object.keys(parseDocBlock(text).pragmas);
  32508. return pragmas.includes("prettier") || pragmas.includes("format");
  32509. }
  32510. function insertPragma$a(originalText) {
  32511. const {
  32512. shebang,
  32513. text,
  32514. pragmas,
  32515. comments
  32516. } = parseDocBlock(originalText);
  32517. const strippedText = strip(text);
  32518. const docBlock = print$2({
  32519. pragmas: Object.assign({
  32520. format: ""
  32521. }, pragmas),
  32522. comments: comments.trimStart()
  32523. });
  32524. return (shebang ? `${shebang}\n` : "") + // normalise newlines (mitigate use of os.EOL by jest-docblock)
  32525. normalizeEndOfLine(docBlock) + (strippedText.startsWith("\n") ? "\n" : "\n\n") + strippedText;
  32526. }
  32527. var pragma$5 = {
  32528. hasPragma: hasPragma$4,
  32529. insertPragma: insertPragma$a
  32530. };
  32531. const {
  32532. getLast: getLast$c,
  32533. hasNewline: hasNewline$6,
  32534. getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  32535. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$1,
  32536. hasNewlineInRange: hasNewlineInRange$3,
  32537. addLeadingComment,
  32538. addTrailingComment,
  32539. addDanglingComment,
  32540. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$2,
  32541. isNonEmptyArray: isNonEmptyArray$f
  32542. } = util$5;
  32543. const {
  32544. isBlockComment: isBlockComment$3,
  32545. getFunctionParameters: getFunctionParameters$5,
  32546. isPrettierIgnoreComment,
  32547. isJsxNode: isJsxNode$6,
  32548. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  32549. hasFlowAnnotationComment: hasFlowAnnotationComment$1,
  32550. hasIgnoreComment: hasIgnoreComment$1,
  32551. isCallLikeExpression: isCallLikeExpression$1,
  32552. getCallArguments: getCallArguments$4,
  32553. isCallExpression: isCallExpression$c,
  32554. isMemberExpression: isMemberExpression$8,
  32555. isObjectProperty: isObjectProperty$4,
  32556. getComments: getComments$4,
  32557. CommentCheckFlags: CommentCheckFlags$e
  32558. } = utils$5;
  32559. const {
  32560. locStart: locStart$p,
  32561. locEnd: locEnd$o
  32562. } = loc$6;
  32563. /**
  32564. * @typedef {import("./types/estree").Node} Node
  32565. * @typedef {import("./types/estree").Comment} Comment
  32566. * @typedef {import("../common/ast-path")} AstPath
  32567. *
  32568. * @typedef {Object} CommentContext
  32569. * @property {Comment} comment
  32570. * @property {Node} precedingNode
  32571. * @property {Node} enclosingNode
  32572. * @property {Node} followingNode
  32573. * @property {string} text
  32574. * @property {any} options
  32575. * @property {Node} ast
  32576. * @property {boolean} isLastComment
  32577. */
  32578. /**
  32579. * @param {CommentContext} context
  32580. * @returns {boolean}
  32581. */
  32582. function handleOwnLineComment(context) {
  32583. return [handleIgnoreComments, handleLastFunctionArgComments, handleMemberExpressionComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleImportSpecifierComments, handleForComments, handleUnionTypeComments, handleOnlyComments, handleImportDeclarationComments, handleAssignmentPatternComments, handleMethodNameComments, handleLabeledStatementComments].some(fn => fn(context));
  32584. }
  32585. /**
  32586. * @param {CommentContext} context
  32587. * @returns {boolean}
  32588. */
  32589. function handleEndOfLineComment(context) {
  32590. return [handleClosureTypeCastComments, handleLastFunctionArgComments, handleConditionalExpressionComments, handleImportSpecifierComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleLabeledStatementComments, handleCallExpressionComments, handlePropertyComments, handleOnlyComments, handleTypeAliasComments, handleVariableDeclaratorComments].some(fn => fn(context));
  32591. }
  32592. /**
  32593. * @param {CommentContext} context
  32594. * @returns {boolean}
  32595. */
  32596. function handleRemainingComment(context) {
  32597. return [handleIgnoreComments, handleIfStatementComments, handleWhileComments, handleObjectPropertyAssignment, handleCommentInEmptyParens, handleMethodNameComments, handleOnlyComments, handleCommentAfterArrowParams, handleFunctionNameComments, handleTSMappedTypeComments, handleBreakAndContinueStatementComments, handleTSFunctionTrailingComments].some(fn => fn(context));
  32598. }
  32599. /**
  32600. * @param {Node} node
  32601. * @returns {void}
  32602. */
  32603. function addBlockStatementFirstComment(node, comment) {
  32604. // @ts-expect-error
  32605. const firstNonEmptyNode = (node.body || node.properties).find(({
  32606. type
  32607. }) => type !== "EmptyStatement");
  32608. if (firstNonEmptyNode) {
  32609. addLeadingComment(firstNonEmptyNode, comment);
  32610. } else {
  32611. addDanglingComment(node, comment);
  32612. }
  32613. }
  32614. /**
  32615. * @param {Node} node
  32616. * @returns {void}
  32617. */
  32618. function addBlockOrNotComment(node, comment) {
  32619. if (node.type === "BlockStatement") {
  32620. addBlockStatementFirstComment(node, comment);
  32621. } else {
  32622. addLeadingComment(node, comment);
  32623. }
  32624. }
  32625. function handleClosureTypeCastComments({
  32626. comment,
  32627. followingNode
  32628. }) {
  32629. if (followingNode && isTypeCastComment(comment)) {
  32630. addLeadingComment(followingNode, comment);
  32631. return true;
  32632. }
  32633. return false;
  32634. } // There are often comments before the else clause of if statements like
  32635. //
  32636. // if (1) { ... }
  32637. // // comment
  32638. // else { ... }
  32639. //
  32640. // They are being attached as leading comments of the BlockExpression which
  32641. // is not well printed. What we want is to instead move the comment inside
  32642. // of the block and make it leadingComment of the first element of the block
  32643. // or dangling comment of the block if there is nothing inside
  32644. //
  32645. // if (1) { ... }
  32646. // else {
  32647. // // comment
  32648. // ...
  32649. // }
  32650. function handleIfStatementComments({
  32651. comment,
  32652. precedingNode,
  32653. enclosingNode,
  32654. followingNode,
  32655. text
  32656. }) {
  32657. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  32658. return false;
  32659. } // We unfortunately have no way using the AST or location of nodes to know
  32660. // if the comment is positioned before the condition parenthesis:
  32661. // if (a /* comment */) {}
  32662. // The only workaround I found is to look at the next character to see if
  32663. // it is a ).
  32664. const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
  32665. if (nextCharacter === ")") {
  32666. addTrailingComment(precedingNode, comment);
  32667. return true;
  32668. } // Comments before `else`:
  32669. // - treat as trailing comments of the consequent, if it's a BlockStatement
  32670. // - treat as a dangling comment otherwise
  32671. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  32672. if (precedingNode.type === "BlockStatement") {
  32673. addTrailingComment(precedingNode, comment);
  32674. } else {
  32675. addDanglingComment(enclosingNode, comment);
  32676. }
  32677. return true;
  32678. }
  32679. if (followingNode.type === "BlockStatement") {
  32680. addBlockStatementFirstComment(followingNode, comment);
  32681. return true;
  32682. }
  32683. if (followingNode.type === "IfStatement") {
  32684. addBlockOrNotComment(followingNode.consequent, comment);
  32685. return true;
  32686. } // For comments positioned after the condition parenthesis in an if statement
  32687. // before the consequent without brackets on, such as
  32688. // if (a) /* comment */ true,
  32689. // we look at the next character to see if the following node
  32690. // is the consequent for the if statement
  32691. if (enclosingNode.consequent === followingNode) {
  32692. addLeadingComment(followingNode, comment);
  32693. return true;
  32694. }
  32695. return false;
  32696. }
  32697. function handleWhileComments({
  32698. comment,
  32699. precedingNode,
  32700. enclosingNode,
  32701. followingNode,
  32702. text
  32703. }) {
  32704. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  32705. return false;
  32706. } // We unfortunately have no way using the AST or location of nodes to know
  32707. // if the comment is positioned before the condition parenthesis:
  32708. // while (a /* comment */) {}
  32709. // The only workaround I found is to look at the next character to see if
  32710. // it is a ).
  32711. const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
  32712. if (nextCharacter === ")") {
  32713. addTrailingComment(precedingNode, comment);
  32714. return true;
  32715. }
  32716. if (followingNode.type === "BlockStatement") {
  32717. addBlockStatementFirstComment(followingNode, comment);
  32718. return true;
  32719. }
  32720. if (enclosingNode.body === followingNode) {
  32721. addLeadingComment(followingNode, comment);
  32722. return true;
  32723. }
  32724. return false;
  32725. } // Same as IfStatement but for TryStatement
  32726. function handleTryStatementComments({
  32727. comment,
  32728. precedingNode,
  32729. enclosingNode,
  32730. followingNode
  32731. }) {
  32732. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  32733. return false;
  32734. }
  32735. if (enclosingNode.type === "CatchClause" && precedingNode) {
  32736. addTrailingComment(precedingNode, comment);
  32737. return true;
  32738. }
  32739. if (followingNode.type === "BlockStatement") {
  32740. addBlockStatementFirstComment(followingNode, comment);
  32741. return true;
  32742. }
  32743. if (followingNode.type === "TryStatement") {
  32744. addBlockOrNotComment(followingNode.finalizer, comment);
  32745. return true;
  32746. }
  32747. if (followingNode.type === "CatchClause") {
  32748. addBlockOrNotComment(followingNode.body, comment);
  32749. return true;
  32750. }
  32751. return false;
  32752. }
  32753. function handleMemberExpressionComments({
  32754. comment,
  32755. enclosingNode,
  32756. followingNode
  32757. }) {
  32758. if (isMemberExpression$8(enclosingNode) && followingNode && followingNode.type === "Identifier") {
  32759. addLeadingComment(enclosingNode, comment);
  32760. return true;
  32761. }
  32762. return false;
  32763. }
  32764. function handleConditionalExpressionComments({
  32765. comment,
  32766. precedingNode,
  32767. enclosingNode,
  32768. followingNode,
  32769. text
  32770. }) {
  32771. const isSameLineAsPrecedingNode = precedingNode && !hasNewlineInRange$3(text, locEnd$o(precedingNode), locStart$p(comment));
  32772. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && (enclosingNode.type === "ConditionalExpression" || enclosingNode.type === "TSConditionalType") && followingNode) {
  32773. addLeadingComment(followingNode, comment);
  32774. return true;
  32775. }
  32776. return false;
  32777. }
  32778. function handleObjectPropertyAssignment({
  32779. comment,
  32780. precedingNode,
  32781. enclosingNode
  32782. }) {
  32783. if (isObjectProperty$4(enclosingNode) && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  32784. addTrailingComment(enclosingNode.value.left, comment);
  32785. return true;
  32786. }
  32787. return false;
  32788. }
  32789. function handleClassComments({
  32790. comment,
  32791. precedingNode,
  32792. enclosingNode,
  32793. followingNode
  32794. }) {
  32795. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression" || enclosingNode.type === "DeclareClass" || enclosingNode.type === "DeclareInterface" || enclosingNode.type === "InterfaceDeclaration" || enclosingNode.type === "TSInterfaceDeclaration")) {
  32796. if (isNonEmptyArray$f(enclosingNode.decorators) && !(followingNode && followingNode.type === "Decorator")) {
  32797. addTrailingComment(getLast$c(enclosingNode.decorators), comment);
  32798. return true;
  32799. }
  32800. if (enclosingNode.body && followingNode === enclosingNode.body) {
  32801. addBlockStatementFirstComment(enclosingNode.body, comment);
  32802. return true;
  32803. } // Don't add leading comments to `implements`, `extends`, `mixins` to
  32804. // avoid printing the comment after the keyword.
  32805. if (followingNode) {
  32806. for (const prop of ["implements", "extends", "mixins"]) {
  32807. if (enclosingNode[prop] && followingNode === enclosingNode[prop][0]) {
  32808. if (precedingNode && (precedingNode === enclosingNode.id || precedingNode === enclosingNode.typeParameters || precedingNode === enclosingNode.superClass)) {
  32809. addTrailingComment(precedingNode, comment);
  32810. } else {
  32811. addDanglingComment(enclosingNode, comment, prop);
  32812. }
  32813. return true;
  32814. }
  32815. }
  32816. }
  32817. }
  32818. return false;
  32819. }
  32820. function handleMethodNameComments({
  32821. comment,
  32822. precedingNode,
  32823. enclosingNode,
  32824. text
  32825. }) {
  32826. // This is only needed for estree parsers (flow, typescript) to attach
  32827. // after a method name:
  32828. // obj = { fn /*comment*/() {} };
  32829. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "TSAbstractMethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  32830. // comment should be attached to value instead of key
  32831. getNextNonSpaceNonCommentCharacter$1(text, precedingNode, locEnd$o) !== ":") {
  32832. addTrailingComment(precedingNode, comment);
  32833. return true;
  32834. } // Print comments between decorators and class methods as a trailing comment
  32835. // on the decorator node instead of the method node
  32836. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "PropertyDefinition" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "MethodDefinition")) {
  32837. addTrailingComment(precedingNode, comment);
  32838. return true;
  32839. }
  32840. return false;
  32841. }
  32842. function handleFunctionNameComments({
  32843. comment,
  32844. precedingNode,
  32845. enclosingNode,
  32846. text
  32847. }) {
  32848. if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== "(") {
  32849. return false;
  32850. }
  32851. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  32852. addTrailingComment(precedingNode, comment);
  32853. return true;
  32854. }
  32855. return false;
  32856. }
  32857. function handleCommentAfterArrowParams({
  32858. comment,
  32859. enclosingNode,
  32860. text
  32861. }) {
  32862. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  32863. return false;
  32864. }
  32865. const index = getNextNonSpaceNonCommentCharacterIndex$2(text, comment, locEnd$o);
  32866. if (index !== false && text.slice(index, index + 2) === "=>") {
  32867. addDanglingComment(enclosingNode, comment);
  32868. return true;
  32869. }
  32870. return false;
  32871. }
  32872. function handleCommentInEmptyParens({
  32873. comment,
  32874. enclosingNode,
  32875. text
  32876. }) {
  32877. if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== ")") {
  32878. return false;
  32879. } // Only add dangling comments to fix the case when no params are present,
  32880. // i.e. a function without any argument.
  32881. if (enclosingNode && (isRealFunctionLikeNode(enclosingNode) && getFunctionParameters$5(enclosingNode).length === 0 || isCallLikeExpression$1(enclosingNode) && getCallArguments$4(enclosingNode).length === 0)) {
  32882. addDanglingComment(enclosingNode, comment);
  32883. return true;
  32884. }
  32885. if (enclosingNode && (enclosingNode.type === "MethodDefinition" || enclosingNode.type === "TSAbstractMethodDefinition") && getFunctionParameters$5(enclosingNode.value).length === 0) {
  32886. addDanglingComment(enclosingNode.value, comment);
  32887. return true;
  32888. }
  32889. return false;
  32890. }
  32891. function handleLastFunctionArgComments({
  32892. comment,
  32893. precedingNode,
  32894. enclosingNode,
  32895. followingNode,
  32896. text
  32897. }) {
  32898. // Flow function type definitions
  32899. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  32900. addTrailingComment(precedingNode, comment);
  32901. return true;
  32902. } // Real functions and TypeScript function type definitions
  32903. if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && isRealFunctionLikeNode(enclosingNode) && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ")") {
  32904. addTrailingComment(precedingNode, comment);
  32905. return true;
  32906. }
  32907. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  32908. const functionParamRightParenIndex = (() => {
  32909. const parameters = getFunctionParameters$5(enclosingNode);
  32910. if (parameters.length > 0) {
  32911. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(getLast$c(parameters)));
  32912. }
  32913. const functionParamLeftParenIndex = getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(enclosingNode.id));
  32914. return functionParamLeftParenIndex !== false && getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  32915. })();
  32916. if (locStart$p(comment) > functionParamRightParenIndex) {
  32917. addBlockStatementFirstComment(followingNode, comment);
  32918. return true;
  32919. }
  32920. }
  32921. return false;
  32922. }
  32923. function handleImportSpecifierComments({
  32924. comment,
  32925. enclosingNode
  32926. }) {
  32927. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  32928. addLeadingComment(enclosingNode, comment);
  32929. return true;
  32930. }
  32931. return false;
  32932. }
  32933. function handleLabeledStatementComments({
  32934. comment,
  32935. enclosingNode
  32936. }) {
  32937. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  32938. addLeadingComment(enclosingNode, comment);
  32939. return true;
  32940. }
  32941. return false;
  32942. }
  32943. function handleBreakAndContinueStatementComments({
  32944. comment,
  32945. enclosingNode
  32946. }) {
  32947. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  32948. addTrailingComment(enclosingNode, comment);
  32949. return true;
  32950. }
  32951. return false;
  32952. }
  32953. function handleCallExpressionComments({
  32954. comment,
  32955. precedingNode,
  32956. enclosingNode
  32957. }) {
  32958. if (isCallExpression$c(enclosingNode) && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  32959. addLeadingComment(enclosingNode.arguments[0], comment);
  32960. return true;
  32961. }
  32962. return false;
  32963. }
  32964. function handleUnionTypeComments({
  32965. comment,
  32966. precedingNode,
  32967. enclosingNode,
  32968. followingNode
  32969. }) {
  32970. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  32971. if (isPrettierIgnoreComment(comment)) {
  32972. followingNode.prettierIgnore = true;
  32973. comment.unignore = true;
  32974. }
  32975. if (precedingNode) {
  32976. addTrailingComment(precedingNode, comment);
  32977. return true;
  32978. }
  32979. return false;
  32980. }
  32981. if (followingNode && (followingNode.type === "UnionTypeAnnotation" || followingNode.type === "TSUnionType") && isPrettierIgnoreComment(comment)) {
  32982. followingNode.types[0].prettierIgnore = true;
  32983. comment.unignore = true;
  32984. }
  32985. return false;
  32986. }
  32987. function handlePropertyComments({
  32988. comment,
  32989. enclosingNode
  32990. }) {
  32991. if (isObjectProperty$4(enclosingNode)) {
  32992. addLeadingComment(enclosingNode, comment);
  32993. return true;
  32994. }
  32995. return false;
  32996. }
  32997. function handleOnlyComments({
  32998. comment,
  32999. enclosingNode,
  33000. followingNode,
  33001. ast,
  33002. isLastComment
  33003. }) {
  33004. // With Flow the enclosingNode is undefined so use the AST instead.
  33005. if (ast && ast.body && ast.body.length === 0) {
  33006. if (isLastComment) {
  33007. addDanglingComment(ast, comment);
  33008. } else {
  33009. addLeadingComment(ast, comment);
  33010. }
  33011. return true;
  33012. }
  33013. if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && !isNonEmptyArray$f(enclosingNode.directives)) {
  33014. if (isLastComment) {
  33015. addDanglingComment(enclosingNode, comment);
  33016. } else {
  33017. addLeadingComment(enclosingNode, comment);
  33018. }
  33019. return true;
  33020. }
  33021. if (followingNode && followingNode.type === "Program" && followingNode.body.length === 0 && enclosingNode && enclosingNode.type === "ModuleExpression") {
  33022. addDanglingComment(followingNode, comment);
  33023. return true;
  33024. }
  33025. return false;
  33026. }
  33027. function handleForComments({
  33028. comment,
  33029. enclosingNode
  33030. }) {
  33031. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  33032. addLeadingComment(enclosingNode, comment);
  33033. return true;
  33034. }
  33035. return false;
  33036. }
  33037. function handleImportDeclarationComments({
  33038. comment,
  33039. precedingNode,
  33040. enclosingNode,
  33041. text
  33042. }) {
  33043. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && hasNewline$6(text, locEnd$o(comment))) {
  33044. addTrailingComment(precedingNode, comment);
  33045. return true;
  33046. }
  33047. return false;
  33048. }
  33049. function handleAssignmentPatternComments({
  33050. comment,
  33051. enclosingNode
  33052. }) {
  33053. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  33054. addLeadingComment(enclosingNode, comment);
  33055. return true;
  33056. }
  33057. return false;
  33058. }
  33059. function handleTypeAliasComments({
  33060. comment,
  33061. enclosingNode
  33062. }) {
  33063. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  33064. addLeadingComment(enclosingNode, comment);
  33065. return true;
  33066. }
  33067. return false;
  33068. }
  33069. function handleVariableDeclaratorComments({
  33070. comment,
  33071. enclosingNode,
  33072. followingNode
  33073. }) {
  33074. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression" || isBlockComment$3(comment))) {
  33075. addLeadingComment(followingNode, comment);
  33076. return true;
  33077. }
  33078. return false;
  33079. }
  33080. function handleTSFunctionTrailingComments({
  33081. comment,
  33082. enclosingNode,
  33083. followingNode,
  33084. text
  33085. }) {
  33086. if (!followingNode && enclosingNode && (enclosingNode.type === "TSMethodSignature" || enclosingNode.type === "TSDeclareFunction" || enclosingNode.type === "TSAbstractMethodDefinition") && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ";") {
  33087. addTrailingComment(enclosingNode, comment);
  33088. return true;
  33089. }
  33090. return false;
  33091. }
  33092. function handleIgnoreComments({
  33093. comment,
  33094. enclosingNode,
  33095. followingNode
  33096. }) {
  33097. if (isPrettierIgnoreComment(comment) && enclosingNode && enclosingNode.type === "TSMappedType" && followingNode && followingNode.type === "TSTypeParameter" && followingNode.constraint) {
  33098. enclosingNode.prettierIgnore = true;
  33099. comment.unignore = true;
  33100. return true;
  33101. }
  33102. }
  33103. function handleTSMappedTypeComments({
  33104. comment,
  33105. precedingNode,
  33106. enclosingNode,
  33107. followingNode
  33108. }) {
  33109. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  33110. return false;
  33111. }
  33112. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  33113. addLeadingComment(followingNode.name, comment);
  33114. return true;
  33115. }
  33116. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  33117. addTrailingComment(precedingNode.constraint, comment);
  33118. return true;
  33119. }
  33120. return false;
  33121. }
  33122. /**
  33123. * @param {Node} node
  33124. * @returns {boolean}
  33125. */
  33126. function isRealFunctionLikeNode(node) {
  33127. return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "TSDeclareFunction" || node.type === "TSCallSignatureDeclaration" || node.type === "TSConstructSignatureDeclaration" || node.type === "TSMethodSignature" || node.type === "TSConstructorType" || node.type === "TSFunctionType" || node.type === "TSDeclareMethod";
  33128. }
  33129. /**
  33130. * @param {any} node
  33131. * @returns {Node[] | void}
  33132. */
  33133. function getCommentChildNodes(node, options) {
  33134. // Prevent attaching comments to FunctionExpression in this case:
  33135. // class Foo {
  33136. // bar() // comment
  33137. // {
  33138. // baz();
  33139. // }
  33140. // }
  33141. if ((options.parser === "typescript" || options.parser === "flow" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree") && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && getFunctionParameters$5(node.value).length === 0 && !node.value.returnType && !isNonEmptyArray$f(node.value.typeParameters) && node.value.body) {
  33142. return [...(node.decorators || []), node.key, node.value.body];
  33143. }
  33144. }
  33145. /**
  33146. * @param {Comment} comment
  33147. * @returns {boolean}
  33148. */
  33149. function isTypeCastComment(comment) {
  33150. return isBlockComment$3(comment) && comment.value[0] === "*" && // TypeScript expects the type to be enclosed in curly brackets, however
  33151. // Closure Compiler accepts types in parens and even without any delimiters at all.
  33152. // That's why we just search for "@type".
  33153. /@type\b/.test(comment.value);
  33154. }
  33155. /**
  33156. * @param {AstPath} path
  33157. * @returns {boolean}
  33158. */
  33159. function willPrintOwnComments$1(path
  33160. /*, options */
  33161. ) {
  33162. const node = path.getValue();
  33163. const parent = path.getParentNode();
  33164. const hasFlowAnnotations = node => hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Leading)) || hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Trailing));
  33165. return (node && (isJsxNode$6(node) || hasFlowShorthandAnnotationComment$2(node) || isCallExpression$c(parent) && hasFlowAnnotations(node)) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$1(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
  33166. }
  33167. var comments = {
  33168. handleOwnLineComment,
  33169. handleEndOfLineComment,
  33170. handleRemainingComment,
  33171. isTypeCastComment,
  33172. getCommentChildNodes,
  33173. willPrintOwnComments: willPrintOwnComments$1
  33174. };
  33175. const {
  33176. getFunctionParameters: getFunctionParameters$4,
  33177. getLeftSidePathName: getLeftSidePathName$1,
  33178. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$1,
  33179. hasNakedLeftSide: hasNakedLeftSide$2,
  33180. hasNode: hasNode$1,
  33181. isBitwiseOperator,
  33182. startsWithNoLookaheadToken: startsWithNoLookaheadToken$1,
  33183. shouldFlatten: shouldFlatten$1,
  33184. getPrecedence,
  33185. isCallExpression: isCallExpression$b,
  33186. isMemberExpression: isMemberExpression$7,
  33187. isObjectProperty: isObjectProperty$3
  33188. } = utils$5;
  33189. function needsParens(path, options) {
  33190. const parent = path.getParentNode();
  33191. if (!parent) {
  33192. return false;
  33193. }
  33194. const name = path.getName();
  33195. const node = path.getNode(); // to avoid unexpected `}}` in HTML interpolations
  33196. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
  33197. return true;
  33198. } // Only statements don't need parentheses.
  33199. if (isStatement(node)) {
  33200. return false;
  33201. }
  33202. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  33203. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  33204. // AST, which we handle separately.
  33205. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
  33206. return true;
  33207. } // Identifiers never need parentheses.
  33208. if (node.type === "Identifier") {
  33209. // ...unless those identifiers are embed placeholders. They might be substituted by complex
  33210. // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
  33211. // let tpl = html`<script> f((${expr}) / 2); </script>`;
  33212. // If the inner JS formatter removes the parens, the expression might change its meaning:
  33213. // f((a + b) / 2) vs f(a + b / 2)
  33214. if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
  33215. return true;
  33216. } // `for (async of []);` is invalid
  33217. if (name === "left" && node.name === "async" && parent.type === "ForOfStatement" && !parent.await) {
  33218. return true;
  33219. }
  33220. return false;
  33221. }
  33222. switch (parent.type) {
  33223. case "ParenthesizedExpression":
  33224. return false;
  33225. case "ClassDeclaration":
  33226. case "ClassExpression":
  33227. {
  33228. // Add parens around the extends clause of a class. It is needed for almost
  33229. // all expressions.
  33230. if (name === "superClass" && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression" || node.type === "TSNonNullExpression")) {
  33231. return true;
  33232. }
  33233. break;
  33234. }
  33235. case "ExportDefaultDeclaration":
  33236. {
  33237. return (// `export default function` or `export default class` can't be followed by
  33238. // anything after. So an expression like `export default (function(){}).toString()`
  33239. // needs to be followed by a parentheses
  33240. shouldWrapFunctionForExportDefault(path, options) || // `export default (foo, bar)` also needs parentheses
  33241. node.type === "SequenceExpression"
  33242. );
  33243. }
  33244. case "Decorator":
  33245. {
  33246. if (name === "expression") {
  33247. let hasCallExpression = false;
  33248. let hasMemberExpression = false;
  33249. let current = node;
  33250. while (current) {
  33251. switch (current.type) {
  33252. case "MemberExpression":
  33253. hasMemberExpression = true;
  33254. current = current.object;
  33255. break;
  33256. case "CallExpression":
  33257. if (
  33258. /** @(x().y) */
  33259. hasMemberExpression ||
  33260. /** @(x().y()) */
  33261. hasCallExpression) {
  33262. return true;
  33263. }
  33264. hasCallExpression = true;
  33265. current = current.callee;
  33266. break;
  33267. case "Identifier":
  33268. return false;
  33269. default:
  33270. return true;
  33271. }
  33272. }
  33273. return true;
  33274. }
  33275. break;
  33276. }
  33277. case "ExpressionStatement":
  33278. {
  33279. if (startsWithNoLookaheadToken$1(node,
  33280. /* forbidFunctionClassAndDoExpr */
  33281. true)) {
  33282. return true;
  33283. }
  33284. break;
  33285. }
  33286. case "ArrowFunctionExpression":
  33287. {
  33288. if (name === "body" && node.type !== "SequenceExpression" && // these have parens added anyway
  33289. startsWithNoLookaheadToken$1(node,
  33290. /* forbidFunctionClassAndDoExpr */
  33291. false)) {
  33292. return true;
  33293. }
  33294. break;
  33295. }
  33296. }
  33297. switch (node.type) {
  33298. case "UpdateExpression":
  33299. if (parent.type === "UnaryExpression") {
  33300. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  33301. }
  33302. // else fallthrough
  33303. case "UnaryExpression":
  33304. switch (parent.type) {
  33305. case "UnaryExpression":
  33306. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  33307. case "BindExpression":
  33308. return true;
  33309. case "MemberExpression":
  33310. case "OptionalMemberExpression":
  33311. return name === "object";
  33312. case "TaggedTemplateExpression":
  33313. return true;
  33314. case "NewExpression":
  33315. case "CallExpression":
  33316. case "OptionalCallExpression":
  33317. return name === "callee";
  33318. case "BinaryExpression":
  33319. return name === "left" && parent.operator === "**";
  33320. case "TSNonNullExpression":
  33321. return true;
  33322. default:
  33323. return false;
  33324. }
  33325. case "BinaryExpression":
  33326. {
  33327. if (parent.type === "UpdateExpression" || parent.type === "PipelineTopicExpression" && node.operator === "|>") {
  33328. return true;
  33329. } // We add parentheses to any `a in b` inside `ForStatement` initializer
  33330. // https://github.com/prettier/prettier/issues/907#issuecomment-284304321
  33331. if (node.operator === "in" && isPathInForStatementInitializer(path)) {
  33332. return true;
  33333. }
  33334. if (node.operator === "|>" && node.extra && node.extra.parenthesized) {
  33335. const grandParent = path.getParentNode(1);
  33336. if (grandParent.type === "BinaryExpression" && grandParent.operator === "|>") {
  33337. return true;
  33338. }
  33339. }
  33340. }
  33341. // fallthrough
  33342. case "TSTypeAssertion":
  33343. case "TSAsExpression":
  33344. case "LogicalExpression":
  33345. switch (parent.type) {
  33346. case "TSAsExpression":
  33347. // example: foo as unknown as Bar
  33348. return node.type !== "TSAsExpression";
  33349. case "ConditionalExpression":
  33350. return node.type === "TSAsExpression";
  33351. case "CallExpression":
  33352. case "NewExpression":
  33353. case "OptionalCallExpression":
  33354. return name === "callee";
  33355. case "ClassExpression":
  33356. case "ClassDeclaration":
  33357. return name === "superClass";
  33358. case "TSTypeAssertion":
  33359. case "TaggedTemplateExpression":
  33360. case "UnaryExpression":
  33361. case "JSXSpreadAttribute":
  33362. case "SpreadElement":
  33363. case "SpreadProperty":
  33364. case "BindExpression":
  33365. case "AwaitExpression":
  33366. case "TSNonNullExpression":
  33367. case "UpdateExpression":
  33368. return true;
  33369. case "MemberExpression":
  33370. case "OptionalMemberExpression":
  33371. return name === "object";
  33372. case "AssignmentExpression":
  33373. case "AssignmentPattern":
  33374. return name === "left" && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  33375. case "LogicalExpression":
  33376. if (node.type === "LogicalExpression") {
  33377. return parent.operator !== node.operator;
  33378. }
  33379. // else fallthrough
  33380. case "BinaryExpression":
  33381. {
  33382. const {
  33383. operator,
  33384. type
  33385. } = node;
  33386. if (!operator && type !== "TSTypeAssertion") {
  33387. return true;
  33388. }
  33389. const precedence = getPrecedence(operator);
  33390. const parentOperator = parent.operator;
  33391. const parentPrecedence = getPrecedence(parentOperator);
  33392. if (parentPrecedence > precedence) {
  33393. return true;
  33394. }
  33395. if (name === "right" && parentPrecedence === precedence) {
  33396. return true;
  33397. }
  33398. if (parentPrecedence === precedence && !shouldFlatten$1(parentOperator, operator)) {
  33399. return true;
  33400. }
  33401. if (parentPrecedence < precedence && operator === "%") {
  33402. return parentOperator === "+" || parentOperator === "-";
  33403. } // Add parenthesis when working with bitwise operators
  33404. // It's not strictly needed but helps with code understanding
  33405. if (isBitwiseOperator(parentOperator)) {
  33406. return true;
  33407. }
  33408. return false;
  33409. }
  33410. default:
  33411. return false;
  33412. }
  33413. case "SequenceExpression":
  33414. switch (parent.type) {
  33415. case "ReturnStatement":
  33416. return false;
  33417. case "ForStatement":
  33418. // Although parentheses wouldn't hurt around sequence
  33419. // expressions in the head of for loops, traditional style
  33420. // dictates that e.g. i++, j++ should not be wrapped with
  33421. // parentheses.
  33422. return false;
  33423. case "ExpressionStatement":
  33424. return name !== "expression";
  33425. case "ArrowFunctionExpression":
  33426. // We do need parentheses, but SequenceExpressions are handled
  33427. // specially when printing bodies of arrow functions.
  33428. return name !== "body";
  33429. default:
  33430. // Otherwise err on the side of overparenthesization, adding
  33431. // explicit exceptions above if this proves overzealous.
  33432. return true;
  33433. }
  33434. case "YieldExpression":
  33435. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  33436. return true;
  33437. }
  33438. if (name === "expression" && node.argument && node.argument.type === "PipelinePrimaryTopicReference" && parent.type === "PipelineTopicExpression") {
  33439. return true;
  33440. }
  33441. // else fallthrough
  33442. case "AwaitExpression":
  33443. switch (parent.type) {
  33444. case "TaggedTemplateExpression":
  33445. case "UnaryExpression":
  33446. case "LogicalExpression":
  33447. case "SpreadElement":
  33448. case "SpreadProperty":
  33449. case "TSAsExpression":
  33450. case "TSNonNullExpression":
  33451. case "BindExpression":
  33452. return true;
  33453. case "MemberExpression":
  33454. case "OptionalMemberExpression":
  33455. return name === "object";
  33456. case "NewExpression":
  33457. case "CallExpression":
  33458. case "OptionalCallExpression":
  33459. return name === "callee";
  33460. case "ConditionalExpression":
  33461. return name === "test";
  33462. case "BinaryExpression":
  33463. {
  33464. if (!node.argument && parent.operator === "|>") {
  33465. return false;
  33466. }
  33467. return true;
  33468. }
  33469. default:
  33470. return false;
  33471. }
  33472. case "TSConditionalType":
  33473. if (name === "extendsType" && parent.type === "TSConditionalType") {
  33474. return true;
  33475. }
  33476. // fallthrough
  33477. case "TSFunctionType":
  33478. case "TSConstructorType":
  33479. if (name === "checkType" && parent.type === "TSConditionalType") {
  33480. return true;
  33481. }
  33482. // fallthrough
  33483. case "TSUnionType":
  33484. case "TSIntersectionType":
  33485. if ((parent.type === "TSUnionType" || parent.type === "TSIntersectionType") && parent.types.length > 1 && (!node.types || node.types.length > 1)) {
  33486. return true;
  33487. }
  33488. // fallthrough
  33489. case "TSInferType":
  33490. if (node.type === "TSInferType" && parent.type === "TSRestType") {
  33491. return false;
  33492. }
  33493. // fallthrough
  33494. case "TSTypeOperator":
  33495. return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || name === "objectType" && parent.type === "TSIndexedAccessType" || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && /^TSJSDoc/.test(path.getParentNode(1).type);
  33496. case "ArrayTypeAnnotation":
  33497. return parent.type === "NullableTypeAnnotation";
  33498. case "IntersectionTypeAnnotation":
  33499. case "UnionTypeAnnotation":
  33500. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  33501. case "NullableTypeAnnotation":
  33502. return parent.type === "ArrayTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  33503. case "FunctionTypeAnnotation":
  33504. {
  33505. const ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
  33506. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || name === "objectType" && (ancestor.type === "IndexedAccessType" || ancestor.type === "OptionalIndexedAccessType") || // We should check ancestor's parent to know whether the parentheses
  33507. // are really needed, but since ??T doesn't make sense this check
  33508. // will almost never be true.
  33509. ancestor.type === "NullableTypeAnnotation" || parent.type === "FunctionTypeParam" && parent.name === null && getFunctionParameters$4(node).some(param => param.typeAnnotation && param.typeAnnotation.type === "NullableTypeAnnotation");
  33510. }
  33511. case "OptionalIndexedAccessType":
  33512. return name === "objectType" && parent.type === "IndexedAccessType";
  33513. case "TypeofTypeAnnotation":
  33514. return name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  33515. case "StringLiteral":
  33516. case "NumericLiteral":
  33517. case "Literal":
  33518. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && !parent.directive) {
  33519. // To avoid becoming a directive
  33520. const grandParent = path.getParentNode(1);
  33521. return grandParent.type === "Program" || grandParent.type === "BlockStatement";
  33522. }
  33523. return name === "object" && parent.type === "MemberExpression" && typeof node.value === "number";
  33524. case "AssignmentExpression":
  33525. {
  33526. const grandParent = path.getParentNode(1);
  33527. if (name === "body" && parent.type === "ArrowFunctionExpression") {
  33528. return true;
  33529. }
  33530. if (name === "key" && (parent.type === "ClassProperty" || parent.type === "PropertyDefinition") && parent.computed) {
  33531. return false;
  33532. }
  33533. if ((name === "init" || name === "update") && parent.type === "ForStatement") {
  33534. return false;
  33535. }
  33536. if (parent.type === "ExpressionStatement") {
  33537. return node.left.type === "ObjectPattern";
  33538. }
  33539. if (name === "key" && parent.type === "TSPropertySignature") {
  33540. return false;
  33541. }
  33542. if (parent.type === "AssignmentExpression") {
  33543. return false;
  33544. }
  33545. if (parent.type === "SequenceExpression" && grandParent && grandParent.type === "ForStatement" && (grandParent.init === parent || grandParent.update === parent)) {
  33546. return false;
  33547. }
  33548. if (name === "value" && parent.type === "Property" && grandParent && grandParent.type === "ObjectPattern" && grandParent.properties.includes(parent)) {
  33549. return false;
  33550. }
  33551. if (parent.type === "NGChainedExpression") {
  33552. return false;
  33553. }
  33554. return true;
  33555. }
  33556. case "ConditionalExpression":
  33557. switch (parent.type) {
  33558. case "TaggedTemplateExpression":
  33559. case "UnaryExpression":
  33560. case "SpreadElement":
  33561. case "SpreadProperty":
  33562. case "BinaryExpression":
  33563. case "LogicalExpression":
  33564. case "NGPipeExpression":
  33565. case "ExportDefaultDeclaration":
  33566. case "AwaitExpression":
  33567. case "JSXSpreadAttribute":
  33568. case "TSTypeAssertion":
  33569. case "TypeCastExpression":
  33570. case "TSAsExpression":
  33571. case "TSNonNullExpression":
  33572. return true;
  33573. case "NewExpression":
  33574. case "CallExpression":
  33575. case "OptionalCallExpression":
  33576. return name === "callee";
  33577. case "ConditionalExpression":
  33578. return name === "test";
  33579. case "MemberExpression":
  33580. case "OptionalMemberExpression":
  33581. return name === "object";
  33582. default:
  33583. return false;
  33584. }
  33585. case "FunctionExpression":
  33586. switch (parent.type) {
  33587. case "NewExpression":
  33588. case "CallExpression":
  33589. case "OptionalCallExpression":
  33590. // Not always necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  33591. // Is necessary if it is `expression` of `ExpressionStatement`.
  33592. return name === "callee";
  33593. case "TaggedTemplateExpression":
  33594. return true;
  33595. // This is basically a kind of IIFE.
  33596. default:
  33597. return false;
  33598. }
  33599. case "ArrowFunctionExpression":
  33600. switch (parent.type) {
  33601. case "PipelineTopicExpression":
  33602. return Boolean(node.extra && node.extra.parenthesized);
  33603. case "BinaryExpression":
  33604. return parent.operator !== "|>" || node.extra && node.extra.parenthesized;
  33605. case "NewExpression":
  33606. case "CallExpression":
  33607. case "OptionalCallExpression":
  33608. return name === "callee";
  33609. case "MemberExpression":
  33610. case "OptionalMemberExpression":
  33611. return name === "object";
  33612. case "TSAsExpression":
  33613. case "TSNonNullExpression":
  33614. case "BindExpression":
  33615. case "TaggedTemplateExpression":
  33616. case "UnaryExpression":
  33617. case "LogicalExpression":
  33618. case "AwaitExpression":
  33619. case "TSTypeAssertion":
  33620. return true;
  33621. case "ConditionalExpression":
  33622. return name === "test";
  33623. default:
  33624. return false;
  33625. }
  33626. case "ClassExpression":
  33627. switch (parent.type) {
  33628. case "NewExpression":
  33629. return name === "callee";
  33630. default:
  33631. return false;
  33632. }
  33633. case "OptionalMemberExpression":
  33634. case "OptionalCallExpression":
  33635. {
  33636. const parentParent = path.getParentNode(1);
  33637. if (name === "object" && parent.type === "MemberExpression" || name === "callee" && (parent.type === "CallExpression" || parent.type === "NewExpression") || parent.type === "TSNonNullExpression" && parentParent.type === "MemberExpression" && parentParent.object === parent) {
  33638. return true;
  33639. }
  33640. }
  33641. // fallthrough
  33642. case "CallExpression":
  33643. case "MemberExpression":
  33644. case "TaggedTemplateExpression":
  33645. case "TSNonNullExpression":
  33646. if (name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression")) {
  33647. let object = node;
  33648. while (object) {
  33649. switch (object.type) {
  33650. case "CallExpression":
  33651. case "OptionalCallExpression":
  33652. return true;
  33653. case "MemberExpression":
  33654. case "OptionalMemberExpression":
  33655. case "BindExpression":
  33656. object = object.object;
  33657. break;
  33658. // tagged templates are basically member expressions from a grammar perspective
  33659. // see https://tc39.github.io/ecma262/#prod-MemberExpression
  33660. case "TaggedTemplateExpression":
  33661. object = object.tag;
  33662. break;
  33663. case "TSNonNullExpression":
  33664. object = object.expression;
  33665. break;
  33666. default:
  33667. return false;
  33668. }
  33669. }
  33670. }
  33671. return false;
  33672. case "BindExpression":
  33673. return name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression") || name === "object" && isMemberExpression$7(parent);
  33674. case "NGPipeExpression":
  33675. if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" && // Preserve parens for compatibility with AngularJS expressions
  33676. !(node.extra && node.extra.parenthesized) || parent.type === "ArrayExpression" || isCallExpression$b(parent) && parent.arguments[name] === node || name === "right" && parent.type === "NGPipeExpression" || name === "property" && parent.type === "MemberExpression" || parent.type === "AssignmentExpression") {
  33677. return false;
  33678. }
  33679. return true;
  33680. case "JSXFragment":
  33681. case "JSXElement":
  33682. return name === "callee" || name === "left" && parent.type === "BinaryExpression" && parent.operator === "<" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "NewExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && !isCallExpression$b(parent) && !isObjectProperty$3(parent) && parent.type !== "ReturnStatement" && parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && parent.type !== "YieldExpression";
  33683. case "TypeAnnotation":
  33684. return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node);
  33685. }
  33686. return false;
  33687. }
  33688. function isStatement(node) {
  33689. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "PropertyDefinition" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
  33690. }
  33691. function isPathInForStatementInitializer(path) {
  33692. let i = 0;
  33693. let node = path.getValue();
  33694. while (node) {
  33695. const parent = path.getParentNode(i++);
  33696. if (parent && parent.type === "ForStatement" && parent.init === node) {
  33697. return true;
  33698. }
  33699. node = parent;
  33700. }
  33701. return false;
  33702. }
  33703. function includesFunctionTypeInObjectType(node) {
  33704. return hasNode$1(node, n1 => n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined) || undefined);
  33705. }
  33706. function endsWithRightBracket(node) {
  33707. switch (node.type) {
  33708. case "ObjectExpression":
  33709. return true;
  33710. default:
  33711. return false;
  33712. }
  33713. }
  33714. function isFollowedByRightBracket(path) {
  33715. const node = path.getValue();
  33716. const parent = path.getParentNode();
  33717. const name = path.getName();
  33718. switch (parent.type) {
  33719. case "NGPipeExpression":
  33720. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  33721. return path.callParent(isFollowedByRightBracket);
  33722. }
  33723. break;
  33724. case "ObjectProperty":
  33725. if (name === "value") {
  33726. const parentParent = path.getParentNode(1);
  33727. return getLast_1(parentParent.properties) === parent;
  33728. }
  33729. break;
  33730. case "BinaryExpression":
  33731. case "LogicalExpression":
  33732. if (name === "right") {
  33733. return path.callParent(isFollowedByRightBracket);
  33734. }
  33735. break;
  33736. case "ConditionalExpression":
  33737. if (name === "alternate") {
  33738. return path.callParent(isFollowedByRightBracket);
  33739. }
  33740. break;
  33741. case "UnaryExpression":
  33742. if (parent.prefix) {
  33743. return path.callParent(isFollowedByRightBracket);
  33744. }
  33745. break;
  33746. }
  33747. return false;
  33748. }
  33749. function shouldWrapFunctionForExportDefault(path, options) {
  33750. const node = path.getValue();
  33751. const parent = path.getParentNode();
  33752. if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
  33753. return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
  33754. // (e.g. `export default (function() {})();`)
  33755. // in this case we don't need to add extra parens
  33756. !needsParens(path, options);
  33757. }
  33758. if (!hasNakedLeftSide$2(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
  33759. return false;
  33760. }
  33761. return path.call(childPath => shouldWrapFunctionForExportDefault(childPath, options), ...getLeftSidePathName$1(path, node));
  33762. }
  33763. var needsParens_1 = needsParens;
  33764. function preprocess$3(ast, options) {
  33765. switch (options.parser) {
  33766. case "json":
  33767. case "json5":
  33768. case "json-stringify":
  33769. case "__js_expression":
  33770. case "__vue_expression":
  33771. return Object.assign(Object.assign({}, ast), {}, {
  33772. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  33773. node: ast,
  33774. comments: [],
  33775. rootMarker: options.rootMarker
  33776. });
  33777. default:
  33778. return ast;
  33779. }
  33780. }
  33781. var printPreprocess$3 = preprocess$3;
  33782. const {
  33783. builders: {
  33784. join: join$s,
  33785. line: line$x,
  33786. group: group$B,
  33787. softline: softline$r,
  33788. indent: indent$u
  33789. }
  33790. } = doc;
  33791. function printHtmlBinding$1(path, options, print) {
  33792. const node = path.getValue();
  33793. if (options.__onHtmlBindingRoot && path.getName() === null) {
  33794. options.__onHtmlBindingRoot(node, options);
  33795. }
  33796. if (node.type !== "File") {
  33797. return;
  33798. }
  33799. if (options.__isVueForBindingLeft) {
  33800. return path.call(functionDeclarationPath => {
  33801. const printed = join$s([",", line$x], functionDeclarationPath.map(print, "params"));
  33802. const {
  33803. params
  33804. } = functionDeclarationPath.getValue();
  33805. if (params.length === 1) {
  33806. return printed;
  33807. }
  33808. return ["(", indent$u([softline$r, group$B(printed)]), softline$r, ")"];
  33809. }, "program", "body", 0);
  33810. }
  33811. if (options.__isVueBindings) {
  33812. return path.call(functionDeclarationPath => join$s([",", line$x], functionDeclarationPath.map(print, "params")), "program", "body", 0);
  33813. }
  33814. } // based on https://github.com/prettier/prettier/blob/main/src/language-html/syntax-vue.js isVueEventBindingExpression()
  33815. function isVueEventBindingExpression$3(node) {
  33816. switch (node.type) {
  33817. case "MemberExpression":
  33818. switch (node.property.type) {
  33819. case "Identifier":
  33820. case "NumericLiteral":
  33821. case "StringLiteral":
  33822. return isVueEventBindingExpression$3(node.object);
  33823. }
  33824. return false;
  33825. case "Identifier":
  33826. return true;
  33827. default:
  33828. return false;
  33829. }
  33830. }
  33831. var htmlBinding = {
  33832. isVueEventBindingExpression: isVueEventBindingExpression$3,
  33833. printHtmlBinding: printHtmlBinding$1
  33834. };
  33835. const {
  33836. printComments: printComments$5
  33837. } = comments$1;
  33838. const {
  33839. getLast: getLast$b
  33840. } = util$5;
  33841. const {
  33842. builders: {
  33843. join: join$r,
  33844. line: line$w,
  33845. softline: softline$q,
  33846. group: group$A,
  33847. indent: indent$t,
  33848. align: align$4,
  33849. ifBreak: ifBreak$m,
  33850. indentIfBreak: indentIfBreak$3
  33851. },
  33852. utils: {
  33853. cleanDoc: cleanDoc$2,
  33854. getDocParts: getDocParts$6,
  33855. isConcat: isConcat$1
  33856. }
  33857. } = doc;
  33858. const {
  33859. hasLeadingOwnLineComment: hasLeadingOwnLineComment$3,
  33860. isBinaryish: isBinaryish$3,
  33861. isJsxNode: isJsxNode$5,
  33862. shouldFlatten,
  33863. hasComment: hasComment$g,
  33864. CommentCheckFlags: CommentCheckFlags$d,
  33865. isCallExpression: isCallExpression$a,
  33866. isMemberExpression: isMemberExpression$6,
  33867. isObjectProperty: isObjectProperty$2
  33868. } = utils$5;
  33869. /** @typedef {import("../../document").Doc} Doc */
  33870. let uid = 0;
  33871. function printBinaryishExpression$2(path, options, print) {
  33872. const node = path.getValue();
  33873. const parent = path.getParentNode();
  33874. const parentParent = path.getParentNode(1);
  33875. const isInsideParenthesis = node !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "SwitchStatement" || parent.type === "DoWhileStatement");
  33876. const parts = printBinaryishExpressions(path, print, options,
  33877. /* isNested */
  33878. false, isInsideParenthesis); // if (
  33879. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  33880. // ) {
  33881. //
  33882. // looks super weird, we want to break the children if the parent breaks
  33883. //
  33884. // if (
  33885. // this.hasPlugin("dynamicImports") &&
  33886. // this.lookahead().type === tt.parenLeft
  33887. // ) {
  33888. if (isInsideParenthesis) {
  33889. return parts;
  33890. } // Break between the parens in
  33891. // unaries or in a member or specific call expression, i.e.
  33892. //
  33893. // (
  33894. // a &&
  33895. // b &&
  33896. // c
  33897. // ).call()
  33898. if (isCallExpression$a(parent) && parent.callee === node || parent.type === "UnaryExpression" || isMemberExpression$6(parent) && !parent.computed) {
  33899. return group$A([indent$t([softline$q, ...parts]), softline$q]);
  33900. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  33901. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  33902. const shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "ThrowStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || node.operator !== "|" && parent.type === "JsExpressionRoot" || node.type !== "NGPipeExpression" && (parent.type === "NGRoot" && options.parser === "__ng_binding" || parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || node === parent.body && parent.type === "ArrowFunctionExpression" || node !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "ThrowStatement" && !isCallExpression$a(parentParent) || parent.type === "TemplateLiteral";
  33903. const shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "PropertyDefinition" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || isObjectProperty$2(parent);
  33904. const samePrecedenceSubExpression = isBinaryish$3(node.left) && shouldFlatten(node.operator, node.left.operator);
  33905. if (shouldNotIndent || shouldInlineLogicalExpression$1(node) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression$1(node) && shouldIndentIfInlining) {
  33906. return group$A(parts);
  33907. }
  33908. if (parts.length === 0) {
  33909. return "";
  33910. } // If the right part is a JSX node, we include it in a separate group to
  33911. // prevent it breaking the whole chain, so we can print the expression like:
  33912. //
  33913. // foo && bar && (
  33914. // <Foo>
  33915. // <Bar />
  33916. // </Foo>
  33917. // )
  33918. const hasJsx = isJsxNode$5(node.right);
  33919. const firstGroupIndex = parts.findIndex(part => typeof part !== "string" && !Array.isArray(part) && part.type === "group"); // Separate the leftmost expression, possibly with its leading comments.
  33920. const headParts = parts.slice(0, firstGroupIndex === -1 ? 1 : firstGroupIndex + 1);
  33921. const rest = parts.slice(headParts.length, hasJsx ? -1 : undefined);
  33922. const groupId = Symbol("logicalChain-" + ++uid);
  33923. const chain = group$A([// Don't include the initial expression in the indentation
  33924. // level. The first item is guaranteed to be the first
  33925. // left-most expression.
  33926. ...headParts, indent$t(rest)], {
  33927. id: groupId
  33928. });
  33929. if (!hasJsx) {
  33930. return chain;
  33931. }
  33932. const jsxPart = getLast$b(parts);
  33933. return group$A([chain, indentIfBreak$3(jsxPart, {
  33934. groupId
  33935. })]);
  33936. } // For binary expressions to be consistent, we need to group
  33937. // subsequent operators with the same precedence level under a single
  33938. // group. Otherwise they will be nested such that some of them break
  33939. // onto new lines but not all. Operators with the same precedence
  33940. // level should either all break or not. Because we group them by
  33941. // precedence level and the AST is structured based on precedence
  33942. // level, things are naturally broken up correctly, i.e. `&&` is
  33943. // broken before `+`.
  33944. function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
  33945. /** @type{Doc[]} */
  33946. let parts = [];
  33947. const node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  33948. if (isBinaryish$3(node)) {
  33949. // Put all operators with the same precedence level in the same
  33950. // group. The reason we only need to do this with the `left`
  33951. // expression is because given an expression like `1 + 2 - 3`, it
  33952. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  33953. // is where the rest of the expression will exist. Binary
  33954. // expressions on the right side mean they have a difference
  33955. // precedence level and should be treated as a separate group, so
  33956. // print them normally. (This doesn't hold for the `**` operator,
  33957. // which is unique in that it is right-associative.)
  33958. if (shouldFlatten(node.operator, node.left.operator)) {
  33959. // Flatten them out by recursively calling this function.
  33960. parts = [...parts, ...path.call(left => printBinaryishExpressions(left, print, options,
  33961. /* isNested */
  33962. true, isInsideParenthesis), "left")];
  33963. } else {
  33964. parts.push(group$A(print("left")));
  33965. }
  33966. const shouldInline = shouldInlineLogicalExpression$1(node);
  33967. const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$3(options.originalText, node.right);
  33968. const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  33969. const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group$A(indent$t([softline$q, ": ", join$r([softline$q, ":", ifBreak$m(" ")], path.map(print, "arguments").map(arg => align$4(2, group$A(arg))))])) : "";
  33970. const right = shouldInline ? [operator, " ", print("right"), rightSuffix] : [lineBeforeOperator ? line$w : "", operator, lineBeforeOperator ? " " : line$w, print("right"), rightSuffix]; // If there's only a single binary expression, we want to create a group
  33971. // in order to avoid having a small right part like -1 be on its own line.
  33972. const parent = path.getParentNode();
  33973. const shouldBreak = hasComment$g(node.left, CommentCheckFlags$d.Trailing | CommentCheckFlags$d.Line);
  33974. const shouldGroup = shouldBreak || !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  33975. parts.push(lineBeforeOperator ? "" : " ", shouldGroup ? group$A(right, {
  33976. shouldBreak
  33977. }) : right); // The root comments are already printed, but we need to manually print
  33978. // the other ones since we don't call the normal print on BinaryExpression,
  33979. // only for the left and right parts
  33980. if (isNested && hasComment$g(node)) {
  33981. const printed = cleanDoc$2(printComments$5(path, parts, options));
  33982. /* istanbul ignore else */
  33983. if (isConcat$1(printed) || printed.type === "fill") {
  33984. parts = getDocParts$6(printed);
  33985. } else {
  33986. parts = [printed];
  33987. }
  33988. }
  33989. } else {
  33990. // Our stopping case. Simply print the node normally.
  33991. parts.push(group$A(print()));
  33992. }
  33993. return parts;
  33994. }
  33995. function shouldInlineLogicalExpression$1(node) {
  33996. if (node.type !== "LogicalExpression") {
  33997. return false;
  33998. }
  33999. if (node.right.type === "ObjectExpression" && node.right.properties.length > 0) {
  34000. return true;
  34001. }
  34002. if (node.right.type === "ArrayExpression" && node.right.elements.length > 0) {
  34003. return true;
  34004. }
  34005. if (isJsxNode$5(node.right)) {
  34006. return true;
  34007. }
  34008. return false;
  34009. }
  34010. var binaryish = {
  34011. printBinaryishExpression: printBinaryishExpression$2,
  34012. shouldInlineLogicalExpression: shouldInlineLogicalExpression$1
  34013. };
  34014. const {
  34015. builders: {
  34016. join: join$q,
  34017. line: line$v,
  34018. group: group$z
  34019. }
  34020. } = doc;
  34021. const {
  34022. hasNode,
  34023. hasComment: hasComment$f,
  34024. getComments: getComments$3
  34025. } = utils$5;
  34026. const {
  34027. printBinaryishExpression: printBinaryishExpression$1
  34028. } = binaryish;
  34029. /** @typedef {import("../../common/ast-path")} AstPath */
  34030. function printAngular$1(path, options, print) {
  34031. const node = path.getValue(); // Angular nodes always starts with `NG`
  34032. if (!node.type.startsWith("NG")) {
  34033. return;
  34034. }
  34035. switch (node.type) {
  34036. case "NGRoot":
  34037. return [print("node"), !hasComment$f(node.node) ? "" : " //" + getComments$3(node.node)[0].value.trimEnd()];
  34038. case "NGPipeExpression":
  34039. return printBinaryishExpression$1(path, options, print);
  34040. case "NGChainedExpression":
  34041. return group$z(join$q([";", line$v], path.map(childPath => hasNgSideEffect(childPath) ? print() : ["(", print(), ")"], "expressions")));
  34042. case "NGEmptyExpression":
  34043. return "";
  34044. case "NGQuotedExpression":
  34045. return [node.prefix, ": ", node.value.trim()];
  34046. case "NGMicrosyntax":
  34047. return path.map((childPath, index) => [index === 0 ? "" : isNgForOf(childPath.getValue(), index, node) ? " " : [";", line$v], print()], "body");
  34048. case "NGMicrosyntaxKey":
  34049. return /^[$_a-z][\w$]*(?:-[$_a-z][\w$])*$/i.test(node.name) ? node.name : JSON.stringify(node.name);
  34050. case "NGMicrosyntaxExpression":
  34051. return [print("expression"), node.alias === null ? "" : [" as ", print("alias")]];
  34052. case "NGMicrosyntaxKeyedExpression":
  34053. {
  34054. const index = path.getName();
  34055. const parentNode = path.getParentNode();
  34056. const shouldNotPrintColon = isNgForOf(node, index, parentNode) || (index === 1 && (node.key.name === "then" || node.key.name === "else") || index === 2 && node.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
  34057. return [print("key"), shouldNotPrintColon ? " " : ": ", print("expression")];
  34058. }
  34059. case "NGMicrosyntaxLet":
  34060. return ["let ", print("key"), node.value === null ? "" : [" = ", print("value")]];
  34061. case "NGMicrosyntaxAs":
  34062. return [print("key"), " as ", print("alias")];
  34063. default:
  34064. /* istanbul ignore next */
  34065. throw new Error(`Unknown Angular node type: ${JSON.stringify(node.type)}.`);
  34066. }
  34067. }
  34068. function isNgForOf(node, index, parentNode) {
  34069. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  34070. }
  34071. /** identify if an angular expression seems to have side effects */
  34072. /**
  34073. * @param {AstPath} path
  34074. * @returns {boolean}
  34075. */
  34076. function hasNgSideEffect(path) {
  34077. return hasNode(path.getValue(), node => {
  34078. switch (node.type) {
  34079. case undefined:
  34080. return false;
  34081. case "CallExpression":
  34082. case "OptionalCallExpression":
  34083. case "AssignmentExpression":
  34084. return true;
  34085. }
  34086. });
  34087. }
  34088. var angular = {
  34089. printAngular: printAngular$1
  34090. };
  34091. const {
  34092. printComments: printComments$4,
  34093. printDanglingComments: printDanglingComments$d
  34094. } = comments$1;
  34095. const {
  34096. builders: {
  34097. line: line$u,
  34098. hardline: hardline$w,
  34099. softline: softline$p,
  34100. group: group$y,
  34101. indent: indent$s,
  34102. conditionalGroup: conditionalGroup$4,
  34103. fill: fill$8,
  34104. ifBreak: ifBreak$l,
  34105. lineSuffixBoundary,
  34106. join: join$p
  34107. },
  34108. utils: {
  34109. willBreak: willBreak$5
  34110. }
  34111. } = doc;
  34112. const {
  34113. getLast: getLast$a,
  34114. getPreferredQuote
  34115. } = util$5;
  34116. const {
  34117. isJsxNode: isJsxNode$4,
  34118. rawText: rawText$4,
  34119. isLiteral: isLiteral$2,
  34120. isCallExpression: isCallExpression$9,
  34121. isStringLiteral: isStringLiteral$4,
  34122. isBinaryish: isBinaryish$2,
  34123. hasComment: hasComment$e,
  34124. CommentCheckFlags: CommentCheckFlags$c,
  34125. hasNodeIgnoreComment
  34126. } = utils$5;
  34127. const {
  34128. willPrintOwnComments
  34129. } = comments;
  34130. const isEmptyStringOrAnyLine = doc => doc === "" || doc === line$u || doc === hardline$w || doc === softline$p;
  34131. /**
  34132. * @typedef {import("../../common/ast-path")} AstPath
  34133. * @typedef {import("../types/estree").Node} Node
  34134. * @typedef {import("../types/estree").JSXElement} JSXElement
  34135. */
  34136. // JSX expands children from the inside-out, instead of the outside-in.
  34137. // This is both to break children before attributes,
  34138. // and to ensure that when children break, their parents do as well.
  34139. //
  34140. // Any element that is written without any newlines and fits on a single line
  34141. // is left that way.
  34142. // Not only that, any user-written-line containing multiple JSX siblings
  34143. // should also be kept on one line if possible,
  34144. // so each user-written-line is wrapped in its own group.
  34145. //
  34146. // Elements that contain newlines or don't fit on a single line (recursively)
  34147. // are fully-split, using hardline and shouldBreak: true.
  34148. //
  34149. // To support that case properly, all leading and trailing spaces
  34150. // are stripped from the list of children, and replaced with a single hardline.
  34151. function printJsxElementInternal(path, options, print) {
  34152. const node = path.getValue();
  34153. if (node.type === "JSXElement" && isEmptyJsxElement(node)) {
  34154. return [print("openingElement"), print("closingElement")];
  34155. }
  34156. const openingLines = node.type === "JSXElement" ? print("openingElement") : print("openingFragment");
  34157. const closingLines = node.type === "JSXElement" ? print("closingElement") : print("closingFragment");
  34158. if (node.children.length === 1 && node.children[0].type === "JSXExpressionContainer" && (node.children[0].expression.type === "TemplateLiteral" || node.children[0].expression.type === "TaggedTemplateExpression")) {
  34159. return [openingLines, ...path.map(print, "children"), closingLines];
  34160. } // Convert `{" "}` to text nodes containing a space.
  34161. // This makes it easy to turn them into `jsxWhitespace` which
  34162. // can then print as either a space or `{" "}` when breaking.
  34163. node.children = node.children.map(child => {
  34164. if (isJsxWhitespaceExpression(child)) {
  34165. return {
  34166. type: "JSXText",
  34167. value: " ",
  34168. raw: " "
  34169. };
  34170. }
  34171. return child;
  34172. });
  34173. const containsTag = node.children.filter(isJsxNode$4).length > 0;
  34174. const containsMultipleExpressions = node.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
  34175. const containsMultipleAttributes = node.type === "JSXElement" && node.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  34176. let forcedBreak = willBreak$5(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  34177. const isMdxBlock = path.getParentNode().rootMarker === "mdx";
  34178. const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  34179. const jsxWhitespace = isMdxBlock ? " " : ifBreak$l([rawJsxWhitespace, softline$p], " ");
  34180. const isFacebookTranslationTag = node.openingElement && node.openingElement.name && node.openingElement.name.name === "fbt";
  34181. const children = printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
  34182. const containsText = node.children.some(child => isMeaningfulJsxText(child)); // We can end up we multiple whitespace elements with empty string
  34183. // content between them.
  34184. // We need to remove empty whitespace and softlines before JSX whitespace
  34185. // to get the correct output.
  34186. for (let i = children.length - 2; i >= 0; i--) {
  34187. const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  34188. const isPairOfHardlines = children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === hardline$w;
  34189. const isLineFollowedByJsxWhitespace = (children[i] === softline$p || children[i] === hardline$w) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  34190. const isJsxWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$p || children[i + 2] === hardline$w);
  34191. const isDoubleJsxWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  34192. const isPairOfHardOrSoftLines = children[i] === softline$p && children[i + 1] === "" && children[i + 2] === hardline$w || children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === softline$p;
  34193. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJsxWhitespace || isDoubleJsxWhitespace || isPairOfHardOrSoftLines) {
  34194. children.splice(i, 2);
  34195. } else if (isJsxWhitespaceFollowedByLine) {
  34196. children.splice(i + 1, 2);
  34197. }
  34198. } // Trim trailing lines (or empty strings)
  34199. while (children.length > 0 && isEmptyStringOrAnyLine(getLast$a(children))) {
  34200. children.pop();
  34201. } // Trim leading lines (or empty strings)
  34202. while (children.length > 1 && isEmptyStringOrAnyLine(children[0]) && isEmptyStringOrAnyLine(children[1])) {
  34203. children.shift();
  34204. children.shift();
  34205. } // Tweak how we format children if outputting this element over multiple lines.
  34206. // Also detect whether we will force this element to output over multiple lines.
  34207. const multilineChildren = [];
  34208. for (const [i, child] of children.entries()) {
  34209. // There are a number of situations where we need to ensure we display
  34210. // whitespace as `{" "}` when outputting this element over multiple lines.
  34211. if (child === jsxWhitespace) {
  34212. if (i === 1 && children[i - 1] === "") {
  34213. if (children.length === 2) {
  34214. // Solitary whitespace
  34215. multilineChildren.push(rawJsxWhitespace);
  34216. continue;
  34217. } // Leading whitespace
  34218. multilineChildren.push([rawJsxWhitespace, hardline$w]);
  34219. continue;
  34220. } else if (i === children.length - 1) {
  34221. // Trailing whitespace
  34222. multilineChildren.push(rawJsxWhitespace);
  34223. continue;
  34224. } else if (children[i - 1] === "" && children[i - 2] === hardline$w) {
  34225. // Whitespace after line break
  34226. multilineChildren.push(rawJsxWhitespace);
  34227. continue;
  34228. }
  34229. }
  34230. multilineChildren.push(child);
  34231. if (willBreak$5(child)) {
  34232. forcedBreak = true;
  34233. }
  34234. } // If there is text we use `fill` to fit as much onto each line as possible.
  34235. // When there is no text (just tags and expressions) we use `group`
  34236. // to output each on a separate line.
  34237. const content = containsText ? fill$8(multilineChildren) : group$y(multilineChildren, {
  34238. shouldBreak: true
  34239. });
  34240. if (isMdxBlock) {
  34241. return content;
  34242. }
  34243. const multiLineElem = group$y([openingLines, indent$s([hardline$w, content]), hardline$w, closingLines]);
  34244. if (forcedBreak) {
  34245. return multiLineElem;
  34246. }
  34247. return conditionalGroup$4([group$y([openingLines, ...children, closingLines]), multiLineElem]);
  34248. } // JSX Children are strange, mostly for two reasons:
  34249. // 1. JSX reads newlines into string values, instead of skipping them like JS
  34250. // 2. up to one whitespace between elements within a line is significant,
  34251. // but not between lines.
  34252. //
  34253. // Leading, trailing, and lone whitespace all need to
  34254. // turn themselves into the rather ugly `{' '}` when breaking.
  34255. //
  34256. // We print JSX using the `fill` doc primitive.
  34257. // This requires that we give it an array of alternating
  34258. // content and whitespace elements.
  34259. // To ensure this we add dummy `""` content elements as needed.
  34260. function printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
  34261. const parts = [];
  34262. path.each((childPath, i, children) => {
  34263. const child = childPath.getValue();
  34264. if (isLiteral$2(child)) {
  34265. const text = rawText$4(child); // Contains a non-whitespace character
  34266. if (isMeaningfulJsxText(child)) {
  34267. const words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  34268. if (words[0] === "") {
  34269. parts.push("");
  34270. words.shift();
  34271. if (/\n/.test(words[0])) {
  34272. const next = children[i + 1];
  34273. parts.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  34274. } else {
  34275. parts.push(jsxWhitespace);
  34276. }
  34277. words.shift();
  34278. }
  34279. let endWhitespace; // Ends with whitespace
  34280. if (getLast$a(words) === "") {
  34281. words.pop();
  34282. endWhitespace = words.pop();
  34283. } // This was whitespace only without a new line.
  34284. if (words.length === 0) {
  34285. return;
  34286. }
  34287. for (const [i, word] of words.entries()) {
  34288. if (i % 2 === 1) {
  34289. parts.push(line$u);
  34290. } else {
  34291. parts.push(word);
  34292. }
  34293. }
  34294. if (endWhitespace !== undefined) {
  34295. if (/\n/.test(endWhitespace)) {
  34296. const next = children[i + 1];
  34297. parts.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$a(parts), child, next));
  34298. } else {
  34299. parts.push(jsxWhitespace);
  34300. }
  34301. } else {
  34302. const next = children[i + 1];
  34303. parts.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$a(parts), child, next));
  34304. }
  34305. } else if (/\n/.test(text)) {
  34306. // Keep (up to one) blank line between tags/expressions/text.
  34307. // Note: We don't keep blank lines between text elements.
  34308. if (text.match(/\n/g).length > 1) {
  34309. parts.push("", hardline$w);
  34310. }
  34311. } else {
  34312. parts.push("", jsxWhitespace);
  34313. }
  34314. } else {
  34315. const printedChild = print();
  34316. parts.push(printedChild);
  34317. const next = children[i + 1];
  34318. const directlyFollowedByMeaningfulText = next && isMeaningfulJsxText(next);
  34319. if (directlyFollowedByMeaningfulText) {
  34320. const firstWord = trimJsxWhitespace(rawText$4(next)).split(matchJsxWhitespaceRegex)[0];
  34321. parts.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
  34322. } else {
  34323. parts.push(hardline$w);
  34324. }
  34325. }
  34326. }, "children");
  34327. return parts;
  34328. }
  34329. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  34330. if (isFacebookTranslationTag) {
  34331. return "";
  34332. }
  34333. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  34334. return child.length === 1 ? softline$p : hardline$w;
  34335. }
  34336. return softline$p;
  34337. }
  34338. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  34339. if (isFacebookTranslationTag) {
  34340. return hardline$w;
  34341. }
  34342. if (child.length === 1) {
  34343. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$w : softline$p;
  34344. }
  34345. return hardline$w;
  34346. }
  34347. function maybeWrapJsxElementInParens(path, elem, options) {
  34348. const parent = path.getParentNode();
  34349. /* istanbul ignore next */
  34350. if (!parent) {
  34351. return elem;
  34352. }
  34353. const NO_WRAP_PARENTS = {
  34354. ArrayExpression: true,
  34355. JSXAttribute: true,
  34356. JSXElement: true,
  34357. JSXExpressionContainer: true,
  34358. JSXFragment: true,
  34359. ExpressionStatement: true,
  34360. CallExpression: true,
  34361. OptionalCallExpression: true,
  34362. ConditionalExpression: true,
  34363. JsExpressionRoot: true
  34364. };
  34365. if (NO_WRAP_PARENTS[parent.type]) {
  34366. return elem;
  34367. }
  34368. const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallExpression$9, node => node.type === "JSXExpressionContainer");
  34369. const needsParens = needsParens_1(path, options);
  34370. return group$y([needsParens ? "" : ifBreak$l("("), indent$s([softline$p, elem]), softline$p, needsParens ? "" : ifBreak$l(")")], {
  34371. shouldBreak
  34372. });
  34373. }
  34374. function printJsxAttribute(path, options, print) {
  34375. const node = path.getValue();
  34376. const parts = [];
  34377. parts.push(print("name"));
  34378. if (node.value) {
  34379. let res;
  34380. if (isStringLiteral$4(node.value)) {
  34381. const raw = rawText$4(node.value); // Unescape all quotes so we get an accurate preferred quote
  34382. let final = raw.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  34383. const quote = getPreferredQuote(final, options.jsxSingleQuote ? "'" : '"');
  34384. const escape = quote === "'" ? "&apos;" : "&quot;";
  34385. final = final.slice(1, -1).replace(new RegExp(quote, "g"), escape);
  34386. res = [quote, final, quote];
  34387. } else {
  34388. res = print("value");
  34389. }
  34390. parts.push("=", res);
  34391. }
  34392. return parts;
  34393. }
  34394. function printJsxExpressionContainer(path, options, print) {
  34395. const node = path.getValue();
  34396. const parent = path.getParentNode(0);
  34397. const shouldInline = node.expression.type === "JSXEmptyExpression" || !hasComment$e(node.expression) && (node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression" || node.expression.type === "ArrowFunctionExpression" || isCallExpression$9(node.expression) || node.expression.type === "FunctionExpression" || node.expression.type === "TemplateLiteral" || node.expression.type === "TaggedTemplateExpression" || node.expression.type === "DoExpression" || isJsxNode$4(parent) && (node.expression.type === "ConditionalExpression" || isBinaryish$2(node.expression)));
  34398. if (shouldInline) {
  34399. return group$y(["{", print("expression"), lineSuffixBoundary, "}"]);
  34400. }
  34401. return group$y(["{", indent$s([softline$p, print("expression")]), softline$p, lineSuffixBoundary, "}"]);
  34402. }
  34403. function printJsxOpeningElement(path, options, print) {
  34404. const node = path.getValue();
  34405. const nameHasComments = node.name && hasComment$e(node.name) || node.typeParameters && hasComment$e(node.typeParameters); // Don't break self-closing elements with no attributes and no comments
  34406. if (node.selfClosing && node.attributes.length === 0 && !nameHasComments) {
  34407. return ["<", print("name"), print("typeParameters"), " />"];
  34408. } // don't break up opening elements with a single long text attribute
  34409. if (node.attributes && node.attributes.length === 1 && node.attributes[0].value && isStringLiteral$4(node.attributes[0].value) && !node.attributes[0].value.value.includes("\n") && // We should break for the following cases:
  34410. // <div
  34411. // // comment
  34412. // attr="value"
  34413. // >
  34414. // <div
  34415. // attr="value"
  34416. // // comment
  34417. // >
  34418. !nameHasComments && !hasComment$e(node.attributes[0])) {
  34419. return group$y(["<", print("name"), print("typeParameters"), " ", ...path.map(print, "attributes"), node.selfClosing ? " />" : ">"]);
  34420. }
  34421. const lastAttrHasTrailingComments = node.attributes.length > 0 && hasComment$e(getLast$a(node.attributes), CommentCheckFlags$c.Trailing);
  34422. const bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  34423. // kept unbroken regardless of `bracketSameLine`.
  34424. // jsxBracketSameLine is deprecated in favour of bracketSameLine,
  34425. // but is still needed for backwards compatibility.
  34426. node.attributes.length === 0 && !nameHasComments || (options.bracketSameLine || options.jsxBracketSameLine) && (!nameHasComments || node.attributes.length > 0) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  34427. // string literal with newlines
  34428. const shouldBreak = node.attributes && node.attributes.some(attr => attr.value && isStringLiteral$4(attr.value) && attr.value.value.includes("\n"));
  34429. return group$y(["<", print("name"), print("typeParameters"), indent$s(path.map(() => [line$u, print()], "attributes")), node.selfClosing ? line$u : bracketSameLine ? ">" : softline$p, node.selfClosing ? "/>" : bracketSameLine ? "" : ">"], {
  34430. shouldBreak
  34431. });
  34432. }
  34433. function printJsxClosingElement(path, options, print) {
  34434. const node = path.getValue();
  34435. const parts = [];
  34436. parts.push("</");
  34437. const printed = print("name");
  34438. if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Line)) {
  34439. parts.push(indent$s([hardline$w, printed]), hardline$w);
  34440. } else if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Block)) {
  34441. parts.push(" ", printed);
  34442. } else {
  34443. parts.push(printed);
  34444. }
  34445. parts.push(">");
  34446. return parts;
  34447. }
  34448. function printJsxOpeningClosingFragment(path, options
  34449. /*, print*/
  34450. ) {
  34451. const node = path.getValue();
  34452. const nodeHasComment = hasComment$e(node);
  34453. const hasOwnLineComment = hasComment$e(node, CommentCheckFlags$c.Line);
  34454. const isOpeningFragment = node.type === "JSXOpeningFragment";
  34455. return [isOpeningFragment ? "<" : "</", indent$s([hasOwnLineComment ? hardline$w : nodeHasComment && !isOpeningFragment ? " " : "", printDanglingComments$d(path, options, true)]), hasOwnLineComment ? hardline$w : "", ">"];
  34456. }
  34457. function printJsxElement(path, options, print) {
  34458. const elem = printComments$4(path, printJsxElementInternal(path, options, print), options);
  34459. return maybeWrapJsxElementInParens(path, elem, options);
  34460. }
  34461. function printJsxEmptyExpression(path, options
  34462. /*, print*/
  34463. ) {
  34464. const node = path.getValue();
  34465. const requiresHardline = hasComment$e(node, CommentCheckFlags$c.Line);
  34466. return [printDanglingComments$d(path, options,
  34467. /* sameIndent */
  34468. !requiresHardline), requiresHardline ? hardline$w : ""];
  34469. } // `JSXSpreadAttribute` and `JSXSpreadChild`
  34470. function printJsxSpreadAttribute(path, options, print) {
  34471. const node = path.getValue();
  34472. return ["{", path.call(p => {
  34473. const printed = ["...", print()];
  34474. const node = p.getValue();
  34475. if (!hasComment$e(node) || !willPrintOwnComments(p)) {
  34476. return printed;
  34477. }
  34478. return [indent$s([softline$p, printComments$4(p, printed, options)]), softline$p];
  34479. }, node.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"];
  34480. }
  34481. function printJsx$1(path, options, print) {
  34482. const node = path.getValue(); // JSX nodes always starts with `JSX`
  34483. if (!node.type.startsWith("JSX")) {
  34484. return;
  34485. }
  34486. switch (node.type) {
  34487. case "JSXAttribute":
  34488. return printJsxAttribute(path, options, print);
  34489. case "JSXIdentifier":
  34490. return String(node.name);
  34491. case "JSXNamespacedName":
  34492. return join$p(":", [print("namespace"), print("name")]);
  34493. case "JSXMemberExpression":
  34494. return join$p(".", [print("object"), print("property")]);
  34495. case "JSXSpreadAttribute":
  34496. return printJsxSpreadAttribute(path, options, print);
  34497. case "JSXSpreadChild":
  34498. {
  34499. // Same as `printJsxSpreadAttribute`
  34500. const printJsxSpreadChild = printJsxSpreadAttribute;
  34501. return printJsxSpreadChild(path, options, print);
  34502. }
  34503. case "JSXExpressionContainer":
  34504. return printJsxExpressionContainer(path, options, print);
  34505. case "JSXFragment":
  34506. case "JSXElement":
  34507. return printJsxElement(path, options, print);
  34508. case "JSXOpeningElement":
  34509. return printJsxOpeningElement(path, options, print);
  34510. case "JSXClosingElement":
  34511. return printJsxClosingElement(path, options, print);
  34512. case "JSXOpeningFragment":
  34513. case "JSXClosingFragment":
  34514. return printJsxOpeningClosingFragment(path, options
  34515. /*, print*/
  34516. );
  34517. case "JSXEmptyExpression":
  34518. return printJsxEmptyExpression(path, options
  34519. /*, print*/
  34520. );
  34521. case "JSXText":
  34522. /* istanbul ignore next */
  34523. throw new Error("JSXTest should be handled by JSXElement");
  34524. default:
  34525. /* istanbul ignore next */
  34526. throw new Error(`Unknown JSX node type: ${JSON.stringify(node.type)}.`);
  34527. }
  34528. } // Only space, newline, carriage return, and tab are treated as whitespace
  34529. // inside JSX.
  34530. const jsxWhitespaceChars = " \n\r\t";
  34531. const matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)");
  34532. const containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  34533. const trimJsxWhitespace = text => text.replace(new RegExp("(?:^" + matchJsxWhitespaceRegex.source + "|" + matchJsxWhitespaceRegex.source + "$)"), "");
  34534. /**
  34535. * @param {JSXElement} node
  34536. * @returns {boolean}
  34537. */
  34538. function isEmptyJsxElement(node) {
  34539. if (node.children.length === 0) {
  34540. return true;
  34541. }
  34542. if (node.children.length > 1) {
  34543. return false;
  34544. } // if there is one text child and does not contain any meaningful text
  34545. // we can treat the element as empty.
  34546. const child = node.children[0];
  34547. return isLiteral$2(child) && !isMeaningfulJsxText(child);
  34548. } // Meaningful if it contains non-whitespace characters,
  34549. // or it contains whitespace without a new line.
  34550. /**
  34551. * @param {Node} node
  34552. * @returns {boolean}
  34553. */
  34554. function isMeaningfulJsxText(node) {
  34555. return isLiteral$2(node) && (containsNonJsxWhitespaceRegex.test(rawText$4(node)) || !/\n/.test(rawText$4(node)));
  34556. } // Detect an expression node representing `{" "}`
  34557. function isJsxWhitespaceExpression(node) {
  34558. return node.type === "JSXExpressionContainer" && isLiteral$2(node.expression) && node.expression.value === " " && !hasComment$e(node.expression);
  34559. }
  34560. /**
  34561. * @param {AstPath} path
  34562. * @returns {boolean}
  34563. */
  34564. function hasJsxIgnoreComment$1(path) {
  34565. const node = path.getValue();
  34566. const parent = path.getParentNode();
  34567. if (!parent || !node || !isJsxNode$4(node) || !isJsxNode$4(parent)) {
  34568. return false;
  34569. } // Lookup the previous sibling, ignoring any empty JSXText elements
  34570. const index = parent.children.indexOf(node);
  34571. let prevSibling = null;
  34572. for (let i = index; i > 0; i--) {
  34573. const candidate = parent.children[i - 1];
  34574. if (candidate.type === "JSXText" && !isMeaningfulJsxText(candidate)) {
  34575. continue;
  34576. }
  34577. prevSibling = candidate;
  34578. break;
  34579. }
  34580. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && hasNodeIgnoreComment(prevSibling.expression);
  34581. }
  34582. var jsx = {
  34583. hasJsxIgnoreComment: hasJsxIgnoreComment$1,
  34584. printJsx: printJsx$1
  34585. };
  34586. // `Array.prototype.flat` method
  34587. // https://tc39.es/ecma262/#sec-array.prototype.flat
  34588. _export({ target: 'Array', proto: true }, {
  34589. flat: function flat(/* depthArg = 1 */) {
  34590. var depthArg = arguments.length ? arguments[0] : undefined;
  34591. var O = toObject(this);
  34592. var sourceLen = toLength(O.length);
  34593. var A = arraySpeciesCreate(O, 0);
  34594. A.length = flattenIntoArray_1(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
  34595. return A;
  34596. }
  34597. });
  34598. const {
  34599. isNonEmptyArray: isNonEmptyArray$e
  34600. } = util$5;
  34601. const {
  34602. builders: {
  34603. indent: indent$r,
  34604. join: join$o,
  34605. line: line$t
  34606. }
  34607. } = doc;
  34608. const {
  34609. isFlowAnnotationComment: isFlowAnnotationComment$1
  34610. } = utils$5;
  34611. function printOptionalToken$9(path) {
  34612. const node = path.getValue();
  34613. if (!node.optional || node.type === "Identifier" && node === path.getParentNode().key) {
  34614. return "";
  34615. }
  34616. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  34617. return "?.";
  34618. }
  34619. return "?";
  34620. }
  34621. function printFunctionTypeParameters$4(path, options, print) {
  34622. const fun = path.getValue();
  34623. if (fun.typeArguments) {
  34624. return print("typeArguments");
  34625. }
  34626. if (fun.typeParameters) {
  34627. return print("typeParameters");
  34628. }
  34629. return "";
  34630. }
  34631. function printTypeAnnotation$5(path, options, print) {
  34632. const node = path.getValue();
  34633. if (!node.typeAnnotation) {
  34634. return "";
  34635. }
  34636. const parentNode = path.getParentNode();
  34637. const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  34638. const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  34639. if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation)) {
  34640. return [" /*: ", print("typeAnnotation"), " */"];
  34641. }
  34642. return [isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", print("typeAnnotation")];
  34643. }
  34644. function printBindExpressionCallee$2(path, options, print) {
  34645. return ["::", print("callee")];
  34646. }
  34647. function printTypeScriptModifiers$2(path, options, print) {
  34648. const node = path.getValue();
  34649. if (!isNonEmptyArray$e(node.modifiers)) {
  34650. return "";
  34651. }
  34652. return [join$o(" ", path.map(print, "modifiers")), " "];
  34653. }
  34654. function adjustClause$1(node, clause, forceSpace) {
  34655. if (node.type === "EmptyStatement") {
  34656. return ";";
  34657. }
  34658. if (node.type === "BlockStatement" || forceSpace) {
  34659. return [" ", clause];
  34660. }
  34661. return indent$r([line$t, clause]);
  34662. }
  34663. function printRestSpread$2(path, options, print) {
  34664. return ["...", print("argument"), printTypeAnnotation$5(path, options, print)];
  34665. }
  34666. var misc$1 = {
  34667. printOptionalToken: printOptionalToken$9,
  34668. printFunctionTypeParameters: printFunctionTypeParameters$4,
  34669. printBindExpressionCallee: printBindExpressionCallee$2,
  34670. printTypeScriptModifiers: printTypeScriptModifiers$2,
  34671. printTypeAnnotation: printTypeAnnotation$5,
  34672. printRestSpread: printRestSpread$2,
  34673. adjustClause: adjustClause$1
  34674. };
  34675. const {
  34676. printDanglingComments: printDanglingComments$c
  34677. } = comments$1;
  34678. const {
  34679. builders: {
  34680. line: line$s,
  34681. softline: softline$o,
  34682. hardline: hardline$v,
  34683. group: group$x,
  34684. indent: indent$q,
  34685. ifBreak: ifBreak$k,
  34686. fill: fill$7
  34687. }
  34688. } = doc;
  34689. const {
  34690. getLast: getLast$9,
  34691. hasNewline: hasNewline$5
  34692. } = util$5;
  34693. const {
  34694. shouldPrintComma: shouldPrintComma$a,
  34695. hasComment: hasComment$d,
  34696. CommentCheckFlags: CommentCheckFlags$b,
  34697. isNextLineEmpty: isNextLineEmpty$b,
  34698. isNumericLiteral: isNumericLiteral$4,
  34699. isSignedNumericLiteral: isSignedNumericLiteral$1
  34700. } = utils$5;
  34701. const {
  34702. locStart: locStart$o
  34703. } = loc$6;
  34704. const {
  34705. printOptionalToken: printOptionalToken$8,
  34706. printTypeAnnotation: printTypeAnnotation$4
  34707. } = misc$1;
  34708. /** @typedef {import("../../document").Doc} Doc */
  34709. function printArray$1(path, options, print) {
  34710. const node = path.getValue();
  34711. /** @type{Doc[]} */
  34712. const parts = [];
  34713. const openBracket = node.type === "TupleExpression" ? "#[" : "[";
  34714. const closeBracket = "]";
  34715. if (node.elements.length === 0) {
  34716. if (!hasComment$d(node, CommentCheckFlags$b.Dangling)) {
  34717. parts.push(openBracket, closeBracket);
  34718. } else {
  34719. parts.push(group$x([openBracket, printDanglingComments$c(path, options), softline$o, closeBracket]));
  34720. }
  34721. } else {
  34722. const lastElem = getLast$9(node.elements);
  34723. const canHaveTrailingComma = !(lastElem && lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  34724. // changes its length based on the number of commas. The algorithm
  34725. // is that if the last argument is null, we need to force insert
  34726. // a comma to ensure JavaScript recognizes it.
  34727. // [,].length === 1
  34728. // [1,].length === 1
  34729. // [1,,].length === 2
  34730. //
  34731. // Note that getLast returns null if the array is empty, but
  34732. // we already check for an empty array just above so we are safe
  34733. const needsForcedTrailingComma = lastElem === null;
  34734. const groupId = Symbol("array");
  34735. const shouldBreak = !options.__inJestEach && node.elements.length > 1 && node.elements.every((element, i, elements) => {
  34736. const elementType = element && element.type;
  34737. if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") {
  34738. return false;
  34739. }
  34740. const nextElement = elements[i + 1];
  34741. if (nextElement && elementType !== nextElement.type) {
  34742. return false;
  34743. }
  34744. const itemsKey = elementType === "ArrayExpression" ? "elements" : "properties";
  34745. return element[itemsKey] && element[itemsKey].length > 1;
  34746. });
  34747. const shouldUseConciseFormatting = isConciselyPrintedArray$1(node, options);
  34748. const trailingComma = !canHaveTrailingComma ? "" : needsForcedTrailingComma ? "," : !shouldPrintComma$a(options) ? "" : shouldUseConciseFormatting ? ifBreak$k(",", "", {
  34749. groupId
  34750. }) : ifBreak$k(",");
  34751. parts.push(group$x([openBracket, indent$q([softline$o, shouldUseConciseFormatting ? printArrayItemsConcisely(path, options, print, trailingComma) : [printArrayItems$3(path, options, "elements", print), trailingComma], printDanglingComments$c(path, options,
  34752. /* sameIndent */
  34753. true)]), softline$o, closeBracket], {
  34754. shouldBreak,
  34755. id: groupId
  34756. }));
  34757. }
  34758. parts.push(printOptionalToken$8(path), printTypeAnnotation$4(path, options, print));
  34759. return parts;
  34760. }
  34761. function isConciselyPrintedArray$1(node, options) {
  34762. return node.elements.length > 1 && node.elements.every(element => element && (isNumericLiteral$4(element) || isSignedNumericLiteral$1(element) && !hasComment$d(element.argument)) && !hasComment$d(element, CommentCheckFlags$b.Trailing | CommentCheckFlags$b.Line, comment => !hasNewline$5(options.originalText, locStart$o(comment), {
  34763. backwards: true
  34764. })));
  34765. }
  34766. function printArrayItems$3(path, options, printPath, print) {
  34767. const printedElements = [];
  34768. let separatorParts = [];
  34769. path.each(childPath => {
  34770. printedElements.push(separatorParts, group$x(print()));
  34771. separatorParts = [",", line$s];
  34772. if (childPath.getValue() && isNextLineEmpty$b(childPath.getValue(), options)) {
  34773. separatorParts.push(softline$o);
  34774. }
  34775. }, printPath);
  34776. return printedElements;
  34777. }
  34778. function printArrayItemsConcisely(path, options, print, trailingComma) {
  34779. const parts = [];
  34780. path.each((childPath, i, elements) => {
  34781. const isLast = i === elements.length - 1;
  34782. parts.push([print(), isLast ? trailingComma : ","]);
  34783. if (!isLast) {
  34784. parts.push(isNextLineEmpty$b(childPath.getValue(), options) ? [hardline$v, hardline$v] : hasComment$d(elements[i + 1], CommentCheckFlags$b.Leading | CommentCheckFlags$b.Line) ? hardline$v : line$s);
  34785. }
  34786. }, "elements");
  34787. return fill$7(parts);
  34788. }
  34789. var array = {
  34790. printArray: printArray$1,
  34791. printArrayItems: printArrayItems$3,
  34792. isConciselyPrintedArray: isConciselyPrintedArray$1
  34793. };
  34794. const {
  34795. printDanglingComments: printDanglingComments$b
  34796. } = comments$1;
  34797. const {
  34798. getLast: getLast$8,
  34799. getPenultimate
  34800. } = util$5;
  34801. const {
  34802. getFunctionParameters: getFunctionParameters$3,
  34803. hasComment: hasComment$c,
  34804. CommentCheckFlags: CommentCheckFlags$a,
  34805. isFunctionCompositionArgs,
  34806. isJsxNode: isJsxNode$3,
  34807. isLongCurriedCallExpression: isLongCurriedCallExpression$1,
  34808. shouldPrintComma: shouldPrintComma$9,
  34809. getCallArguments: getCallArguments$3,
  34810. iterateCallArgumentsPath: iterateCallArgumentsPath$1,
  34811. isNextLineEmpty: isNextLineEmpty$a,
  34812. isCallExpression: isCallExpression$8,
  34813. isStringLiteral: isStringLiteral$3,
  34814. isObjectProperty: isObjectProperty$1
  34815. } = utils$5;
  34816. const {
  34817. builders: {
  34818. line: line$r,
  34819. hardline: hardline$u,
  34820. softline: softline$n,
  34821. group: group$w,
  34822. indent: indent$p,
  34823. conditionalGroup: conditionalGroup$3,
  34824. ifBreak: ifBreak$j,
  34825. breakParent: breakParent$9
  34826. },
  34827. utils: {
  34828. willBreak: willBreak$4
  34829. }
  34830. } = doc;
  34831. const {
  34832. ArgExpansionBailout: ArgExpansionBailout$2
  34833. } = errors;
  34834. const {
  34835. isConciselyPrintedArray
  34836. } = array;
  34837. function printCallArguments(path, options, print) {
  34838. const node = path.getValue();
  34839. const isDynamicImport = node.type === "ImportExpression";
  34840. const args = getCallArguments$3(node);
  34841. if (args.length === 0) {
  34842. return ["(", printDanglingComments$b(path, options,
  34843. /* sameIndent */
  34844. true), ")"];
  34845. } // useEffect(() => { ... }, [foo, bar, baz])
  34846. if (isReactHookCallWithDepsArray(args)) {
  34847. return ["(", print(["arguments", 0]), ", ", print(["arguments", 1]), ")"];
  34848. }
  34849. let anyArgEmptyLine = false;
  34850. let hasEmptyLineFollowingFirstArg = false;
  34851. const lastArgIndex = args.length - 1;
  34852. const printedArguments = [];
  34853. iterateCallArgumentsPath$1(path, (argPath, index) => {
  34854. const arg = argPath.getNode();
  34855. const parts = [print()];
  34856. if (index === lastArgIndex) ; else if (isNextLineEmpty$a(arg, options)) {
  34857. if (index === 0) {
  34858. hasEmptyLineFollowingFirstArg = true;
  34859. }
  34860. anyArgEmptyLine = true;
  34861. parts.push(",", hardline$u, hardline$u);
  34862. } else {
  34863. parts.push(",", line$r);
  34864. }
  34865. printedArguments.push(parts);
  34866. });
  34867. const maybeTrailingComma = // Dynamic imports cannot have trailing commas
  34868. !(isDynamicImport || node.callee && node.callee.type === "Import") && shouldPrintComma$9(options, "all") ? "," : "";
  34869. function allArgsBrokenOut() {
  34870. return group$w(["(", indent$p([line$r, ...printedArguments]), maybeTrailingComma, line$r, ")"], {
  34871. shouldBreak: true
  34872. });
  34873. }
  34874. if (anyArgEmptyLine || path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs(args)) {
  34875. return allArgsBrokenOut();
  34876. }
  34877. const shouldGroupFirst = shouldGroupFirstArg(args);
  34878. const shouldGroupLast = shouldGroupLastArg(args, options);
  34879. if (shouldGroupFirst || shouldGroupLast) {
  34880. if (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$4) : printedArguments.slice(0, -1).some(willBreak$4)) {
  34881. return allArgsBrokenOut();
  34882. } // We want to print the last argument with a special flag
  34883. let printedExpanded = [];
  34884. try {
  34885. path.try(() => {
  34886. iterateCallArgumentsPath$1(path, (argPath, i) => {
  34887. if (shouldGroupFirst && i === 0) {
  34888. printedExpanded = [[print([], {
  34889. expandFirstArg: true
  34890. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$u : line$r, hasEmptyLineFollowingFirstArg ? hardline$u : ""], ...printedArguments.slice(1)];
  34891. }
  34892. if (shouldGroupLast && i === lastArgIndex) {
  34893. printedExpanded = [...printedArguments.slice(0, -1), print([], {
  34894. expandLastArg: true
  34895. })];
  34896. }
  34897. });
  34898. });
  34899. } catch (caught) {
  34900. if (caught instanceof ArgExpansionBailout$2) {
  34901. return allArgsBrokenOut();
  34902. }
  34903. /* istanbul ignore next */
  34904. throw caught;
  34905. }
  34906. return [printedArguments.some(willBreak$4) ? breakParent$9 : "", conditionalGroup$3([["(", ...printedExpanded, ")"], shouldGroupFirst ? ["(", group$w(printedExpanded[0], {
  34907. shouldBreak: true
  34908. }), ...printedExpanded.slice(1), ")"] : ["(", ...printedArguments.slice(0, -1), group$w(getLast$8(printedExpanded), {
  34909. shouldBreak: true
  34910. }), ")"], allArgsBrokenOut()])];
  34911. }
  34912. const contents = ["(", indent$p([softline$n, ...printedArguments]), ifBreak$j(maybeTrailingComma), softline$n, ")"];
  34913. if (isLongCurriedCallExpression$1(path)) {
  34914. // By not wrapping the arguments in a group, the printer prioritizes
  34915. // breaking up these arguments rather than the args of the parent call.
  34916. return contents;
  34917. }
  34918. return group$w(contents, {
  34919. shouldBreak: printedArguments.some(willBreak$4) || anyArgEmptyLine
  34920. });
  34921. }
  34922. function couldGroupArg(arg, arrowChainRecursion = false) {
  34923. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || hasComment$c(arg)) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || hasComment$c(arg)) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && (!arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference" || // https://github.com/prettier/prettier/issues/7542
  34924. isNonEmptyBlockStatement(arg.body)) && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" && couldGroupArg(arg.body, true) || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || !arrowChainRecursion && (isCallExpression$8(arg.body) || arg.body.type === "ConditionalExpression") || isJsxNode$3(arg.body)) || arg.type === "DoExpression" || arg.type === "ModuleExpression";
  34925. }
  34926. function shouldGroupLastArg(args, options) {
  34927. const lastArg = getLast$8(args);
  34928. const penultimateArg = getPenultimate(args);
  34929. return !hasComment$c(lastArg, CommentCheckFlags$a.Leading) && !hasComment$c(lastArg, CommentCheckFlags$a.Trailing) && couldGroupArg(lastArg) && (!penultimateArg || penultimateArg.type !== lastArg.type) && (args.length !== 2 || penultimateArg.type !== "ArrowFunctionExpression" || lastArg.type !== "ArrayExpression") && !(args.length > 1 && lastArg.type === "ArrayExpression" && isConciselyPrintedArray(lastArg, options));
  34930. }
  34931. function shouldGroupFirstArg(args) {
  34932. if (args.length !== 2) {
  34933. return false;
  34934. }
  34935. const [firstArg, secondArg] = args;
  34936. if (firstArg.type === "ModuleExpression" && isTypeModuleObjectExpression(secondArg)) {
  34937. return true;
  34938. }
  34939. return !hasComment$c(firstArg) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
  34940. }
  34941. function isReactHookCallWithDepsArray(args) {
  34942. return args.length === 2 && args[0].type === "ArrowFunctionExpression" && getFunctionParameters$3(args[0]).length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.some(arg => hasComment$c(arg));
  34943. }
  34944. function isNonEmptyBlockStatement(node) {
  34945. return node.type === "BlockStatement" && (node.body.some(node => node.type !== "EmptyStatement") || hasComment$c(node, CommentCheckFlags$a.Dangling));
  34946. } // { type: "module" }
  34947. function isTypeModuleObjectExpression(node) {
  34948. return node.type === "ObjectExpression" && node.properties.length === 1 && isObjectProperty$1(node.properties[0]) && node.properties[0].key.type === "Identifier" && node.properties[0].key.name === "type" && isStringLiteral$3(node.properties[0].value) && node.properties[0].value.value === "module";
  34949. }
  34950. var callArguments = printCallArguments;
  34951. const {
  34952. builders: {
  34953. softline: softline$m,
  34954. group: group$v,
  34955. indent: indent$o,
  34956. label: label$2
  34957. }
  34958. } = doc;
  34959. const {
  34960. isNumericLiteral: isNumericLiteral$3,
  34961. isMemberExpression: isMemberExpression$5,
  34962. isCallExpression: isCallExpression$7
  34963. } = utils$5;
  34964. const {
  34965. printOptionalToken: printOptionalToken$7
  34966. } = misc$1;
  34967. function printMemberExpression$1(path, options, print) {
  34968. const node = path.getValue();
  34969. const parent = path.getParentNode();
  34970. let firstNonMemberParent;
  34971. let i = 0;
  34972. do {
  34973. firstNonMemberParent = path.getParentNode(i);
  34974. i++;
  34975. } while (firstNonMemberParent && (isMemberExpression$5(firstNonMemberParent) || firstNonMemberParent.type === "TSNonNullExpression"));
  34976. const objectDoc = print("object");
  34977. const lookupDoc = printMemberLookup$1(path, options, print);
  34978. const shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || node.computed || node.object.type === "Identifier" && node.property.type === "Identifier" && !isMemberExpression$5(parent) || (parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator") && (isCallExpression$7(node.object) && node.object.arguments.length > 0 || node.object.type === "TSNonNullExpression" && isCallExpression$7(node.object.expression) && node.object.expression.arguments.length > 0 || objectDoc.label === "member-chain");
  34979. return label$2(objectDoc.label === "member-chain" ? "member-chain" : "member", [objectDoc, shouldInline ? lookupDoc : group$v(indent$o([softline$m, lookupDoc]))]);
  34980. }
  34981. function printMemberLookup$1(path, options, print) {
  34982. const property = print("property");
  34983. const node = path.getValue();
  34984. const optional = printOptionalToken$7(path);
  34985. if (!node.computed) {
  34986. return [optional, ".", property];
  34987. }
  34988. if (!node.property || isNumericLiteral$3(node.property)) {
  34989. return [optional, "[", property, "]"];
  34990. }
  34991. return group$v([optional, "[", indent$o([softline$m, property]), softline$m, "]"]);
  34992. }
  34993. var member = {
  34994. printMemberExpression: printMemberExpression$1,
  34995. printMemberLookup: printMemberLookup$1
  34996. };
  34997. const {
  34998. printComments: printComments$3
  34999. } = comments$1;
  35000. const {
  35001. getLast: getLast$7,
  35002. isNextLineEmptyAfterIndex,
  35003. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1
  35004. } = util$5;
  35005. const {
  35006. isCallExpression: isCallExpression$6,
  35007. isMemberExpression: isMemberExpression$4,
  35008. isFunctionOrArrowExpression,
  35009. isLongCurriedCallExpression,
  35010. isMemberish: isMemberish$1,
  35011. isNumericLiteral: isNumericLiteral$2,
  35012. isSimpleCallArgument,
  35013. hasComment: hasComment$b,
  35014. CommentCheckFlags: CommentCheckFlags$9,
  35015. isNextLineEmpty: isNextLineEmpty$9
  35016. } = utils$5;
  35017. const {
  35018. locEnd: locEnd$n
  35019. } = loc$6;
  35020. const {
  35021. builders: {
  35022. join: join$n,
  35023. hardline: hardline$t,
  35024. group: group$u,
  35025. indent: indent$n,
  35026. conditionalGroup: conditionalGroup$2,
  35027. breakParent: breakParent$8,
  35028. label: label$1
  35029. },
  35030. utils: {
  35031. willBreak: willBreak$3
  35032. }
  35033. } = doc;
  35034. const {
  35035. printMemberLookup
  35036. } = member;
  35037. const {
  35038. printOptionalToken: printOptionalToken$6,
  35039. printFunctionTypeParameters: printFunctionTypeParameters$3,
  35040. printBindExpressionCallee: printBindExpressionCallee$1
  35041. } = misc$1; // We detect calls on member expressions specially to format a
  35042. // common pattern better. The pattern we are looking for is this:
  35043. //
  35044. // arr
  35045. // .map(x => x + 1)
  35046. // .filter(x => x > 10)
  35047. // .some(x => x % 2)
  35048. //
  35049. // The way it is structured in the AST is via a nested sequence of
  35050. // MemberExpression and CallExpression. We need to traverse the AST
  35051. // and make groups out of it to print it in the desired way.
  35052. function printMemberChain(path, options, print) {
  35053. const parent = path.getParentNode();
  35054. const isExpressionStatement = !parent || parent.type === "ExpressionStatement"; // The first phase is to linearize the AST by traversing it down.
  35055. //
  35056. // a().b()
  35057. // has the following AST structure:
  35058. // CallExpression(MemberExpression(CallExpression(Identifier)))
  35059. // and we transform it into
  35060. // [Identifier, CallExpression, MemberExpression, CallExpression]
  35061. const printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  35062. // the first group whether it is in parentheses or not
  35063. function shouldInsertEmptyLineAfter(node) {
  35064. const {
  35065. originalText
  35066. } = options;
  35067. const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$1(originalText, node, locEnd$n);
  35068. const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  35069. // line after that parenthesis
  35070. if (nextChar === ")") {
  35071. return nextCharIndex !== false && isNextLineEmptyAfterIndex(originalText, nextCharIndex + 1);
  35072. }
  35073. return isNextLineEmpty$9(node, options);
  35074. }
  35075. function rec(path) {
  35076. const node = path.getValue();
  35077. if (isCallExpression$6(node) && (isMemberish$1(node.callee) || isCallExpression$6(node.callee))) {
  35078. printedNodes.unshift({
  35079. node,
  35080. printed: [printComments$3(path, [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), callArguments(path, options, print)], options), shouldInsertEmptyLineAfter(node) ? hardline$t : ""]
  35081. });
  35082. path.call(callee => rec(callee), "callee");
  35083. } else if (isMemberish$1(node)) {
  35084. printedNodes.unshift({
  35085. node,
  35086. needsParens: needsParens_1(path, options),
  35087. printed: printComments$3(path, isMemberExpression$4(node) ? printMemberLookup(path, options, print) : printBindExpressionCallee$1(path, options, print), options)
  35088. });
  35089. path.call(object => rec(object), "object");
  35090. } else if (node.type === "TSNonNullExpression") {
  35091. printedNodes.unshift({
  35092. node,
  35093. printed: printComments$3(path, "!", options)
  35094. });
  35095. path.call(expression => rec(expression), "expression");
  35096. } else {
  35097. printedNodes.unshift({
  35098. node,
  35099. printed: print()
  35100. });
  35101. }
  35102. } // Note: the comments of the root node have already been printed, so we
  35103. // need to extract this first call without printing them as they would
  35104. // if handled inside of the recursive call.
  35105. const node = path.getValue();
  35106. printedNodes.unshift({
  35107. node,
  35108. printed: [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), callArguments(path, options, print)]
  35109. });
  35110. if (node.callee) {
  35111. path.call(callee => rec(callee), "callee");
  35112. } // Once we have a linear list of printed nodes, we want to create groups out
  35113. // of it.
  35114. //
  35115. // a().b.c().d().e
  35116. // will be grouped as
  35117. // [
  35118. // [Identifier, CallExpression],
  35119. // [MemberExpression, MemberExpression, CallExpression],
  35120. // [MemberExpression, CallExpression],
  35121. // [MemberExpression],
  35122. // ]
  35123. // so that we can print it as
  35124. // a()
  35125. // .b.c()
  35126. // .d()
  35127. // .e
  35128. // The first group is the first node followed by
  35129. // - as many CallExpression as possible
  35130. // < fn()()() >.something()
  35131. // - as many array accessors as possible
  35132. // < fn()[0][1][2] >.something()
  35133. // - then, as many MemberExpression as possible but the last one
  35134. // < this.items >.something()
  35135. const groups = [];
  35136. let currentGroup = [printedNodes[0]];
  35137. let i = 1;
  35138. for (; i < printedNodes.length; ++i) {
  35139. if (printedNodes[i].node.type === "TSNonNullExpression" || isCallExpression$6(printedNodes[i].node) || isMemberExpression$4(printedNodes[i].node) && printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
  35140. currentGroup.push(printedNodes[i]);
  35141. } else {
  35142. break;
  35143. }
  35144. }
  35145. if (!isCallExpression$6(printedNodes[0].node)) {
  35146. for (; i + 1 < printedNodes.length; ++i) {
  35147. if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
  35148. currentGroup.push(printedNodes[i]);
  35149. } else {
  35150. break;
  35151. }
  35152. }
  35153. }
  35154. groups.push(currentGroup);
  35155. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  35156. // a sequence of CallExpression. To compute it, we keep adding things to the
  35157. // group until we has seen a CallExpression in the past and reach a
  35158. // MemberExpression
  35159. let hasSeenCallExpression = false;
  35160. for (; i < printedNodes.length; ++i) {
  35161. if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
  35162. // [0] should be appended at the end of the group instead of the
  35163. // beginning of the next one
  35164. if (printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
  35165. currentGroup.push(printedNodes[i]);
  35166. continue;
  35167. }
  35168. groups.push(currentGroup);
  35169. currentGroup = [];
  35170. hasSeenCallExpression = false;
  35171. }
  35172. if (isCallExpression$6(printedNodes[i].node) || printedNodes[i].node.type === "ImportExpression") {
  35173. hasSeenCallExpression = true;
  35174. }
  35175. currentGroup.push(printedNodes[i]);
  35176. if (hasComment$b(printedNodes[i].node, CommentCheckFlags$9.Trailing)) {
  35177. groups.push(currentGroup);
  35178. currentGroup = [];
  35179. hasSeenCallExpression = false;
  35180. }
  35181. }
  35182. if (currentGroup.length > 0) {
  35183. groups.push(currentGroup);
  35184. } // There are cases like Object.keys(), Observable.of(), _.values() where
  35185. // they are the subject of all the chained calls and therefore should
  35186. // be kept on the same line:
  35187. //
  35188. // Object.keys(items)
  35189. // .filter(x => x)
  35190. // .map(x => x)
  35191. //
  35192. // In order to detect those cases, we use an heuristic: if the first
  35193. // node is an identifier with the name starting with a capital
  35194. // letter or just a sequence of _$. The rationale is that they are
  35195. // likely to be factories.
  35196. function isFactory(name) {
  35197. return /^[A-Z]|^[$_]+$/.test(name);
  35198. } // In case the Identifier is shorter than tab width, we can keep the
  35199. // first call in a single line, if it's an ExpressionStatement.
  35200. //
  35201. // d3.scaleLinear()
  35202. // .domain([0, 100])
  35203. // .range([0, width]);
  35204. //
  35205. function isShort(name) {
  35206. return name.length <= options.tabWidth;
  35207. }
  35208. function shouldNotWrap(groups) {
  35209. const hasComputed = groups[1].length > 0 && groups[1][0].node.computed;
  35210. if (groups[0].length === 1) {
  35211. const firstNode = groups[0][0].node;
  35212. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpressionStatement && isShort(firstNode.name) || hasComputed);
  35213. }
  35214. const lastNode = getLast$7(groups[0]).node;
  35215. return isMemberExpression$4(lastNode) && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  35216. }
  35217. const shouldMerge = groups.length >= 2 && !hasComment$b(groups[1][0].node) && shouldNotWrap(groups);
  35218. function printGroup(printedGroup) {
  35219. const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
  35220. // accordingly
  35221. if (printedGroup.length > 0 && getLast$7(printedGroup).needsParens) {
  35222. return ["(", ...printed, ")"];
  35223. }
  35224. return printed;
  35225. }
  35226. function printIndentedGroup(groups) {
  35227. /* istanbul ignore next */
  35228. if (groups.length === 0) {
  35229. return "";
  35230. }
  35231. return indent$n(group$u([hardline$t, join$n(hardline$t, groups.map(printGroup))]));
  35232. }
  35233. const printedGroups = groups.map(printGroup);
  35234. const oneLine = printedGroups;
  35235. const cutoff = shouldMerge ? 3 : 2;
  35236. const flatGroups = groups.flat();
  35237. const nodeHasComment = flatGroups.slice(1, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Leading)) || flatGroups.slice(0, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Trailing)) || groups[cutoff] && hasComment$b(groups[cutoff][0].node, CommentCheckFlags$9.Leading); // If we only have a single `.`, we shouldn't do anything fancy and just
  35238. // render everything concatenated together.
  35239. if (groups.length <= cutoff && !nodeHasComment) {
  35240. if (isLongCurriedCallExpression(path)) {
  35241. return oneLine;
  35242. }
  35243. return group$u(oneLine);
  35244. } // Find out the last node in the first group and check if it has an
  35245. // empty line after
  35246. const lastNodeBeforeIndent = getLast$7(groups[shouldMerge ? 1 : 0]).node;
  35247. const shouldHaveEmptyLineBeforeIndent = !isCallExpression$6(lastNodeBeforeIndent) && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  35248. const expanded = [printGroup(groups[0]), shouldMerge ? groups.slice(1, 2).map(printGroup) : "", shouldHaveEmptyLineBeforeIndent ? hardline$t : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))];
  35249. const callExpressions = printedNodes.map(({
  35250. node
  35251. }) => node).filter(isCallExpression$6);
  35252. function lastGroupWillBreakAndOtherCallsHaveFunctionArguments() {
  35253. const lastGroupNode = getLast$7(getLast$7(groups)).node;
  35254. const lastGroupDoc = getLast$7(printedGroups);
  35255. return isCallExpression$6(lastGroupNode) && willBreak$3(lastGroupDoc) && callExpressions.slice(0, -1).some(node => node.arguments.some(isFunctionOrArrowExpression));
  35256. }
  35257. let result; // We don't want to print in one line if at least one of these conditions occurs:
  35258. // * the chain has comments,
  35259. // * the chain is an expression statement and all the arguments are literal-like ("fluent configuration" pattern),
  35260. // * the chain is longer than 2 calls and has non-trivial arguments or more than 2 arguments in any call but the first one,
  35261. // * any group but the last one has a hard line,
  35262. // * the last call's arguments have a hard line and other calls have non-trivial arguments.
  35263. if (nodeHasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$3) || lastGroupWillBreakAndOtherCallsHaveFunctionArguments()) {
  35264. result = group$u(expanded);
  35265. } else {
  35266. result = [// We only need to check `oneLine` because if `expanded` is chosen
  35267. // that means that the parent group has already been broken
  35268. // naturally
  35269. willBreak$3(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$8 : "", conditionalGroup$2([oneLine, expanded])];
  35270. }
  35271. return label$1("member-chain", result);
  35272. }
  35273. var memberChain = printMemberChain;
  35274. const {
  35275. builders: {
  35276. join: join$m,
  35277. group: group$t
  35278. }
  35279. } = doc;
  35280. const {
  35281. getCallArguments: getCallArguments$2,
  35282. hasFlowAnnotationComment,
  35283. isCallExpression: isCallExpression$5,
  35284. isMemberish,
  35285. isStringLiteral: isStringLiteral$2,
  35286. isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$1,
  35287. isTestCall: isTestCall$2,
  35288. iterateCallArgumentsPath
  35289. } = utils$5;
  35290. const {
  35291. printOptionalToken: printOptionalToken$5,
  35292. printFunctionTypeParameters: printFunctionTypeParameters$2
  35293. } = misc$1;
  35294. function printCallExpression$2(path, options, print) {
  35295. const node = path.getValue();
  35296. const parentNode = path.getParentNode();
  35297. const isNew = node.type === "NewExpression";
  35298. const isDynamicImport = node.type === "ImportExpression";
  35299. const optional = printOptionalToken$5(path);
  35300. const args = getCallArguments$2(node);
  35301. if ( // Dangling comments are not handled, all these special cases should have arguments #9668
  35302. args.length > 0 && (!isDynamicImport && !isNew && isCommonsJsOrAmdCall(node, parentNode) || args.length === 1 && isTemplateOnItsOwnLine$1(args[0], options.originalText) || !isNew && isTestCall$2(node, parentNode))) {
  35303. const printed = [];
  35304. iterateCallArgumentsPath(path, () => {
  35305. printed.push(print());
  35306. });
  35307. return [isNew ? "new " : "", print("callee"), optional, printFunctionTypeParameters$2(path, options, print), "(", join$m(", ", printed), ")"];
  35308. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  35309. // stay with the Identifier. For example:
  35310. //
  35311. // foo /*:: <SomeGeneric> */(bar);
  35312. //
  35313. // Here, we ensure that such comments stay between the Identifier and the Callee.
  35314. const isIdentifierWithFlowAnnotation = (options.parser === "babel" || options.parser === "babel-flow") && node.callee && node.callee.type === "Identifier" && hasFlowAnnotationComment(node.callee.trailingComments);
  35315. if (isIdentifierWithFlowAnnotation) {
  35316. node.callee.trailingComments[0].printed = true;
  35317. } // We detect calls on member lookups and possibly print them in a
  35318. // special chain format. See `printMemberChain` for more info.
  35319. if (!isDynamicImport && !isNew && isMemberish(node.callee) && !path.call(path => needsParens_1(path, options), "callee")) {
  35320. return memberChain(path, options, print);
  35321. }
  35322. const contents = [isNew ? "new " : "", isDynamicImport ? "import" : print("callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${node.callee.trailingComments[0].value.slice(2).trim()} */` : "", printFunctionTypeParameters$2(path, options, print), callArguments(path, options, print)]; // We group here when the callee is itself a call expression.
  35323. // See `isLongCurriedCallExpression` for more info.
  35324. if (isDynamicImport || isCallExpression$5(node.callee)) {
  35325. return group$t(contents);
  35326. }
  35327. return contents;
  35328. }
  35329. function isCommonsJsOrAmdCall(node, parentNode) {
  35330. if (node.callee.type !== "Identifier") {
  35331. return false;
  35332. }
  35333. if (node.callee.name === "require") {
  35334. return true;
  35335. }
  35336. if (node.callee.name === "define") {
  35337. const args = getCallArguments$2(node);
  35338. return parentNode.type === "ExpressionStatement" && (args.length === 1 || args.length === 2 && args[0].type === "ArrayExpression" || args.length === 3 && isStringLiteral$2(args[0]) && args[1].type === "ArrayExpression");
  35339. }
  35340. return false;
  35341. }
  35342. var callExpression = {
  35343. printCallExpression: printCallExpression$2
  35344. };
  35345. const {
  35346. isNonEmptyArray: isNonEmptyArray$d,
  35347. getStringWidth: getStringWidth$1
  35348. } = util$5;
  35349. const {
  35350. builders: {
  35351. line: line$q,
  35352. group: group$s,
  35353. indent: indent$m,
  35354. indentIfBreak: indentIfBreak$2
  35355. },
  35356. utils: {
  35357. cleanDoc: cleanDoc$1,
  35358. willBreak: willBreak$2
  35359. }
  35360. } = doc;
  35361. const {
  35362. hasLeadingOwnLineComment: hasLeadingOwnLineComment$2,
  35363. isBinaryish: isBinaryish$1,
  35364. isStringLiteral: isStringLiteral$1,
  35365. isLiteral: isLiteral$1,
  35366. isNumericLiteral: isNumericLiteral$1,
  35367. isCallExpression: isCallExpression$4,
  35368. isMemberExpression: isMemberExpression$3,
  35369. getCallArguments: getCallArguments$1,
  35370. rawText: rawText$3,
  35371. hasComment: hasComment$a,
  35372. isSignedNumericLiteral,
  35373. isObjectProperty
  35374. } = utils$5;
  35375. const {
  35376. shouldInlineLogicalExpression
  35377. } = binaryish;
  35378. const {
  35379. printCallExpression: printCallExpression$1
  35380. } = callExpression;
  35381. function printAssignment$3(path, options, print, leftDoc, operator, rightPropertyName) {
  35382. const layout = chooseLayout(path, options, print, leftDoc, rightPropertyName);
  35383. const rightDoc = print(rightPropertyName, {
  35384. assignmentLayout: layout
  35385. });
  35386. switch (layout) {
  35387. // First break after operator, then the sides are broken independently on their own lines
  35388. case "break-after-operator":
  35389. return group$s([group$s(leftDoc), operator, group$s(indent$m([line$q, rightDoc]))]);
  35390. // First break right-hand side, then left-hand side
  35391. case "never-break-after-operator":
  35392. return group$s([group$s(leftDoc), operator, " ", rightDoc]);
  35393. // First break right-hand side, then after operator
  35394. case "fluid":
  35395. {
  35396. const groupId = Symbol("assignment");
  35397. return group$s([group$s(leftDoc), operator, group$s(indent$m(line$q), {
  35398. id: groupId
  35399. }), indentIfBreak$2(rightDoc, {
  35400. groupId
  35401. })]);
  35402. }
  35403. case "break-lhs":
  35404. return group$s([leftDoc, operator, " ", group$s(rightDoc)]);
  35405. // Parts of assignment chains aren't wrapped in groups.
  35406. // Once one of them breaks, the chain breaks too.
  35407. case "chain":
  35408. return [group$s(leftDoc), operator, line$q, rightDoc];
  35409. case "chain-tail":
  35410. return [group$s(leftDoc), operator, indent$m([line$q, rightDoc])];
  35411. case "chain-tail-arrow-chain":
  35412. return [group$s(leftDoc), operator, rightDoc];
  35413. case "only-left":
  35414. return leftDoc;
  35415. }
  35416. }
  35417. function printAssignmentExpression$1(path, options, print) {
  35418. const node = path.getValue();
  35419. return printAssignment$3(path, options, print, print("left"), [" ", node.operator], "right");
  35420. }
  35421. function printVariableDeclarator$1(path, options, print) {
  35422. return printAssignment$3(path, options, print, print("id"), " =", "init");
  35423. }
  35424. function chooseLayout(path, options, print, leftDoc, rightPropertyName) {
  35425. const node = path.getValue();
  35426. const rightNode = node[rightPropertyName];
  35427. if (!rightNode) {
  35428. return "only-left";
  35429. } // Short assignment chains (only 2 segments) are NOT formatted as chains.
  35430. // 1) a = b = c; (expression statements)
  35431. // 2) var/let/const a = b = c;
  35432. const isTail = !isAssignment(rightNode);
  35433. const shouldUseChainFormatting = path.match(isAssignment, isAssignmentOrVariableDeclarator, node => !isTail || node.type !== "ExpressionStatement" && node.type !== "VariableDeclaration");
  35434. if (shouldUseChainFormatting) {
  35435. return !isTail ? "chain" : rightNode.type === "ArrowFunctionExpression" && rightNode.body.type === "ArrowFunctionExpression" ? "chain-tail-arrow-chain" : "chain-tail";
  35436. }
  35437. const isHeadOfLongChain = !isTail && isAssignment(rightNode.right);
  35438. if (isHeadOfLongChain || hasLeadingOwnLineComment$2(options.originalText, rightNode)) {
  35439. return "break-after-operator";
  35440. }
  35441. if (rightNode.type === "CallExpression" && rightNode.callee.name === "require" || // do not put values on a separate line from the key in json
  35442. options.parser === "json5" || options.parser === "json") {
  35443. return "never-break-after-operator";
  35444. }
  35445. if (isComplexDestructuring(node) || isComplexTypeAliasParams(node) || hasComplexTypeAnnotation(node)) {
  35446. return "break-lhs";
  35447. } // wrapping object properties with very short keys usually doesn't add much value
  35448. const hasShortKey = isObjectPropertyWithShortKey(node, leftDoc, options);
  35449. if (path.call(() => shouldBreakAfterOperator(path, options, print, hasShortKey), rightPropertyName)) {
  35450. return "break-after-operator";
  35451. }
  35452. if (hasShortKey || rightNode.type === "TemplateLiteral" || rightNode.type === "TaggedTemplateExpression" || rightNode.type === "BooleanLiteral" || isNumericLiteral$1(rightNode) || rightNode.type === "ClassExpression") {
  35453. return "never-break-after-operator";
  35454. }
  35455. return "fluid";
  35456. }
  35457. function shouldBreakAfterOperator(path, options, print, hasShortKey) {
  35458. const rightNode = path.getValue();
  35459. if (isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode)) {
  35460. return true;
  35461. }
  35462. switch (rightNode.type) {
  35463. case "StringLiteralTypeAnnotation":
  35464. case "SequenceExpression":
  35465. return true;
  35466. case "ConditionalExpression":
  35467. {
  35468. const {
  35469. test
  35470. } = rightNode;
  35471. return isBinaryish$1(test) && !shouldInlineLogicalExpression(test);
  35472. }
  35473. case "ClassExpression":
  35474. return isNonEmptyArray$d(rightNode.decorators);
  35475. }
  35476. if (hasShortKey) {
  35477. return false;
  35478. }
  35479. let node = rightNode;
  35480. const propertiesForPath = [];
  35481. for (;;) {
  35482. if (node.type === "UnaryExpression") {
  35483. node = node.argument;
  35484. propertiesForPath.push("argument");
  35485. } else if (node.type === "TSNonNullExpression") {
  35486. node = node.expression;
  35487. propertiesForPath.push("expression");
  35488. } else {
  35489. break;
  35490. }
  35491. }
  35492. if (isStringLiteral$1(node) || path.call(() => isPoorlyBreakableMemberOrCallChain(path, options, print), ...propertiesForPath)) {
  35493. return true;
  35494. }
  35495. return false;
  35496. } // prefer to break destructuring assignment
  35497. // if it includes default values or non-shorthand properties
  35498. function isComplexDestructuring(node) {
  35499. if (isAssignmentOrVariableDeclarator(node)) {
  35500. const leftNode = node.left || node.id;
  35501. return leftNode.type === "ObjectPattern" && leftNode.properties.length > 2 && leftNode.properties.some(property => isObjectProperty(property) && (!property.shorthand || property.value && property.value.type === "AssignmentPattern"));
  35502. }
  35503. return false;
  35504. }
  35505. function isAssignment(node) {
  35506. return node.type === "AssignmentExpression";
  35507. }
  35508. function isAssignmentOrVariableDeclarator(node) {
  35509. return isAssignment(node) || node.type === "VariableDeclarator";
  35510. }
  35511. function isComplexTypeAliasParams(node) {
  35512. const typeParams = getTypeParametersFromTypeAlias(node);
  35513. if (isNonEmptyArray$d(typeParams)) {
  35514. const constraintPropertyName = node.type === "TSTypeAliasDeclaration" ? "constraint" : "bound";
  35515. if (typeParams.length > 1 && typeParams.some(param => param[constraintPropertyName] || param.default)) {
  35516. return true;
  35517. }
  35518. }
  35519. return false;
  35520. }
  35521. function getTypeParametersFromTypeAlias(node) {
  35522. if (isTypeAlias(node) && node.typeParameters && node.typeParameters.params) {
  35523. return node.typeParameters.params;
  35524. }
  35525. return null;
  35526. }
  35527. function isTypeAlias(node) {
  35528. return node.type === "TSTypeAliasDeclaration" || node.type === "TypeAlias";
  35529. }
  35530. function hasComplexTypeAnnotation(node) {
  35531. if (node.type !== "VariableDeclarator") {
  35532. return false;
  35533. }
  35534. const {
  35535. typeAnnotation
  35536. } = node.id;
  35537. if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
  35538. return false;
  35539. }
  35540. const typeParams = getTypeParametersFromTypeReference(typeAnnotation.typeAnnotation);
  35541. return isNonEmptyArray$d(typeParams) && typeParams.length > 1 && typeParams.some(param => isNonEmptyArray$d(getTypeParametersFromTypeReference(param)) || param.type === "TSConditionalType");
  35542. }
  35543. function getTypeParametersFromTypeReference(node) {
  35544. if (isTypeReference(node) && node.typeParameters && node.typeParameters.params) {
  35545. return node.typeParameters.params;
  35546. }
  35547. return null;
  35548. }
  35549. function isTypeReference(node) {
  35550. return node.type === "TSTypeReference" || node.type === "GenericTypeAnnotation";
  35551. }
  35552. /**
  35553. * A chain with no calls at all or whose calls are all without arguments or with lone short arguments,
  35554. * excluding chains printed by `printMemberChain`
  35555. */
  35556. function isPoorlyBreakableMemberOrCallChain(path, options, print, deep = false) {
  35557. const node = path.getValue();
  35558. const goDeeper = () => isPoorlyBreakableMemberOrCallChain(path, options, print, true);
  35559. if (node.type === "TSNonNullExpression") {
  35560. return path.call(goDeeper, "expression");
  35561. }
  35562. if (isCallExpression$4(node)) {
  35563. /** @type {any} TODO */
  35564. const doc = printCallExpression$1(path, options, print);
  35565. if (doc.label === "member-chain") {
  35566. return false;
  35567. }
  35568. const args = getCallArguments$1(node);
  35569. const isPoorlyBreakableCall = args.length === 0 || args.length === 1 && isLoneShortArgument(args[0], options);
  35570. if (!isPoorlyBreakableCall) {
  35571. return false;
  35572. }
  35573. if (isCallExpressionWithComplexTypeArguments(node, print)) {
  35574. return false;
  35575. }
  35576. return path.call(goDeeper, "callee");
  35577. }
  35578. if (isMemberExpression$3(node)) {
  35579. return path.call(goDeeper, "object");
  35580. }
  35581. return deep && (node.type === "Identifier" || node.type === "ThisExpression");
  35582. }
  35583. const LONE_SHORT_ARGUMENT_THRESHOLD_RATE = 0.25;
  35584. function isLoneShortArgument(node, {
  35585. printWidth
  35586. }) {
  35587. if (hasComment$a(node)) {
  35588. return false;
  35589. }
  35590. const threshold = printWidth * LONE_SHORT_ARGUMENT_THRESHOLD_RATE;
  35591. if (node.type === "ThisExpression" || node.type === "Identifier" && node.name.length <= threshold || isSignedNumericLiteral(node) && !hasComment$a(node.argument)) {
  35592. return true;
  35593. }
  35594. const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
  35595. if (regexpPattern) {
  35596. return regexpPattern.length <= threshold;
  35597. }
  35598. if (isStringLiteral$1(node)) {
  35599. return rawText$3(node).length <= threshold;
  35600. }
  35601. if (node.type === "TemplateLiteral") {
  35602. return node.expressions.length === 0 && node.quasis[0].value.raw.length <= threshold && !node.quasis[0].value.raw.includes("\n");
  35603. }
  35604. return isLiteral$1(node);
  35605. }
  35606. function isObjectPropertyWithShortKey(node, keyDoc, options) {
  35607. if (!isObjectProperty(node)) {
  35608. return false;
  35609. } // TODO: for performance, it might make sense to use a more lightweight
  35610. // version of cleanDoc, such that it would stop once it detects that
  35611. // the doc can't be reduced to a string.
  35612. keyDoc = cleanDoc$1(keyDoc);
  35613. const MIN_OVERLAP_FOR_BREAK = 3; // ↓↓ - insufficient overlap for a line break
  35614. // key1: longValue1,
  35615. // ↓↓↓↓↓↓ - overlap is long enough to break
  35616. // key2abcd:
  35617. // longValue2
  35618. return typeof keyDoc === "string" && getStringWidth$1(keyDoc) < options.tabWidth + MIN_OVERLAP_FOR_BREAK;
  35619. }
  35620. function isCallExpressionWithComplexTypeArguments(node, print) {
  35621. const typeArgs = getTypeArgumentsFromCallExpression(node);
  35622. if (isNonEmptyArray$d(typeArgs)) {
  35623. if (typeArgs.length > 1) {
  35624. return true;
  35625. }
  35626. if (typeArgs.length === 1) {
  35627. const firstArg = typeArgs[0];
  35628. if (firstArg.type === "TSUnionType" || firstArg.type === "UnionTypeAnnotation" || firstArg.type === "TSIntersectionType" || firstArg.type === "IntersectionTypeAnnotation") {
  35629. return true;
  35630. }
  35631. }
  35632. const typeArgsKeyName = node.typeParameters ? "typeParameters" : "typeArguments";
  35633. if (willBreak$2(print(typeArgsKeyName))) {
  35634. return true;
  35635. }
  35636. }
  35637. return false;
  35638. }
  35639. function getTypeArgumentsFromCallExpression(node) {
  35640. return node.typeParameters && node.typeParameters.params || node.typeArguments && node.typeArguments.params;
  35641. }
  35642. var assignment = {
  35643. printVariableDeclarator: printVariableDeclarator$1,
  35644. printAssignmentExpression: printAssignmentExpression$1,
  35645. printAssignment: printAssignment$3
  35646. };
  35647. const {
  35648. getNextNonSpaceNonCommentCharacter
  35649. } = util$5;
  35650. const {
  35651. printDanglingComments: printDanglingComments$a
  35652. } = comments$1;
  35653. const {
  35654. builders: {
  35655. line: line$p,
  35656. hardline: hardline$s,
  35657. softline: softline$l,
  35658. group: group$r,
  35659. indent: indent$l,
  35660. ifBreak: ifBreak$i
  35661. },
  35662. utils: {
  35663. removeLines: removeLines$2,
  35664. willBreak: willBreak$1
  35665. }
  35666. } = doc;
  35667. const {
  35668. getFunctionParameters: getFunctionParameters$2,
  35669. iterateFunctionParametersPath,
  35670. isSimpleType: isSimpleType$1,
  35671. isTestCall: isTestCall$1,
  35672. isTypeAnnotationAFunction,
  35673. isObjectType: isObjectType$1,
  35674. isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$1,
  35675. hasRestParameter,
  35676. shouldPrintComma: shouldPrintComma$8,
  35677. hasComment: hasComment$9,
  35678. isNextLineEmpty: isNextLineEmpty$8
  35679. } = utils$5;
  35680. const {
  35681. locEnd: locEnd$m
  35682. } = loc$6;
  35683. const {
  35684. ArgExpansionBailout: ArgExpansionBailout$1
  35685. } = errors;
  35686. const {
  35687. printFunctionTypeParameters: printFunctionTypeParameters$1
  35688. } = misc$1;
  35689. function printFunctionParameters$3(path, print, options, expandArg, printTypeParams) {
  35690. const functionNode = path.getValue();
  35691. const parameters = getFunctionParameters$2(functionNode);
  35692. const typeParams = printTypeParams ? printFunctionTypeParameters$1(path, options, print) : "";
  35693. if (parameters.length === 0) {
  35694. return [typeParams, "(", printDanglingComments$a(path, options,
  35695. /* sameIndent */
  35696. true, comment => getNextNonSpaceNonCommentCharacter(options.originalText, comment, locEnd$m) === ")"), ")"];
  35697. }
  35698. const parent = path.getParentNode();
  35699. const isParametersInTestCall = isTestCall$1(parent);
  35700. const shouldHugParameters = shouldHugFunctionParameters$1(functionNode);
  35701. const printed = [];
  35702. iterateFunctionParametersPath(path, (parameterPath, index) => {
  35703. const isLastParameter = index === parameters.length - 1;
  35704. if (isLastParameter && functionNode.rest) {
  35705. printed.push("...");
  35706. }
  35707. printed.push(print());
  35708. if (isLastParameter) {
  35709. return;
  35710. }
  35711. printed.push(",");
  35712. if (isParametersInTestCall || shouldHugParameters) {
  35713. printed.push(" ");
  35714. } else if (isNextLineEmpty$8(parameters[index], options)) {
  35715. printed.push(hardline$s, hardline$s);
  35716. } else {
  35717. printed.push(line$p);
  35718. }
  35719. }); // If the parent is a call with the first/last argument expansion and this is the
  35720. // params of the first/last argument, we don't want the arguments to break and instead
  35721. // want the whole expression to be on a new line.
  35722. //
  35723. // Good: Bad:
  35724. // verylongcall( verylongcall((
  35725. // (a, b) => { a,
  35726. // } b,
  35727. // ) ) => {
  35728. // })
  35729. if (expandArg) {
  35730. if (willBreak$1(typeParams) || willBreak$1(printed)) {
  35731. // Removing lines in this case leads to broken or ugly output
  35732. throw new ArgExpansionBailout$1();
  35733. }
  35734. return group$r([removeLines$2(typeParams), "(", removeLines$2(printed), ")"]);
  35735. } // Single object destructuring should hug
  35736. //
  35737. // function({
  35738. // a,
  35739. // b,
  35740. // c
  35741. // }) {}
  35742. const hasNotParameterDecorator = parameters.every(node => !node.decorators);
  35743. if (shouldHugParameters && hasNotParameterDecorator) {
  35744. return [typeParams, "(", ...printed, ")"];
  35745. } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  35746. if (isParametersInTestCall) {
  35747. return [typeParams, "(", ...printed, ")"];
  35748. }
  35749. const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent) || isTypeAnnotationAFunction(parent) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === functionNode) && parameters.length === 1 && parameters[0].name === null && // `type q = (this: string) => void;`
  35750. functionNode.this !== parameters[0] && parameters[0].typeAnnotation && functionNode.typeParameters === null && isSimpleType$1(parameters[0].typeAnnotation) && !functionNode.rest;
  35751. if (isFlowShorthandWithOneArg) {
  35752. if (options.arrowParens === "always") {
  35753. return ["(", ...printed, ")"];
  35754. }
  35755. return printed;
  35756. }
  35757. return [typeParams, "(", indent$l([softline$l, ...printed]), ifBreak$i(!hasRestParameter(functionNode) && shouldPrintComma$8(options, "all") ? "," : ""), softline$l, ")"];
  35758. }
  35759. function shouldHugFunctionParameters$1(node) {
  35760. if (!node) {
  35761. return false;
  35762. }
  35763. const parameters = getFunctionParameters$2(node);
  35764. if (parameters.length !== 1) {
  35765. return false;
  35766. }
  35767. const [parameter] = parameters;
  35768. return !hasComment$9(parameter) && (parameter.type === "ObjectPattern" || parameter.type === "ArrayPattern" || parameter.type === "Identifier" && parameter.typeAnnotation && (parameter.typeAnnotation.type === "TypeAnnotation" || parameter.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$1(parameter.typeAnnotation.typeAnnotation) || parameter.type === "FunctionTypeParam" && isObjectType$1(parameter.typeAnnotation) || parameter.type === "AssignmentPattern" && (parameter.left.type === "ObjectPattern" || parameter.left.type === "ArrayPattern") && (parameter.right.type === "Identifier" || parameter.right.type === "ObjectExpression" && parameter.right.properties.length === 0 || parameter.right.type === "ArrayExpression" && parameter.right.elements.length === 0));
  35769. }
  35770. function getReturnTypeNode(functionNode) {
  35771. let returnTypeNode;
  35772. if (functionNode.returnType) {
  35773. returnTypeNode = functionNode.returnType;
  35774. if (returnTypeNode.typeAnnotation) {
  35775. returnTypeNode = returnTypeNode.typeAnnotation;
  35776. }
  35777. } else if (functionNode.typeAnnotation) {
  35778. returnTypeNode = functionNode.typeAnnotation;
  35779. }
  35780. return returnTypeNode;
  35781. } // When parameters are grouped, the return type annotation breaks first.
  35782. function shouldGroupFunctionParameters$3(functionNode, returnTypeDoc) {
  35783. const returnTypeNode = getReturnTypeNode(functionNode);
  35784. if (!returnTypeNode) {
  35785. return false;
  35786. }
  35787. const typeParameters = functionNode.typeParameters && functionNode.typeParameters.params;
  35788. if (typeParameters) {
  35789. if (typeParameters.length > 1) {
  35790. return false;
  35791. }
  35792. if (typeParameters.length === 1) {
  35793. const typeParameter = typeParameters[0];
  35794. if (typeParameter.constraint || typeParameter.default) {
  35795. return false;
  35796. }
  35797. }
  35798. }
  35799. return getFunctionParameters$2(functionNode).length === 1 && (isObjectType$1(returnTypeNode) || willBreak$1(returnTypeDoc));
  35800. }
  35801. var functionParameters = {
  35802. printFunctionParameters: printFunctionParameters$3,
  35803. shouldHugFunctionParameters: shouldHugFunctionParameters$1,
  35804. shouldGroupFunctionParameters: shouldGroupFunctionParameters$3
  35805. };
  35806. const {
  35807. printComments: printComments$2,
  35808. printDanglingComments: printDanglingComments$9
  35809. } = comments$1;
  35810. const {
  35811. getLast: getLast$6
  35812. } = util$5;
  35813. const {
  35814. builders: {
  35815. group: group$q,
  35816. join: join$l,
  35817. line: line$o,
  35818. softline: softline$k,
  35819. indent: indent$k,
  35820. align: align$3,
  35821. ifBreak: ifBreak$h
  35822. }
  35823. } = doc;
  35824. const {
  35825. locStart: locStart$n
  35826. } = loc$6;
  35827. const {
  35828. isSimpleType,
  35829. isObjectType,
  35830. hasLeadingOwnLineComment: hasLeadingOwnLineComment$1,
  35831. isObjectTypePropertyAFunction,
  35832. shouldPrintComma: shouldPrintComma$7
  35833. } = utils$5;
  35834. const {
  35835. printAssignment: printAssignment$2
  35836. } = assignment;
  35837. const {
  35838. printFunctionParameters: printFunctionParameters$2,
  35839. shouldGroupFunctionParameters: shouldGroupFunctionParameters$2
  35840. } = functionParameters;
  35841. const {
  35842. printArrayItems: printArrayItems$2
  35843. } = array;
  35844. function shouldHugType$2(node) {
  35845. if (isSimpleType(node) || isObjectType(node)) {
  35846. return true;
  35847. }
  35848. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  35849. const voidCount = node.types.filter(node => node.type === "VoidTypeAnnotation" || node.type === "TSVoidKeyword" || node.type === "NullLiteralTypeAnnotation" || node.type === "TSNullKeyword").length;
  35850. const hasObject = node.types.some(node => node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  35851. node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference");
  35852. if (node.types.length - 1 === voidCount && hasObject) {
  35853. return true;
  35854. }
  35855. }
  35856. return false;
  35857. }
  35858. function printOpaqueType$1(path, options, print) {
  35859. const semi = options.semi ? ";" : "";
  35860. const node = path.getValue();
  35861. const parts = [];
  35862. parts.push("opaque type ", print("id"), print("typeParameters"));
  35863. if (node.supertype) {
  35864. parts.push(": ", print("supertype"));
  35865. }
  35866. if (node.impltype) {
  35867. parts.push(" = ", print("impltype"));
  35868. }
  35869. parts.push(semi);
  35870. return parts;
  35871. }
  35872. function printTypeAlias$2(path, options, print) {
  35873. const semi = options.semi ? ";" : "";
  35874. const node = path.getValue();
  35875. const parts = [];
  35876. if (node.declare) {
  35877. parts.push("declare ");
  35878. }
  35879. parts.push("type ", print("id"), print("typeParameters"));
  35880. const rightPropertyName = node.type === "TSTypeAliasDeclaration" ? "typeAnnotation" : "right";
  35881. return [printAssignment$2(path, options, print, parts, " =", rightPropertyName), semi];
  35882. } // `TSIntersectionType` and `IntersectionTypeAnnotation`
  35883. function printIntersectionType$2(path, options, print) {
  35884. const node = path.getValue();
  35885. const types = path.map(print, "types");
  35886. const result = [];
  35887. let wasIndented = false;
  35888. for (let i = 0; i < types.length; ++i) {
  35889. if (i === 0) {
  35890. result.push(types[i]);
  35891. } else if (isObjectType(node.types[i - 1]) && isObjectType(node.types[i])) {
  35892. // If both are objects, don't indent
  35893. result.push([" & ", wasIndented ? indent$k(types[i]) : types[i]]);
  35894. } else if (!isObjectType(node.types[i - 1]) && !isObjectType(node.types[i])) {
  35895. // If no object is involved, go to the next line if it breaks
  35896. result.push(indent$k([" &", line$o, types[i]]));
  35897. } else {
  35898. // If you go from object to non-object or vis-versa, then inline it
  35899. if (i > 1) {
  35900. wasIndented = true;
  35901. }
  35902. result.push(" & ", i > 1 ? indent$k(types[i]) : types[i]);
  35903. }
  35904. }
  35905. return group$q(result);
  35906. } // `TSUnionType` and `UnionTypeAnnotation`
  35907. function printUnionType$2(path, options, print) {
  35908. const node = path.getValue(); // single-line variation
  35909. // A | B | C
  35910. // multi-line variation
  35911. // | A
  35912. // | B
  35913. // | C
  35914. const parent = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  35915. const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name && path.getParentNode(1).this !== parent) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, node)); // {
  35916. // a: string
  35917. // } | null | void
  35918. // should be inlined and not be printed in the multi-line variant
  35919. const shouldHug = shouldHugType$2(node); // We want to align the children but without its comment, so it looks like
  35920. // | child1
  35921. // // comment
  35922. // | child2
  35923. const printed = path.map(typePath => {
  35924. let printedType = print();
  35925. if (!shouldHug) {
  35926. printedType = align$3(2, printedType);
  35927. }
  35928. return printComments$2(typePath, printedType, options);
  35929. }, "types");
  35930. if (shouldHug) {
  35931. return join$l(" | ", printed);
  35932. }
  35933. const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, node);
  35934. const code = [ifBreak$h([shouldAddStartLine ? line$o : "", "| "]), join$l([line$o, "| "], printed)];
  35935. if (needsParens_1(path, options)) {
  35936. return group$q([indent$k(code), softline$k]);
  35937. }
  35938. if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
  35939. return group$q([indent$k([ifBreak$h(["(", softline$k]), code]), softline$k, ifBreak$h(")")]);
  35940. }
  35941. return group$q(shouldIndent ? indent$k(code) : code);
  35942. } // `TSFunctionType` and `FunctionTypeAnnotation`
  35943. function printFunctionType$2(path, options, print) {
  35944. const node = path.getValue();
  35945. const parts = []; // FunctionTypeAnnotation is ambiguous:
  35946. // declare function foo(a: B): void; OR
  35947. // var A: (a: B) => void;
  35948. const parent = path.getParentNode(0);
  35949. const parentParent = path.getParentNode(1);
  35950. const parentParentParent = path.getParentNode(2);
  35951. let isArrowFunctionTypeAnnotation = node.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !parent.variance && !parent.optional && locStart$n(parent) === locStart$n(node) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
  35952. let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation"); // Sadly we can't put it inside of AstPath::needsColon because we are
  35953. // printing ":" as part of the expression and it would put parenthesis
  35954. // around :(
  35955. const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
  35956. if (isObjectTypePropertyAFunction(parent)) {
  35957. isArrowFunctionTypeAnnotation = true;
  35958. needsColon = true;
  35959. }
  35960. if (needsParens) {
  35961. parts.push("(");
  35962. }
  35963. const parametersDoc = printFunctionParameters$2(path, print, options,
  35964. /* expandArg */
  35965. false,
  35966. /* printTypeParams */
  35967. true); // The returnType is not wrapped in a TypeAnnotation, so the colon
  35968. // needs to be added separately.
  35969. const returnTypeDoc = node.returnType || node.predicate || node.typeAnnotation ? [isArrowFunctionTypeAnnotation ? " => " : ": ", print("returnType"), print("predicate"), print("typeAnnotation")] : "";
  35970. const shouldGroupParameters = shouldGroupFunctionParameters$2(node, returnTypeDoc);
  35971. parts.push(shouldGroupParameters ? group$q(parametersDoc) : parametersDoc);
  35972. if (returnTypeDoc) {
  35973. parts.push(returnTypeDoc);
  35974. }
  35975. if (needsParens) {
  35976. parts.push(")");
  35977. }
  35978. return group$q(parts);
  35979. } // `TSTupleType` and `TupleTypeAnnotation`
  35980. function printTupleType$2(path, options, print) {
  35981. const node = path.getValue();
  35982. const typesField = node.type === "TSTupleType" ? "elementTypes" : "types";
  35983. const hasRest = node[typesField].length > 0 && getLast$6(node[typesField]).type === "TSRestType";
  35984. return group$q(["[", indent$k([softline$k, printArrayItems$2(path, options, typesField, print)]), ifBreak$h(shouldPrintComma$7(options, "all") && !hasRest ? "," : ""), printDanglingComments$9(path, options,
  35985. /* sameIndent */
  35986. true), softline$k, "]"]);
  35987. } // `TSIndexedAccessType`, `IndexedAccessType`, and `OptionalIndexedAccessType`
  35988. function printIndexedAccessType$2(path, options, print) {
  35989. const node = path.getValue();
  35990. const leftDelimiter = node.type === "OptionalIndexedAccessType" && node.optional ? "?.[" : "[";
  35991. return [print("objectType"), leftDelimiter, print("indexType"), "]"];
  35992. }
  35993. var typeAnnotation = {
  35994. printOpaqueType: printOpaqueType$1,
  35995. printTypeAlias: printTypeAlias$2,
  35996. printIntersectionType: printIntersectionType$2,
  35997. printUnionType: printUnionType$2,
  35998. printFunctionType: printFunctionType$2,
  35999. printTupleType: printTupleType$2,
  36000. printIndexedAccessType: printIndexedAccessType$2,
  36001. shouldHugType: shouldHugType$2
  36002. };
  36003. const {
  36004. printDanglingComments: printDanglingComments$8
  36005. } = comments$1;
  36006. const {
  36007. builders: {
  36008. join: join$k,
  36009. line: line$n,
  36010. hardline: hardline$r,
  36011. softline: softline$j,
  36012. group: group$p,
  36013. indent: indent$j,
  36014. ifBreak: ifBreak$g
  36015. }
  36016. } = doc;
  36017. const {
  36018. isTestCall,
  36019. hasComment: hasComment$8,
  36020. CommentCheckFlags: CommentCheckFlags$8,
  36021. isTSXFile,
  36022. shouldPrintComma: shouldPrintComma$6,
  36023. getFunctionParameters: getFunctionParameters$1
  36024. } = utils$5;
  36025. const {
  36026. createGroupIdMapper: createGroupIdMapper$1
  36027. } = util$5;
  36028. const {
  36029. shouldHugType: shouldHugType$1
  36030. } = typeAnnotation;
  36031. const getTypeParametersGroupId$2 = createGroupIdMapper$1("typeParameters");
  36032. function printTypeParameters$2(path, options, print, paramsKey) {
  36033. const node = path.getValue();
  36034. if (!node[paramsKey]) {
  36035. return "";
  36036. } // for TypeParameterDeclaration typeParameters is a single node
  36037. if (!Array.isArray(node[paramsKey])) {
  36038. return print(paramsKey);
  36039. }
  36040. const grandparent = path.getNode(2);
  36041. const isParameterInTestCall = grandparent && isTestCall(grandparent);
  36042. const shouldInline = isParameterInTestCall || node[paramsKey].length === 0 || node[paramsKey].length === 1 && (shouldHugType$1(node[paramsKey][0]) || node[paramsKey][0].type === "NullableTypeAnnotation");
  36043. if (shouldInline) {
  36044. return ["<", join$k(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(path, options), ">"];
  36045. } // Keep comma if the file extension is .tsx and
  36046. // has one type parameter that isn't extend with any types.
  36047. // Because, otherwise formatted result will be invalid as tsx.
  36048. const trailingComma = node.type === "TSTypeParameterInstantiation" // https://github.com/microsoft/TypeScript/issues/21984
  36049. ? "" : getFunctionParameters$1(node).length === 1 && isTSXFile(options) && !node[paramsKey][0].constraint && path.getParentNode().type === "ArrowFunctionExpression" ? "," : shouldPrintComma$6(options, "all") ? ifBreak$g(",") : "";
  36050. return group$p(["<", indent$j([softline$j, join$k([",", line$n], path.map(print, paramsKey))]), trailingComma, softline$j, ">"], {
  36051. id: getTypeParametersGroupId$2(node)
  36052. });
  36053. }
  36054. function printDanglingCommentsForInline(path, options) {
  36055. const node = path.getValue();
  36056. if (!hasComment$8(node, CommentCheckFlags$8.Dangling)) {
  36057. return "";
  36058. }
  36059. const hasOnlyBlockComments = !hasComment$8(node, CommentCheckFlags$8.Line);
  36060. const printed = printDanglingComments$8(path, options,
  36061. /* sameIndent */
  36062. hasOnlyBlockComments);
  36063. if (hasOnlyBlockComments) {
  36064. return printed;
  36065. }
  36066. return [printed, hardline$r];
  36067. }
  36068. function printTypeParameter$2(path, options, print) {
  36069. const node = path.getValue();
  36070. const parts = [];
  36071. const parent = path.getParentNode();
  36072. if (parent.type === "TSMappedType") {
  36073. parts.push("[", print("name"));
  36074. if (node.constraint) {
  36075. parts.push(" in ", print("constraint"));
  36076. }
  36077. if (parent.nameType) {
  36078. parts.push(" as ", path.callParent(() => print("nameType")));
  36079. }
  36080. parts.push("]");
  36081. return parts;
  36082. }
  36083. if (node.variance) {
  36084. parts.push(print("variance"));
  36085. }
  36086. parts.push(print("name"));
  36087. if (node.bound) {
  36088. parts.push(": ", print("bound"));
  36089. }
  36090. if (node.constraint) {
  36091. parts.push(" extends ", print("constraint"));
  36092. }
  36093. if (node.default) {
  36094. parts.push(" = ", print("default"));
  36095. }
  36096. return parts;
  36097. }
  36098. var typeParameters = {
  36099. printTypeParameter: printTypeParameter$2,
  36100. printTypeParameters: printTypeParameters$2,
  36101. getTypeParametersGroupId: getTypeParametersGroupId$2
  36102. };
  36103. const {
  36104. printComments: printComments$1
  36105. } = comments$1;
  36106. const {
  36107. printString: printString$3,
  36108. printNumber: printNumber$3
  36109. } = util$5;
  36110. const {
  36111. isNumericLiteral,
  36112. isSimpleNumber,
  36113. isStringLiteral,
  36114. isStringPropSafeToUnquote,
  36115. rawText: rawText$2
  36116. } = utils$5;
  36117. const {
  36118. printAssignment: printAssignment$1
  36119. } = assignment;
  36120. const needsQuoteProps = new WeakMap();
  36121. function printPropertyKey$4(path, options, print) {
  36122. const node = path.getNode();
  36123. if (node.computed) {
  36124. return ["[", print("key"), "]"];
  36125. }
  36126. const parent = path.getParentNode();
  36127. const {
  36128. key
  36129. } = node; // flow has `Identifier` key, other parsers use `PrivateIdentifier` (ESTree) or `PrivateName`
  36130. if (node.type === "ClassPrivateProperty" && key.type === "Identifier") {
  36131. return ["#", print("key")];
  36132. }
  36133. if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
  36134. const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral(prop.key) && !isStringPropSafeToUnquote(prop, options));
  36135. needsQuoteProps.set(parent, objectHasStringProp);
  36136. }
  36137. if ((key.type === "Identifier" || isNumericLiteral(key) && isSimpleNumber(printNumber$3(rawText$2(key))) && // Avoid converting 999999999999999999999 to 1e+21, 0.99999999999999999 to 1 and 1.0 to 1.
  36138. String(key.value) === printNumber$3(rawText$2(key)) && // Quoting number keys is safe in JS and Flow, but not in TypeScript (as
  36139. // mentioned in `isStringPropSafeToUnquote`).
  36140. !(options.parser === "typescript" || options.parser === "babel-ts")) && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
  36141. // a -> "a"
  36142. // 1 -> "1"
  36143. // 1.5 -> "1.5"
  36144. const prop = printString$3(JSON.stringify(key.type === "Identifier" ? key.name : key.value.toString()), options);
  36145. return path.call(keyPath => printComments$1(keyPath, prop, options), "key");
  36146. }
  36147. if (isStringPropSafeToUnquote(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
  36148. // 'a' -> a
  36149. // '1' -> 1
  36150. // '1.5' -> 1.5
  36151. return path.call(keyPath => printComments$1(keyPath, /^\d/.test(key.value) ? printNumber$3(key.value) : key.value, options), "key");
  36152. }
  36153. return print("key");
  36154. }
  36155. function printProperty$1(path, options, print) {
  36156. const node = path.getValue();
  36157. if (node.shorthand) {
  36158. return print("value");
  36159. }
  36160. return printAssignment$1(path, options, print, printPropertyKey$4(path, options, print), ":", "value");
  36161. }
  36162. var property = {
  36163. printProperty: printProperty$1,
  36164. printPropertyKey: printPropertyKey$4
  36165. };
  36166. /** @typedef {import("../../document/doc-builders").Doc} Doc */
  36167. const {
  36168. printDanglingComments: printDanglingComments$7,
  36169. printCommentsSeparately
  36170. } = comments$1;
  36171. const {
  36172. getNextNonSpaceNonCommentCharacterIndex
  36173. } = util$5;
  36174. const {
  36175. builders: {
  36176. line: line$m,
  36177. softline: softline$i,
  36178. group: group$o,
  36179. indent: indent$i,
  36180. ifBreak: ifBreak$f,
  36181. hardline: hardline$q,
  36182. join: join$j,
  36183. indentIfBreak: indentIfBreak$1
  36184. },
  36185. utils: {
  36186. removeLines: removeLines$1,
  36187. willBreak
  36188. }
  36189. } = doc;
  36190. const {
  36191. ArgExpansionBailout
  36192. } = errors;
  36193. const {
  36194. getFunctionParameters,
  36195. hasLeadingOwnLineComment,
  36196. isFlowAnnotationComment,
  36197. isJsxNode: isJsxNode$2,
  36198. isTemplateOnItsOwnLine,
  36199. shouldPrintComma: shouldPrintComma$5,
  36200. startsWithNoLookaheadToken,
  36201. isBinaryish,
  36202. isLineComment: isLineComment$2,
  36203. hasComment: hasComment$7,
  36204. getComments: getComments$2,
  36205. CommentCheckFlags: CommentCheckFlags$7,
  36206. isCallLikeExpression,
  36207. isCallExpression: isCallExpression$3,
  36208. getCallArguments,
  36209. hasNakedLeftSide: hasNakedLeftSide$1,
  36210. getLeftSide
  36211. } = utils$5;
  36212. const {
  36213. locEnd: locEnd$l
  36214. } = loc$6;
  36215. const {
  36216. printFunctionParameters: printFunctionParameters$1,
  36217. shouldGroupFunctionParameters: shouldGroupFunctionParameters$1
  36218. } = functionParameters;
  36219. const {
  36220. printPropertyKey: printPropertyKey$3
  36221. } = property;
  36222. const {
  36223. printFunctionTypeParameters
  36224. } = misc$1;
  36225. function printFunction$2(path, print, options, args) {
  36226. const node = path.getValue();
  36227. let expandArg = false;
  36228. if ((node.type === "FunctionDeclaration" || node.type === "FunctionExpression") && args && args.expandLastArg) {
  36229. const parent = path.getParentNode();
  36230. if (isCallExpression$3(parent) && getCallArguments(parent).length > 1) {
  36231. expandArg = true;
  36232. }
  36233. }
  36234. const parts = []; // For TypeScript the TSDeclareFunction node shares the AST
  36235. // structure with FunctionDeclaration
  36236. if (node.type === "TSDeclareFunction" && node.declare) {
  36237. parts.push("declare ");
  36238. }
  36239. if (node.async) {
  36240. parts.push("async ");
  36241. }
  36242. if (node.generator) {
  36243. parts.push("function* ");
  36244. } else {
  36245. parts.push("function ");
  36246. }
  36247. if (node.id) {
  36248. parts.push(print("id"));
  36249. }
  36250. const parametersDoc = printFunctionParameters$1(path, print, options, expandArg);
  36251. const returnTypeDoc = printReturnType(path, print, options);
  36252. const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
  36253. parts.push(printFunctionTypeParameters(path, options, print), group$o([shouldGroupParameters ? group$o(parametersDoc) : parametersDoc, returnTypeDoc]), node.body ? " " : "", print("body"));
  36254. if (options.semi && (node.declare || !node.body)) {
  36255. parts.push(";");
  36256. }
  36257. return parts;
  36258. }
  36259. function printMethod$2(path, options, print) {
  36260. const node = path.getNode();
  36261. const {
  36262. kind
  36263. } = node;
  36264. const value = node.value || node;
  36265. const parts = [];
  36266. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  36267. if (value.async) {
  36268. parts.push("async ");
  36269. }
  36270. } else {
  36271. assert__default['default'].ok(kind === "get" || kind === "set");
  36272. parts.push(kind, " ");
  36273. } // A `getter`/`setter` can't be a generator, but it's recoverable
  36274. if (value.generator) {
  36275. parts.push("*");
  36276. }
  36277. parts.push(printPropertyKey$3(path, options, print), node.optional || node.key.optional ? "?" : "");
  36278. if (node === value) {
  36279. parts.push(printMethodInternal$1(path, options, print));
  36280. } else if (value.type === "FunctionExpression") {
  36281. parts.push(path.call(path => printMethodInternal$1(path, options, print), "value"));
  36282. } else {
  36283. parts.push(print("value"));
  36284. }
  36285. return parts;
  36286. }
  36287. function printMethodInternal$1(path, options, print) {
  36288. const node = path.getNode();
  36289. const parametersDoc = printFunctionParameters$1(path, print, options);
  36290. const returnTypeDoc = printReturnType(path, print, options);
  36291. const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
  36292. const parts = [printFunctionTypeParameters(path, options, print), group$o([shouldGroupParameters ? group$o(parametersDoc) : parametersDoc, returnTypeDoc])];
  36293. if (node.body) {
  36294. parts.push(" ", print("body"));
  36295. } else {
  36296. parts.push(options.semi ? ";" : "");
  36297. }
  36298. return parts;
  36299. }
  36300. function printArrowFunctionSignature(path, options, print, args) {
  36301. const node = path.getValue();
  36302. const parts = [];
  36303. if (node.async) {
  36304. parts.push("async ");
  36305. }
  36306. if (shouldPrintParamsWithoutParens$1(path, options)) {
  36307. parts.push(print(["params", 0]));
  36308. } else {
  36309. const expandArg = args && (args.expandLastArg || args.expandFirstArg);
  36310. let returnTypeDoc = printReturnType(path, print, options);
  36311. if (expandArg) {
  36312. if (willBreak(returnTypeDoc)) {
  36313. throw new ArgExpansionBailout();
  36314. }
  36315. returnTypeDoc = group$o(removeLines$1(returnTypeDoc));
  36316. }
  36317. parts.push(group$o([printFunctionParameters$1(path, print, options, expandArg,
  36318. /* printTypeParams */
  36319. true), returnTypeDoc]));
  36320. }
  36321. const dangling = printDanglingComments$7(path, options,
  36322. /* sameIndent */
  36323. true, comment => {
  36324. const nextCharacter = getNextNonSpaceNonCommentCharacterIndex(options.originalText, comment, locEnd$l);
  36325. return nextCharacter !== false && options.originalText.slice(nextCharacter, nextCharacter + 2) === "=>";
  36326. });
  36327. if (dangling) {
  36328. parts.push(" ", dangling);
  36329. }
  36330. return parts;
  36331. }
  36332. function printArrowChain(path, args, signatures, shouldBreak, bodyDoc, tailNode) {
  36333. const name = path.getName();
  36334. const parent = path.getParentNode();
  36335. const isCallee = isCallLikeExpression(parent) && name === "callee";
  36336. const isAssignmentRhs = Boolean(args && args.assignmentLayout);
  36337. const shouldPutBodyOnSeparateLine = tailNode.body.type !== "BlockStatement" && tailNode.body.type !== "ObjectExpression";
  36338. const shouldBreakBeforeChain = isCallee && shouldPutBodyOnSeparateLine || args && args.assignmentLayout === "chain-tail-arrow-chain";
  36339. const groupId = Symbol("arrow-chain");
  36340. return group$o([group$o(indent$i([isCallee || isAssignmentRhs ? softline$i : "", group$o(join$j([" =>", line$m], signatures), {
  36341. shouldBreak
  36342. })]), {
  36343. id: groupId,
  36344. shouldBreak: shouldBreakBeforeChain
  36345. }), " =>", indentIfBreak$1(shouldPutBodyOnSeparateLine ? indent$i([line$m, bodyDoc]) : [" ", bodyDoc], {
  36346. groupId
  36347. }), isCallee ? ifBreak$f(softline$i, "", {
  36348. groupId
  36349. }) : ""]);
  36350. }
  36351. function printArrowFunction$1(path, options, print, args) {
  36352. let node = path.getValue();
  36353. /** @type {Doc[]} */
  36354. const signatures = [];
  36355. const body = [];
  36356. let chainShouldBreak = false;
  36357. (function rec() {
  36358. const doc = printArrowFunctionSignature(path, options, print, args);
  36359. if (signatures.length === 0) {
  36360. signatures.push(doc);
  36361. } else {
  36362. const {
  36363. leading,
  36364. trailing
  36365. } = printCommentsSeparately(path, options);
  36366. signatures.push([leading, doc]);
  36367. body.unshift(trailing);
  36368. }
  36369. chainShouldBreak = chainShouldBreak || node.returnType && getFunctionParameters(node).length > 0 || node.typeParameters || getFunctionParameters(node).some(param => param.type !== "Identifier");
  36370. if (node.body.type !== "ArrowFunctionExpression" || args && args.expandLastArg) {
  36371. body.unshift(print("body", args));
  36372. } else {
  36373. node = node.body;
  36374. path.call(rec, "body");
  36375. }
  36376. })();
  36377. if (signatures.length > 1) {
  36378. return printArrowChain(path, args, signatures, chainShouldBreak, body, node);
  36379. }
  36380. const parts = signatures;
  36381. parts.push(" =>"); // We want to always keep these types of nodes on the same line
  36382. // as the arrow.
  36383. if (!hasLeadingOwnLineComment(options.originalText, node.body) && (node.body.type === "ArrayExpression" || node.body.type === "ObjectExpression" || node.body.type === "BlockStatement" || isJsxNode$2(node.body) || isTemplateOnItsOwnLine(node.body, options.originalText) || node.body.type === "ArrowFunctionExpression" || node.body.type === "DoExpression")) {
  36384. return group$o([...parts, " ", body]);
  36385. } // We handle sequence expressions as the body of arrows specially,
  36386. // so that the required parentheses end up on their own lines.
  36387. if (node.body.type === "SequenceExpression") {
  36388. return group$o([...parts, group$o([" (", indent$i([softline$i, body]), softline$i, ")"])]);
  36389. } // if the arrow function is expanded as last argument, we are adding a
  36390. // level of indentation and need to add a softline to align the closing )
  36391. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  36392. // we should align the expression's closing } with the line with the opening {.
  36393. const shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !hasComment$7(node);
  36394. const printTrailingComma = args && args.expandLastArg && shouldPrintComma$5(options, "all"); // In order to avoid confusion between
  36395. // a => a ? a : a
  36396. // a <= a ? a : a
  36397. const shouldAddParens = node.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken(node.body,
  36398. /* forbidFunctionAndClass */
  36399. false);
  36400. return group$o([...parts, group$o([indent$i([line$m, shouldAddParens ? ifBreak$f("", "(") : "", body, shouldAddParens ? ifBreak$f("", ")") : ""]), shouldAddSoftLine ? [ifBreak$f(printTrailingComma ? "," : ""), softline$i] : ""])]);
  36401. }
  36402. function canPrintParamsWithoutParens(node) {
  36403. const parameters = getFunctionParameters(node);
  36404. return parameters.length === 1 && !node.typeParameters && !hasComment$7(node, CommentCheckFlags$7.Dangling) && parameters[0].type === "Identifier" && !parameters[0].typeAnnotation && !hasComment$7(parameters[0]) && !parameters[0].optional && !node.predicate && !node.returnType;
  36405. }
  36406. function shouldPrintParamsWithoutParens$1(path, options) {
  36407. if (options.arrowParens === "always") {
  36408. return false;
  36409. }
  36410. if (options.arrowParens === "avoid") {
  36411. const node = path.getValue();
  36412. return canPrintParamsWithoutParens(node);
  36413. } // Fallback default; should be unreachable
  36414. /* istanbul ignore next */
  36415. return false;
  36416. }
  36417. /** @returns {Doc} */
  36418. function printReturnType(path, print, options) {
  36419. const node = path.getValue();
  36420. const returnType = print("returnType");
  36421. if (node.returnType && isFlowAnnotationComment(options.originalText, node.returnType)) {
  36422. return [" /*: ", returnType, " */"];
  36423. }
  36424. const parts = [returnType]; // prepend colon to TypeScript type annotation
  36425. if (node.returnType && node.returnType.typeAnnotation) {
  36426. parts.unshift(": ");
  36427. }
  36428. if (node.predicate) {
  36429. // The return type will already add the colon, but otherwise we
  36430. // need to do it ourselves
  36431. parts.push(node.returnType ? " " : ": ", print("predicate"));
  36432. }
  36433. return parts;
  36434. } // `ReturnStatement` and `ThrowStatement`
  36435. function printReturnOrThrowArgument(path, options, print) {
  36436. const node = path.getValue();
  36437. const semi = options.semi ? ";" : "";
  36438. const parts = [];
  36439. if (node.argument) {
  36440. if (returnArgumentHasLeadingComment(options, node.argument)) {
  36441. parts.push([" (", indent$i([hardline$q, print("argument")]), hardline$q, ")"]);
  36442. } else if (isBinaryish(node.argument) || node.argument.type === "SequenceExpression") {
  36443. parts.push(group$o([ifBreak$f(" (", " "), indent$i([softline$i, print("argument")]), softline$i, ifBreak$f(")")]));
  36444. } else {
  36445. parts.push(" ", print("argument"));
  36446. }
  36447. }
  36448. const comments = getComments$2(node);
  36449. const lastComment = getLast_1(comments);
  36450. const isLastCommentLine = lastComment && isLineComment$2(lastComment);
  36451. if (isLastCommentLine) {
  36452. parts.push(semi);
  36453. }
  36454. if (hasComment$7(node, CommentCheckFlags$7.Dangling)) {
  36455. parts.push(" ", printDanglingComments$7(path, options,
  36456. /* sameIndent */
  36457. true));
  36458. }
  36459. if (!isLastCommentLine) {
  36460. parts.push(semi);
  36461. }
  36462. return parts;
  36463. }
  36464. function printReturnStatement$1(path, options, print) {
  36465. return ["return", printReturnOrThrowArgument(path, options, print)];
  36466. }
  36467. function printThrowStatement$1(path, options, print) {
  36468. return ["throw", printReturnOrThrowArgument(path, options, print)];
  36469. } // This recurses the return argument, looking for the first token
  36470. // (the leftmost leaf node) and, if it (or its parents) has any
  36471. // leadingComments, returns true (so it can be wrapped in parens).
  36472. function returnArgumentHasLeadingComment(options, argument) {
  36473. if (hasLeadingOwnLineComment(options.originalText, argument)) {
  36474. return true;
  36475. }
  36476. if (hasNakedLeftSide$1(argument)) {
  36477. let leftMost = argument;
  36478. let newLeftMost;
  36479. while (newLeftMost = getLeftSide(leftMost)) {
  36480. leftMost = newLeftMost;
  36481. if (hasLeadingOwnLineComment(options.originalText, leftMost)) {
  36482. return true;
  36483. }
  36484. }
  36485. }
  36486. return false;
  36487. }
  36488. var _function = {
  36489. printFunction: printFunction$2,
  36490. printArrowFunction: printArrowFunction$1,
  36491. printMethod: printMethod$2,
  36492. printReturnStatement: printReturnStatement$1,
  36493. printThrowStatement: printThrowStatement$1,
  36494. printMethodInternal: printMethodInternal$1,
  36495. shouldPrintParamsWithoutParens: shouldPrintParamsWithoutParens$1
  36496. };
  36497. const {
  36498. isNonEmptyArray: isNonEmptyArray$c,
  36499. hasNewline: hasNewline$4
  36500. } = util$5;
  36501. const {
  36502. builders: {
  36503. line: line$l,
  36504. hardline: hardline$p,
  36505. join: join$i,
  36506. breakParent: breakParent$7,
  36507. group: group$n
  36508. }
  36509. } = doc;
  36510. const {
  36511. locStart: locStart$m,
  36512. locEnd: locEnd$k
  36513. } = loc$6;
  36514. const {
  36515. getParentExportDeclaration: getParentExportDeclaration$1
  36516. } = utils$5;
  36517. function printClassMemberDecorators$1(path, options, print) {
  36518. const node = path.getValue();
  36519. return group$n([join$i(line$l, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$p : line$l]);
  36520. }
  36521. function printDecoratorsBeforeExport$1(path, options, print) {
  36522. // Export declarations are responsible for printing any decorators
  36523. // that logically apply to node.declaration.
  36524. return [join$i(hardline$p, path.map(print, "declaration", "decorators")), hardline$p];
  36525. }
  36526. function printDecorators$1(path, options, print) {
  36527. const node = path.getValue();
  36528. const {
  36529. decorators
  36530. } = node;
  36531. if (!isNonEmptyArray$c(decorators) || // If the parent node is an export declaration and the decorator
  36532. // was written before the export, the export will be responsible
  36533. // for printing the decorators.
  36534. hasDecoratorsBeforeExport$1(path.getParentNode())) {
  36535. return;
  36536. }
  36537. const shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  36538. return [getParentExportDeclaration$1(path) ? hardline$p : shouldBreak ? breakParent$7 : "", join$i(line$l, path.map(print, "decorators")), line$l];
  36539. }
  36540. function hasNewlineBetweenOrAfterDecorators(node, options) {
  36541. return node.decorators.some(decorator => hasNewline$4(options.originalText, locEnd$k(decorator)));
  36542. }
  36543. function hasDecoratorsBeforeExport$1(node) {
  36544. if (node.type !== "ExportDefaultDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "DeclareExportDeclaration") {
  36545. return false;
  36546. }
  36547. const decorators = node.declaration && node.declaration.decorators;
  36548. return isNonEmptyArray$c(decorators) && locStart$m(node, {
  36549. ignoreDecorators: true
  36550. }) > locStart$m(decorators[0]);
  36551. }
  36552. var decorators = {
  36553. printDecorators: printDecorators$1,
  36554. printClassMemberDecorators: printClassMemberDecorators$1,
  36555. printDecoratorsBeforeExport: printDecoratorsBeforeExport$1,
  36556. hasDecoratorsBeforeExport: hasDecoratorsBeforeExport$1
  36557. };
  36558. const {
  36559. isNonEmptyArray: isNonEmptyArray$b,
  36560. createGroupIdMapper
  36561. } = util$5;
  36562. const {
  36563. printComments,
  36564. printDanglingComments: printDanglingComments$6
  36565. } = comments$1;
  36566. const {
  36567. builders: {
  36568. join: join$h,
  36569. line: line$k,
  36570. hardline: hardline$o,
  36571. softline: softline$h,
  36572. group: group$m,
  36573. indent: indent$h,
  36574. ifBreak: ifBreak$e
  36575. }
  36576. } = doc;
  36577. const {
  36578. hasComment: hasComment$6,
  36579. CommentCheckFlags: CommentCheckFlags$6
  36580. } = utils$5;
  36581. const {
  36582. getTypeParametersGroupId: getTypeParametersGroupId$1
  36583. } = typeParameters;
  36584. const {
  36585. printMethod: printMethod$1
  36586. } = _function;
  36587. const {
  36588. printOptionalToken: printOptionalToken$4,
  36589. printTypeAnnotation: printTypeAnnotation$3
  36590. } = misc$1;
  36591. const {
  36592. printPropertyKey: printPropertyKey$2
  36593. } = property;
  36594. const {
  36595. printAssignment
  36596. } = assignment;
  36597. const {
  36598. printClassMemberDecorators
  36599. } = decorators;
  36600. function printClass$2(path, options, print) {
  36601. const node = path.getValue();
  36602. const parts = [];
  36603. if (node.declare) {
  36604. parts.push("declare ");
  36605. }
  36606. if (node.abstract) {
  36607. parts.push("abstract ");
  36608. }
  36609. parts.push("class"); // Keep old behaviour of extends in same line
  36610. // If there is only on extends and there are not comments
  36611. const groupMode = node.id && hasComment$6(node.id, CommentCheckFlags$6.Trailing) || node.superClass && hasComment$6(node.superClass) || isNonEmptyArray$b(node.extends) || // DeclareClass
  36612. isNonEmptyArray$b(node.mixins) || isNonEmptyArray$b(node.implements);
  36613. const partsGroup = [];
  36614. const extendsParts = [];
  36615. if (node.id) {
  36616. partsGroup.push(" ", print("id"));
  36617. }
  36618. partsGroup.push(print("typeParameters"));
  36619. if (node.superClass) {
  36620. const printed = ["extends ", printSuperClass(path, options, print), print("superTypeParameters")];
  36621. const printedWithComments = path.call(superClass => printComments(superClass, printed, options), "superClass");
  36622. if (groupMode) {
  36623. extendsParts.push(line$k, group$m(printedWithComments));
  36624. } else {
  36625. extendsParts.push(" ", printedWithComments);
  36626. }
  36627. } else {
  36628. extendsParts.push(printList(path, options, print, "extends"));
  36629. }
  36630. extendsParts.push(printList(path, options, print, "mixins"), printList(path, options, print, "implements"));
  36631. if (groupMode) {
  36632. let printedPartsGroup;
  36633. if (shouldIndentOnlyHeritageClauses(node)) {
  36634. printedPartsGroup = [...partsGroup, indent$h(extendsParts)];
  36635. } else {
  36636. printedPartsGroup = indent$h([...partsGroup, extendsParts]);
  36637. }
  36638. parts.push(group$m(printedPartsGroup, {
  36639. id: getHeritageGroupId(node)
  36640. }));
  36641. } else {
  36642. parts.push(...partsGroup, ...extendsParts);
  36643. }
  36644. parts.push(" ", print("body"));
  36645. return parts;
  36646. }
  36647. const getHeritageGroupId = createGroupIdMapper("heritageGroup");
  36648. function printHardlineAfterHeritage$2(node) {
  36649. return ifBreak$e(hardline$o, "", {
  36650. groupId: getHeritageGroupId(node)
  36651. });
  36652. }
  36653. function hasMultipleHeritage(node) {
  36654. return ["superClass", "extends", "mixins", "implements"].filter(key => Boolean(node[key])).length > 1;
  36655. }
  36656. function shouldIndentOnlyHeritageClauses(node) {
  36657. return node.typeParameters && !hasComment$6(node.typeParameters, CommentCheckFlags$6.Trailing | CommentCheckFlags$6.Line) && !hasMultipleHeritage(node);
  36658. }
  36659. function printList(path, options, print, listName) {
  36660. const node = path.getValue();
  36661. if (!isNonEmptyArray$b(node[listName])) {
  36662. return "";
  36663. }
  36664. const printedLeadingComments = printDanglingComments$6(path, options,
  36665. /* sameIndent */
  36666. true, ({
  36667. marker
  36668. }) => marker === listName);
  36669. return [shouldIndentOnlyHeritageClauses(node) ? ifBreak$e(" ", line$k, {
  36670. groupId: getTypeParametersGroupId$1(node.typeParameters)
  36671. }) : line$k, printedLeadingComments, printedLeadingComments && hardline$o, listName, group$m(indent$h([line$k, join$h([",", line$k], path.map(print, listName))]))];
  36672. }
  36673. function printSuperClass(path, options, print) {
  36674. const printed = print("superClass");
  36675. const parent = path.getParentNode();
  36676. if (parent.type === "AssignmentExpression") {
  36677. return group$m(ifBreak$e(["(", indent$h([softline$h, printed]), softline$h, ")"], printed));
  36678. }
  36679. return printed;
  36680. }
  36681. function printClassMethod$2(path, options, print) {
  36682. const node = path.getValue();
  36683. const parts = [];
  36684. if (isNonEmptyArray$b(node.decorators)) {
  36685. parts.push(printClassMemberDecorators(path, options, print));
  36686. }
  36687. if (node.accessibility) {
  36688. parts.push(node.accessibility + " ");
  36689. } // "readonly" and "declare" are supported by only "babel-ts"
  36690. // https://github.com/prettier/prettier/issues/9760
  36691. if (node.readonly) {
  36692. parts.push("readonly ");
  36693. }
  36694. if (node.declare) {
  36695. parts.push("declare ");
  36696. }
  36697. if (node.static) {
  36698. parts.push("static ");
  36699. }
  36700. if (node.type === "TSAbstractMethodDefinition" || node.abstract) {
  36701. parts.push("abstract ");
  36702. }
  36703. if (node.override) {
  36704. parts.push("override ");
  36705. }
  36706. parts.push(printMethod$1(path, options, print));
  36707. return parts;
  36708. }
  36709. function printClassProperty$2(path, options, print) {
  36710. const node = path.getValue();
  36711. const parts = [];
  36712. const semi = options.semi ? ";" : "";
  36713. if (isNonEmptyArray$b(node.decorators)) {
  36714. parts.push(printClassMemberDecorators(path, options, print));
  36715. }
  36716. if (node.accessibility) {
  36717. parts.push(node.accessibility + " ");
  36718. }
  36719. if (node.declare) {
  36720. parts.push("declare ");
  36721. }
  36722. if (node.static) {
  36723. parts.push("static ");
  36724. }
  36725. if (node.type === "TSAbstractClassProperty" || node.abstract) {
  36726. parts.push("abstract ");
  36727. }
  36728. if (node.override) {
  36729. parts.push("override ");
  36730. }
  36731. if (node.readonly) {
  36732. parts.push("readonly ");
  36733. }
  36734. if (node.variance) {
  36735. parts.push(print("variance"));
  36736. }
  36737. parts.push(printPropertyKey$2(path, options, print), printOptionalToken$4(path), printTypeAnnotation$3(path, options, print));
  36738. return [printAssignment(path, options, print, parts, " =", "value"), semi];
  36739. }
  36740. var _class = {
  36741. printClass: printClass$2,
  36742. printClassMethod: printClassMethod$2,
  36743. printClassProperty: printClassProperty$2,
  36744. printHardlineAfterHeritage: printHardlineAfterHeritage$2
  36745. };
  36746. const {
  36747. isNonEmptyArray: isNonEmptyArray$a
  36748. } = util$5;
  36749. const {
  36750. builders: {
  36751. join: join$g,
  36752. line: line$j,
  36753. group: group$l,
  36754. indent: indent$g,
  36755. ifBreak: ifBreak$d
  36756. }
  36757. } = doc;
  36758. const {
  36759. hasComment: hasComment$5,
  36760. identity,
  36761. CommentCheckFlags: CommentCheckFlags$5
  36762. } = utils$5;
  36763. const {
  36764. getTypeParametersGroupId
  36765. } = typeParameters;
  36766. const {
  36767. printTypeScriptModifiers: printTypeScriptModifiers$1
  36768. } = misc$1;
  36769. function printInterface$2(path, options, print) {
  36770. const node = path.getValue();
  36771. const parts = [];
  36772. if (node.declare) {
  36773. parts.push("declare ");
  36774. }
  36775. if (node.type === "TSInterfaceDeclaration") {
  36776. parts.push(node.abstract ? "abstract " : "", printTypeScriptModifiers$1(path, options, print));
  36777. }
  36778. parts.push("interface");
  36779. const partsGroup = [];
  36780. const extendsParts = [];
  36781. if (node.type !== "InterfaceTypeAnnotation") {
  36782. partsGroup.push(" ", print("id"), print("typeParameters"));
  36783. }
  36784. const shouldIndentOnlyHeritageClauses = node.typeParameters && !hasComment$5(node.typeParameters, CommentCheckFlags$5.Trailing | CommentCheckFlags$5.Line);
  36785. if (isNonEmptyArray$a(node.extends)) {
  36786. extendsParts.push(shouldIndentOnlyHeritageClauses ? ifBreak$d(" ", line$j, {
  36787. groupId: getTypeParametersGroupId(node.typeParameters)
  36788. }) : line$j, "extends ", (node.extends.length === 1 ? identity : indent$g)(join$g([",", line$j], path.map(print, "extends"))));
  36789. }
  36790. if (node.id && hasComment$5(node.id, CommentCheckFlags$5.Trailing) || isNonEmptyArray$a(node.extends)) {
  36791. if (shouldIndentOnlyHeritageClauses) {
  36792. parts.push(group$l([...partsGroup, indent$g(extendsParts)]));
  36793. } else {
  36794. parts.push(group$l(indent$g([...partsGroup, ...extendsParts])));
  36795. }
  36796. } else {
  36797. parts.push(...partsGroup, ...extendsParts);
  36798. }
  36799. parts.push(" ", print("body"));
  36800. return group$l(parts);
  36801. }
  36802. var _interface = {
  36803. printInterface: printInterface$2
  36804. };
  36805. const {
  36806. isNonEmptyArray: isNonEmptyArray$9
  36807. } = util$5;
  36808. const {
  36809. builders: {
  36810. softline: softline$g,
  36811. group: group$k,
  36812. indent: indent$f,
  36813. join: join$f,
  36814. line: line$i,
  36815. ifBreak: ifBreak$c,
  36816. hardline: hardline$n
  36817. }
  36818. } = doc;
  36819. const {
  36820. printDanglingComments: printDanglingComments$5
  36821. } = comments$1;
  36822. const {
  36823. hasComment: hasComment$4,
  36824. CommentCheckFlags: CommentCheckFlags$4,
  36825. shouldPrintComma: shouldPrintComma$4,
  36826. needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$1
  36827. } = utils$5;
  36828. const {
  36829. locStart: locStart$l,
  36830. hasSameLoc
  36831. } = loc$6;
  36832. const {
  36833. hasDecoratorsBeforeExport,
  36834. printDecoratorsBeforeExport
  36835. } = decorators;
  36836. /**
  36837. * @typedef {import("../../document").Doc} Doc
  36838. */
  36839. function printImportDeclaration$1(path, options, print) {
  36840. const node = path.getValue();
  36841. const semi = options.semi ? ";" : "";
  36842. /** @type{Doc[]} */
  36843. const parts = [];
  36844. const {
  36845. importKind
  36846. } = node;
  36847. parts.push("import");
  36848. if (importKind && importKind !== "value") {
  36849. parts.push(" ", importKind);
  36850. }
  36851. parts.push(printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
  36852. return parts;
  36853. }
  36854. function printExportDeclaration$2(path, options, print) {
  36855. const node = path.getValue();
  36856. /** @type{Doc[]} */
  36857. const parts = []; // Only print decorators here if they were written before the export,
  36858. // otherwise they are printed by the node.declaration
  36859. if (hasDecoratorsBeforeExport(node)) {
  36860. parts.push(printDecoratorsBeforeExport(path, options, print));
  36861. }
  36862. const {
  36863. type,
  36864. exportKind,
  36865. declaration
  36866. } = node;
  36867. parts.push("export");
  36868. const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
  36869. if (isDefaultExport) {
  36870. parts.push(" default");
  36871. }
  36872. if (hasComment$4(node, CommentCheckFlags$4.Dangling)) {
  36873. parts.push(" ", printDanglingComments$5(path, options,
  36874. /* sameIndent */
  36875. true));
  36876. if (needsHardlineAfterDanglingComment$1(node)) {
  36877. parts.push(hardline$n);
  36878. }
  36879. }
  36880. if (declaration) {
  36881. parts.push(" ", print("declaration"));
  36882. } else {
  36883. parts.push(exportKind === "type" ? " type" : "", printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print));
  36884. }
  36885. if (shouldExportDeclarationPrintSemi(node, options)) {
  36886. parts.push(";");
  36887. }
  36888. return parts;
  36889. }
  36890. function printExportAllDeclaration$2(path, options, print) {
  36891. const node = path.getValue();
  36892. const semi = options.semi ? ";" : "";
  36893. /** @type{Doc[]} */
  36894. const parts = [];
  36895. const {
  36896. exportKind,
  36897. exported
  36898. } = node;
  36899. parts.push("export");
  36900. if (exportKind === "type") {
  36901. parts.push(" type");
  36902. }
  36903. parts.push(" *");
  36904. if (exported) {
  36905. parts.push(" as ", print("exported"));
  36906. }
  36907. parts.push(printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
  36908. return parts;
  36909. }
  36910. function shouldExportDeclarationPrintSemi(node, options) {
  36911. if (!options.semi) {
  36912. return false;
  36913. }
  36914. const {
  36915. type,
  36916. declaration
  36917. } = node;
  36918. const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
  36919. if (!declaration) {
  36920. return true;
  36921. }
  36922. const {
  36923. type: declarationType
  36924. } = declaration;
  36925. if (isDefaultExport && declarationType !== "ClassDeclaration" && declarationType !== "FunctionDeclaration" && declarationType !== "TSInterfaceDeclaration" && declarationType !== "DeclareClass" && declarationType !== "DeclareFunction" && declarationType !== "TSDeclareFunction" && declarationType !== "EnumDeclaration") {
  36926. return true;
  36927. }
  36928. return false;
  36929. }
  36930. function printModuleSource(path, options, print) {
  36931. const node = path.getValue();
  36932. if (!node.source) {
  36933. return "";
  36934. }
  36935. /** @type{Doc[]} */
  36936. const parts = [];
  36937. if (!shouldNotPrintSpecifiers(node, options)) {
  36938. parts.push(" from");
  36939. }
  36940. parts.push(" ", print("source"));
  36941. return parts;
  36942. }
  36943. function printModuleSpecifiers(path, options, print) {
  36944. const node = path.getValue();
  36945. if (shouldNotPrintSpecifiers(node, options)) {
  36946. return "";
  36947. }
  36948. /** @type{Doc[]} */
  36949. const parts = [" "];
  36950. if (isNonEmptyArray$9(node.specifiers)) {
  36951. const standaloneSpecifiers = [];
  36952. const groupedSpecifiers = [];
  36953. path.each(() => {
  36954. const specifierType = path.getValue().type;
  36955. if (specifierType === "ExportNamespaceSpecifier" || specifierType === "ExportDefaultSpecifier" || specifierType === "ImportNamespaceSpecifier" || specifierType === "ImportDefaultSpecifier") {
  36956. standaloneSpecifiers.push(print());
  36957. } else if (specifierType === "ExportSpecifier" || specifierType === "ImportSpecifier") {
  36958. groupedSpecifiers.push(print());
  36959. } else {
  36960. /* istanbul ignore next */
  36961. throw new Error(`Unknown specifier type ${JSON.stringify(specifierType)}`);
  36962. }
  36963. }, "specifiers");
  36964. parts.push(join$f(", ", standaloneSpecifiers));
  36965. if (groupedSpecifiers.length > 0) {
  36966. if (standaloneSpecifiers.length > 0) {
  36967. parts.push(", ");
  36968. }
  36969. const canBreak = groupedSpecifiers.length > 1 || standaloneSpecifiers.length > 0 || node.specifiers.some(node => hasComment$4(node));
  36970. if (canBreak) {
  36971. parts.push(group$k(["{", indent$f([options.bracketSpacing ? line$i : softline$g, join$f([",", line$i], groupedSpecifiers)]), ifBreak$c(shouldPrintComma$4(options) ? "," : ""), options.bracketSpacing ? line$i : softline$g, "}"]));
  36972. } else {
  36973. parts.push(["{", options.bracketSpacing ? " " : "", ...groupedSpecifiers, options.bracketSpacing ? " " : "", "}"]);
  36974. }
  36975. }
  36976. } else {
  36977. parts.push("{}");
  36978. }
  36979. return parts;
  36980. }
  36981. function shouldNotPrintSpecifiers(node, options) {
  36982. const {
  36983. type,
  36984. importKind,
  36985. source,
  36986. specifiers
  36987. } = node;
  36988. if (type !== "ImportDeclaration" || isNonEmptyArray$9(specifiers) || importKind === "type") {
  36989. return false;
  36990. } // TODO: check tokens
  36991. return !/{\s*}/.test(options.originalText.slice(locStart$l(node), locStart$l(source)));
  36992. }
  36993. function printImportAssertions(path, options, print) {
  36994. const node = path.getNode();
  36995. if (isNonEmptyArray$9(node.assertions)) {
  36996. return [" assert {", options.bracketSpacing ? " " : "", join$f(", ", path.map(print, "assertions")), options.bracketSpacing ? " " : "", "}"];
  36997. }
  36998. return "";
  36999. }
  37000. function printModuleSpecifier$1(path, options, print) {
  37001. const node = path.getNode();
  37002. const {
  37003. type,
  37004. importKind
  37005. } = node;
  37006. /** @type{Doc[]} */
  37007. const parts = [];
  37008. if (type === "ImportSpecifier" && importKind) {
  37009. parts.push(importKind, " ");
  37010. }
  37011. const isImport = type.startsWith("Import");
  37012. const leftSideProperty = isImport ? "imported" : "local";
  37013. const rightSideProperty = isImport ? "local" : "exported";
  37014. let left = "";
  37015. let right = "";
  37016. if (type === "ExportNamespaceSpecifier" || type === "ImportNamespaceSpecifier") {
  37017. left = "*";
  37018. } else if (node[leftSideProperty]) {
  37019. left = print(leftSideProperty);
  37020. }
  37021. if (node[rightSideProperty] && (!node[leftSideProperty] || // import {a as a} from '.'
  37022. !hasSameLoc(node[leftSideProperty], node[rightSideProperty]))) {
  37023. right = print(rightSideProperty);
  37024. }
  37025. parts.push(left, left && right ? " as " : "", right);
  37026. return parts;
  37027. }
  37028. var module$1 = {
  37029. printImportDeclaration: printImportDeclaration$1,
  37030. printExportDeclaration: printExportDeclaration$2,
  37031. printExportAllDeclaration: printExportAllDeclaration$2,
  37032. printModuleSpecifier: printModuleSpecifier$1
  37033. };
  37034. const {
  37035. printDanglingComments: printDanglingComments$4
  37036. } = comments$1;
  37037. const {
  37038. builders: {
  37039. line: line$h,
  37040. softline: softline$f,
  37041. group: group$j,
  37042. indent: indent$e,
  37043. ifBreak: ifBreak$b,
  37044. hardline: hardline$m
  37045. }
  37046. } = doc;
  37047. const {
  37048. getLast: getLast$5,
  37049. hasNewlineInRange: hasNewlineInRange$2,
  37050. hasNewline: hasNewline$3,
  37051. isNonEmptyArray: isNonEmptyArray$8
  37052. } = util$5;
  37053. const {
  37054. shouldPrintComma: shouldPrintComma$3,
  37055. hasComment: hasComment$3,
  37056. getComments: getComments$1,
  37057. CommentCheckFlags: CommentCheckFlags$3,
  37058. isNextLineEmpty: isNextLineEmpty$7
  37059. } = utils$5;
  37060. const {
  37061. locStart: locStart$k,
  37062. locEnd: locEnd$j
  37063. } = loc$6;
  37064. const {
  37065. printOptionalToken: printOptionalToken$3,
  37066. printTypeAnnotation: printTypeAnnotation$2
  37067. } = misc$1;
  37068. const {
  37069. shouldHugFunctionParameters
  37070. } = functionParameters;
  37071. const {
  37072. shouldHugType
  37073. } = typeAnnotation;
  37074. const {
  37075. printHardlineAfterHeritage: printHardlineAfterHeritage$1
  37076. } = _class;
  37077. /** @typedef {import("../../document").Doc} Doc */
  37078. function printObject$3(path, options, print) {
  37079. const semi = options.semi ? ";" : "";
  37080. const node = path.getValue();
  37081. let propertiesField;
  37082. if (node.type === "TSTypeLiteral") {
  37083. propertiesField = "members";
  37084. } else if (node.type === "TSInterfaceBody") {
  37085. propertiesField = "body";
  37086. } else {
  37087. propertiesField = "properties";
  37088. }
  37089. const isTypeAnnotation = node.type === "ObjectTypeAnnotation";
  37090. const fields = [propertiesField];
  37091. if (isTypeAnnotation) {
  37092. fields.push("indexers", "callProperties", "internalSlots");
  37093. }
  37094. const firstProperty = fields.map(field => node[field][0]).sort((a, b) => locStart$k(a) - locStart$k(b))[0];
  37095. const parent = path.getParentNode(0);
  37096. const isFlowInterfaceLikeBody = isTypeAnnotation && parent && (parent.type === "InterfaceDeclaration" || parent.type === "DeclareInterface" || parent.type === "DeclareClass") && path.getName() === "body";
  37097. const shouldBreak = node.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || node.type === "ObjectPattern" && parent.type !== "FunctionDeclaration" && parent.type !== "FunctionExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "ObjectMethod" && parent.type !== "ClassMethod" && parent.type !== "ClassPrivateMethod" && parent.type !== "AssignmentPattern" && parent.type !== "CatchClause" && node.properties.some(property => property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern")) || node.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$2(options.originalText, locStart$k(node), locStart$k(firstProperty));
  37098. const separator = isFlowInterfaceLikeBody ? ";" : node.type === "TSInterfaceBody" || node.type === "TSTypeLiteral" ? ifBreak$b(semi, ";") : ",";
  37099. const leftBrace = node.type === "RecordExpression" ? "#{" : node.exact ? "{|" : "{";
  37100. const rightBrace = node.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  37101. // interleaved in the source code. So we need to reorder them before
  37102. // printing them.
  37103. const propsAndLoc = [];
  37104. for (const field of fields) {
  37105. path.each(childPath => {
  37106. const node = childPath.getValue();
  37107. propsAndLoc.push({
  37108. node,
  37109. printed: print(),
  37110. loc: locStart$k(node)
  37111. });
  37112. }, field);
  37113. }
  37114. if (fields.length > 1) {
  37115. propsAndLoc.sort((a, b) => a.loc - b.loc);
  37116. }
  37117. /** @type {Doc[]} */
  37118. let separatorParts = [];
  37119. const props = propsAndLoc.map(prop => {
  37120. const result = [...separatorParts, group$j(prop.printed)];
  37121. separatorParts = [separator, line$h];
  37122. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasComment$3(prop.node, CommentCheckFlags$3.PrettierIgnore)) {
  37123. separatorParts.shift();
  37124. }
  37125. if (isNextLineEmpty$7(prop.node, options)) {
  37126. separatorParts.push(hardline$m);
  37127. }
  37128. return result;
  37129. });
  37130. if (node.inexact) {
  37131. let printed;
  37132. if (hasComment$3(node, CommentCheckFlags$3.Dangling)) {
  37133. const hasLineComments = hasComment$3(node, CommentCheckFlags$3.Line);
  37134. const printedDanglingComments = printDanglingComments$4(path, options,
  37135. /* sameIndent */
  37136. true);
  37137. printed = [printedDanglingComments, hasLineComments || hasNewline$3(options.originalText, locEnd$j(getLast$5(getComments$1(node)))) ? hardline$m : line$h, "..."];
  37138. } else {
  37139. printed = ["..."];
  37140. }
  37141. props.push([...separatorParts, ...printed]);
  37142. }
  37143. const lastElem = getLast$5(node[propertiesField]);
  37144. const canHaveTrailingSeparator = !(node.inexact || lastElem && lastElem.type === "RestElement" || lastElem && (lastElem.type === "TSPropertySignature" || lastElem.type === "TSCallSignatureDeclaration" || lastElem.type === "TSMethodSignature" || lastElem.type === "TSConstructSignatureDeclaration") && hasComment$3(lastElem, CommentCheckFlags$3.PrettierIgnore));
  37145. let content;
  37146. if (props.length === 0) {
  37147. if (!hasComment$3(node, CommentCheckFlags$3.Dangling)) {
  37148. return [leftBrace, rightBrace, printTypeAnnotation$2(path, options, print)];
  37149. }
  37150. content = group$j([leftBrace, printDanglingComments$4(path, options), softline$f, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)]);
  37151. } else {
  37152. content = [isFlowInterfaceLikeBody && isNonEmptyArray$8(node.properties) ? printHardlineAfterHeritage$1(parent) : "", leftBrace, indent$e([options.bracketSpacing ? line$h : softline$f, ...props]), ifBreak$b(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$3(options)) ? separator : ""), options.bracketSpacing ? line$h : softline$f, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)];
  37153. } // If we inline the object as first argument of the parent, we don't want
  37154. // to create another group so that the object breaks before the return
  37155. // type
  37156. if (path.match(node => node.type === "ObjectPattern" && !node.decorators, (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || path.match(shouldHugType, (node, name) => name === "typeAnnotation", (node, name) => name === "typeAnnotation", (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || !shouldBreak && path.match(node => node.type === "ObjectPattern", node => node.type === "AssignmentExpression" || node.type === "VariableDeclarator")) {
  37157. return content;
  37158. }
  37159. return group$j(content, {
  37160. shouldBreak
  37161. });
  37162. }
  37163. var object$1 = {
  37164. printObject: printObject$3
  37165. };
  37166. /** @typedef {import("../../document").Doc} Doc */
  37167. const {
  37168. printDanglingComments: printDanglingComments$3
  37169. } = comments$1;
  37170. const {
  37171. printString: printString$2,
  37172. printNumber: printNumber$2
  37173. } = util$5;
  37174. const {
  37175. builders: {
  37176. hardline: hardline$l,
  37177. softline: softline$e,
  37178. group: group$i,
  37179. indent: indent$d
  37180. }
  37181. } = doc;
  37182. const {
  37183. getParentExportDeclaration,
  37184. isFunctionNotation,
  37185. isGetterOrSetter,
  37186. rawText: rawText$1,
  37187. shouldPrintComma: shouldPrintComma$2
  37188. } = utils$5;
  37189. const {
  37190. locStart: locStart$j,
  37191. locEnd: locEnd$i
  37192. } = loc$6;
  37193. const {
  37194. printClass: printClass$1
  37195. } = _class;
  37196. const {
  37197. printOpaqueType,
  37198. printTypeAlias: printTypeAlias$1,
  37199. printIntersectionType: printIntersectionType$1,
  37200. printUnionType: printUnionType$1,
  37201. printFunctionType: printFunctionType$1,
  37202. printTupleType: printTupleType$1,
  37203. printIndexedAccessType: printIndexedAccessType$1
  37204. } = typeAnnotation;
  37205. const {
  37206. printInterface: printInterface$1
  37207. } = _interface;
  37208. const {
  37209. printTypeParameter: printTypeParameter$1,
  37210. printTypeParameters: printTypeParameters$1
  37211. } = typeParameters;
  37212. const {
  37213. printExportDeclaration: printExportDeclaration$1,
  37214. printExportAllDeclaration: printExportAllDeclaration$1
  37215. } = module$1;
  37216. const {
  37217. printArrayItems: printArrayItems$1
  37218. } = array;
  37219. const {
  37220. printObject: printObject$2
  37221. } = object$1;
  37222. const {
  37223. printPropertyKey: printPropertyKey$1
  37224. } = property;
  37225. const {
  37226. printOptionalToken: printOptionalToken$2,
  37227. printTypeAnnotation: printTypeAnnotation$1,
  37228. printRestSpread: printRestSpread$1
  37229. } = misc$1;
  37230. function printFlow$1(path, options, print) {
  37231. const node = path.getValue();
  37232. const semi = options.semi ? ";" : "";
  37233. /** @type{Doc[]} */
  37234. const parts = [];
  37235. switch (node.type) {
  37236. case "DeclareClass":
  37237. return printFlowDeclaration(path, printClass$1(path, options, print));
  37238. case "DeclareFunction":
  37239. return printFlowDeclaration(path, ["function ", print("id"), node.predicate ? " " : "", print("predicate"), semi]);
  37240. case "DeclareModule":
  37241. return printFlowDeclaration(path, ["module ", print("id"), " ", print("body")]);
  37242. case "DeclareModuleExports":
  37243. return printFlowDeclaration(path, ["module.exports", ": ", print("typeAnnotation"), semi]);
  37244. case "DeclareVariable":
  37245. return printFlowDeclaration(path, ["var ", print("id"), semi]);
  37246. case "DeclareOpaqueType":
  37247. return printFlowDeclaration(path, printOpaqueType(path, options, print));
  37248. case "DeclareInterface":
  37249. return printFlowDeclaration(path, printInterface$1(path, options, print));
  37250. case "DeclareTypeAlias":
  37251. return printFlowDeclaration(path, printTypeAlias$1(path, options, print));
  37252. case "DeclareExportDeclaration":
  37253. return printFlowDeclaration(path, printExportDeclaration$1(path, options, print));
  37254. case "DeclareExportAllDeclaration":
  37255. return printFlowDeclaration(path, printExportAllDeclaration$1(path, options, print));
  37256. case "OpaqueType":
  37257. return printOpaqueType(path, options, print);
  37258. case "TypeAlias":
  37259. return printTypeAlias$1(path, options, print);
  37260. case "IntersectionTypeAnnotation":
  37261. return printIntersectionType$1(path, options, print);
  37262. case "UnionTypeAnnotation":
  37263. return printUnionType$1(path, options, print);
  37264. case "FunctionTypeAnnotation":
  37265. return printFunctionType$1(path, options, print);
  37266. case "TupleTypeAnnotation":
  37267. return printTupleType$1(path, options, print);
  37268. case "GenericTypeAnnotation":
  37269. return [print("id"), printTypeParameters$1(path, options, print, "typeParameters")];
  37270. case "IndexedAccessType":
  37271. case "OptionalIndexedAccessType":
  37272. return printIndexedAccessType$1(path, options, print);
  37273. // Type Annotations for Facebook Flow, typically stripped out or
  37274. // transformed away before printing.
  37275. case "TypeAnnotation":
  37276. return print("typeAnnotation");
  37277. case "TypeParameter":
  37278. return printTypeParameter$1(path, options, print);
  37279. case "TypeofTypeAnnotation":
  37280. return ["typeof ", print("argument")];
  37281. case "ExistsTypeAnnotation":
  37282. return "*";
  37283. case "EmptyTypeAnnotation":
  37284. return "empty";
  37285. case "MixedTypeAnnotation":
  37286. return "mixed";
  37287. case "ArrayTypeAnnotation":
  37288. return [print("elementType"), "[]"];
  37289. case "BooleanLiteralTypeAnnotation":
  37290. return String(node.value);
  37291. case "EnumDeclaration":
  37292. return ["enum ", print("id"), " ", print("body")];
  37293. case "EnumBooleanBody":
  37294. case "EnumNumberBody":
  37295. case "EnumStringBody":
  37296. case "EnumSymbolBody":
  37297. {
  37298. if (node.type === "EnumSymbolBody" || node.explicitType) {
  37299. let type = null;
  37300. switch (node.type) {
  37301. case "EnumBooleanBody":
  37302. type = "boolean";
  37303. break;
  37304. case "EnumNumberBody":
  37305. type = "number";
  37306. break;
  37307. case "EnumStringBody":
  37308. type = "string";
  37309. break;
  37310. case "EnumSymbolBody":
  37311. type = "symbol";
  37312. break;
  37313. }
  37314. parts.push("of ", type, " ");
  37315. }
  37316. if (node.members.length === 0 && !node.hasUnknownMembers) {
  37317. parts.push(group$i(["{", printDanglingComments$3(path, options), softline$e, "}"]));
  37318. } else {
  37319. const members = node.members.length > 0 ? [hardline$l, printArrayItems$1(path, options, "members", print), node.hasUnknownMembers || shouldPrintComma$2(options) ? "," : ""] : [];
  37320. parts.push(group$i(["{", indent$d([...members, ...(node.hasUnknownMembers ? [hardline$l, "..."] : [])]), printDanglingComments$3(path, options,
  37321. /* sameIndent */
  37322. true), hardline$l, "}"]));
  37323. }
  37324. return parts;
  37325. }
  37326. case "EnumBooleanMember":
  37327. case "EnumNumberMember":
  37328. case "EnumStringMember":
  37329. return [print("id"), " = ", typeof node.init === "object" ? print("init") : String(node.init)];
  37330. case "EnumDefaultedMember":
  37331. return print("id");
  37332. case "FunctionTypeParam":
  37333. {
  37334. const name = node.name ? print("name") : path.getParentNode().this === node ? "this" : "";
  37335. return [name, printOptionalToken$2(path), name ? ": " : "", print("typeAnnotation")];
  37336. }
  37337. case "InterfaceDeclaration":
  37338. case "InterfaceTypeAnnotation":
  37339. return printInterface$1(path, options, print);
  37340. case "ClassImplements":
  37341. case "InterfaceExtends":
  37342. return [print("id"), print("typeParameters")];
  37343. case "NullableTypeAnnotation":
  37344. return ["?", print("typeAnnotation")];
  37345. case "Variance":
  37346. {
  37347. const {
  37348. kind
  37349. } = node;
  37350. assert__default['default'].ok(kind === "plus" || kind === "minus");
  37351. return kind === "plus" ? "+" : "-";
  37352. }
  37353. case "ObjectTypeCallProperty":
  37354. if (node.static) {
  37355. parts.push("static ");
  37356. }
  37357. parts.push(print("value"));
  37358. return parts;
  37359. case "ObjectTypeIndexer":
  37360. {
  37361. return [node.variance ? print("variance") : "", "[", print("id"), node.id ? ": " : "", print("key"), "]: ", print("value")];
  37362. }
  37363. case "ObjectTypeProperty":
  37364. {
  37365. let modifier = "";
  37366. if (node.proto) {
  37367. modifier = "proto ";
  37368. } else if (node.static) {
  37369. modifier = "static ";
  37370. }
  37371. return [modifier, isGetterOrSetter(node) ? node.kind + " " : "", node.variance ? print("variance") : "", printPropertyKey$1(path, options, print), printOptionalToken$2(path), isFunctionNotation(node) ? "" : ": ", print("value")];
  37372. }
  37373. case "ObjectTypeAnnotation":
  37374. return printObject$2(path, options, print);
  37375. case "ObjectTypeInternalSlot":
  37376. return [node.static ? "static " : "", "[[", print("id"), "]]", printOptionalToken$2(path), node.method ? "" : ": ", print("value")];
  37377. // Same as `RestElement`
  37378. case "ObjectTypeSpreadProperty":
  37379. return printRestSpread$1(path, options, print);
  37380. case "QualifiedTypeIdentifier":
  37381. return [print("qualification"), ".", print("id")];
  37382. case "StringLiteralTypeAnnotation":
  37383. return printString$2(rawText$1(node), options);
  37384. case "NumberLiteralTypeAnnotation":
  37385. assert__default['default'].strictEqual(typeof node.value, "number");
  37386. // fall through
  37387. case "BigIntLiteralTypeAnnotation":
  37388. if (node.extra) {
  37389. return printNumber$2(node.extra.raw);
  37390. }
  37391. return printNumber$2(node.raw);
  37392. case "TypeCastExpression":
  37393. {
  37394. return ["(", print("expression"), printTypeAnnotation$1(path, options, print), ")"];
  37395. }
  37396. case "TypeParameterDeclaration":
  37397. case "TypeParameterInstantiation":
  37398. {
  37399. const printed = printTypeParameters$1(path, options, print, "params");
  37400. if (options.parser === "flow") {
  37401. const start = locStart$j(node);
  37402. const end = locEnd$i(node);
  37403. const commentStartIndex = options.originalText.lastIndexOf("/*", start);
  37404. const commentEndIndex = options.originalText.indexOf("*/", end);
  37405. if (commentStartIndex !== -1 && commentEndIndex !== -1) {
  37406. const comment = options.originalText.slice(commentStartIndex + 2, commentEndIndex).trim();
  37407. if (comment.startsWith("::") && !comment.includes("/*") && !comment.includes("*/")) {
  37408. return ["/*:: ", printed, " */"];
  37409. }
  37410. }
  37411. }
  37412. return printed;
  37413. }
  37414. case "InferredPredicate":
  37415. return "%checks";
  37416. // Unhandled types below. If encountered, nodes of these types should
  37417. // be either left alone or desugared into AST types that are fully
  37418. // supported by the pretty-printer.
  37419. case "DeclaredPredicate":
  37420. return ["%checks(", print("value"), ")"];
  37421. case "AnyTypeAnnotation":
  37422. return "any";
  37423. case "BooleanTypeAnnotation":
  37424. return "boolean";
  37425. case "BigIntTypeAnnotation":
  37426. return "bigint";
  37427. case "NullLiteralTypeAnnotation":
  37428. return "null";
  37429. case "NumberTypeAnnotation":
  37430. return "number";
  37431. case "SymbolTypeAnnotation":
  37432. return "symbol";
  37433. case "StringTypeAnnotation":
  37434. return "string";
  37435. case "VoidTypeAnnotation":
  37436. return "void";
  37437. case "ThisTypeAnnotation":
  37438. return "this";
  37439. // These types are unprintable because they serve as abstract
  37440. // supertypes for other (printable) types.
  37441. case "Node":
  37442. case "Printable":
  37443. case "SourceLocation":
  37444. case "Position":
  37445. case "Statement":
  37446. case "Function":
  37447. case "Pattern":
  37448. case "Expression":
  37449. case "Declaration":
  37450. case "Specifier":
  37451. case "NamedSpecifier":
  37452. case "Comment":
  37453. case "MemberTypeAnnotation": // Flow
  37454. case "Type":
  37455. /* istanbul ignore next */
  37456. throw new Error("unprintable type: " + JSON.stringify(node.type));
  37457. }
  37458. }
  37459. function printFlowDeclaration(path, printed) {
  37460. const parentExportDecl = getParentExportDeclaration(path);
  37461. if (parentExportDecl) {
  37462. assert__default['default'].strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  37463. return printed;
  37464. } // If the parent node has type DeclareExportDeclaration, then it
  37465. // will be responsible for printing the "declare" token. Otherwise
  37466. // it needs to be printed with this non-exported declaration node.
  37467. return ["declare ", printed];
  37468. }
  37469. var flow = {
  37470. printFlow: printFlow$1
  37471. };
  37472. const {
  37473. hasNewlineInRange: hasNewlineInRange$1
  37474. } = util$5;
  37475. const {
  37476. isJsxNode: isJsxNode$1,
  37477. isBlockComment: isBlockComment$2,
  37478. getComments,
  37479. isCallExpression: isCallExpression$2,
  37480. isMemberExpression: isMemberExpression$2
  37481. } = utils$5;
  37482. const {
  37483. locStart: locStart$i,
  37484. locEnd: locEnd$h
  37485. } = loc$6;
  37486. const {
  37487. builders: {
  37488. line: line$g,
  37489. softline: softline$d,
  37490. group: group$h,
  37491. indent: indent$c,
  37492. align: align$2,
  37493. ifBreak: ifBreak$a,
  37494. dedent: dedent$3,
  37495. breakParent: breakParent$6
  37496. }
  37497. } = doc;
  37498. /**
  37499. * @typedef {import("../../document").Doc} Doc
  37500. * @typedef {import("../../common/ast-path")} AstPath
  37501. *
  37502. * @typedef {any} Options - Prettier options (TBD ...)
  37503. */
  37504. // If we have nested conditional expressions, we want to print them in JSX mode
  37505. // if there's at least one JSXElement somewhere in the tree.
  37506. //
  37507. // A conditional expression chain like this should be printed in normal mode,
  37508. // because there aren't JSXElements anywhere in it:
  37509. //
  37510. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  37511. //
  37512. // But a conditional expression chain like this should be printed in JSX mode,
  37513. // because there is a JSXElement in the last ConditionalExpression:
  37514. //
  37515. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  37516. //
  37517. // This type of ConditionalExpression chain is structured like this in the AST:
  37518. //
  37519. // ConditionalExpression {
  37520. // test: ...,
  37521. // consequent: ...,
  37522. // alternate: ConditionalExpression {
  37523. // test: ...,
  37524. // consequent: ...,
  37525. // alternate: ConditionalExpression {
  37526. // test: ...,
  37527. // consequent: ...,
  37528. // alternate: ...,
  37529. // }
  37530. // }
  37531. // }
  37532. function conditionalExpressionChainContainsJsx(node) {
  37533. // Given this code:
  37534. //
  37535. // // Using a ConditionalExpression as the consequent is uncommon, but should
  37536. // // be handled.
  37537. // A ? B : C ? D : E ? F ? G : H : I
  37538. //
  37539. // which has this AST:
  37540. //
  37541. // ConditionalExpression {
  37542. // test: Identifier(A),
  37543. // consequent: Identifier(B),
  37544. // alternate: ConditionalExpression {
  37545. // test: Identifier(C),
  37546. // consequent: Identifier(D),
  37547. // alternate: ConditionalExpression {
  37548. // test: Identifier(E),
  37549. // consequent: ConditionalExpression {
  37550. // test: Identifier(F),
  37551. // consequent: Identifier(G),
  37552. // alternate: Identifier(H),
  37553. // },
  37554. // alternate: Identifier(I),
  37555. // }
  37556. // }
  37557. // }
  37558. //
  37559. // We don't care about whether each node was the test, consequent, or alternate
  37560. // We are only checking if there's any JSXElements inside.
  37561. const conditionalExpressions = [node];
  37562. for (let index = 0; index < conditionalExpressions.length; index++) {
  37563. const conditionalExpression = conditionalExpressions[index];
  37564. for (const property of ["test", "consequent", "alternate"]) {
  37565. const node = conditionalExpression[property];
  37566. if (isJsxNode$1(node)) {
  37567. return true;
  37568. }
  37569. if (node.type === "ConditionalExpression") {
  37570. conditionalExpressions.push(node);
  37571. }
  37572. }
  37573. }
  37574. return false;
  37575. }
  37576. function printTernaryTest(path, options, print) {
  37577. const node = path.getValue();
  37578. const isConditionalExpression = node.type === "ConditionalExpression";
  37579. const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
  37580. const parent = path.getParentNode();
  37581. const printed = isConditionalExpression ? print("test") : [print("checkType"), " ", "extends", " ", print("extendsType")];
  37582. /**
  37583. * a
  37584. * ? b
  37585. * : multiline
  37586. * test
  37587. * node
  37588. * ^^ align(2)
  37589. * ? d
  37590. * : e
  37591. */
  37592. if (parent.type === node.type && parent[alternateNodePropertyName] === node) {
  37593. return align$2(2, printed);
  37594. }
  37595. return printed;
  37596. }
  37597. const ancestorNameMap = new Map([["AssignmentExpression", "right"], ["VariableDeclarator", "init"], ["ReturnStatement", "argument"], ["ThrowStatement", "argument"], ["UnaryExpression", "argument"], ["YieldExpression", "argument"]]);
  37598. function shouldExtraIndentForConditionalExpression(path) {
  37599. const node = path.getValue();
  37600. if (node.type !== "ConditionalExpression") {
  37601. return false;
  37602. }
  37603. let parent;
  37604. let child = node;
  37605. for (let ancestorCount = 0; !parent; ancestorCount++) {
  37606. const node = path.getParentNode(ancestorCount);
  37607. if (isCallExpression$2(node) && node.callee === child || isMemberExpression$2(node) && node.object === child || node.type === "TSNonNullExpression" && node.expression === child) {
  37608. child = node;
  37609. continue;
  37610. } // Reached chain root
  37611. if (node.type === "NewExpression" && node.callee === child || node.type === "TSAsExpression" && node.expression === child) {
  37612. parent = path.getParentNode(ancestorCount + 1);
  37613. child = node;
  37614. } else {
  37615. parent = node;
  37616. }
  37617. } // Do not add indent to direct `ConditionalExpression`
  37618. if (child === node) {
  37619. return false;
  37620. }
  37621. return parent[ancestorNameMap.get(parent.type)] === child;
  37622. }
  37623. /**
  37624. * The following is the shared logic for
  37625. * ternary operators, namely ConditionalExpression
  37626. * and TSConditionalType
  37627. * @param {AstPath} path - The path to the ConditionalExpression/TSConditionalType node.
  37628. * @param {Options} options - Prettier options
  37629. * @param {Function} print - Print function to call recursively
  37630. * @returns {Doc}
  37631. */
  37632. function printTernary$2(path, options, print) {
  37633. const node = path.getValue();
  37634. const isConditionalExpression = node.type === "ConditionalExpression";
  37635. const consequentNodePropertyName = isConditionalExpression ? "consequent" : "trueType";
  37636. const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
  37637. const testNodePropertyNames = isConditionalExpression ? ["test"] : ["checkType", "extendsType"];
  37638. const consequentNode = node[consequentNodePropertyName];
  37639. const alternateNode = node[alternateNodePropertyName];
  37640. const parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  37641. // See `tests/format/jsx/conditional-expression.js` for more info.
  37642. let jsxMode = false;
  37643. const parent = path.getParentNode();
  37644. const isParentTest = parent.type === node.type && testNodePropertyNames.some(prop => parent[prop] === node);
  37645. let forceNoIndent = parent.type === node.type && !isParentTest; // Find the outermost non-ConditionalExpression parent, and the outermost
  37646. // ConditionalExpression parent. We'll use these to determine if we should
  37647. // print in JSX mode.
  37648. let currentParent;
  37649. let previousParent;
  37650. let i = 0;
  37651. do {
  37652. previousParent = currentParent || node;
  37653. currentParent = path.getParentNode(i);
  37654. i++;
  37655. } while (currentParent && currentParent.type === node.type && testNodePropertyNames.every(prop => currentParent[prop] !== previousParent));
  37656. const firstNonConditionalParent = currentParent || parent;
  37657. const lastConditionalParent = previousParent;
  37658. if (isConditionalExpression && (isJsxNode$1(node[testNodePropertyNames[0]]) || isJsxNode$1(consequentNode) || isJsxNode$1(alternateNode) || conditionalExpressionChainContainsJsx(lastConditionalParent))) {
  37659. jsxMode = true;
  37660. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  37661. // parens when using ?: within JSX, because the parens are analogous to
  37662. // curly braces in an if statement.
  37663. const wrap = doc => [ifBreak$a("("), indent$c([softline$d, doc]), softline$d, ifBreak$a(")")]; // The only things we don't wrap are:
  37664. // * Nested conditional expressions in alternates
  37665. // * null
  37666. // * undefined
  37667. const isNil = node => node.type === "NullLiteral" || node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined";
  37668. parts.push(" ? ", isNil(consequentNode) ? print(consequentNodePropertyName) : wrap(print(consequentNodePropertyName)), " : ", alternateNode.type === node.type || isNil(alternateNode) ? print(alternateNodePropertyName) : wrap(print(alternateNodePropertyName)));
  37669. } else {
  37670. // normal mode
  37671. const part = [line$g, "? ", consequentNode.type === node.type ? ifBreak$a("", "(") : "", align$2(2, print(consequentNodePropertyName)), consequentNode.type === node.type ? ifBreak$a("", ")") : "", line$g, ": ", alternateNode.type === node.type ? print(alternateNodePropertyName) : align$2(2, print(alternateNodePropertyName))];
  37672. parts.push(parent.type !== node.type || parent[alternateNodePropertyName] === node || isParentTest ? part : options.useTabs ? dedent$3(indent$c(part)) : align$2(Math.max(0, options.tabWidth - 2), part));
  37673. } // We want a whole chain of ConditionalExpressions to all
  37674. // break if any of them break. That means we should only group around the
  37675. // outer-most ConditionalExpression.
  37676. const comments = [...testNodePropertyNames.map(propertyName => getComments(node[propertyName])), getComments(consequentNode), getComments(alternateNode)].flat();
  37677. const shouldBreak = comments.some(comment => isBlockComment$2(comment) && hasNewlineInRange$1(options.originalText, locStart$i(comment), locEnd$h(comment)));
  37678. const maybeGroup = doc => parent === firstNonConditionalParent ? group$h(doc, {
  37679. shouldBreak
  37680. }) : shouldBreak ? [doc, breakParent$6] : doc; // Break the closing paren to keep the chain right after it:
  37681. // (a
  37682. // ? b
  37683. // : c
  37684. // ).call()
  37685. const breakClosingParen = !jsxMode && (isMemberExpression$2(parent) || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
  37686. const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
  37687. const result = maybeGroup([printTernaryTest(path, options, print), forceNoIndent ? parts : indent$c(parts), isConditionalExpression && breakClosingParen && !shouldExtraIndent ? softline$d : ""]);
  37688. return isParentTest || shouldExtraIndent ? group$h([indent$c([softline$d, result]), softline$d]) : result;
  37689. }
  37690. var ternary = {
  37691. printTernary: printTernary$2
  37692. };
  37693. const {
  37694. builders: {
  37695. hardline: hardline$k
  37696. }
  37697. } = doc;
  37698. const {
  37699. getLeftSidePathName,
  37700. hasNakedLeftSide,
  37701. isJsxNode,
  37702. isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$1,
  37703. hasComment: hasComment$2,
  37704. CommentCheckFlags: CommentCheckFlags$2,
  37705. isNextLineEmpty: isNextLineEmpty$6
  37706. } = utils$5;
  37707. const {
  37708. shouldPrintParamsWithoutParens
  37709. } = _function;
  37710. /**
  37711. * @typedef {import("../../document").Doc} Doc
  37712. * @typedef {import("../../common/ast-path")} AstPath
  37713. */
  37714. function printStatementSequence(path, options, print, property) {
  37715. const node = path.getValue();
  37716. const parts = [];
  37717. const isClassBody = node.type === "ClassBody";
  37718. const lastStatement = getLastStatement(node[property]);
  37719. path.each((path, index, statements) => {
  37720. const node = path.getValue(); // Skip printing EmptyStatement nodes to avoid leaving stray
  37721. // semicolons lying around.
  37722. if (node.type === "EmptyStatement") {
  37723. return;
  37724. }
  37725. const printed = print(); // in no-semi mode, prepend statement with semicolon if it might break ASI
  37726. // don't prepend the only JSX element in a program with semicolon
  37727. if (!options.semi && !isClassBody && !isTheOnlyJsxElementInMarkdown$1(options, path) && statementNeedsASIProtection(path, options)) {
  37728. if (hasComment$2(node, CommentCheckFlags$2.Leading)) {
  37729. parts.push(print([], {
  37730. needsSemi: true
  37731. }));
  37732. } else {
  37733. parts.push(";", printed);
  37734. }
  37735. } else {
  37736. parts.push(printed);
  37737. }
  37738. if (!options.semi && isClassBody && isClassProperty(node) && // `ClassBody` don't allow `EmptyStatement`,
  37739. // so we can use `statements` to get next node
  37740. shouldPrintSemicolonAfterClassProperty(node, statements[index + 1])) {
  37741. parts.push(";");
  37742. }
  37743. if (node !== lastStatement) {
  37744. parts.push(hardline$k);
  37745. if (isNextLineEmpty$6(node, options)) {
  37746. parts.push(hardline$k);
  37747. }
  37748. }
  37749. }, property);
  37750. return parts;
  37751. }
  37752. function getLastStatement(statements) {
  37753. for (let i = statements.length - 1; i >= 0; i--) {
  37754. const statement = statements[i];
  37755. if (statement.type !== "EmptyStatement") {
  37756. return statement;
  37757. }
  37758. }
  37759. }
  37760. function statementNeedsASIProtection(path, options) {
  37761. const node = path.getNode();
  37762. if (node.type !== "ExpressionStatement") {
  37763. return false;
  37764. }
  37765. return path.call(childPath => expressionNeedsASIProtection(childPath, options), "expression");
  37766. }
  37767. function expressionNeedsASIProtection(path, options) {
  37768. const node = path.getValue();
  37769. switch (node.type) {
  37770. case "ParenthesizedExpression":
  37771. case "TypeCastExpression":
  37772. case "ArrayExpression":
  37773. case "ArrayPattern":
  37774. case "TemplateLiteral":
  37775. case "TemplateElement":
  37776. case "RegExpLiteral":
  37777. return true;
  37778. case "ArrowFunctionExpression":
  37779. {
  37780. if (!shouldPrintParamsWithoutParens(path, options)) {
  37781. return true;
  37782. }
  37783. break;
  37784. }
  37785. case "UnaryExpression":
  37786. {
  37787. const {
  37788. prefix,
  37789. operator
  37790. } = node;
  37791. if (prefix && (operator === "+" || operator === "-")) {
  37792. return true;
  37793. }
  37794. break;
  37795. }
  37796. case "BindExpression":
  37797. {
  37798. if (!node.object) {
  37799. return true;
  37800. }
  37801. break;
  37802. }
  37803. case "Literal":
  37804. {
  37805. if (node.regex) {
  37806. return true;
  37807. }
  37808. break;
  37809. }
  37810. default:
  37811. {
  37812. if (isJsxNode(node)) {
  37813. return true;
  37814. }
  37815. }
  37816. }
  37817. if (needsParens_1(path, options)) {
  37818. return true;
  37819. }
  37820. if (!hasNakedLeftSide(node)) {
  37821. return false;
  37822. }
  37823. return path.call(childPath => expressionNeedsASIProtection(childPath, options), ...getLeftSidePathName(path, node));
  37824. }
  37825. function printBody$1(path, options, print) {
  37826. return printStatementSequence(path, options, print, "body");
  37827. }
  37828. function printSwitchCaseConsequent$1(path, options, print) {
  37829. return printStatementSequence(path, options, print, "consequent");
  37830. }
  37831. const isClassProperty = ({
  37832. type
  37833. }) => type === "ClassProperty" || type === "PropertyDefinition" || type === "ClassPrivateProperty";
  37834. /**
  37835. * @returns {boolean}
  37836. */
  37837. function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
  37838. const name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  37839. // so isn't properly tested yet.
  37840. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  37841. return true;
  37842. }
  37843. if (!nextNode) {
  37844. return false;
  37845. }
  37846. if (nextNode.static || nextNode.accessibility // TypeScript
  37847. ) {
  37848. return false;
  37849. }
  37850. if (!nextNode.computed) {
  37851. const name = nextNode.key && nextNode.key.name;
  37852. if (name === "in" || name === "instanceof") {
  37853. return true;
  37854. }
  37855. } // Flow variance sigil +/- requires semi if there's no
  37856. // "declare" or "static" keyword before it.
  37857. if (isClassProperty(nextNode) && nextNode.variance && !nextNode.static && !nextNode.declare) {
  37858. return true;
  37859. }
  37860. switch (nextNode.type) {
  37861. case "ClassProperty":
  37862. case "PropertyDefinition":
  37863. case "TSAbstractClassProperty":
  37864. return nextNode.computed;
  37865. case "MethodDefinition": // Flow
  37866. case "TSAbstractMethodDefinition": // TypeScript
  37867. case "ClassMethod":
  37868. case "ClassPrivateMethod":
  37869. {
  37870. // Babel
  37871. const isAsync = nextNode.value ? nextNode.value.async : nextNode.async;
  37872. if (isAsync || nextNode.kind === "get" || nextNode.kind === "set") {
  37873. return false;
  37874. }
  37875. const isGenerator = nextNode.value ? nextNode.value.generator : nextNode.generator;
  37876. if (nextNode.computed || isGenerator) {
  37877. return true;
  37878. }
  37879. return false;
  37880. }
  37881. case "TSIndexSignature":
  37882. return true;
  37883. }
  37884. /* istanbul ignore next */
  37885. return false;
  37886. }
  37887. var statement = {
  37888. printBody: printBody$1,
  37889. printSwitchCaseConsequent: printSwitchCaseConsequent$1
  37890. };
  37891. const {
  37892. printDanglingComments: printDanglingComments$2
  37893. } = comments$1;
  37894. const {
  37895. isNonEmptyArray: isNonEmptyArray$7
  37896. } = util$5;
  37897. const {
  37898. builders: {
  37899. hardline: hardline$j,
  37900. indent: indent$b
  37901. }
  37902. } = doc;
  37903. const {
  37904. hasComment: hasComment$1,
  37905. CommentCheckFlags: CommentCheckFlags$1,
  37906. isNextLineEmpty: isNextLineEmpty$5
  37907. } = utils$5;
  37908. const {
  37909. printHardlineAfterHeritage
  37910. } = _class;
  37911. const {
  37912. printBody
  37913. } = statement;
  37914. /** @typedef {import("../../document").Doc} Doc */
  37915. function printBlock$3(path, options, print) {
  37916. const node = path.getValue();
  37917. const parts = [];
  37918. if (node.type === "StaticBlock") {
  37919. parts.push("static ");
  37920. }
  37921. if (node.type === "ClassBody" && isNonEmptyArray$7(node.body)) {
  37922. const parent = path.getParentNode();
  37923. parts.push(printHardlineAfterHeritage(parent));
  37924. }
  37925. parts.push("{");
  37926. const printed = printBlockBody$1(path, options, print);
  37927. if (printed) {
  37928. parts.push(indent$b([hardline$j, printed]), hardline$j);
  37929. } else {
  37930. const parent = path.getParentNode();
  37931. const parentParent = path.getParentNode(1);
  37932. if (!(parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ObjectMethod" || parent.type === "ClassMethod" || parent.type === "ClassPrivateMethod" || parent.type === "ForStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement" || parent.type === "DoExpression" || parent.type === "CatchClause" && !parentParent.finalizer || parent.type === "TSModuleDeclaration" || parent.type === "TSDeclareFunction" || node.type === "StaticBlock" || node.type === "ClassBody")) {
  37933. parts.push(hardline$j);
  37934. }
  37935. }
  37936. parts.push("}");
  37937. return parts;
  37938. }
  37939. function printBlockBody$1(path, options, print) {
  37940. const node = path.getValue();
  37941. const nodeHasDirectives = isNonEmptyArray$7(node.directives);
  37942. const nodeHasBody = node.body.some(node => node.type !== "EmptyStatement");
  37943. const nodeHasComment = hasComment$1(node, CommentCheckFlags$1.Dangling);
  37944. if (!nodeHasDirectives && !nodeHasBody && !nodeHasComment) {
  37945. return "";
  37946. }
  37947. const parts = []; // Babel 6
  37948. if (nodeHasDirectives) {
  37949. path.each((childPath, index, directives) => {
  37950. parts.push(print());
  37951. if (index < directives.length - 1 || nodeHasBody || nodeHasComment) {
  37952. parts.push(hardline$j);
  37953. if (isNextLineEmpty$5(childPath.getValue(), options)) {
  37954. parts.push(hardline$j);
  37955. }
  37956. }
  37957. }, "directives");
  37958. }
  37959. if (nodeHasBody) {
  37960. parts.push(printBody(path, options, print));
  37961. }
  37962. if (nodeHasComment) {
  37963. parts.push(printDanglingComments$2(path, options,
  37964. /* sameIndent */
  37965. true));
  37966. }
  37967. if (node.type === "Program") {
  37968. const parent = path.getParentNode();
  37969. if (!parent || parent.type !== "ModuleExpression") {
  37970. parts.push(hardline$j);
  37971. }
  37972. }
  37973. return parts;
  37974. }
  37975. var block$1 = {
  37976. printBlock: printBlock$3,
  37977. printBlockBody: printBlockBody$1
  37978. };
  37979. const {
  37980. printDanglingComments: printDanglingComments$1
  37981. } = comments$1;
  37982. const {
  37983. hasNewlineInRange
  37984. } = util$5;
  37985. const {
  37986. builders: {
  37987. join: join$e,
  37988. line: line$f,
  37989. hardline: hardline$i,
  37990. softline: softline$c,
  37991. group: group$g,
  37992. indent: indent$a,
  37993. conditionalGroup: conditionalGroup$1,
  37994. ifBreak: ifBreak$9
  37995. }
  37996. } = doc;
  37997. const {
  37998. isLiteral,
  37999. getTypeScriptMappedTypeModifier,
  38000. shouldPrintComma: shouldPrintComma$1,
  38001. isCallExpression: isCallExpression$1,
  38002. isMemberExpression: isMemberExpression$1
  38003. } = utils$5;
  38004. const {
  38005. locStart: locStart$h,
  38006. locEnd: locEnd$g
  38007. } = loc$6;
  38008. const {
  38009. printOptionalToken: printOptionalToken$1,
  38010. printTypeScriptModifiers
  38011. } = misc$1;
  38012. const {
  38013. printTernary: printTernary$1
  38014. } = ternary;
  38015. const {
  38016. printFunctionParameters,
  38017. shouldGroupFunctionParameters
  38018. } = functionParameters;
  38019. const {
  38020. printTemplateLiteral: printTemplateLiteral$1
  38021. } = templateLiteral;
  38022. const {
  38023. printArrayItems
  38024. } = array;
  38025. const {
  38026. printObject: printObject$1
  38027. } = object$1;
  38028. const {
  38029. printClassProperty: printClassProperty$1,
  38030. printClassMethod: printClassMethod$1
  38031. } = _class;
  38032. const {
  38033. printTypeParameter,
  38034. printTypeParameters
  38035. } = typeParameters;
  38036. const {
  38037. printPropertyKey
  38038. } = property;
  38039. const {
  38040. printFunction: printFunction$1,
  38041. printMethodInternal
  38042. } = _function;
  38043. const {
  38044. printInterface
  38045. } = _interface;
  38046. const {
  38047. printBlock: printBlock$2
  38048. } = block$1;
  38049. const {
  38050. printTypeAlias,
  38051. printIntersectionType,
  38052. printUnionType,
  38053. printFunctionType,
  38054. printTupleType,
  38055. printIndexedAccessType
  38056. } = typeAnnotation;
  38057. function printTypescript$1(path, options, print) {
  38058. const node = path.getValue(); // TypeScript nodes always starts with `TS`
  38059. if (!node.type.startsWith("TS")) {
  38060. return;
  38061. }
  38062. if (node.type.endsWith("Keyword")) {
  38063. return node.type.slice(2, -7).toLowerCase();
  38064. }
  38065. const semi = options.semi ? ";" : "";
  38066. const parts = [];
  38067. switch (node.type) {
  38068. case "TSThisType":
  38069. return "this";
  38070. case "TSTypeAssertion":
  38071. {
  38072. const shouldBreakAfterCast = !(node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression");
  38073. const castGroup = group$g(["<", indent$a([softline$c, print("typeAnnotation")]), softline$c, ">"]);
  38074. const exprContents = [ifBreak$9("("), indent$a([softline$c, print("expression")]), softline$c, ifBreak$9(")")];
  38075. if (shouldBreakAfterCast) {
  38076. return conditionalGroup$1([[castGroup, print("expression")], [castGroup, group$g(exprContents, {
  38077. shouldBreak: true
  38078. })], [castGroup, print("expression")]]);
  38079. }
  38080. return group$g([castGroup, print("expression")]);
  38081. }
  38082. case "TSDeclareFunction":
  38083. return printFunction$1(path, print, options);
  38084. case "TSExportAssignment":
  38085. return ["export = ", print("expression"), semi];
  38086. case "TSModuleBlock":
  38087. return printBlock$2(path, options, print);
  38088. case "TSInterfaceBody":
  38089. case "TSTypeLiteral":
  38090. return printObject$1(path, options, print);
  38091. case "TSTypeAliasDeclaration":
  38092. return printTypeAlias(path, options, print);
  38093. case "TSQualifiedName":
  38094. return join$e(".", [print("left"), print("right")]);
  38095. case "TSAbstractMethodDefinition":
  38096. case "TSDeclareMethod":
  38097. return printClassMethod$1(path, options, print);
  38098. case "TSAbstractClassProperty":
  38099. return printClassProperty$1(path, options, print);
  38100. case "TSInterfaceHeritage":
  38101. case "TSExpressionWithTypeArguments":
  38102. // Babel AST
  38103. parts.push(print("expression"));
  38104. if (node.typeParameters) {
  38105. parts.push(print("typeParameters"));
  38106. }
  38107. return parts;
  38108. case "TSTemplateLiteralType":
  38109. return printTemplateLiteral$1(path, print, options);
  38110. case "TSNamedTupleMember":
  38111. return [print("label"), node.optional ? "?" : "", ": ", print("elementType")];
  38112. case "TSRestType":
  38113. return ["...", print("typeAnnotation")];
  38114. case "TSOptionalType":
  38115. return [print("typeAnnotation"), "?"];
  38116. case "TSInterfaceDeclaration":
  38117. return printInterface(path, options, print);
  38118. case "TSClassImplements":
  38119. return [print("expression"), print("typeParameters")];
  38120. case "TSTypeParameterDeclaration":
  38121. case "TSTypeParameterInstantiation":
  38122. return printTypeParameters(path, options, print, "params");
  38123. case "TSTypeParameter":
  38124. return printTypeParameter(path, options, print);
  38125. case "TSAsExpression":
  38126. {
  38127. parts.push(print("expression"), " as ", print("typeAnnotation"));
  38128. const parent = path.getParentNode();
  38129. if (isCallExpression$1(parent) && parent.callee === node || isMemberExpression$1(parent) && parent.object === node) {
  38130. return group$g([indent$a([softline$c, ...parts]), softline$c]);
  38131. }
  38132. return parts;
  38133. }
  38134. case "TSArrayType":
  38135. return [print("elementType"), "[]"];
  38136. case "TSPropertySignature":
  38137. {
  38138. if (node.readonly) {
  38139. parts.push("readonly ");
  38140. }
  38141. parts.push(printPropertyKey(path, options, print), printOptionalToken$1(path));
  38142. if (node.typeAnnotation) {
  38143. parts.push(": ", print("typeAnnotation"));
  38144. } // This isn't valid semantically, but it's in the AST so we can print it.
  38145. if (node.initializer) {
  38146. parts.push(" = ", print("initializer"));
  38147. }
  38148. return parts;
  38149. }
  38150. case "TSParameterProperty":
  38151. if (node.accessibility) {
  38152. parts.push(node.accessibility + " ");
  38153. }
  38154. if (node.export) {
  38155. parts.push("export ");
  38156. }
  38157. if (node.static) {
  38158. parts.push("static ");
  38159. }
  38160. if (node.override) {
  38161. parts.push("override ");
  38162. }
  38163. if (node.readonly) {
  38164. parts.push("readonly ");
  38165. }
  38166. parts.push(print("parameter"));
  38167. return parts;
  38168. case "TSTypeQuery":
  38169. return ["typeof ", print("exprName")];
  38170. case "TSIndexSignature":
  38171. {
  38172. const parent = path.getParentNode(); // The typescript parser accepts multiple parameters here. If you're
  38173. // using them, it makes sense to have a trailing comma. But if you
  38174. // aren't, this is more like a computed property name than an array.
  38175. // So we leave off the trailing comma when there's just one parameter.
  38176. const trailingComma = node.parameters.length > 1 ? ifBreak$9(shouldPrintComma$1(options) ? "," : "") : "";
  38177. const parametersGroup = group$g([indent$a([softline$c, join$e([", ", softline$c], path.map(print, "parameters"))]), trailingComma, softline$c]);
  38178. return [node.export ? "export " : "", node.accessibility ? [node.accessibility, " "] : "", node.static ? "static " : "", node.readonly ? "readonly " : "", node.declare ? "declare " : "", "[", node.parameters ? parametersGroup : "", node.typeAnnotation ? "]: " : "]", node.typeAnnotation ? print("typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""];
  38179. }
  38180. case "TSTypePredicate":
  38181. return [node.asserts ? "asserts " : "", print("parameterName"), node.typeAnnotation ? [" is ", print("typeAnnotation")] : ""];
  38182. case "TSNonNullExpression":
  38183. return [print("expression"), "!"];
  38184. case "TSImportType":
  38185. return [!node.isTypeOf ? "" : "typeof ", "import(", print(node.parameter ? "parameter" : "argument"), ")", !node.qualifier ? "" : [".", print("qualifier")], printTypeParameters(path, options, print, "typeParameters")];
  38186. case "TSLiteralType":
  38187. return print("literal");
  38188. case "TSIndexedAccessType":
  38189. return printIndexedAccessType(path, options, print);
  38190. case "TSConstructSignatureDeclaration":
  38191. case "TSCallSignatureDeclaration":
  38192. case "TSConstructorType":
  38193. {
  38194. if (node.type === "TSConstructorType" && node.abstract) {
  38195. parts.push("abstract ");
  38196. }
  38197. if (node.type !== "TSCallSignatureDeclaration") {
  38198. parts.push("new ");
  38199. }
  38200. parts.push(group$g(printFunctionParameters(path, print, options,
  38201. /* expandArg */
  38202. false,
  38203. /* printTypeParams */
  38204. true)));
  38205. if (node.returnType || node.typeAnnotation) {
  38206. const isType = node.type === "TSConstructorType";
  38207. parts.push(isType ? " => " : ": ", print("returnType"), print("typeAnnotation"));
  38208. }
  38209. return parts;
  38210. }
  38211. case "TSTypeOperator":
  38212. return [node.operator, " ", print("typeAnnotation")];
  38213. case "TSMappedType":
  38214. {
  38215. const shouldBreak = hasNewlineInRange(options.originalText, locStart$h(node), locEnd$g(node));
  38216. return group$g(["{", indent$a([options.bracketSpacing ? line$f : softline$c, node.readonly ? [getTypeScriptMappedTypeModifier(node.readonly, "readonly"), " "] : "", printTypeScriptModifiers(path, options, print), print("typeParameter"), node.optional ? getTypeScriptMappedTypeModifier(node.optional, "?") : "", node.typeAnnotation ? ": " : "", print("typeAnnotation"), ifBreak$9(semi)]), printDanglingComments$1(path, options,
  38217. /* sameIndent */
  38218. true), options.bracketSpacing ? line$f : softline$c, "}"], {
  38219. shouldBreak
  38220. });
  38221. }
  38222. case "TSMethodSignature":
  38223. {
  38224. const kind = node.kind && node.kind !== "method" ? `${node.kind} ` : "";
  38225. parts.push(node.accessibility ? [node.accessibility, " "] : "", kind, node.export ? "export " : "", node.static ? "static " : "", node.readonly ? "readonly " : "", // "abstract" and "declare" are supported by only "babel-ts"
  38226. // https://github.com/prettier/prettier/issues/9760
  38227. node.abstract ? "abstract " : "", node.declare ? "declare " : "", node.computed ? "[" : "", print("key"), node.computed ? "]" : "", printOptionalToken$1(path));
  38228. const parametersDoc = printFunctionParameters(path, print, options,
  38229. /* expandArg */
  38230. false,
  38231. /* printTypeParams */
  38232. true);
  38233. const returnTypePropertyName = node.returnType ? "returnType" : "typeAnnotation";
  38234. const returnTypeNode = node[returnTypePropertyName];
  38235. const returnTypeDoc = returnTypeNode ? print(returnTypePropertyName) : "";
  38236. const shouldGroupParameters = shouldGroupFunctionParameters(node, returnTypeDoc);
  38237. parts.push(shouldGroupParameters ? group$g(parametersDoc) : parametersDoc);
  38238. if (returnTypeNode) {
  38239. parts.push(": ", group$g(returnTypeDoc));
  38240. }
  38241. return group$g(parts);
  38242. }
  38243. case "TSNamespaceExportDeclaration":
  38244. parts.push("export as namespace ", print("id"));
  38245. if (options.semi) {
  38246. parts.push(";");
  38247. }
  38248. return group$g(parts);
  38249. case "TSEnumDeclaration":
  38250. if (node.declare) {
  38251. parts.push("declare ");
  38252. }
  38253. if (node.modifiers) {
  38254. parts.push(printTypeScriptModifiers(path, options, print));
  38255. }
  38256. if (node.const) {
  38257. parts.push("const ");
  38258. }
  38259. parts.push("enum ", print("id"), " ");
  38260. if (node.members.length === 0) {
  38261. parts.push(group$g(["{", printDanglingComments$1(path, options), softline$c, "}"]));
  38262. } else {
  38263. parts.push(group$g(["{", indent$a([hardline$i, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""]), printDanglingComments$1(path, options,
  38264. /* sameIndent */
  38265. true), hardline$i, "}"]));
  38266. }
  38267. return parts;
  38268. case "TSEnumMember":
  38269. parts.push(print("id"));
  38270. if (node.initializer) {
  38271. parts.push(" = ", print("initializer"));
  38272. }
  38273. return parts;
  38274. case "TSImportEqualsDeclaration":
  38275. if (node.isExport) {
  38276. parts.push("export ");
  38277. }
  38278. parts.push("import ");
  38279. if (node.importKind && node.importKind !== "value") {
  38280. parts.push(node.importKind, " ");
  38281. }
  38282. parts.push(print("id"), " = ", print("moduleReference"));
  38283. if (options.semi) {
  38284. parts.push(";");
  38285. }
  38286. return group$g(parts);
  38287. case "TSExternalModuleReference":
  38288. return ["require(", print("expression"), ")"];
  38289. case "TSModuleDeclaration":
  38290. {
  38291. const parent = path.getParentNode();
  38292. const isExternalModule = isLiteral(node.id);
  38293. const parentIsDeclaration = parent.type === "TSModuleDeclaration";
  38294. const bodyIsDeclaration = node.body && node.body.type === "TSModuleDeclaration";
  38295. if (parentIsDeclaration) {
  38296. parts.push(".");
  38297. } else {
  38298. if (node.declare) {
  38299. parts.push("declare ");
  38300. }
  38301. parts.push(printTypeScriptModifiers(path, options, print));
  38302. const textBetweenNodeAndItsId = options.originalText.slice(locStart$h(node), locStart$h(node.id)); // Global declaration looks like this:
  38303. // (declare)? global { ... }
  38304. const isGlobalDeclaration = node.id.type === "Identifier" && node.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  38305. if (!isGlobalDeclaration) {
  38306. parts.push(isExternalModule || /(?:^|\s)module(?:\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  38307. }
  38308. }
  38309. parts.push(print("id"));
  38310. if (bodyIsDeclaration) {
  38311. parts.push(print("body"));
  38312. } else if (node.body) {
  38313. parts.push(" ", group$g(print("body")));
  38314. } else {
  38315. parts.push(semi);
  38316. }
  38317. return parts;
  38318. }
  38319. // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
  38320. case "TSPrivateIdentifier":
  38321. return node.escapedText;
  38322. case "TSConditionalType":
  38323. return printTernary$1(path, options, print);
  38324. case "TSInferType":
  38325. return ["infer", " ", print("typeParameter")];
  38326. case "TSIntersectionType":
  38327. return printIntersectionType(path, options, print);
  38328. case "TSUnionType":
  38329. return printUnionType(path, options, print);
  38330. case "TSFunctionType":
  38331. return printFunctionType(path, options, print);
  38332. case "TSTupleType":
  38333. return printTupleType(path, options, print);
  38334. case "TSTypeReference":
  38335. return [print("typeName"), printTypeParameters(path, options, print, "typeParameters")];
  38336. case "TSTypeAnnotation":
  38337. return print("typeAnnotation");
  38338. case "TSEmptyBodyFunctionExpression":
  38339. return printMethodInternal(path, options, print);
  38340. // These are not valid TypeScript. Printing them just for the sake of error recovery.
  38341. case "TSJSDocAllType":
  38342. return "*";
  38343. case "TSJSDocUnknownType":
  38344. return "?";
  38345. case "TSJSDocNullableType":
  38346. return ["?", print("typeAnnotation")];
  38347. case "TSJSDocNonNullableType":
  38348. return ["!", print("typeAnnotation")];
  38349. default:
  38350. /* istanbul ignore next */
  38351. throw new Error(`Unknown TypeScript node type: ${JSON.stringify(node.type)}.`);
  38352. }
  38353. }
  38354. var typescript = {
  38355. printTypescript: printTypescript$1
  38356. };
  38357. const {
  38358. hasNewline: hasNewline$2
  38359. } = util$5;
  38360. const {
  38361. builders: {
  38362. join: join$d,
  38363. hardline: hardline$h
  38364. },
  38365. utils: {
  38366. replaceTextEndOfLine: replaceTextEndOfLine$a
  38367. }
  38368. } = doc;
  38369. const {
  38370. isLineComment: isLineComment$1,
  38371. isBlockComment: isBlockComment$1
  38372. } = utils$5;
  38373. const {
  38374. locStart: locStart$g,
  38375. locEnd: locEnd$f
  38376. } = loc$6;
  38377. function printComment$2(commentPath, options) {
  38378. const comment = commentPath.getValue();
  38379. if (isLineComment$1(comment)) {
  38380. // Supports `//`, `#!`, `<!--`, and `-->`
  38381. return options.originalText.slice(locStart$g(comment), locEnd$f(comment)).trimEnd();
  38382. }
  38383. if (isBlockComment$1(comment)) {
  38384. if (isIndentableBlockComment(comment)) {
  38385. const printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  38386. // printed as a `lineSuffix` which causes the comments to be
  38387. // interleaved. See https://github.com/prettier/prettier/issues/4412
  38388. if (comment.trailing && !hasNewline$2(options.originalText, locStart$g(comment), {
  38389. backwards: true
  38390. })) {
  38391. return [hardline$h, printed];
  38392. }
  38393. return printed;
  38394. }
  38395. const commentEnd = locEnd$f(comment);
  38396. const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
  38397. return ["/*", replaceTextEndOfLine$a(comment.value), isInsideFlowComment ? "*-/" : "*/"];
  38398. }
  38399. /* istanbul ignore next */
  38400. throw new Error("Not a comment: " + JSON.stringify(comment));
  38401. }
  38402. function isIndentableBlockComment(comment) {
  38403. // If the comment has multiple lines and every line starts with a star
  38404. // we can fix the indentation of each line. The stars in the `/*` and
  38405. // `*/` delimiters are not included in the comment value, so add them
  38406. // back first.
  38407. const lines = `*${comment.value}*`.split("\n");
  38408. return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
  38409. }
  38410. function printIndentableBlockComment(comment) {
  38411. const lines = comment.value.split("\n");
  38412. return ["/*", join$d(hardline$h, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"];
  38413. }
  38414. var comment = {
  38415. printComment: printComment$2
  38416. };
  38417. const {
  38418. printString: printString$1,
  38419. printNumber: printNumber$1
  38420. } = util$5;
  38421. function printLiteral$1(path, options
  38422. /*, print*/
  38423. ) {
  38424. const node = path.getNode();
  38425. switch (node.type) {
  38426. case "RegExpLiteral":
  38427. // Babel 6 Literal split
  38428. return printRegex(node);
  38429. case "BigIntLiteral":
  38430. // babel: node.extra.raw, flow: node.bigint
  38431. return printBigInt(node.bigint || node.extra.raw);
  38432. case "NumericLiteral":
  38433. // Babel 6 Literal split
  38434. return printNumber$1(node.extra.raw);
  38435. case "StringLiteral":
  38436. // Babel 6 Literal split
  38437. return printString$1(node.extra.raw, options);
  38438. case "NullLiteral":
  38439. // Babel 6 Literal split
  38440. return "null";
  38441. case "BooleanLiteral":
  38442. // Babel 6 Literal split
  38443. return String(node.value);
  38444. case "DecimalLiteral":
  38445. return printNumber$1(node.value) + "m";
  38446. case "Literal":
  38447. {
  38448. if (node.regex) {
  38449. return printRegex(node.regex);
  38450. }
  38451. if (node.bigint) {
  38452. return printBigInt(node.raw);
  38453. }
  38454. if (node.decimal) {
  38455. return printNumber$1(node.decimal) + "m";
  38456. }
  38457. const {
  38458. value
  38459. } = node;
  38460. if (typeof value === "number") {
  38461. return printNumber$1(node.raw);
  38462. }
  38463. if (typeof value === "string") {
  38464. return printString$1(node.raw, options);
  38465. }
  38466. return String(value);
  38467. }
  38468. }
  38469. }
  38470. function printBigInt(raw) {
  38471. return raw.toLowerCase();
  38472. }
  38473. function printRegex({
  38474. pattern,
  38475. flags
  38476. }) {
  38477. flags = [...flags].sort().join("");
  38478. return `/${pattern}/${flags}`;
  38479. }
  38480. var literal = {
  38481. printLiteral: printLiteral$1
  38482. };
  38483. /** @typedef {import("../document").Doc} Doc */
  38484. // TODO(azz): anything that imports from main shouldn't be in a `language-*` dir.
  38485. const {
  38486. printDanglingComments
  38487. } = comments$1;
  38488. const {
  38489. hasNewline: hasNewline$1
  38490. } = util$5;
  38491. const {
  38492. builders: {
  38493. join: join$c,
  38494. line: line$e,
  38495. hardline: hardline$g,
  38496. softline: softline$b,
  38497. group: group$f,
  38498. indent: indent$9
  38499. },
  38500. utils: {
  38501. replaceTextEndOfLine: replaceTextEndOfLine$9
  38502. }
  38503. } = doc;
  38504. const {
  38505. insertPragma: insertPragma$9
  38506. } = pragma$5;
  38507. const {
  38508. hasFlowShorthandAnnotationComment,
  38509. hasComment,
  38510. CommentCheckFlags,
  38511. isTheOnlyJsxElementInMarkdown,
  38512. isBlockComment,
  38513. isLineComment,
  38514. isNextLineEmpty: isNextLineEmpty$4,
  38515. needsHardlineAfterDanglingComment,
  38516. rawText,
  38517. hasIgnoreComment,
  38518. isCallExpression,
  38519. isMemberExpression
  38520. } = utils$5;
  38521. const {
  38522. locStart: locStart$f,
  38523. locEnd: locEnd$e
  38524. } = loc$6;
  38525. const {
  38526. printHtmlBinding,
  38527. isVueEventBindingExpression: isVueEventBindingExpression$2
  38528. } = htmlBinding;
  38529. const {
  38530. printAngular
  38531. } = angular;
  38532. const {
  38533. printJsx,
  38534. hasJsxIgnoreComment
  38535. } = jsx;
  38536. const {
  38537. printFlow
  38538. } = flow;
  38539. const {
  38540. printTypescript
  38541. } = typescript;
  38542. const {
  38543. printOptionalToken,
  38544. printBindExpressionCallee,
  38545. printTypeAnnotation,
  38546. adjustClause,
  38547. printRestSpread
  38548. } = misc$1;
  38549. const {
  38550. printImportDeclaration,
  38551. printExportDeclaration,
  38552. printExportAllDeclaration,
  38553. printModuleSpecifier
  38554. } = module$1;
  38555. const {
  38556. printTernary
  38557. } = ternary;
  38558. const {
  38559. printTemplateLiteral
  38560. } = templateLiteral;
  38561. const {
  38562. printArray
  38563. } = array;
  38564. const {
  38565. printObject
  38566. } = object$1;
  38567. const {
  38568. printClass,
  38569. printClassMethod,
  38570. printClassProperty
  38571. } = _class;
  38572. const {
  38573. printProperty
  38574. } = property;
  38575. const {
  38576. printFunction,
  38577. printArrowFunction,
  38578. printMethod,
  38579. printReturnStatement,
  38580. printThrowStatement
  38581. } = _function;
  38582. const {
  38583. printCallExpression
  38584. } = callExpression;
  38585. const {
  38586. printVariableDeclarator,
  38587. printAssignmentExpression
  38588. } = assignment;
  38589. const {
  38590. printBinaryishExpression
  38591. } = binaryish;
  38592. const {
  38593. printSwitchCaseConsequent
  38594. } = statement;
  38595. const {
  38596. printMemberExpression
  38597. } = member;
  38598. const {
  38599. printBlock: printBlock$1,
  38600. printBlockBody
  38601. } = block$1;
  38602. const {
  38603. printComment: printComment$1
  38604. } = comment;
  38605. const {
  38606. printLiteral
  38607. } = literal;
  38608. const {
  38609. printDecorators
  38610. } = decorators;
  38611. function genericPrint$6(path, options, print, args) {
  38612. const printed = printPathNoParens(path, options, print, args);
  38613. if (!printed) {
  38614. return "";
  38615. }
  38616. const node = path.getValue();
  38617. const {
  38618. type
  38619. } = node; // Their decorators are handled themselves, and they can't have parentheses
  38620. if (type === "ClassMethod" || type === "ClassPrivateMethod" || type === "ClassProperty" || type === "PropertyDefinition" || type === "TSAbstractClassProperty" || type === "ClassPrivateProperty" || type === "MethodDefinition" || type === "TSAbstractMethodDefinition" || type === "TSDeclareMethod") {
  38621. return printed;
  38622. }
  38623. const printedDecorators = printDecorators(path, options, print); // Nodes with decorators can't have parentheses and don't need leading semicolons
  38624. if (printedDecorators) {
  38625. return group$f([...printedDecorators, printed]);
  38626. }
  38627. const needsParens = needsParens_1(path, options);
  38628. if (!needsParens) {
  38629. return args && args.needsSemi ? [";", printed] : printed;
  38630. }
  38631. const parts = [args && args.needsSemi ? ";(" : "(", printed];
  38632. if (hasFlowShorthandAnnotationComment(node)) {
  38633. const [comment] = node.trailingComments;
  38634. parts.push(" /*", comment.value.trimStart(), "*/");
  38635. comment.printed = true;
  38636. }
  38637. parts.push(")");
  38638. return parts;
  38639. }
  38640. function printPathNoParens(path, options, print, args) {
  38641. const node = path.getValue();
  38642. const semi = options.semi ? ";" : "";
  38643. if (!node) {
  38644. return "";
  38645. }
  38646. if (typeof node === "string") {
  38647. return node;
  38648. }
  38649. for (const printer of [printLiteral, printHtmlBinding, printAngular, printJsx, printFlow, printTypescript]) {
  38650. const printed = printer(path, options, print);
  38651. if (typeof printed !== "undefined") {
  38652. return printed;
  38653. }
  38654. }
  38655. /** @type{Doc[]} */
  38656. let parts = [];
  38657. switch (node.type) {
  38658. case "JsExpressionRoot":
  38659. return print("node");
  38660. case "JsonRoot":
  38661. return [print("node"), hardline$g];
  38662. case "File":
  38663. // Print @babel/parser's InterpreterDirective here so that
  38664. // leading comments on the `Program` node get printed after the hashbang.
  38665. if (node.program && node.program.interpreter) {
  38666. parts.push(print(["program", "interpreter"]));
  38667. }
  38668. parts.push(print("program"));
  38669. return parts;
  38670. case "Program":
  38671. return printBlockBody(path, options, print);
  38672. // Babel extension.
  38673. case "EmptyStatement":
  38674. return "";
  38675. case "ExpressionStatement":
  38676. // Detect Flow and TypeScript directives
  38677. if (node.directive) {
  38678. return [printDirective(node.expression, options), semi];
  38679. }
  38680. if (options.parser === "__vue_event_binding") {
  38681. const parent = path.getParentNode();
  38682. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === node) {
  38683. return [print("expression"), isVueEventBindingExpression$2(node.expression) ? ";" : ""];
  38684. }
  38685. } // Do not append semicolon after the only JSX element in a program
  38686. return [print("expression"), isTheOnlyJsxElementInMarkdown(options, path) ? "" : semi];
  38687. // Babel non-standard node. Used for Closure-style type casts. See postprocess.js.
  38688. case "ParenthesizedExpression":
  38689. {
  38690. const shouldHug = !hasComment(node.expression) && (node.expression.type === "ObjectExpression" || node.expression.type === "ArrayExpression");
  38691. if (shouldHug) {
  38692. return ["(", print("expression"), ")"];
  38693. }
  38694. return group$f(["(", indent$9([softline$b, print("expression")]), softline$b, ")"]);
  38695. }
  38696. case "AssignmentExpression":
  38697. return printAssignmentExpression(path, options, print);
  38698. case "VariableDeclarator":
  38699. return printVariableDeclarator(path, options, print);
  38700. case "BinaryExpression":
  38701. case "LogicalExpression":
  38702. return printBinaryishExpression(path, options, print);
  38703. case "AssignmentPattern":
  38704. return [print("left"), " = ", print("right")];
  38705. case "OptionalMemberExpression":
  38706. case "MemberExpression":
  38707. {
  38708. return printMemberExpression(path, options, print);
  38709. }
  38710. case "MetaProperty":
  38711. return [print("meta"), ".", print("property")];
  38712. case "BindExpression":
  38713. if (node.object) {
  38714. parts.push(print("object"));
  38715. }
  38716. parts.push(group$f(indent$9([softline$b, printBindExpressionCallee(path, options, print)])));
  38717. return parts;
  38718. case "Identifier":
  38719. {
  38720. return [node.name, printOptionalToken(path), printTypeAnnotation(path, options, print)];
  38721. }
  38722. case "V8IntrinsicIdentifier":
  38723. return ["%", node.name];
  38724. case "SpreadElement":
  38725. case "SpreadElementPattern":
  38726. case "SpreadProperty":
  38727. case "SpreadPropertyPattern":
  38728. case "RestElement":
  38729. return printRestSpread(path, options, print);
  38730. case "FunctionDeclaration":
  38731. case "FunctionExpression":
  38732. return printFunction(path, print, options, args);
  38733. case "ArrowFunctionExpression":
  38734. return printArrowFunction(path, options, print, args);
  38735. case "YieldExpression":
  38736. parts.push("yield");
  38737. if (node.delegate) {
  38738. parts.push("*");
  38739. }
  38740. if (node.argument) {
  38741. parts.push(" ", print("argument"));
  38742. }
  38743. return parts;
  38744. case "AwaitExpression":
  38745. {
  38746. parts.push("await");
  38747. if (node.argument) {
  38748. parts.push(" ", print("argument"));
  38749. const parent = path.getParentNode();
  38750. if (isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node) {
  38751. parts = [indent$9([softline$b, ...parts]), softline$b];
  38752. const parentAwaitOrBlock = path.findAncestor(node => node.type === "AwaitExpression" || node.type === "BlockStatement");
  38753. if (!parentAwaitOrBlock || parentAwaitOrBlock.type !== "AwaitExpression") {
  38754. return group$f(parts);
  38755. }
  38756. }
  38757. }
  38758. return parts;
  38759. }
  38760. case "ExportDefaultDeclaration":
  38761. case "ExportNamedDeclaration":
  38762. return printExportDeclaration(path, options, print);
  38763. case "ExportAllDeclaration":
  38764. return printExportAllDeclaration(path, options, print);
  38765. case "ImportDeclaration":
  38766. return printImportDeclaration(path, options, print);
  38767. case "ImportSpecifier":
  38768. case "ExportSpecifier":
  38769. case "ImportNamespaceSpecifier":
  38770. case "ExportNamespaceSpecifier":
  38771. case "ImportDefaultSpecifier":
  38772. case "ExportDefaultSpecifier":
  38773. return printModuleSpecifier(path, options, print);
  38774. case "ImportAttribute":
  38775. return [print("key"), ": ", print("value")];
  38776. case "Import":
  38777. return "import";
  38778. case "BlockStatement":
  38779. case "StaticBlock":
  38780. case "ClassBody":
  38781. return printBlock$1(path, options, print);
  38782. case "ThrowStatement":
  38783. return printThrowStatement(path, options, print);
  38784. case "ReturnStatement":
  38785. return printReturnStatement(path, options, print);
  38786. case "NewExpression":
  38787. case "ImportExpression":
  38788. case "OptionalCallExpression":
  38789. case "CallExpression":
  38790. return printCallExpression(path, options, print);
  38791. case "ObjectExpression":
  38792. case "ObjectPattern":
  38793. case "RecordExpression":
  38794. return printObject(path, options, print);
  38795. // Babel 6
  38796. case "ObjectProperty": // Non-standard AST node type.
  38797. case "Property":
  38798. if (node.method || node.kind === "get" || node.kind === "set") {
  38799. return printMethod(path, options, print);
  38800. }
  38801. return printProperty(path, options, print);
  38802. case "ObjectMethod":
  38803. return printMethod(path, options, print);
  38804. case "Decorator":
  38805. return ["@", print("expression")];
  38806. case "ArrayExpression":
  38807. case "ArrayPattern":
  38808. case "TupleExpression":
  38809. return printArray(path, options, print);
  38810. case "SequenceExpression":
  38811. {
  38812. const parent = path.getParentNode(0);
  38813. if (parent.type === "ExpressionStatement" || parent.type === "ForStatement") {
  38814. // For ExpressionStatements and for-loop heads, which are among
  38815. // the few places a SequenceExpression appears unparenthesized, we want
  38816. // to indent expressions after the first.
  38817. const parts = [];
  38818. path.each((expressionPath, index) => {
  38819. if (index === 0) {
  38820. parts.push(print());
  38821. } else {
  38822. parts.push(",", indent$9([line$e, print()]));
  38823. }
  38824. }, "expressions");
  38825. return group$f(parts);
  38826. }
  38827. return group$f(join$c([",", line$e], path.map(print, "expressions")));
  38828. }
  38829. case "ThisExpression":
  38830. return "this";
  38831. case "Super":
  38832. return "super";
  38833. case "Directive":
  38834. return [print("value"), semi];
  38835. // Babel 6
  38836. case "DirectiveLiteral":
  38837. return printDirective(node, options);
  38838. case "UnaryExpression":
  38839. parts.push(node.operator);
  38840. if (/[a-z]$/.test(node.operator)) {
  38841. parts.push(" ");
  38842. }
  38843. if (hasComment(node.argument)) {
  38844. parts.push(group$f(["(", indent$9([softline$b, print("argument")]), softline$b, ")"]));
  38845. } else {
  38846. parts.push(print("argument"));
  38847. }
  38848. return parts;
  38849. case "UpdateExpression":
  38850. parts.push(print("argument"), node.operator);
  38851. if (node.prefix) {
  38852. parts.reverse();
  38853. }
  38854. return parts;
  38855. case "ConditionalExpression":
  38856. return printTernary(path, options, print);
  38857. case "VariableDeclaration":
  38858. {
  38859. const printed = path.map(print, "declarations"); // We generally want to terminate all variable declarations with a
  38860. // semicolon, except when they in the () part of for loops.
  38861. const parentNode = path.getParentNode();
  38862. const isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement";
  38863. const hasValue = node.declarations.some(decl => decl.init);
  38864. let firstVariable;
  38865. if (printed.length === 1 && !hasComment(node.declarations[0])) {
  38866. firstVariable = printed[0];
  38867. } else if (printed.length > 0) {
  38868. // Indent first var to comply with eslint one-var rule
  38869. firstVariable = indent$9(printed[0]);
  38870. }
  38871. parts = [node.declare ? "declare " : "", node.kind, firstVariable ? [" ", firstVariable] : "", indent$9(printed.slice(1).map(p => [",", hasValue && !isParentForLoop ? hardline$g : line$e, p]))];
  38872. if (!(isParentForLoop && parentNode.body !== node)) {
  38873. parts.push(semi);
  38874. }
  38875. return group$f(parts);
  38876. }
  38877. case "WithStatement":
  38878. return group$f(["with (", print("object"), ")", adjustClause(node.body, print("body"))]);
  38879. case "IfStatement":
  38880. {
  38881. const con = adjustClause(node.consequent, print("consequent"));
  38882. const opening = group$f(["if (", group$f([indent$9([softline$b, print("test")]), softline$b]), ")", con]);
  38883. parts.push(opening);
  38884. if (node.alternate) {
  38885. const commentOnOwnLine = hasComment(node.consequent, CommentCheckFlags.Trailing | CommentCheckFlags.Line) || needsHardlineAfterDanglingComment(node);
  38886. const elseOnSameLine = node.consequent.type === "BlockStatement" && !commentOnOwnLine;
  38887. parts.push(elseOnSameLine ? " " : hardline$g);
  38888. if (hasComment(node, CommentCheckFlags.Dangling)) {
  38889. parts.push(printDanglingComments(path, options, true), commentOnOwnLine ? hardline$g : " ");
  38890. }
  38891. parts.push("else", group$f(adjustClause(node.alternate, print("alternate"), node.alternate.type === "IfStatement")));
  38892. }
  38893. return parts;
  38894. }
  38895. case "ForStatement":
  38896. {
  38897. const body = adjustClause(node.body, print("body")); // We want to keep dangling comments above the loop to stay consistent.
  38898. // Any comment positioned between the for statement and the parentheses
  38899. // is going to be printed before the statement.
  38900. const dangling = printDanglingComments(path, options,
  38901. /* sameLine */
  38902. true);
  38903. const printedComments = dangling ? [dangling, softline$b] : "";
  38904. if (!node.init && !node.test && !node.update) {
  38905. return [printedComments, group$f(["for (;;)", body])];
  38906. }
  38907. return [printedComments, group$f(["for (", group$f([indent$9([softline$b, print("init"), ";", line$e, print("test"), ";", line$e, print("update")]), softline$b]), ")", body])];
  38908. }
  38909. case "WhileStatement":
  38910. return group$f(["while (", group$f([indent$9([softline$b, print("test")]), softline$b]), ")", adjustClause(node.body, print("body"))]);
  38911. case "ForInStatement":
  38912. return group$f(["for (", print("left"), " in ", print("right"), ")", adjustClause(node.body, print("body"))]);
  38913. case "ForOfStatement":
  38914. return group$f(["for", node.await ? " await" : "", " (", print("left"), " of ", print("right"), ")", adjustClause(node.body, print("body"))]);
  38915. case "DoWhileStatement":
  38916. {
  38917. const clause = adjustClause(node.body, print("body"));
  38918. const doBody = group$f(["do", clause]);
  38919. parts = [doBody];
  38920. if (node.body.type === "BlockStatement") {
  38921. parts.push(" ");
  38922. } else {
  38923. parts.push(hardline$g);
  38924. }
  38925. parts.push("while (", group$f([indent$9([softline$b, print("test")]), softline$b]), ")", semi);
  38926. return parts;
  38927. }
  38928. case "DoExpression":
  38929. return [node.async ? "async " : "", "do ", print("body")];
  38930. case "BreakStatement":
  38931. parts.push("break");
  38932. if (node.label) {
  38933. parts.push(" ", print("label"));
  38934. }
  38935. parts.push(semi);
  38936. return parts;
  38937. case "ContinueStatement":
  38938. parts.push("continue");
  38939. if (node.label) {
  38940. parts.push(" ", print("label"));
  38941. }
  38942. parts.push(semi);
  38943. return parts;
  38944. case "LabeledStatement":
  38945. if (node.body.type === "EmptyStatement") {
  38946. return [print("label"), ":;"];
  38947. }
  38948. return [print("label"), ": ", print("body")];
  38949. case "TryStatement":
  38950. return ["try ", print("block"), node.handler ? [" ", print("handler")] : "", node.finalizer ? [" finally ", print("finalizer")] : ""];
  38951. case "CatchClause":
  38952. if (node.param) {
  38953. const parameterHasComments = hasComment(node.param, comment => !isBlockComment(comment) || comment.leading && hasNewline$1(options.originalText, locEnd$e(comment)) || comment.trailing && hasNewline$1(options.originalText, locStart$f(comment), {
  38954. backwards: true
  38955. }));
  38956. const param = print("param");
  38957. return ["catch ", parameterHasComments ? ["(", indent$9([softline$b, param]), softline$b, ") "] : ["(", param, ") "], print("body")];
  38958. }
  38959. return ["catch ", print("body")];
  38960. // Note: ignoring n.lexical because it has no printing consequences.
  38961. case "SwitchStatement":
  38962. return [group$f(["switch (", indent$9([softline$b, print("discriminant")]), softline$b, ")"]), " {", node.cases.length > 0 ? indent$9([hardline$g, join$c(hardline$g, path.map((casePath, index, cases) => {
  38963. const caseNode = casePath.getValue();
  38964. return [print(), index !== cases.length - 1 && isNextLineEmpty$4(caseNode, options) ? hardline$g : ""];
  38965. }, "cases"))]) : "", hardline$g, "}"];
  38966. case "SwitchCase":
  38967. {
  38968. if (node.test) {
  38969. parts.push("case ", print("test"), ":");
  38970. } else {
  38971. parts.push("default:");
  38972. }
  38973. const consequent = node.consequent.filter(node => node.type !== "EmptyStatement");
  38974. if (consequent.length > 0) {
  38975. const cons = printSwitchCaseConsequent(path, options, print);
  38976. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? [" ", cons] : indent$9([hardline$g, cons]));
  38977. }
  38978. return parts;
  38979. }
  38980. // JSX extensions below.
  38981. case "DebuggerStatement":
  38982. return ["debugger", semi];
  38983. case "ClassDeclaration":
  38984. case "ClassExpression":
  38985. return printClass(path, options, print);
  38986. case "ClassMethod":
  38987. case "ClassPrivateMethod":
  38988. case "MethodDefinition":
  38989. return printClassMethod(path, options, print);
  38990. case "ClassProperty":
  38991. case "PropertyDefinition":
  38992. case "ClassPrivateProperty":
  38993. return printClassProperty(path, options, print);
  38994. case "TemplateElement":
  38995. return replaceTextEndOfLine$9(node.value.raw);
  38996. case "TemplateLiteral":
  38997. return printTemplateLiteral(path, print, options);
  38998. case "TaggedTemplateExpression":
  38999. return [print("tag"), print("typeParameters"), print("quasi")];
  39000. case "PrivateIdentifier":
  39001. return ["#", print("name")];
  39002. case "PrivateName":
  39003. return ["#", print("id")];
  39004. case "InterpreterDirective":
  39005. parts.push("#!", node.value, hardline$g);
  39006. if (isNextLineEmpty$4(node, options)) {
  39007. parts.push(hardline$g);
  39008. }
  39009. return parts;
  39010. // For hack-style pipeline
  39011. case "TopicReference":
  39012. return "%";
  39013. case "ArgumentPlaceholder":
  39014. return "?";
  39015. case "ModuleExpression":
  39016. {
  39017. parts.push("module {");
  39018. const printed = print("body");
  39019. if (printed) {
  39020. parts.push(indent$9([hardline$g, printed]), hardline$g);
  39021. }
  39022. parts.push("}");
  39023. return parts;
  39024. }
  39025. default:
  39026. /* istanbul ignore next */
  39027. throw new Error("unknown type: " + JSON.stringify(node.type));
  39028. }
  39029. }
  39030. function printDirective(node, options) {
  39031. const raw = rawText(node);
  39032. const rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  39033. // the quotes on a DirectiveLiteral.
  39034. if (rawContent.includes('"') || rawContent.includes("'")) {
  39035. return raw;
  39036. }
  39037. const enclosingQuote = options.singleQuote ? "'" : '"'; // Directives are exact code unit sequences, which means that you can't
  39038. // change the escape sequences they use.
  39039. // See https://github.com/prettier/prettier/issues/1555
  39040. // and https://tc39.github.io/ecma262/#directive-prologue
  39041. return enclosingQuote + rawContent + enclosingQuote;
  39042. }
  39043. function canAttachComment$1(node) {
  39044. return node.type && !isBlockComment(node) && !isLineComment(node) && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import" && // `babel-ts` don't have similar node for `class Foo { bar() /* bat */; }`
  39045. node.type !== "TSEmptyBodyFunctionExpression";
  39046. }
  39047. var printerEstree = {
  39048. preprocess: printPreprocess$3,
  39049. print: genericPrint$6,
  39050. embed: embed_1$4,
  39051. insertPragma: insertPragma$9,
  39052. massageAstNode: clean_1$4,
  39053. hasPrettierIgnore(path) {
  39054. return hasIgnoreComment(path) || hasJsxIgnoreComment(path);
  39055. },
  39056. willPrintOwnComments: comments.willPrintOwnComments,
  39057. canAttachComment: canAttachComment$1,
  39058. printComment: printComment$1,
  39059. isBlockComment,
  39060. handleComments: {
  39061. // TODO: Make this as default behavior
  39062. avoidAstMutation: true,
  39063. ownLine: comments.handleOwnLineComment,
  39064. endOfLine: comments.handleEndOfLineComment,
  39065. remaining: comments.handleRemainingComment
  39066. },
  39067. getCommentChildNodes: comments.getCommentChildNodes
  39068. };
  39069. const {
  39070. builders: {
  39071. hardline: hardline$f,
  39072. indent: indent$8,
  39073. join: join$b
  39074. }
  39075. } = doc;
  39076. function genericPrint$5(path, options, print) {
  39077. const node = path.getValue();
  39078. switch (node.type) {
  39079. case "JsonRoot":
  39080. return [print("node"), hardline$f];
  39081. case "ArrayExpression":
  39082. {
  39083. if (node.elements.length === 0) {
  39084. return "[]";
  39085. }
  39086. const printed = path.map(() => path.getValue() === null ? "null" : print(), "elements");
  39087. return ["[", indent$8([hardline$f, join$b([",", hardline$f], printed)]), hardline$f, "]"];
  39088. }
  39089. case "ObjectExpression":
  39090. return node.properties.length === 0 ? "{}" : ["{", indent$8([hardline$f, join$b([",", hardline$f], path.map(print, "properties"))]), hardline$f, "}"];
  39091. case "ObjectProperty":
  39092. return [print("key"), ": ", print("value")];
  39093. case "UnaryExpression":
  39094. return [node.operator === "+" ? "" : node.operator, print("argument")];
  39095. case "NullLiteral":
  39096. return "null";
  39097. case "BooleanLiteral":
  39098. return node.value ? "true" : "false";
  39099. case "StringLiteral":
  39100. case "NumericLiteral":
  39101. return JSON.stringify(node.value);
  39102. case "Identifier":
  39103. {
  39104. const parent = path.getParentNode();
  39105. if (parent && parent.type === "ObjectProperty" && parent.key === node) {
  39106. return JSON.stringify(node.name);
  39107. }
  39108. return node.name;
  39109. }
  39110. case "TemplateLiteral":
  39111. // There is only one `TemplateElement`
  39112. return print(["quasis", 0]);
  39113. case "TemplateElement":
  39114. return JSON.stringify(node.value.cooked);
  39115. default:
  39116. /* istanbul ignore next */
  39117. throw new Error("unknown type: " + JSON.stringify(node.type));
  39118. }
  39119. }
  39120. const ignoredProperties$3 = new Set(["start", "end", "extra", "loc", "comments", "leadingComments", "trailingComments", "innerComments", "errors", "range", "tokens"]);
  39121. function clean$6(node, newNode
  39122. /*, parent*/
  39123. ) {
  39124. const {
  39125. type
  39126. } = node; // We print quoted key
  39127. if (type === "ObjectProperty" && node.key.type === "Identifier") {
  39128. newNode.key = {
  39129. type: "StringLiteral",
  39130. value: node.key.name
  39131. };
  39132. return;
  39133. }
  39134. if (type === "UnaryExpression" && node.operator === "+") {
  39135. return newNode.argument;
  39136. } // We print holes in array as `null`
  39137. if (type === "ArrayExpression") {
  39138. for (const [index, element] of node.elements.entries()) {
  39139. if (element === null) {
  39140. newNode.elements.splice(index, 0, {
  39141. type: "NullLiteral"
  39142. });
  39143. }
  39144. }
  39145. return;
  39146. } // We print `TemplateLiteral` as string
  39147. if (type === "TemplateLiteral") {
  39148. return {
  39149. type: "StringLiteral",
  39150. value: node.quasis[0].value.cooked
  39151. };
  39152. }
  39153. }
  39154. clean$6.ignoredProperties = ignoredProperties$3;
  39155. var printerEstreeJson = {
  39156. preprocess: printPreprocess$3,
  39157. print: genericPrint$5,
  39158. massageAstNode: clean$6
  39159. };
  39160. const CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  39161. var commonOptions = {
  39162. bracketSpacing: {
  39163. since: "0.0.0",
  39164. category: CATEGORY_COMMON,
  39165. type: "boolean",
  39166. default: true,
  39167. description: "Print spaces between brackets.",
  39168. oppositeDescription: "Do not print spaces between brackets."
  39169. },
  39170. singleQuote: {
  39171. since: "0.0.0",
  39172. category: CATEGORY_COMMON,
  39173. type: "boolean",
  39174. default: false,
  39175. description: "Use single quotes instead of double quotes."
  39176. },
  39177. proseWrap: {
  39178. since: "1.8.2",
  39179. category: CATEGORY_COMMON,
  39180. type: "choice",
  39181. default: [{
  39182. since: "1.8.2",
  39183. value: true
  39184. }, {
  39185. since: "1.9.0",
  39186. value: "preserve"
  39187. }],
  39188. description: "How to wrap prose.",
  39189. choices: [{
  39190. since: "1.9.0",
  39191. value: "always",
  39192. description: "Wrap prose if it exceeds the print width."
  39193. }, {
  39194. since: "1.9.0",
  39195. value: "never",
  39196. description: "Do not wrap prose."
  39197. }, {
  39198. since: "1.9.0",
  39199. value: "preserve",
  39200. description: "Wrap prose as-is."
  39201. }]
  39202. },
  39203. bracketSameLine: {
  39204. since: "2.4.0",
  39205. category: CATEGORY_COMMON,
  39206. type: "boolean",
  39207. default: false,
  39208. description: "Put > of opening tags on the last line instead of on a new line."
  39209. }
  39210. };
  39211. const CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  39212. var options$5 = {
  39213. arrowParens: {
  39214. since: "1.9.0",
  39215. category: CATEGORY_JAVASCRIPT,
  39216. type: "choice",
  39217. default: [{
  39218. since: "1.9.0",
  39219. value: "avoid"
  39220. }, {
  39221. since: "2.0.0",
  39222. value: "always"
  39223. }],
  39224. description: "Include parentheses around a sole arrow function parameter.",
  39225. choices: [{
  39226. value: "always",
  39227. description: "Always include parens. Example: `(x) => x`"
  39228. }, {
  39229. value: "avoid",
  39230. description: "Omit parens when possible. Example: `x => x`"
  39231. }]
  39232. },
  39233. bracketSameLine: commonOptions.bracketSameLine,
  39234. bracketSpacing: commonOptions.bracketSpacing,
  39235. jsxBracketSameLine: {
  39236. since: "0.17.0",
  39237. category: CATEGORY_JAVASCRIPT,
  39238. type: "boolean",
  39239. description: "Put > on the last line instead of at a new line.",
  39240. deprecated: "2.4.0"
  39241. },
  39242. semi: {
  39243. since: "1.0.0",
  39244. category: CATEGORY_JAVASCRIPT,
  39245. type: "boolean",
  39246. default: true,
  39247. description: "Print semicolons.",
  39248. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  39249. },
  39250. singleQuote: commonOptions.singleQuote,
  39251. jsxSingleQuote: {
  39252. since: "1.15.0",
  39253. category: CATEGORY_JAVASCRIPT,
  39254. type: "boolean",
  39255. default: false,
  39256. description: "Use single quotes in JSX."
  39257. },
  39258. quoteProps: {
  39259. since: "1.17.0",
  39260. category: CATEGORY_JAVASCRIPT,
  39261. type: "choice",
  39262. default: "as-needed",
  39263. description: "Change when properties in objects are quoted.",
  39264. choices: [{
  39265. value: "as-needed",
  39266. description: "Only add quotes around object properties where required."
  39267. }, {
  39268. value: "consistent",
  39269. description: "If at least one property in an object requires quotes, quote all properties."
  39270. }, {
  39271. value: "preserve",
  39272. description: "Respect the input use of quotes in object properties."
  39273. }]
  39274. },
  39275. trailingComma: {
  39276. since: "0.0.0",
  39277. category: CATEGORY_JAVASCRIPT,
  39278. type: "choice",
  39279. default: [{
  39280. since: "0.0.0",
  39281. value: false
  39282. }, {
  39283. since: "0.19.0",
  39284. value: "none"
  39285. }, {
  39286. since: "2.0.0",
  39287. value: "es5"
  39288. }],
  39289. description: "Print trailing commas wherever possible when multi-line.",
  39290. choices: [{
  39291. value: "es5",
  39292. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  39293. }, {
  39294. value: "none",
  39295. description: "No trailing commas."
  39296. }, {
  39297. value: "all",
  39298. description: "Trailing commas wherever possible (including function arguments)."
  39299. }]
  39300. }
  39301. };
  39302. var require$$0$7 = require("./parser-babel.js");
  39303. var require$$1$3 = require("./parser-flow.js");
  39304. var require$$2$4 = require("./parser-typescript.js");
  39305. var require$$3$2 = require("./parser-angular.js");
  39306. var require$$4$1 = require("./parser-espree.js");
  39307. var require$$5$1 = require("./parser-meriyah.js");
  39308. var parsers$6 = {
  39309. // JS - Babel
  39310. get babel() {
  39311. return require$$0$7.parsers.babel;
  39312. },
  39313. get "babel-flow"() {
  39314. return require$$0$7.parsers["babel-flow"];
  39315. },
  39316. get "babel-ts"() {
  39317. return require$$0$7.parsers["babel-ts"];
  39318. },
  39319. get json() {
  39320. return require$$0$7.parsers.json;
  39321. },
  39322. get json5() {
  39323. return require$$0$7.parsers.json5;
  39324. },
  39325. get "json-stringify"() {
  39326. return require$$0$7.parsers["json-stringify"];
  39327. },
  39328. get __js_expression() {
  39329. return require$$0$7.parsers.__js_expression;
  39330. },
  39331. get __vue_expression() {
  39332. return require$$0$7.parsers.__vue_expression;
  39333. },
  39334. get __vue_event_binding() {
  39335. return require$$0$7.parsers.__vue_event_binding;
  39336. },
  39337. // JS - Flow
  39338. get flow() {
  39339. return require$$1$3.parsers.flow;
  39340. },
  39341. // JS - TypeScript
  39342. get typescript() {
  39343. return require$$2$4.parsers.typescript;
  39344. },
  39345. // JS - Angular Action
  39346. get __ng_action() {
  39347. return require$$3$2.parsers.__ng_action;
  39348. },
  39349. // JS - Angular Binding
  39350. get __ng_binding() {
  39351. return require$$3$2.parsers.__ng_binding;
  39352. },
  39353. // JS - Angular Interpolation
  39354. get __ng_interpolation() {
  39355. return require$$3$2.parsers.__ng_interpolation;
  39356. },
  39357. // JS - Angular Directive
  39358. get __ng_directive() {
  39359. return require$$3$2.parsers.__ng_directive;
  39360. },
  39361. // JS - espree
  39362. get espree() {
  39363. return require$$4$1.parsers.espree;
  39364. },
  39365. // JS - meriyah
  39366. get meriyah() {
  39367. return require$$5$1.parsers.meriyah;
  39368. },
  39369. // JS - Babel Estree
  39370. get __babel_estree() {
  39371. return require$$0$7.parsers.__babel_estree;
  39372. }
  39373. };
  39374. var name$f = "JavaScript";
  39375. var type$f = "programming";
  39376. var tmScope$f = "source.js";
  39377. var aceMode$f = "javascript";
  39378. var codemirrorMode$b = "javascript";
  39379. var codemirrorMimeType$b = "text/javascript";
  39380. var color$a = "#f1e05a";
  39381. var aliases$6 = [
  39382. "js",
  39383. "node"
  39384. ];
  39385. var extensions$f = [
  39386. ".js",
  39387. "._js",
  39388. ".bones",
  39389. ".cjs",
  39390. ".es",
  39391. ".es6",
  39392. ".frag",
  39393. ".gs",
  39394. ".jake",
  39395. ".jsb",
  39396. ".jscad",
  39397. ".jsfl",
  39398. ".jsm",
  39399. ".jss",
  39400. ".jsx",
  39401. ".mjs",
  39402. ".njs",
  39403. ".pac",
  39404. ".sjs",
  39405. ".ssjs",
  39406. ".xsjs",
  39407. ".xsjslib"
  39408. ];
  39409. var filenames$4 = [
  39410. "Jakefile"
  39411. ];
  39412. var interpreters$1 = [
  39413. "chakra",
  39414. "d8",
  39415. "gjs",
  39416. "js",
  39417. "node",
  39418. "nodejs",
  39419. "qjs",
  39420. "rhino",
  39421. "v8",
  39422. "v8-shell"
  39423. ];
  39424. var languageId$f = 183;
  39425. var require$$0$6 = {
  39426. name: name$f,
  39427. type: type$f,
  39428. tmScope: tmScope$f,
  39429. aceMode: aceMode$f,
  39430. codemirrorMode: codemirrorMode$b,
  39431. codemirrorMimeType: codemirrorMimeType$b,
  39432. color: color$a,
  39433. aliases: aliases$6,
  39434. extensions: extensions$f,
  39435. filenames: filenames$4,
  39436. interpreters: interpreters$1,
  39437. languageId: languageId$f
  39438. };
  39439. var name$e = "TypeScript";
  39440. var type$e = "programming";
  39441. var color$9 = "#2b7489";
  39442. var aliases$5 = [
  39443. "ts"
  39444. ];
  39445. var interpreters = [
  39446. "deno",
  39447. "ts-node"
  39448. ];
  39449. var extensions$e = [
  39450. ".ts"
  39451. ];
  39452. var tmScope$e = "source.ts";
  39453. var aceMode$e = "typescript";
  39454. var codemirrorMode$a = "javascript";
  39455. var codemirrorMimeType$a = "application/typescript";
  39456. var languageId$e = 378;
  39457. var require$$1$2 = {
  39458. name: name$e,
  39459. type: type$e,
  39460. color: color$9,
  39461. aliases: aliases$5,
  39462. interpreters: interpreters,
  39463. extensions: extensions$e,
  39464. tmScope: tmScope$e,
  39465. aceMode: aceMode$e,
  39466. codemirrorMode: codemirrorMode$a,
  39467. codemirrorMimeType: codemirrorMimeType$a,
  39468. languageId: languageId$e
  39469. };
  39470. var name$d = "TSX";
  39471. var type$d = "programming";
  39472. var group$e = "TypeScript";
  39473. var extensions$d = [
  39474. ".tsx"
  39475. ];
  39476. var tmScope$d = "source.tsx";
  39477. var aceMode$d = "javascript";
  39478. var codemirrorMode$9 = "jsx";
  39479. var codemirrorMimeType$9 = "text/jsx";
  39480. var languageId$d = 94901924;
  39481. var require$$2$3 = {
  39482. name: name$d,
  39483. type: type$d,
  39484. group: group$e,
  39485. extensions: extensions$d,
  39486. tmScope: tmScope$d,
  39487. aceMode: aceMode$d,
  39488. codemirrorMode: codemirrorMode$9,
  39489. codemirrorMimeType: codemirrorMimeType$9,
  39490. languageId: languageId$d
  39491. };
  39492. var name$c = "JSON";
  39493. var type$c = "data";
  39494. var tmScope$c = "source.json";
  39495. var aceMode$c = "json";
  39496. var codemirrorMode$8 = "javascript";
  39497. var codemirrorMimeType$8 = "application/json";
  39498. var extensions$c = [
  39499. ".json",
  39500. ".avsc",
  39501. ".geojson",
  39502. ".gltf",
  39503. ".har",
  39504. ".ice",
  39505. ".JSON-tmLanguage",
  39506. ".jsonl",
  39507. ".mcmeta",
  39508. ".tfstate",
  39509. ".tfstate.backup",
  39510. ".topojson",
  39511. ".webapp",
  39512. ".webmanifest",
  39513. ".yy",
  39514. ".yyp"
  39515. ];
  39516. var filenames$3 = [
  39517. ".arcconfig",
  39518. ".htmlhintrc",
  39519. ".imgbotconfig",
  39520. ".tern-config",
  39521. ".tern-project",
  39522. ".watchmanconfig",
  39523. "Pipfile.lock",
  39524. "composer.lock",
  39525. "mcmod.info"
  39526. ];
  39527. var languageId$c = 174;
  39528. var require$$3$1 = {
  39529. name: name$c,
  39530. type: type$c,
  39531. tmScope: tmScope$c,
  39532. aceMode: aceMode$c,
  39533. codemirrorMode: codemirrorMode$8,
  39534. codemirrorMimeType: codemirrorMimeType$8,
  39535. extensions: extensions$c,
  39536. filenames: filenames$3,
  39537. languageId: languageId$c
  39538. };
  39539. var name$b = "JSON with Comments";
  39540. var type$b = "data";
  39541. var group$d = "JSON";
  39542. var tmScope$b = "source.js";
  39543. var aceMode$b = "javascript";
  39544. var codemirrorMode$7 = "javascript";
  39545. var codemirrorMimeType$7 = "text/javascript";
  39546. var aliases$4 = [
  39547. "jsonc"
  39548. ];
  39549. var extensions$b = [
  39550. ".jsonc",
  39551. ".sublime-build",
  39552. ".sublime-commands",
  39553. ".sublime-completions",
  39554. ".sublime-keymap",
  39555. ".sublime-macro",
  39556. ".sublime-menu",
  39557. ".sublime-mousemap",
  39558. ".sublime-project",
  39559. ".sublime-settings",
  39560. ".sublime-theme",
  39561. ".sublime-workspace",
  39562. ".sublime_metrics",
  39563. ".sublime_session"
  39564. ];
  39565. var filenames$2 = [
  39566. ".babelrc",
  39567. ".eslintrc.json",
  39568. ".jscsrc",
  39569. ".jshintrc",
  39570. ".jslintrc",
  39571. "api-extractor.json",
  39572. "devcontainer.json",
  39573. "jsconfig.json",
  39574. "language-configuration.json",
  39575. "tsconfig.json",
  39576. "tslint.json"
  39577. ];
  39578. var languageId$b = 423;
  39579. var require$$4 = {
  39580. name: name$b,
  39581. type: type$b,
  39582. group: group$d,
  39583. tmScope: tmScope$b,
  39584. aceMode: aceMode$b,
  39585. codemirrorMode: codemirrorMode$7,
  39586. codemirrorMimeType: codemirrorMimeType$7,
  39587. aliases: aliases$4,
  39588. extensions: extensions$b,
  39589. filenames: filenames$2,
  39590. languageId: languageId$b
  39591. };
  39592. var name$a = "JSON5";
  39593. var type$a = "data";
  39594. var extensions$a = [
  39595. ".json5"
  39596. ];
  39597. var tmScope$a = "source.js";
  39598. var aceMode$a = "javascript";
  39599. var codemirrorMode$6 = "javascript";
  39600. var codemirrorMimeType$6 = "application/json";
  39601. var languageId$a = 175;
  39602. var require$$5 = {
  39603. name: name$a,
  39604. type: type$a,
  39605. extensions: extensions$a,
  39606. tmScope: tmScope$a,
  39607. aceMode: aceMode$a,
  39608. codemirrorMode: codemirrorMode$6,
  39609. codemirrorMimeType: codemirrorMimeType$6,
  39610. languageId: languageId$a
  39611. };
  39612. const languages$7 = [createLanguage(require$$0$6, data => ({
  39613. since: "0.0.0",
  39614. parsers: ["babel", "espree", "meriyah", "babel-flow", "babel-ts", "flow", "typescript"],
  39615. vscodeLanguageIds: ["javascript", "mongo"],
  39616. interpreters: [...data.interpreters, // https://github.com/google/zx
  39617. "zx"],
  39618. extensions: [...data.extensions.filter(extension => extension !== ".jsx"), // WeiXin Script (Weixin Mini Programs)
  39619. // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
  39620. ".wxs"]
  39621. })), createLanguage(require$$0$6, () => ({
  39622. name: "Flow",
  39623. since: "0.0.0",
  39624. parsers: ["flow", "babel-flow"],
  39625. vscodeLanguageIds: ["javascript"],
  39626. aliases: [],
  39627. filenames: [],
  39628. extensions: [".js.flow"]
  39629. })), createLanguage(require$$0$6, () => ({
  39630. name: "JSX",
  39631. since: "0.0.0",
  39632. parsers: ["babel", "babel-flow", "babel-ts", "flow", "typescript", "espree", "meriyah"],
  39633. vscodeLanguageIds: ["javascriptreact"],
  39634. aliases: undefined,
  39635. filenames: undefined,
  39636. extensions: [".jsx"],
  39637. group: "JavaScript",
  39638. interpreters: undefined,
  39639. tmScope: "source.js.jsx",
  39640. aceMode: "javascript",
  39641. codemirrorMode: "jsx",
  39642. codemirrorMimeType: "text/jsx",
  39643. color: undefined
  39644. })), createLanguage(require$$1$2, () => ({
  39645. since: "1.4.0",
  39646. parsers: ["typescript", "babel-ts"],
  39647. vscodeLanguageIds: ["typescript"]
  39648. })), createLanguage(require$$2$3, () => ({
  39649. since: "1.4.0",
  39650. parsers: ["typescript", "babel-ts"],
  39651. vscodeLanguageIds: ["typescriptreact"]
  39652. })), createLanguage(require$$3$1, () => ({
  39653. name: "JSON.stringify",
  39654. since: "1.13.0",
  39655. parsers: ["json-stringify"],
  39656. vscodeLanguageIds: ["json"],
  39657. extensions: [],
  39658. // .json file defaults to json instead of json-stringify
  39659. filenames: ["package.json", "package-lock.json", "composer.json"]
  39660. })), createLanguage(require$$3$1, data => ({
  39661. since: "1.5.0",
  39662. parsers: ["json"],
  39663. vscodeLanguageIds: ["json"],
  39664. extensions: data.extensions.filter(extension => extension !== ".jsonl")
  39665. })), createLanguage(require$$4, data => ({
  39666. since: "1.5.0",
  39667. parsers: ["json"],
  39668. vscodeLanguageIds: ["jsonc"],
  39669. filenames: [...data.filenames, ".eslintrc"]
  39670. })), createLanguage(require$$5, () => ({
  39671. since: "1.13.0",
  39672. parsers: ["json5"],
  39673. vscodeLanguageIds: ["json5"]
  39674. }))];
  39675. const printers$5 = {
  39676. estree: printerEstree,
  39677. "estree-json": printerEstreeJson
  39678. };
  39679. var languageJs = {
  39680. languages: languages$7,
  39681. options: options$5,
  39682. printers: printers$5,
  39683. parsers: parsers$6
  39684. };
  39685. const {
  39686. isFrontMatterNode: isFrontMatterNode$4
  39687. } = util$5;
  39688. const ignoredProperties$2 = new Set(["raw", // front-matter
  39689. "raws", "sourceIndex", "source", "before", "after", "trailingComma"]);
  39690. function clean$5(ast, newObj, parent) {
  39691. if (isFrontMatterNode$4(ast) && ast.lang === "yaml") {
  39692. delete newObj.value;
  39693. }
  39694. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length > 0) {
  39695. // --insert-pragma
  39696. // first non-front-matter comment
  39697. if (parent.nodes[0] === ast || isFrontMatterNode$4(parent.nodes[0]) && parent.nodes[1] === ast) {
  39698. /**
  39699. * something
  39700. *
  39701. * @format
  39702. */
  39703. delete newObj.text; // standalone pragma
  39704. if (/^\*\s*@(?:format|prettier)\s*$/.test(ast.text)) {
  39705. return null;
  39706. }
  39707. } // Last comment is not parsed, when omitting semicolon, #8675
  39708. if (parent.type === "css-root" && getLast_1(parent.nodes) === ast) {
  39709. return null;
  39710. }
  39711. }
  39712. if (ast.type === "value-root") {
  39713. delete newObj.text;
  39714. }
  39715. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  39716. delete newObj.value;
  39717. }
  39718. if (ast.type === "css-rule") {
  39719. delete newObj.params;
  39720. }
  39721. if (ast.type === "selector-combinator") {
  39722. newObj.value = newObj.value.replace(/\s+/g, " ");
  39723. }
  39724. if (ast.type === "media-feature") {
  39725. newObj.value = newObj.value.replace(/ /g, "");
  39726. }
  39727. if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
  39728. newObj.value = newObj.value.toLowerCase();
  39729. }
  39730. if (ast.type === "css-decl") {
  39731. newObj.prop = newObj.prop.toLowerCase();
  39732. }
  39733. if (ast.type === "css-atrule" || ast.type === "css-import") {
  39734. newObj.name = newObj.name.toLowerCase();
  39735. }
  39736. if (ast.type === "value-number") {
  39737. newObj.unit = newObj.unit.toLowerCase();
  39738. }
  39739. if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
  39740. newObj.value = cleanCSSStrings(newObj.value);
  39741. }
  39742. if (ast.type === "selector-attribute") {
  39743. newObj.attribute = newObj.attribute.trim();
  39744. if (newObj.namespace) {
  39745. if (typeof newObj.namespace === "string") {
  39746. newObj.namespace = newObj.namespace.trim();
  39747. if (newObj.namespace.length === 0) {
  39748. newObj.namespace = true;
  39749. }
  39750. }
  39751. }
  39752. if (newObj.value) {
  39753. newObj.value = newObj.value.trim().replace(/^["']|["']$/g, "");
  39754. delete newObj.quoted;
  39755. }
  39756. }
  39757. if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
  39758. newObj.value = newObj.value.replace(/([\d+.Ee-]+)([A-Za-z]*)/g, (match, numStr, unit) => {
  39759. const num = Number(numStr);
  39760. return Number.isNaN(num) ? match : num + unit.toLowerCase();
  39761. });
  39762. }
  39763. if (ast.type === "selector-tag") {
  39764. const lowercasedValue = ast.value.toLowerCase();
  39765. if (["from", "to"].includes(lowercasedValue)) {
  39766. newObj.value = lowercasedValue;
  39767. }
  39768. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  39769. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  39770. delete newObj.value;
  39771. } // Workaround for SCSS nested properties
  39772. if (ast.type === "selector-unknown") {
  39773. delete newObj.value;
  39774. }
  39775. }
  39776. clean$5.ignoredProperties = ignoredProperties$2;
  39777. function cleanCSSStrings(value) {
  39778. return value.replace(/'/g, '"').replace(/\\([^\dA-Fa-f])/g, "$1");
  39779. }
  39780. var clean_1$3 = clean$5;
  39781. const {
  39782. builders: {
  39783. hardline: hardline$e,
  39784. markAsRoot: markAsRoot$3
  39785. }
  39786. } = doc;
  39787. function print$1(node, textToDoc) {
  39788. if (node.lang === "yaml") {
  39789. const value = node.value.trim();
  39790. const doc = value ? textToDoc(value, {
  39791. parser: "yaml"
  39792. }, {
  39793. stripTrailingHardline: true
  39794. }) : "";
  39795. return markAsRoot$3([node.startDelimiter, hardline$e, doc, doc ? hardline$e : "", node.endDelimiter]);
  39796. }
  39797. }
  39798. var print_1 = print$1;
  39799. const {
  39800. builders: {
  39801. hardline: hardline$d
  39802. }
  39803. } = doc;
  39804. function embed$4(path, print, textToDoc
  39805. /*, options */
  39806. ) {
  39807. const node = path.getValue();
  39808. if (node.type === "front-matter") {
  39809. const doc = print_1(node, textToDoc);
  39810. return doc ? [doc, hardline$d] : "";
  39811. }
  39812. }
  39813. var embed_1$3 = embed$4;
  39814. const frontMatterRegex = new RegExp("^(?<startDelimiter>-{3}|\\+{3})" + // trailing spaces after delimiters are allowed
  39815. "(?<language>[^\\n]*)" + "\\n(?:|(?<value>.*?)\\n)" + // In some markdown processors such as pandoc,
  39816. // "..." can be used as the end delimiter for YAML front-matter.
  39817. // Adding `\.{3}` make the regex matches `+++\n...`, but we'll exclude it later
  39818. "(?<endDelimiter>\\k<startDelimiter>|\\.{3})" + "[^\\S\\n]*(?:\\n|$)", "s");
  39819. function parse(text) {
  39820. const match = text.match(frontMatterRegex);
  39821. if (!match) {
  39822. return {
  39823. content: text
  39824. };
  39825. }
  39826. const {
  39827. startDelimiter,
  39828. language,
  39829. value = "",
  39830. endDelimiter
  39831. } = match.groups;
  39832. let lang = language.trim() || "yaml";
  39833. if (startDelimiter === "+++") {
  39834. lang = "toml";
  39835. } // Only allow yaml to parse with a different end delimiter
  39836. if (lang !== "yaml" && startDelimiter !== endDelimiter) {
  39837. return {
  39838. content: text
  39839. };
  39840. }
  39841. const [raw] = match;
  39842. const frontMatter = {
  39843. type: "front-matter",
  39844. lang,
  39845. value,
  39846. startDelimiter,
  39847. endDelimiter,
  39848. raw: raw.replace(/\n$/, "")
  39849. };
  39850. return {
  39851. frontMatter,
  39852. content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
  39853. };
  39854. }
  39855. var parse_1 = parse;
  39856. function hasPragma$3(text) {
  39857. return pragma$5.hasPragma(parse_1(text).content);
  39858. }
  39859. function insertPragma$8(text) {
  39860. const {
  39861. frontMatter,
  39862. content
  39863. } = parse_1(text);
  39864. return (frontMatter ? frontMatter.raw + "\n\n" : "") + pragma$5.insertPragma(content);
  39865. }
  39866. var pragma$4 = {
  39867. hasPragma: hasPragma$3,
  39868. insertPragma: insertPragma$8
  39869. };
  39870. const {
  39871. isNonEmptyArray: isNonEmptyArray$6
  39872. } = util$5;
  39873. const colorAdjusterFunctions = new Set(["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"]);
  39874. const moduleRuleNames = new Set(["import", "use", "forward"]);
  39875. function getAncestorCounter$1(path, typeOrTypes) {
  39876. const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
  39877. let counter = -1;
  39878. let ancestorNode;
  39879. while (ancestorNode = path.getParentNode(++counter)) {
  39880. if (types.includes(ancestorNode.type)) {
  39881. return counter;
  39882. }
  39883. }
  39884. return -1;
  39885. }
  39886. function getAncestorNode$2(path, typeOrTypes) {
  39887. const counter = getAncestorCounter$1(path, typeOrTypes);
  39888. return counter === -1 ? null : path.getParentNode(counter);
  39889. }
  39890. function getPropOfDeclNode$1(path) {
  39891. const declAncestorNode = getAncestorNode$2(path, "css-decl");
  39892. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  39893. }
  39894. function hasSCSSInterpolation(groupList) {
  39895. if (isNonEmptyArray$6(groupList)) {
  39896. for (let i = groupList.length - 1; i > 0; i--) {
  39897. // If we find `#{`, return true.
  39898. if (groupList[i].type === "word" && groupList[i].value === "{" && groupList[i - 1].type === "word" && groupList[i - 1].value.endsWith("#")) {
  39899. return true;
  39900. }
  39901. }
  39902. }
  39903. return false;
  39904. }
  39905. function hasStringOrFunction(groupList) {
  39906. if (isNonEmptyArray$6(groupList)) {
  39907. for (let i = 0; i < groupList.length; i++) {
  39908. if (groupList[i].type === "string" || groupList[i].type === "func") {
  39909. return true;
  39910. }
  39911. }
  39912. }
  39913. return false;
  39914. }
  39915. function isSCSS$1(parser, text) {
  39916. const hasExplicitParserChoice = parser === "less" || parser === "scss";
  39917. const IS_POSSIBLY_SCSS = /(?:\w\s*:\s*[^:}]+|#){|@import[^\n]+(?:url|,)/;
  39918. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  39919. }
  39920. function isSCSSVariable(node) {
  39921. return Boolean(node && node.type === "word" && node.value.startsWith("$"));
  39922. }
  39923. function isWideKeywords$1(value) {
  39924. return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
  39925. }
  39926. function isKeyframeAtRuleKeywords$1(path, value) {
  39927. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  39928. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
  39929. }
  39930. function maybeToLowerCase$1(value) {
  39931. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  39932. }
  39933. function insideValueFunctionNode$1(path, functionName) {
  39934. const funcAncestorNode = getAncestorNode$2(path, "value-func");
  39935. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  39936. }
  39937. function insideICSSRuleNode$1(path) {
  39938. const ruleAncestorNode = getAncestorNode$2(path, "css-rule");
  39939. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  39940. }
  39941. function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
  39942. const atRuleNames = Array.isArray(atRuleNameOrAtRuleNames) ? atRuleNameOrAtRuleNames : [atRuleNameOrAtRuleNames];
  39943. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  39944. return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
  39945. }
  39946. function insideURLFunctionInImportAtRuleNode$1(path) {
  39947. const node = path.getValue();
  39948. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  39949. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  39950. }
  39951. function isURLFunctionNode$1(node) {
  39952. return node.type === "value-func" && node.value.toLowerCase() === "url";
  39953. }
  39954. function isLastNode$1(path, node) {
  39955. const parentNode = path.getParentNode();
  39956. /* istanbul ignore next */
  39957. if (!parentNode) {
  39958. return false;
  39959. }
  39960. const {
  39961. nodes
  39962. } = parentNode;
  39963. return nodes && nodes.indexOf(node) === nodes.length - 1;
  39964. }
  39965. function isDetachedRulesetDeclarationNode$1(node) {
  39966. // If a Less file ends up being parsed with the SCSS parser, Less
  39967. // variable declarations will be parsed as atrules with names ending
  39968. // with a colon, so keep the original case then.
  39969. /* istanbul ignore next */
  39970. if (!node.selector) {
  39971. return false;
  39972. }
  39973. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  39974. }
  39975. function isForKeywordNode$1(node) {
  39976. return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
  39977. }
  39978. function isIfElseKeywordNode$1(node) {
  39979. return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
  39980. }
  39981. function isEachKeywordNode$1(node) {
  39982. return node.type === "value-word" && node.value === "in";
  39983. }
  39984. function isMultiplicationNode$1(node) {
  39985. return node.type === "value-operator" && node.value === "*";
  39986. }
  39987. function isDivisionNode$1(node) {
  39988. return node.type === "value-operator" && node.value === "/";
  39989. }
  39990. function isAdditionNode$1(node) {
  39991. return node.type === "value-operator" && node.value === "+";
  39992. }
  39993. function isSubtractionNode$1(node) {
  39994. return node.type === "value-operator" && node.value === "-";
  39995. }
  39996. function isModuloNode(node) {
  39997. return node.type === "value-operator" && node.value === "%";
  39998. }
  39999. function isMathOperatorNode$1(node) {
  40000. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  40001. }
  40002. function isEqualityOperatorNode$1(node) {
  40003. return node.type === "value-word" && ["==", "!="].includes(node.value);
  40004. }
  40005. function isRelationalOperatorNode$1(node) {
  40006. return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
  40007. }
  40008. function isSCSSControlDirectiveNode$1(node) {
  40009. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
  40010. }
  40011. function isSCSSNestedPropertyNode(node) {
  40012. /* istanbul ignore next */
  40013. if (!node.selector) {
  40014. return false;
  40015. }
  40016. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  40017. }
  40018. function isDetachedRulesetCallNode$1(node) {
  40019. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  40020. }
  40021. function isTemplatePlaceholderNode$1(node) {
  40022. return node.name.startsWith("prettier-placeholder");
  40023. }
  40024. function isTemplatePropNode$1(node) {
  40025. return node.prop.startsWith("@prettier-placeholder");
  40026. }
  40027. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  40028. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  40029. }
  40030. function hasComposesNode$1(node) {
  40031. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  40032. }
  40033. function hasParensAroundNode$1(node) {
  40034. return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
  40035. }
  40036. function hasEmptyRawBefore$1(node) {
  40037. return node.raws && node.raws.before === "";
  40038. }
  40039. function isKeyValuePairNode$1(node) {
  40040. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  40041. }
  40042. function isKeyValuePairInParenGroupNode(node) {
  40043. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  40044. }
  40045. function isSCSSMapItemNode$1(path) {
  40046. const node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
  40047. if (node.groups.length === 0) {
  40048. return false;
  40049. }
  40050. const parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  40051. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  40052. return false;
  40053. }
  40054. const declNode = getAncestorNode$2(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  40055. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  40056. return true;
  40057. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  40058. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  40059. return true;
  40060. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  40061. if (parentParentNode.type === "value-func") {
  40062. return true;
  40063. }
  40064. return false;
  40065. }
  40066. function isInlineValueCommentNode$1(node) {
  40067. return node.type === "value-comment" && node.inline;
  40068. }
  40069. function isHashNode$1(node) {
  40070. return node.type === "value-word" && node.value === "#";
  40071. }
  40072. function isLeftCurlyBraceNode$1(node) {
  40073. return node.type === "value-word" && node.value === "{";
  40074. }
  40075. function isRightCurlyBraceNode$1(node) {
  40076. return node.type === "value-word" && node.value === "}";
  40077. }
  40078. function isWordNode$1(node) {
  40079. return ["value-word", "value-atword"].includes(node.type);
  40080. }
  40081. function isColonNode$1(node) {
  40082. return node && node.type === "value-colon";
  40083. }
  40084. function isKeyInValuePairNode$1(node, parentNode) {
  40085. if (!isKeyValuePairNode$1(parentNode)) {
  40086. return false;
  40087. }
  40088. const {
  40089. groups
  40090. } = parentNode;
  40091. const index = groups.indexOf(node);
  40092. if (index === -1) {
  40093. return false;
  40094. }
  40095. return isColonNode$1(groups[index + 1]);
  40096. }
  40097. function isMediaAndSupportsKeywords$1(node) {
  40098. return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
  40099. }
  40100. function isColorAdjusterFuncNode$1(node) {
  40101. if (node.type !== "value-func") {
  40102. return false;
  40103. }
  40104. return colorAdjusterFunctions.has(node.value.toLowerCase());
  40105. } // TODO: only check `less` when we don't use `less` to parse `css`
  40106. function isLessParser$1(options) {
  40107. return options.parser === "css" || options.parser === "less";
  40108. }
  40109. function lastLineHasInlineComment$1(text) {
  40110. return /\/\//.test(text.split(/[\n\r]/).pop());
  40111. }
  40112. function stringifyNode(node) {
  40113. if (node.groups) {
  40114. const open = node.open && node.open.value ? node.open.value : "";
  40115. const groups = node.groups.reduce((previousValue, currentValue, index) => previousValue + stringifyNode(currentValue) + (node.groups[0].type === "comma_group" && index !== node.groups.length - 1 ? "," : ""), "");
  40116. const close = node.close && node.close.value ? node.close.value : "";
  40117. return open + groups + close;
  40118. }
  40119. const before = node.raws && node.raws.before ? node.raws.before : "";
  40120. const quote = node.raws && node.raws.quote ? node.raws.quote : "";
  40121. const atword = node.type === "atword" ? "@" : "";
  40122. const value = node.value ? node.value : "";
  40123. const unit = node.unit ? node.unit : "";
  40124. const group = node.group ? stringifyNode(node.group) : "";
  40125. const after = node.raws && node.raws.after ? node.raws.after : "";
  40126. return before + quote + atword + value + quote + unit + group + after;
  40127. }
  40128. function isAtWordPlaceholderNode$1(node) {
  40129. return node && node.type === "value-atword" && node.value.startsWith("prettier-placeholder-");
  40130. }
  40131. function isModuleRuleName(name) {
  40132. return moduleRuleNames.has(name);
  40133. }
  40134. var utils$4 = {
  40135. getAncestorCounter: getAncestorCounter$1,
  40136. getAncestorNode: getAncestorNode$2,
  40137. getPropOfDeclNode: getPropOfDeclNode$1,
  40138. hasSCSSInterpolation,
  40139. hasStringOrFunction,
  40140. maybeToLowerCase: maybeToLowerCase$1,
  40141. insideValueFunctionNode: insideValueFunctionNode$1,
  40142. insideICSSRuleNode: insideICSSRuleNode$1,
  40143. insideAtRuleNode: insideAtRuleNode$1,
  40144. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  40145. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  40146. isWideKeywords: isWideKeywords$1,
  40147. isSCSS: isSCSS$1,
  40148. isSCSSVariable,
  40149. isLastNode: isLastNode$1,
  40150. isLessParser: isLessParser$1,
  40151. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  40152. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  40153. isRelationalOperatorNode: isRelationalOperatorNode$1,
  40154. isEqualityOperatorNode: isEqualityOperatorNode$1,
  40155. isMultiplicationNode: isMultiplicationNode$1,
  40156. isDivisionNode: isDivisionNode$1,
  40157. isAdditionNode: isAdditionNode$1,
  40158. isSubtractionNode: isSubtractionNode$1,
  40159. isModuloNode,
  40160. isMathOperatorNode: isMathOperatorNode$1,
  40161. isEachKeywordNode: isEachKeywordNode$1,
  40162. isForKeywordNode: isForKeywordNode$1,
  40163. isURLFunctionNode: isURLFunctionNode$1,
  40164. isIfElseKeywordNode: isIfElseKeywordNode$1,
  40165. hasComposesNode: hasComposesNode$1,
  40166. hasParensAroundNode: hasParensAroundNode$1,
  40167. hasEmptyRawBefore: hasEmptyRawBefore$1,
  40168. isSCSSNestedPropertyNode,
  40169. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  40170. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  40171. isTemplatePropNode: isTemplatePropNode$1,
  40172. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  40173. isKeyValuePairNode: isKeyValuePairNode$1,
  40174. isKeyValuePairInParenGroupNode,
  40175. isKeyInValuePairNode: isKeyInValuePairNode$1,
  40176. isSCSSMapItemNode: isSCSSMapItemNode$1,
  40177. isInlineValueCommentNode: isInlineValueCommentNode$1,
  40178. isHashNode: isHashNode$1,
  40179. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  40180. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  40181. isWordNode: isWordNode$1,
  40182. isColonNode: isColonNode$1,
  40183. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  40184. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
  40185. lastLineHasInlineComment: lastLineHasInlineComment$1,
  40186. stringifyNode,
  40187. isAtWordPlaceholderNode: isAtWordPlaceholderNode$1,
  40188. isModuleRuleName
  40189. };
  40190. var lineColumnToIndex = function (lineColumn, text) {
  40191. let index = 0;
  40192. for (let i = 0; i < lineColumn.line - 1; ++i) {
  40193. index = text.indexOf("\n", index) + 1;
  40194. }
  40195. return index + lineColumn.column;
  40196. };
  40197. const {
  40198. getLast: getLast$4,
  40199. skipEverythingButNewLine
  40200. } = util$5;
  40201. function calculateLocStart(node, text) {
  40202. // value-* nodes have this
  40203. if (typeof node.sourceIndex === "number") {
  40204. return node.sourceIndex;
  40205. }
  40206. return node.source ? lineColumnToIndex(node.source.start, text) - 1 : null;
  40207. }
  40208. function calculateLocEnd(node, text) {
  40209. if (node.type === "css-comment" && node.inline) {
  40210. return skipEverythingButNewLine(text, node.source.startOffset);
  40211. }
  40212. const endNode = node.nodes && getLast$4(node.nodes);
  40213. if (endNode && node.source && !node.source.end) {
  40214. node = endNode;
  40215. }
  40216. if (node.source && node.source.end) {
  40217. return lineColumnToIndex(node.source.end, text);
  40218. }
  40219. return null;
  40220. }
  40221. function calculateLoc(node, text) {
  40222. if (node.source) {
  40223. node.source.startOffset = calculateLocStart(node, text);
  40224. node.source.endOffset = calculateLocEnd(node, text);
  40225. }
  40226. for (const key in node) {
  40227. const child = node[key];
  40228. if (key === "source" || !child || typeof child !== "object") {
  40229. continue;
  40230. }
  40231. if (child.type === "value-root" || child.type === "value-unknown") {
  40232. calculateValueNodeLoc(child, getValueRootOffset(node), child.text || child.value);
  40233. } else {
  40234. calculateLoc(child, text);
  40235. }
  40236. }
  40237. }
  40238. function calculateValueNodeLoc(node, rootOffset, text) {
  40239. if (node.source) {
  40240. node.source.startOffset = calculateLocStart(node, text) + rootOffset;
  40241. node.source.endOffset = calculateLocEnd(node, text) + rootOffset;
  40242. }
  40243. for (const key in node) {
  40244. const child = node[key];
  40245. if (key === "source" || !child || typeof child !== "object") {
  40246. continue;
  40247. }
  40248. calculateValueNodeLoc(child, rootOffset, text);
  40249. }
  40250. }
  40251. function getValueRootOffset(node) {
  40252. let result = node.source.startOffset;
  40253. if (typeof node.prop === "string") {
  40254. result += node.prop.length;
  40255. }
  40256. if (node.type === "css-atrule" && typeof node.name === "string") {
  40257. result += 1 + node.name.length + node.raws.afterName.match(/^\s*:?\s*/)[0].length;
  40258. }
  40259. if (node.type !== "css-atrule" && node.raws && typeof node.raws.between === "string") {
  40260. result += node.raws.between.length;
  40261. }
  40262. return result;
  40263. }
  40264. /**
  40265. * Workaround for a bug: quotes and asterisks in inline comments corrupt loc data of subsequent nodes.
  40266. * This function replaces the quotes and asterisks with spaces. Later, when the comments are printed,
  40267. * their content is extracted from the original text.
  40268. * - https://github.com/prettier/prettier/issues/7780
  40269. * - https://github.com/shellscape/postcss-less/issues/145
  40270. * - https://github.com/prettier/prettier/issues/8130
  40271. * @param text {string}
  40272. */
  40273. function replaceQuotesInInlineComments(text) {
  40274. /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
  40275. /** @type {State} */
  40276. let state = "initial";
  40277. /** @type {State} */
  40278. let stateToReturnFromQuotes = "initial";
  40279. let inlineCommentStartIndex;
  40280. let inlineCommentContainsQuotes = false;
  40281. const inlineCommentsToReplace = [];
  40282. for (let i = 0; i < text.length; i++) {
  40283. const c = text[i];
  40284. switch (state) {
  40285. case "initial":
  40286. if (c === "'") {
  40287. state = "single-quotes";
  40288. continue;
  40289. }
  40290. if (c === '"') {
  40291. state = "double-quotes";
  40292. continue;
  40293. }
  40294. if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
  40295. state = "url";
  40296. i += 3;
  40297. continue;
  40298. }
  40299. if (c === "*" && text[i - 1] === "/") {
  40300. state = "comment-block";
  40301. continue;
  40302. }
  40303. if (c === "/" && text[i - 1] === "/") {
  40304. state = "comment-inline";
  40305. inlineCommentStartIndex = i - 1;
  40306. continue;
  40307. }
  40308. continue;
  40309. case "single-quotes":
  40310. if (c === "'" && text[i - 1] !== "\\") {
  40311. state = stateToReturnFromQuotes;
  40312. stateToReturnFromQuotes = "initial";
  40313. }
  40314. if (c === "\n" || c === "\r") {
  40315. return text; // invalid input
  40316. }
  40317. continue;
  40318. case "double-quotes":
  40319. if (c === '"' && text[i - 1] !== "\\") {
  40320. state = stateToReturnFromQuotes;
  40321. stateToReturnFromQuotes = "initial";
  40322. }
  40323. if (c === "\n" || c === "\r") {
  40324. return text; // invalid input
  40325. }
  40326. continue;
  40327. case "url":
  40328. if (c === ")") {
  40329. state = "initial";
  40330. }
  40331. if (c === "\n" || c === "\r") {
  40332. return text; // invalid input
  40333. }
  40334. if (c === "'") {
  40335. state = "single-quotes";
  40336. stateToReturnFromQuotes = "url";
  40337. continue;
  40338. }
  40339. if (c === '"') {
  40340. state = "double-quotes";
  40341. stateToReturnFromQuotes = "url";
  40342. continue;
  40343. }
  40344. continue;
  40345. case "comment-block":
  40346. if (c === "/" && text[i - 1] === "*") {
  40347. state = "initial";
  40348. }
  40349. continue;
  40350. case "comment-inline":
  40351. if (c === '"' || c === "'" || c === "*") {
  40352. inlineCommentContainsQuotes = true;
  40353. }
  40354. if (c === "\n" || c === "\r") {
  40355. if (inlineCommentContainsQuotes) {
  40356. inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
  40357. }
  40358. state = "initial";
  40359. inlineCommentContainsQuotes = false;
  40360. }
  40361. continue;
  40362. }
  40363. }
  40364. for (const [start, end] of inlineCommentsToReplace) {
  40365. text = text.slice(0, start) + text.slice(start, end).replace(/["'*]/g, " ") + text.slice(end);
  40366. }
  40367. return text;
  40368. }
  40369. function locStart$e(node) {
  40370. return node.source.startOffset;
  40371. }
  40372. function locEnd$d(node) {
  40373. return node.source.endOffset;
  40374. }
  40375. var loc$5 = {
  40376. locStart: locStart$e,
  40377. locEnd: locEnd$d,
  40378. calculateLoc,
  40379. replaceQuotesInInlineComments
  40380. };
  40381. const {
  40382. printNumber,
  40383. printString,
  40384. hasNewline,
  40385. isFrontMatterNode: isFrontMatterNode$3,
  40386. isNextLineEmpty: isNextLineEmpty$3,
  40387. isNonEmptyArray: isNonEmptyArray$5
  40388. } = util$5;
  40389. const {
  40390. builders: {
  40391. join: join$a,
  40392. line: line$d,
  40393. hardline: hardline$c,
  40394. softline: softline$a,
  40395. group: group$c,
  40396. fill: fill$6,
  40397. indent: indent$7,
  40398. dedent: dedent$2,
  40399. ifBreak: ifBreak$8,
  40400. breakParent: breakParent$5
  40401. },
  40402. utils: {
  40403. removeLines,
  40404. getDocParts: getDocParts$5
  40405. }
  40406. } = doc;
  40407. const {
  40408. insertPragma: insertPragma$7
  40409. } = pragma$4;
  40410. const {
  40411. getAncestorNode: getAncestorNode$1,
  40412. getPropOfDeclNode,
  40413. maybeToLowerCase,
  40414. insideValueFunctionNode,
  40415. insideICSSRuleNode,
  40416. insideAtRuleNode,
  40417. insideURLFunctionInImportAtRuleNode,
  40418. isKeyframeAtRuleKeywords,
  40419. isWideKeywords,
  40420. isSCSS,
  40421. isLastNode,
  40422. isLessParser,
  40423. isSCSSControlDirectiveNode,
  40424. isDetachedRulesetDeclarationNode,
  40425. isRelationalOperatorNode,
  40426. isEqualityOperatorNode,
  40427. isMultiplicationNode,
  40428. isDivisionNode,
  40429. isAdditionNode,
  40430. isSubtractionNode,
  40431. isMathOperatorNode,
  40432. isEachKeywordNode,
  40433. isForKeywordNode,
  40434. isURLFunctionNode,
  40435. isIfElseKeywordNode,
  40436. hasComposesNode,
  40437. hasParensAroundNode,
  40438. hasEmptyRawBefore,
  40439. isKeyValuePairNode,
  40440. isKeyInValuePairNode,
  40441. isDetachedRulesetCallNode,
  40442. isTemplatePlaceholderNode,
  40443. isTemplatePropNode,
  40444. isPostcssSimpleVarNode,
  40445. isSCSSMapItemNode,
  40446. isInlineValueCommentNode,
  40447. isHashNode,
  40448. isLeftCurlyBraceNode,
  40449. isRightCurlyBraceNode,
  40450. isWordNode,
  40451. isColonNode,
  40452. isMediaAndSupportsKeywords,
  40453. isColorAdjusterFuncNode,
  40454. lastLineHasInlineComment,
  40455. isAtWordPlaceholderNode
  40456. } = utils$4;
  40457. const {
  40458. locStart: locStart$d,
  40459. locEnd: locEnd$c
  40460. } = loc$5;
  40461. function shouldPrintComma(options) {
  40462. return options.trailingComma === "es5" || options.trailingComma === "all";
  40463. }
  40464. function genericPrint$4(path, options, print) {
  40465. const node = path.getValue();
  40466. /* istanbul ignore if */
  40467. if (!node) {
  40468. return "";
  40469. }
  40470. if (typeof node === "string") {
  40471. return node;
  40472. }
  40473. switch (node.type) {
  40474. case "front-matter":
  40475. return [node.raw, hardline$c];
  40476. case "css-root":
  40477. {
  40478. const nodes = printNodeSequence(path, options, print);
  40479. const after = node.raws.after.trim();
  40480. return [nodes, after ? ` ${after}` : "", getDocParts$5(nodes).length > 0 ? hardline$c : ""];
  40481. }
  40482. case "css-comment":
  40483. {
  40484. const isInlineComment = node.inline || node.raws.inline;
  40485. const text = options.originalText.slice(locStart$d(node), locEnd$c(node));
  40486. return isInlineComment ? text.trimEnd() : text;
  40487. }
  40488. case "css-rule":
  40489. {
  40490. return [print("selector"), node.important ? " !important" : "", node.nodes ? [node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment(node.selector.value) ? line$d : " ", "{", node.nodes.length > 0 ? indent$7([hardline$c, printNodeSequence(path, options, print)]) : "", hardline$c, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""] : ";"];
  40491. }
  40492. case "css-decl":
  40493. {
  40494. const parentNode = path.getParentNode();
  40495. const {
  40496. between: rawBetween
  40497. } = node.raws;
  40498. const trimmedBetween = rawBetween.trim();
  40499. const isColon = trimmedBetween === ":";
  40500. let value = hasComposesNode(node) ? removeLines(print("value")) : print("value");
  40501. if (!isColon && lastLineHasInlineComment(trimmedBetween)) {
  40502. value = indent$7([hardline$c, dedent$2(value)]);
  40503. }
  40504. return [node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path) ? node.prop : maybeToLowerCase(node.prop), trimmedBetween.startsWith("//") ? " " : "", trimmedBetween, node.extend ? "" : " ", isLessParser(options) && node.extend && node.selector ? ["extend(", print("selector"), ")"] : "", value, node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? [" {", indent$7([softline$a, printNodeSequence(path, options, print)]), softline$a, "}"] : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";" ? "" : options.__isHTMLStyleAttribute && isLastNode(path, node) ? ifBreak$8(";") : ";"];
  40505. }
  40506. case "css-atrule":
  40507. {
  40508. const parentNode = path.getParentNode();
  40509. const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";";
  40510. if (isLessParser(options)) {
  40511. if (node.mixin) {
  40512. return [print("selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  40513. }
  40514. if (node.function) {
  40515. return [node.name, print("params"), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  40516. }
  40517. if (node.variable) {
  40518. return ["@", node.name, ": ", node.value ? print("value") : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? ["{", indent$7([node.nodes.length > 0 ? softline$a : "", printNodeSequence(path, options, print)]), softline$a, "}"] : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  40519. }
  40520. }
  40521. return ["@", // If a Less file ends up being parsed with the SCSS parser, Less
  40522. // variable declarations will be parsed as at-rules with names ending
  40523. // with a colon, so keep the original case then.
  40524. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? [isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? [hardline$c, hardline$c] : /^\s*\n/.test(node.raws.afterName) ? hardline$c : " " : " ", print("params")] : "", node.selector ? indent$7([" ", print("selector")]) : "", node.value ? group$c([" ", print("value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$d : ""]) : node.name === "else" ? " " : "", node.nodes ? [isSCSSControlDirectiveNode(node) ? "" : node.selector && !node.selector.nodes && typeof node.selector.value === "string" && lastLineHasInlineComment(node.selector.value) || !node.selector && typeof node.params === "string" && lastLineHasInlineComment(node.params) ? line$d : " ", "{", indent$7([node.nodes.length > 0 ? softline$a : "", printNodeSequence(path, options, print)]), softline$a, "}"] : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  40525. }
  40526. // postcss-media-query-parser
  40527. case "media-query-list":
  40528. {
  40529. const parts = [];
  40530. path.each(childPath => {
  40531. const node = childPath.getValue();
  40532. if (node.type === "media-query" && node.value === "") {
  40533. return;
  40534. }
  40535. parts.push(print());
  40536. }, "nodes");
  40537. return group$c(indent$7(join$a(line$d, parts)));
  40538. }
  40539. case "media-query":
  40540. {
  40541. return [join$a(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","];
  40542. }
  40543. case "media-type":
  40544. {
  40545. return adjustNumbers(adjustStrings(node.value, options));
  40546. }
  40547. case "media-feature-expression":
  40548. {
  40549. if (!node.nodes) {
  40550. return node.value;
  40551. }
  40552. return ["(", ...path.map(print, "nodes"), ")"];
  40553. }
  40554. case "media-feature":
  40555. {
  40556. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  40557. }
  40558. case "media-colon":
  40559. {
  40560. return [node.value, " "];
  40561. }
  40562. case "media-value":
  40563. {
  40564. return adjustNumbers(adjustStrings(node.value, options));
  40565. }
  40566. case "media-keyword":
  40567. {
  40568. return adjustStrings(node.value, options);
  40569. }
  40570. case "media-url":
  40571. {
  40572. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/g, ")"), options);
  40573. }
  40574. case "media-unknown":
  40575. {
  40576. return node.value;
  40577. }
  40578. // postcss-selector-parser
  40579. case "selector-root":
  40580. {
  40581. return group$c([insideAtRuleNode(path, "custom-selector") ? [getAncestorNode$1(path, "css-atrule").customSelector, line$d] : "", join$a([",", insideAtRuleNode(path, ["extend", "custom-selector", "nest"]) ? line$d : hardline$c], path.map(print, "nodes"))]);
  40582. }
  40583. case "selector-selector":
  40584. {
  40585. return group$c(indent$7(path.map(print, "nodes")));
  40586. }
  40587. case "selector-comment":
  40588. {
  40589. return node.value;
  40590. }
  40591. case "selector-string":
  40592. {
  40593. return adjustStrings(node.value, options);
  40594. }
  40595. case "selector-tag":
  40596. {
  40597. const parentNode = path.getParentNode();
  40598. const index = parentNode && parentNode.nodes.indexOf(node);
  40599. const prevNode = index && parentNode.nodes[index - 1];
  40600. return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords(path, node.value) ? node.value.toLowerCase() : node.value)];
  40601. }
  40602. case "selector-id":
  40603. {
  40604. return ["#", node.value];
  40605. }
  40606. case "selector-class":
  40607. {
  40608. return [".", adjustNumbers(adjustStrings(node.value, options))];
  40609. }
  40610. case "selector-attribute":
  40611. {
  40612. return ["[", node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"];
  40613. }
  40614. case "selector-combinator":
  40615. {
  40616. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  40617. const parentNode = path.getParentNode();
  40618. const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$d;
  40619. return [leading, node.value, isLastNode(path, node) ? "" : " "];
  40620. }
  40621. const leading = node.value.trim().startsWith("(") ? line$d : "";
  40622. const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$d;
  40623. return [leading, value];
  40624. }
  40625. case "selector-universal":
  40626. {
  40627. return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.value];
  40628. }
  40629. case "selector-pseudo":
  40630. {
  40631. return [maybeToLowerCase(node.value), isNonEmptyArray$5(node.nodes) ? ["(", join$a(", ", path.map(print, "nodes")), ")"] : ""];
  40632. }
  40633. case "selector-nesting":
  40634. {
  40635. return node.value;
  40636. }
  40637. case "selector-unknown":
  40638. {
  40639. const ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property
  40640. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  40641. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  40642. } // originalText has to be used for Less, see replaceQuotesInInlineComments in loc.js
  40643. const parentNode = path.getParentNode();
  40644. if (parentNode.raws && parentNode.raws.selector) {
  40645. const start = locStart$d(parentNode);
  40646. const end = start + parentNode.raws.selector.length;
  40647. return options.originalText.slice(start, end).trim();
  40648. } // Same reason above
  40649. const grandParent = path.getParentNode(1);
  40650. if (parentNode.type === "value-paren_group" && grandParent && grandParent.type === "value-func" && grandParent.value === "selector") {
  40651. const start = locStart$d(parentNode.open) + 1;
  40652. const end = locEnd$c(parentNode.close) - 1;
  40653. const selector = options.originalText.slice(start, end).trim();
  40654. return lastLineHasInlineComment(selector) ? [breakParent$5, selector] : selector;
  40655. }
  40656. return node.value;
  40657. }
  40658. // postcss-values-parser
  40659. case "value-value":
  40660. case "value-root":
  40661. {
  40662. return print("group");
  40663. }
  40664. case "value-comment":
  40665. {
  40666. return options.originalText.slice(locStart$d(node), locEnd$c(node));
  40667. }
  40668. case "value-comma_group":
  40669. {
  40670. const parentNode = path.getParentNode();
  40671. const parentParentNode = path.getParentNode(1);
  40672. const declAncestorProp = getPropOfDeclNode(path);
  40673. const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  40674. const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  40675. const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  40676. const hasInlineComment = node.groups.some(node => isInlineValueCommentNode(node));
  40677. const printed = path.map(print, "groups");
  40678. const parts = [];
  40679. const insideURLFunction = insideValueFunctionNode(path, "url");
  40680. let insideSCSSInterpolationInString = false;
  40681. let didBreak = false;
  40682. for (let i = 0; i < node.groups.length; ++i) {
  40683. parts.push(printed[i]);
  40684. const iPrevNode = node.groups[i - 1];
  40685. const iNode = node.groups[i];
  40686. const iNextNode = node.groups[i + 1];
  40687. const iNextNextNode = node.groups[i + 2];
  40688. if (insideURLFunction) {
  40689. if (iNextNode && isAdditionNode(iNextNode) || isAdditionNode(iNode)) {
  40690. parts.push(" ");
  40691. }
  40692. continue;
  40693. } // Ignore SCSS @forward wildcard suffix
  40694. if (insideAtRuleNode(path, "forward") && iNode.type === "value-word" && iNode.value && iPrevNode.type === "value-word" && iPrevNode.value === "as" && iNextNode.type === "value-operator" && iNextNode.value === "*") {
  40695. continue;
  40696. } // Ignore after latest node (i.e. before semicolon)
  40697. if (!iNextNode) {
  40698. continue;
  40699. } // styled.div` background: var(--${one}); `
  40700. if (iNode.type === "value-word" && iNode.value.endsWith("-") && isAtWordPlaceholderNode(iNextNode)) {
  40701. continue;
  40702. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  40703. const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  40704. const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  40705. if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
  40706. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  40707. continue;
  40708. }
  40709. if (insideSCSSInterpolationInString) {
  40710. continue;
  40711. } // Ignore colon (i.e. `:`)
  40712. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  40713. continue;
  40714. } // Ignore `@` in Less (i.e. `@@var;`)
  40715. if (iNode.type === "value-atword" && iNode.value === "") {
  40716. continue;
  40717. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  40718. if (iNode.value === "~") {
  40719. continue;
  40720. } // Ignore escape `\`
  40721. if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
  40722. continue;
  40723. } // Ignore escaped `/`
  40724. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  40725. continue;
  40726. } // Ignore `\` (i.e. `$variable: \@small;`)
  40727. if (iNode.value === "\\") {
  40728. continue;
  40729. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  40730. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  40731. continue;
  40732. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  40733. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  40734. continue;
  40735. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  40736. if (iNode.value === "--" && isHashNode(iNextNode)) {
  40737. continue;
  40738. } // Formatting math operations
  40739. const isMathOperator = isMathOperatorNode(iNode);
  40740. const isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  40741. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  40742. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  40743. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  40744. continue;
  40745. } // absolute paths are only parsed as one token if they are part of url(/abs/path) call
  40746. // but if you have custom -fb-url(/abs/path/) then it is parsed as "division /" and rest
  40747. // of the path. We don't want to put a space after that first division in this case.
  40748. if (!iPrevNode && isDivisionNode(iNode)) {
  40749. continue;
  40750. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  40751. // due to the fact that it is not valid syntax
  40752. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  40753. if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  40754. continue;
  40755. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  40756. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  40757. const isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  40758. const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  40759. const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  40760. if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
  40761. continue;
  40762. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  40763. if (isInlineValueCommentNode(iNode)) {
  40764. if (parentNode.type === "value-paren_group") {
  40765. parts.push(dedent$2(hardline$c));
  40766. continue;
  40767. }
  40768. parts.push(hardline$c);
  40769. continue;
  40770. } // Handle keywords in SCSS control directive
  40771. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  40772. parts.push(" ");
  40773. continue;
  40774. } // At-rule `namespace` should be in one line
  40775. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  40776. parts.push(" ");
  40777. continue;
  40778. } // Formatting `grid` property
  40779. if (isGridValue) {
  40780. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  40781. parts.push(hardline$c);
  40782. didBreak = true;
  40783. } else {
  40784. parts.push(" ");
  40785. }
  40786. continue;
  40787. } // Add `space` before next math operation
  40788. // Note: `grip` property have `/` delimiter and it is not math operation, so
  40789. // `grid` property handles above
  40790. if (isNextMathOperator) {
  40791. parts.push(" ");
  40792. continue;
  40793. } // allow function(returns-list($list)...)
  40794. if (iNextNode && iNextNode.value === "...") {
  40795. continue;
  40796. }
  40797. if (isAtWordPlaceholderNode(iNode) && isAtWordPlaceholderNode(iNextNode) && locEnd$c(iNode) === locStart$d(iNextNode)) {
  40798. continue;
  40799. } // Be default all values go through `line`
  40800. parts.push(line$d);
  40801. }
  40802. if (hasInlineComment) {
  40803. parts.push(breakParent$5);
  40804. }
  40805. if (didBreak) {
  40806. parts.unshift(hardline$c);
  40807. }
  40808. if (isControlDirective) {
  40809. return group$c(indent$7(parts));
  40810. } // Indent is not needed for import url when url is very long
  40811. // and node has two groups
  40812. // when type is value-comma_group
  40813. // example @import url("verylongurl") projection,tv
  40814. if (insideURLFunctionInImportAtRuleNode(path)) {
  40815. return group$c(fill$6(parts));
  40816. }
  40817. return group$c(indent$7(fill$6(parts)));
  40818. }
  40819. case "value-paren_group":
  40820. {
  40821. const parentNode = path.getParentNode();
  40822. if (parentNode && isURLFunctionNode(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
  40823. return [node.open ? print("open") : "", join$a(",", path.map(print, "groups")), node.close ? print("close") : ""];
  40824. }
  40825. if (!node.open) {
  40826. const printed = path.map(print, "groups");
  40827. const res = [];
  40828. for (let i = 0; i < printed.length; i++) {
  40829. if (i !== 0) {
  40830. res.push([",", line$d]);
  40831. }
  40832. res.push(printed[i]);
  40833. }
  40834. return group$c(indent$7(fill$6(res)));
  40835. }
  40836. const isSCSSMapItem = isSCSSMapItemNode(path);
  40837. const lastItem = getLast_1(node.groups);
  40838. const isLastItemComment = lastItem && lastItem.type === "value-comment";
  40839. const isKey = isKeyInValuePairNode(node, parentNode);
  40840. const printed = group$c([node.open ? print("open") : "", indent$7([softline$a, join$a([",", line$d], path.map(childPath => {
  40841. const node = childPath.getValue();
  40842. const printed = print(); // Key/Value pair in open paren already indented
  40843. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[0].type !== "value-paren_group" && node.groups[2] && node.groups[2].type === "value-paren_group") {
  40844. const parts = getDocParts$5(printed.contents.contents);
  40845. parts[1] = group$c(parts[1]);
  40846. return group$c(dedent$2(printed));
  40847. }
  40848. return printed;
  40849. }, "groups"))]), ifBreak$8(!isLastItemComment && isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$a, node.close ? print("close") : ""], {
  40850. shouldBreak: isSCSSMapItem && !isKey
  40851. });
  40852. return isKey ? dedent$2(printed) : printed;
  40853. }
  40854. case "value-func":
  40855. {
  40856. return [node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", print("group")];
  40857. }
  40858. case "value-paren":
  40859. {
  40860. return node.value;
  40861. }
  40862. case "value-number":
  40863. {
  40864. return [printCssNumber(node.value), maybeToLowerCase(node.unit)];
  40865. }
  40866. case "value-operator":
  40867. {
  40868. return node.value;
  40869. }
  40870. case "value-word":
  40871. {
  40872. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  40873. return node.value.toLowerCase();
  40874. }
  40875. return node.value;
  40876. }
  40877. case "value-colon":
  40878. {
  40879. const parentNode = path.getParentNode();
  40880. const index = parentNode && parentNode.groups.indexOf(node);
  40881. const prevNode = index && parentNode.groups[index - 1];
  40882. return [node.value, // Don't add spaces on escaped colon `:`, e.g: grid-template-rows: [row-1-00\:00] auto;
  40883. prevNode && typeof prevNode.value === "string" && getLast_1(prevNode.value) === "\\" || // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  40884. insideValueFunctionNode(path, "url") ? "" : line$d];
  40885. }
  40886. // TODO: confirm this code is dead
  40887. /* istanbul ignore next */
  40888. case "value-comma":
  40889. {
  40890. return [node.value, " "];
  40891. }
  40892. case "value-string":
  40893. {
  40894. return printString(node.raws.quote + node.value + node.raws.quote, options);
  40895. }
  40896. case "value-atword":
  40897. {
  40898. return ["@", node.value];
  40899. }
  40900. case "value-unicode-range":
  40901. {
  40902. return node.value;
  40903. }
  40904. case "value-unknown":
  40905. {
  40906. return node.value;
  40907. }
  40908. default:
  40909. /* istanbul ignore next */
  40910. throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
  40911. }
  40912. }
  40913. function printNodeSequence(path, options, print) {
  40914. const parts = [];
  40915. path.each((pathChild, i, nodes) => {
  40916. const prevNode = nodes[i - 1];
  40917. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  40918. const childNode = pathChild.getValue();
  40919. parts.push(options.originalText.slice(locStart$d(childNode), locEnd$c(childNode)));
  40920. } else {
  40921. parts.push(print());
  40922. }
  40923. if (i !== nodes.length - 1) {
  40924. if (nodes[i + 1].type === "css-comment" && !hasNewline(options.originalText, locStart$d(nodes[i + 1]), {
  40925. backwards: true
  40926. }) && !isFrontMatterNode$3(nodes[i]) || nodes[i + 1].type === "css-atrule" && nodes[i + 1].name === "else" && nodes[i].type !== "css-comment") {
  40927. parts.push(" ");
  40928. } else {
  40929. parts.push(options.__isHTMLStyleAttribute ? line$d : hardline$c);
  40930. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), locEnd$c) && !isFrontMatterNode$3(nodes[i])) {
  40931. parts.push(hardline$c);
  40932. }
  40933. }
  40934. }
  40935. }, "nodes");
  40936. return parts;
  40937. }
  40938. const STRING_REGEX = /(["'])(?:(?!\1)[^\\]|\\.)*\1/gs;
  40939. const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[Ee][+-]?\d+)?/g;
  40940. const STANDARD_UNIT_REGEX = /[A-Za-z]+/g;
  40941. const WORD_PART_REGEX = /[$@]?[A-Z_a-z\u0080-\uFFFF][\w\u0080-\uFFFF-]*/g;
  40942. const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
  40943. function adjustStrings(value, options) {
  40944. return value.replace(STRING_REGEX, match => printString(match, options));
  40945. }
  40946. function quoteAttributeValue(value, options) {
  40947. const quote = options.singleQuote ? "'" : '"';
  40948. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  40949. }
  40950. function adjustNumbers(value) {
  40951. return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase(unit || "") : match);
  40952. }
  40953. function printCssNumber(rawNumber) {
  40954. return printNumber(rawNumber) // Remove trailing `.0`.
  40955. .replace(/\.0(?=$|e)/, "");
  40956. }
  40957. var printerPostcss = {
  40958. print: genericPrint$4,
  40959. embed: embed_1$3,
  40960. insertPragma: insertPragma$7,
  40961. massageAstNode: clean_1$3
  40962. };
  40963. var options$4 = {
  40964. singleQuote: commonOptions.singleQuote
  40965. };
  40966. var parsers$5 = {
  40967. // TODO: switch these to just `postcss` and use `language` instead.
  40968. get css() {
  40969. return require("./parser-postcss.js").parsers.css;
  40970. },
  40971. get less() {
  40972. return require("./parser-postcss.js").parsers.less;
  40973. },
  40974. get scss() {
  40975. return require("./parser-postcss.js").parsers.scss;
  40976. }
  40977. };
  40978. var name$9 = "CSS";
  40979. var type$9 = "markup";
  40980. var tmScope$9 = "source.css";
  40981. var aceMode$9 = "css";
  40982. var codemirrorMode$5 = "css";
  40983. var codemirrorMimeType$5 = "text/css";
  40984. var color$8 = "#563d7c";
  40985. var extensions$9 = [
  40986. ".css"
  40987. ];
  40988. var languageId$9 = 50;
  40989. var require$$0$5 = {
  40990. name: name$9,
  40991. type: type$9,
  40992. tmScope: tmScope$9,
  40993. aceMode: aceMode$9,
  40994. codemirrorMode: codemirrorMode$5,
  40995. codemirrorMimeType: codemirrorMimeType$5,
  40996. color: color$8,
  40997. extensions: extensions$9,
  40998. languageId: languageId$9
  40999. };
  41000. var name$8 = "PostCSS";
  41001. var type$8 = "markup";
  41002. var tmScope$8 = "source.postcss";
  41003. var group$b = "CSS";
  41004. var extensions$8 = [
  41005. ".pcss",
  41006. ".postcss"
  41007. ];
  41008. var aceMode$8 = "text";
  41009. var languageId$8 = 262764437;
  41010. var require$$1$1 = {
  41011. name: name$8,
  41012. type: type$8,
  41013. tmScope: tmScope$8,
  41014. group: group$b,
  41015. extensions: extensions$8,
  41016. aceMode: aceMode$8,
  41017. languageId: languageId$8
  41018. };
  41019. var name$7 = "Less";
  41020. var type$7 = "markup";
  41021. var color$7 = "#1d365d";
  41022. var extensions$7 = [
  41023. ".less"
  41024. ];
  41025. var tmScope$7 = "source.css.less";
  41026. var aceMode$7 = "less";
  41027. var codemirrorMode$4 = "css";
  41028. var codemirrorMimeType$4 = "text/css";
  41029. var languageId$7 = 198;
  41030. var require$$2$2 = {
  41031. name: name$7,
  41032. type: type$7,
  41033. color: color$7,
  41034. extensions: extensions$7,
  41035. tmScope: tmScope$7,
  41036. aceMode: aceMode$7,
  41037. codemirrorMode: codemirrorMode$4,
  41038. codemirrorMimeType: codemirrorMimeType$4,
  41039. languageId: languageId$7
  41040. };
  41041. var name$6 = "SCSS";
  41042. var type$6 = "markup";
  41043. var color$6 = "#c6538c";
  41044. var tmScope$6 = "source.css.scss";
  41045. var aceMode$6 = "scss";
  41046. var codemirrorMode$3 = "css";
  41047. var codemirrorMimeType$3 = "text/x-scss";
  41048. var extensions$6 = [
  41049. ".scss"
  41050. ];
  41051. var languageId$6 = 329;
  41052. var require$$3 = {
  41053. name: name$6,
  41054. type: type$6,
  41055. color: color$6,
  41056. tmScope: tmScope$6,
  41057. aceMode: aceMode$6,
  41058. codemirrorMode: codemirrorMode$3,
  41059. codemirrorMimeType: codemirrorMimeType$3,
  41060. extensions: extensions$6,
  41061. languageId: languageId$6
  41062. };
  41063. const languages$6 = [createLanguage(require$$0$5, data => ({
  41064. since: "1.4.0",
  41065. parsers: ["css"],
  41066. vscodeLanguageIds: ["css"],
  41067. extensions: [...data.extensions, // `WeiXin Style Sheets`(Weixin Mini Programs)
  41068. // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
  41069. ".wxss"]
  41070. })), createLanguage(require$$1$1, () => ({
  41071. since: "1.4.0",
  41072. parsers: ["css"],
  41073. vscodeLanguageIds: ["postcss"]
  41074. })), createLanguage(require$$2$2, () => ({
  41075. since: "1.4.0",
  41076. parsers: ["less"],
  41077. vscodeLanguageIds: ["less"]
  41078. })), createLanguage(require$$3, () => ({
  41079. since: "1.4.0",
  41080. parsers: ["scss"],
  41081. vscodeLanguageIds: ["scss"]
  41082. }))];
  41083. const printers$4 = {
  41084. postcss: printerPostcss
  41085. };
  41086. var languageCss = {
  41087. languages: languages$6,
  41088. options: options$4,
  41089. printers: printers$4,
  41090. parsers: parsers$5
  41091. };
  41092. function locStart$c(node) {
  41093. return node.loc.start.offset;
  41094. }
  41095. function locEnd$b(node) {
  41096. return node.loc.end.offset;
  41097. }
  41098. var loc$4 = {
  41099. locStart: locStart$c,
  41100. locEnd: locEnd$b
  41101. };
  41102. function clean$4(ast, newNode
  41103. /*, parent*/
  41104. ) {
  41105. // (Glimmer/HTML) ignore TextNode
  41106. if (ast.type === "TextNode") {
  41107. const trimmed = ast.chars.trim();
  41108. if (!trimmed) {
  41109. return null;
  41110. }
  41111. newNode.chars = trimmed.replace(/[\t\n\f\r ]+/g, " ");
  41112. } // `class` is reformatted
  41113. if (ast.type === "AttrNode" && ast.name.toLowerCase() === "class") {
  41114. delete newNode.value;
  41115. }
  41116. }
  41117. clean$4.ignoredProperties = new Set(["loc", "selfClosing"]);
  41118. var clean_1$2 = clean$4;
  41119. var htmlVoidElements = [
  41120. "area",
  41121. "base",
  41122. "basefont",
  41123. "bgsound",
  41124. "br",
  41125. "col",
  41126. "command",
  41127. "embed",
  41128. "frame",
  41129. "hr",
  41130. "image",
  41131. "img",
  41132. "input",
  41133. "isindex",
  41134. "keygen",
  41135. "link",
  41136. "menuitem",
  41137. "meta",
  41138. "nextid",
  41139. "param",
  41140. "source",
  41141. "track",
  41142. "wbr"
  41143. ];
  41144. function isLastNodeOfSiblings$1(path) {
  41145. const node = path.getValue();
  41146. const parentNode = path.getParentNode(0);
  41147. if (isParentOfSomeType$1(path, ["ElementNode"]) && getLast_1(parentNode.children) === node) {
  41148. return true;
  41149. }
  41150. if (isParentOfSomeType$1(path, ["Block"]) && getLast_1(parentNode.body) === node) {
  41151. return true;
  41152. }
  41153. return false;
  41154. }
  41155. function isUppercase(string) {
  41156. return string.toUpperCase() === string;
  41157. }
  41158. function isGlimmerComponent(node) {
  41159. return isNodeOfSomeType$1(node, ["ElementNode"]) && typeof node.tag === "string" && (isUppercase(node.tag[0]) || node.tag.includes("."));
  41160. }
  41161. const voidTags = new Set(htmlVoidElements);
  41162. function isVoid$1(node) {
  41163. return isGlimmerComponent(node) && node.children.every(node => isWhitespaceNode$1(node)) || voidTags.has(node.tag);
  41164. }
  41165. function isWhitespaceNode$1(node) {
  41166. return isNodeOfSomeType$1(node, ["TextNode"]) && !/\S/.test(node.chars);
  41167. }
  41168. function isNodeOfSomeType$1(node, types) {
  41169. return node && types.includes(node.type);
  41170. }
  41171. function isParentOfSomeType$1(path, types) {
  41172. const parentNode = path.getParentNode(0);
  41173. return isNodeOfSomeType$1(parentNode, types);
  41174. }
  41175. function isPreviousNodeOfSomeType$1(path, types) {
  41176. const previousNode = getPreviousNode$1(path);
  41177. return isNodeOfSomeType$1(previousNode, types);
  41178. }
  41179. function isNextNodeOfSomeType$1(path, types) {
  41180. const nextNode = getNextNode$1(path);
  41181. return isNodeOfSomeType$1(nextNode, types);
  41182. }
  41183. function getSiblingNode(path, offset) {
  41184. const node = path.getValue();
  41185. const parentNode = path.getParentNode(0) || {};
  41186. const children = parentNode.children || parentNode.body || parentNode.parts || [];
  41187. const index = children.indexOf(node);
  41188. return index !== -1 && children[index + offset];
  41189. }
  41190. function getPreviousNode$1(path, lookBack = 1) {
  41191. return getSiblingNode(path, -lookBack);
  41192. }
  41193. function getNextNode$1(path) {
  41194. return getSiblingNode(path, 1);
  41195. }
  41196. function isPrettierIgnoreNode(node) {
  41197. return isNodeOfSomeType$1(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
  41198. }
  41199. function hasPrettierIgnore$8(path) {
  41200. const node = path.getValue();
  41201. const previousPreviousNode = getPreviousNode$1(path, 2);
  41202. return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
  41203. }
  41204. var utils$3 = {
  41205. getNextNode: getNextNode$1,
  41206. getPreviousNode: getPreviousNode$1,
  41207. hasPrettierIgnore: hasPrettierIgnore$8,
  41208. isLastNodeOfSiblings: isLastNodeOfSiblings$1,
  41209. isNextNodeOfSomeType: isNextNodeOfSomeType$1,
  41210. isNodeOfSomeType: isNodeOfSomeType$1,
  41211. isParentOfSomeType: isParentOfSomeType$1,
  41212. isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
  41213. isVoid: isVoid$1,
  41214. isWhitespaceNode: isWhitespaceNode$1
  41215. };
  41216. const {
  41217. builders: {
  41218. dedent: dedent$1,
  41219. fill: fill$5,
  41220. group: group$a,
  41221. hardline: hardline$b,
  41222. ifBreak: ifBreak$7,
  41223. indent: indent$6,
  41224. join: join$9,
  41225. line: line$c,
  41226. softline: softline$9
  41227. },
  41228. utils: {
  41229. getDocParts: getDocParts$4,
  41230. replaceTextEndOfLine: replaceTextEndOfLine$8
  41231. }
  41232. } = doc;
  41233. const {
  41234. isNonEmptyArray: isNonEmptyArray$4
  41235. } = util$5;
  41236. const {
  41237. locStart: locStart$b,
  41238. locEnd: locEnd$a
  41239. } = loc$4;
  41240. const {
  41241. getNextNode,
  41242. getPreviousNode,
  41243. hasPrettierIgnore: hasPrettierIgnore$7,
  41244. isLastNodeOfSiblings,
  41245. isNextNodeOfSomeType,
  41246. isNodeOfSomeType,
  41247. isParentOfSomeType,
  41248. isPreviousNodeOfSomeType,
  41249. isVoid,
  41250. isWhitespaceNode
  41251. } = utils$3;
  41252. const NEWLINES_TO_PRESERVE_MAX = 2; // Formatter based on @glimmerjs/syntax's built-in test formatter:
  41253. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  41254. function print(path, options, print) {
  41255. const node = path.getValue();
  41256. /* istanbul ignore if*/
  41257. if (!node) {
  41258. return "";
  41259. }
  41260. if (hasPrettierIgnore$7(path)) {
  41261. return options.originalText.slice(locStart$b(node), locEnd$a(node));
  41262. }
  41263. switch (node.type) {
  41264. case "Block":
  41265. case "Program":
  41266. case "Template":
  41267. {
  41268. return group$a(path.map(print, "body"));
  41269. }
  41270. case "ElementNode":
  41271. {
  41272. const startingTag = group$a(printStartingTag(path, print));
  41273. const escapeNextElementNode = options.htmlWhitespaceSensitivity === "ignore" && isNextNodeOfSomeType(path, ["ElementNode"]) ? softline$9 : "";
  41274. if (isVoid(node)) {
  41275. return [startingTag, escapeNextElementNode];
  41276. }
  41277. const endingTag = ["</", node.tag, ">"];
  41278. if (node.children.length === 0) {
  41279. return [startingTag, indent$6(endingTag), escapeNextElementNode];
  41280. }
  41281. if (options.htmlWhitespaceSensitivity === "ignore") {
  41282. return [startingTag, indent$6(printChildren$5(path, options, print)), hardline$b, indent$6(endingTag), escapeNextElementNode];
  41283. }
  41284. return [startingTag, indent$6(group$a(printChildren$5(path, options, print))), indent$6(endingTag), escapeNextElementNode];
  41285. }
  41286. case "BlockStatement":
  41287. {
  41288. const pp = path.getParentNode(1);
  41289. const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === node && pp.inverse.body[0].path.parts[0] === "if";
  41290. if (isElseIf) {
  41291. return [printElseIfBlock(path, print), printProgram(path, print, options), printInverse(path, print, options)];
  41292. }
  41293. return [printOpenBlock(path, print), group$a([printProgram(path, print, options), printInverse(path, print, options), printCloseBlock(path, print, options)])];
  41294. }
  41295. case "ElementModifierStatement":
  41296. {
  41297. return group$a(["{{", printPathAndParams(path, print), "}}"]);
  41298. }
  41299. case "MustacheStatement":
  41300. {
  41301. return group$a([printOpeningMustache(node), printPathAndParams(path, print), printClosingMustache(node)]);
  41302. }
  41303. case "SubExpression":
  41304. {
  41305. return group$a(["(", printSubExpressionPathAndParams(path, print), softline$9, ")"]);
  41306. }
  41307. case "AttrNode":
  41308. {
  41309. const isText = node.value.type === "TextNode";
  41310. const isEmptyText = isText && node.value.chars === ""; // If the text is empty and the value's loc start and end offsets are the
  41311. // same, there is no value for this AttrNode and it should be printed
  41312. // without the `=""`. Example: `<img data-test>` -> `<img data-test>`
  41313. if (isEmptyText && locStart$b(node.value) === locEnd$a(node.value)) {
  41314. return node.name;
  41315. } // Let's assume quotes inside the content of text nodes are already
  41316. // properly escaped with entities, otherwise the parse wouldn't have parsed them.
  41317. const quote = isText ? chooseEnclosingQuote(options, node.value.chars).quote : node.value.type === "ConcatStatement" ? chooseEnclosingQuote(options, node.value.parts.filter(part => part.type === "TextNode").map(part => part.chars).join("")).quote : "";
  41318. const valueDoc = print("value");
  41319. return [node.name, "=", quote, node.name === "class" && quote ? group$a(indent$6(valueDoc)) : valueDoc, quote];
  41320. }
  41321. case "ConcatStatement":
  41322. {
  41323. return path.map(print, "parts");
  41324. }
  41325. case "Hash":
  41326. {
  41327. return join$9(line$c, path.map(print, "pairs"));
  41328. }
  41329. case "HashPair":
  41330. {
  41331. return [node.key, "=", print("value")];
  41332. }
  41333. case "TextNode":
  41334. {
  41335. /* if `{{my-component}}` (or any text containing "{{")
  41336. * makes it to the TextNode, it means it was escaped,
  41337. * so let's print it escaped, ie.; `\{{my-component}}` */
  41338. let text = node.chars.replace(/{{/g, "\\{{");
  41339. const attrName = getCurrentAttributeName(path);
  41340. if (attrName) {
  41341. // TODO: format style and srcset attributes
  41342. if (attrName === "class") {
  41343. const formattedClasses = text.trim().split(/\s+/).join(" ");
  41344. let leadingSpace = false;
  41345. let trailingSpace = false;
  41346. if (isParentOfSomeType(path, ["ConcatStatement"])) {
  41347. if (isPreviousNodeOfSomeType(path, ["MustacheStatement"]) && /^\s/.test(text)) {
  41348. leadingSpace = true;
  41349. }
  41350. if (isNextNodeOfSomeType(path, ["MustacheStatement"]) && /\s$/.test(text) && formattedClasses !== "") {
  41351. trailingSpace = true;
  41352. }
  41353. }
  41354. return [leadingSpace ? line$c : "", formattedClasses, trailingSpace ? line$c : ""];
  41355. }
  41356. return replaceTextEndOfLine$8(text);
  41357. }
  41358. const whitespacesOnlyRE = /^[\t\n\f\r ]*$/;
  41359. const isWhitespaceOnly = whitespacesOnlyRE.test(text);
  41360. const isFirstElement = !getPreviousNode(path);
  41361. const isLastElement = !getNextNode(path);
  41362. if (options.htmlWhitespaceSensitivity !== "ignore") {
  41363. // https://infra.spec.whatwg.org/#ascii-whitespace
  41364. const leadingWhitespacesRE = /^[\t\n\f\r ]*/;
  41365. const trailingWhitespacesRE = /[\t\n\f\r ]*$/; // let's remove the file's final newline
  41366. // https://github.com/ember-cli/ember-new-output/blob/1a04c67ddd02ccb35e0ff41bb5cbce34b31173ef/.editorconfig#L16
  41367. const shouldTrimTrailingNewlines = isLastElement && isParentOfSomeType(path, ["Template"]);
  41368. const shouldTrimLeadingNewlines = isFirstElement && isParentOfSomeType(path, ["Template"]);
  41369. if (isWhitespaceOnly) {
  41370. if (shouldTrimLeadingNewlines || shouldTrimTrailingNewlines) {
  41371. return "";
  41372. }
  41373. let breaks = [line$c];
  41374. const newlines = countNewLines(text);
  41375. if (newlines) {
  41376. breaks = generateHardlines(newlines);
  41377. }
  41378. if (isLastNodeOfSiblings(path)) {
  41379. breaks = breaks.map(newline => dedent$1(newline));
  41380. }
  41381. return breaks;
  41382. }
  41383. const [lead] = text.match(leadingWhitespacesRE);
  41384. const [tail] = text.match(trailingWhitespacesRE);
  41385. let leadBreaks = [];
  41386. if (lead) {
  41387. leadBreaks = [line$c];
  41388. const leadingNewlines = countNewLines(lead);
  41389. if (leadingNewlines) {
  41390. leadBreaks = generateHardlines(leadingNewlines);
  41391. }
  41392. text = text.replace(leadingWhitespacesRE, "");
  41393. }
  41394. let trailBreaks = [];
  41395. if (tail) {
  41396. if (!shouldTrimTrailingNewlines) {
  41397. trailBreaks = [line$c];
  41398. const trailingNewlines = countNewLines(tail);
  41399. if (trailingNewlines) {
  41400. trailBreaks = generateHardlines(trailingNewlines);
  41401. }
  41402. if (isLastNodeOfSiblings(path)) {
  41403. trailBreaks = trailBreaks.map(hardline => dedent$1(hardline));
  41404. }
  41405. }
  41406. text = text.replace(trailingWhitespacesRE, "");
  41407. }
  41408. return [...leadBreaks, fill$5(getTextValueParts$3(text)), ...trailBreaks];
  41409. }
  41410. const lineBreaksCount = countNewLines(text);
  41411. let leadingLineBreaksCount = countLeadingNewLines(text);
  41412. let trailingLineBreaksCount = countTrailingNewLines(text);
  41413. if ((isFirstElement || isLastElement) && isWhitespaceOnly && isParentOfSomeType(path, ["Block", "ElementNode", "Template"])) {
  41414. return "";
  41415. }
  41416. if (isWhitespaceOnly && lineBreaksCount) {
  41417. leadingLineBreaksCount = Math.min(lineBreaksCount, NEWLINES_TO_PRESERVE_MAX);
  41418. trailingLineBreaksCount = 0;
  41419. } else {
  41420. if (isNextNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
  41421. trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
  41422. }
  41423. if (isPreviousNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
  41424. leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
  41425. }
  41426. }
  41427. let leadingSpace = "";
  41428. let trailingSpace = "";
  41429. if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType(path, ["MustacheStatement"])) {
  41430. trailingSpace = " ";
  41431. }
  41432. if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType(path, ["MustacheStatement"])) {
  41433. leadingSpace = " ";
  41434. }
  41435. if (isFirstElement) {
  41436. leadingLineBreaksCount = 0;
  41437. leadingSpace = "";
  41438. }
  41439. if (isLastElement) {
  41440. trailingLineBreaksCount = 0;
  41441. trailingSpace = "";
  41442. }
  41443. text = text.replace(/^[\t\n\f\r ]+/g, leadingSpace).replace(/[\t\n\f\r ]+$/, trailingSpace);
  41444. return [...generateHardlines(leadingLineBreaksCount), fill$5(getTextValueParts$3(text)), ...generateHardlines(trailingLineBreaksCount)];
  41445. }
  41446. case "MustacheCommentStatement":
  41447. {
  41448. const start = locStart$b(node);
  41449. const end = locEnd$a(node); // Starts with `{{~`
  41450. const isLeftWhiteSpaceSensitive = options.originalText.charAt(start + 2) === "~"; // Ends with `{{~`
  41451. const isRightWhitespaceSensitive = options.originalText.charAt(end - 3) === "~";
  41452. const dashes = node.value.includes("}}") ? "--" : "";
  41453. return ["{{", isLeftWhiteSpaceSensitive ? "~" : "", "!", dashes, node.value, dashes, isRightWhitespaceSensitive ? "~" : "", "}}"];
  41454. }
  41455. case "PathExpression":
  41456. {
  41457. return node.original;
  41458. }
  41459. case "BooleanLiteral":
  41460. {
  41461. return String(node.value);
  41462. }
  41463. case "CommentStatement":
  41464. {
  41465. return ["<!--", node.value, "-->"];
  41466. }
  41467. case "StringLiteral":
  41468. {
  41469. return printStringLiteral(node.value, options);
  41470. }
  41471. case "NumberLiteral":
  41472. {
  41473. return String(node.value);
  41474. }
  41475. case "UndefinedLiteral":
  41476. {
  41477. return "undefined";
  41478. }
  41479. case "NullLiteral":
  41480. {
  41481. return "null";
  41482. }
  41483. /* istanbul ignore next */
  41484. default:
  41485. throw new Error("unknown glimmer type: " + JSON.stringify(node.type));
  41486. }
  41487. }
  41488. /* ElementNode print helpers */
  41489. function sortByLoc(a, b) {
  41490. return locStart$b(a) - locStart$b(b);
  41491. }
  41492. function printStartingTag(path, print) {
  41493. const node = path.getValue();
  41494. const types = ["attributes", "modifiers", "comments"].filter(property => isNonEmptyArray$4(node[property]));
  41495. const attributes = types.flatMap(type => node[type]).sort(sortByLoc);
  41496. for (const attributeType of types) {
  41497. path.each(attributePath => {
  41498. const index = attributes.indexOf(attributePath.getValue());
  41499. attributes.splice(index, 1, [line$c, print()]);
  41500. }, attributeType);
  41501. }
  41502. if (isNonEmptyArray$4(node.blockParams)) {
  41503. attributes.push(line$c, printBlockParams(node));
  41504. }
  41505. return ["<", node.tag, indent$6(attributes), printStartingTagEndMarker(node)];
  41506. }
  41507. function printChildren$5(path, options, print) {
  41508. const node = path.getValue();
  41509. const isEmpty = node.children.every(node => isWhitespaceNode(node));
  41510. if (options.htmlWhitespaceSensitivity === "ignore" && isEmpty) {
  41511. return "";
  41512. }
  41513. return path.map((childPath, childIndex) => {
  41514. const printedChild = print();
  41515. if (childIndex === 0 && options.htmlWhitespaceSensitivity === "ignore") {
  41516. return [softline$9, printedChild];
  41517. }
  41518. return printedChild;
  41519. }, "children");
  41520. }
  41521. function printStartingTagEndMarker(node) {
  41522. if (isVoid(node)) {
  41523. return ifBreak$7([softline$9, "/>"], [" />", softline$9]);
  41524. }
  41525. return ifBreak$7([softline$9, ">"], ">");
  41526. }
  41527. /* MustacheStatement print helpers */
  41528. function printOpeningMustache(node) {
  41529. const mustache = node.escaped === false ? "{{{" : "{{";
  41530. const strip = node.strip && node.strip.open ? "~" : "";
  41531. return [mustache, strip];
  41532. }
  41533. function printClosingMustache(node) {
  41534. const mustache = node.escaped === false ? "}}}" : "}}";
  41535. const strip = node.strip && node.strip.close ? "~" : "";
  41536. return [strip, mustache];
  41537. }
  41538. /* BlockStatement print helpers */
  41539. function printOpeningBlockOpeningMustache(node) {
  41540. const opening = printOpeningMustache(node);
  41541. const strip = node.openStrip.open ? "~" : "";
  41542. return [opening, strip, "#"];
  41543. }
  41544. function printOpeningBlockClosingMustache(node) {
  41545. const closing = printClosingMustache(node);
  41546. const strip = node.openStrip.close ? "~" : "";
  41547. return [strip, closing];
  41548. }
  41549. function printClosingBlockOpeningMustache(node) {
  41550. const opening = printOpeningMustache(node);
  41551. const strip = node.closeStrip.open ? "~" : "";
  41552. return [opening, strip, "/"];
  41553. }
  41554. function printClosingBlockClosingMustache(node) {
  41555. const closing = printClosingMustache(node);
  41556. const strip = node.closeStrip.close ? "~" : "";
  41557. return [strip, closing];
  41558. }
  41559. function printInverseBlockOpeningMustache(node) {
  41560. const opening = printOpeningMustache(node);
  41561. const strip = node.inverseStrip.open ? "~" : "";
  41562. return [opening, strip];
  41563. }
  41564. function printInverseBlockClosingMustache(node) {
  41565. const closing = printClosingMustache(node);
  41566. const strip = node.inverseStrip.close ? "~" : "";
  41567. return [strip, closing];
  41568. }
  41569. function printOpenBlock(path, print) {
  41570. const node = path.getValue();
  41571. const openingMustache = printOpeningBlockOpeningMustache(node);
  41572. const closingMustache = printOpeningBlockClosingMustache(node);
  41573. const attributes = [printPath(path, print)];
  41574. const params = printParams(path, print);
  41575. if (params) {
  41576. attributes.push(line$c, params);
  41577. }
  41578. if (isNonEmptyArray$4(node.program.blockParams)) {
  41579. const block = printBlockParams(node.program);
  41580. attributes.push(line$c, block);
  41581. }
  41582. return group$a([openingMustache, indent$6(attributes), softline$9, closingMustache]);
  41583. }
  41584. function printElseBlock(node, options) {
  41585. return [options.htmlWhitespaceSensitivity === "ignore" ? hardline$b : "", printInverseBlockOpeningMustache(node), "else", printInverseBlockClosingMustache(node)];
  41586. }
  41587. function printElseIfBlock(path, print) {
  41588. const parentNode = path.getParentNode(1);
  41589. return [printInverseBlockOpeningMustache(parentNode), "else if ", printParams(path, print), printInverseBlockClosingMustache(parentNode)];
  41590. }
  41591. function printCloseBlock(path, print, options) {
  41592. const node = path.getValue();
  41593. if (options.htmlWhitespaceSensitivity === "ignore") {
  41594. const escape = blockStatementHasOnlyWhitespaceInProgram(node) ? softline$9 : hardline$b;
  41595. return [escape, printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
  41596. }
  41597. return [printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
  41598. }
  41599. function blockStatementHasOnlyWhitespaceInProgram(node) {
  41600. return isNodeOfSomeType(node, ["BlockStatement"]) && node.program.body.every(node => isWhitespaceNode(node));
  41601. }
  41602. function blockStatementHasElseIf(node) {
  41603. return blockStatementHasElse(node) && node.inverse.body.length === 1 && isNodeOfSomeType(node.inverse.body[0], ["BlockStatement"]) && node.inverse.body[0].path.parts[0] === "if";
  41604. }
  41605. function blockStatementHasElse(node) {
  41606. return isNodeOfSomeType(node, ["BlockStatement"]) && node.inverse;
  41607. }
  41608. function printProgram(path, print, options) {
  41609. const node = path.getValue();
  41610. if (blockStatementHasOnlyWhitespaceInProgram(node)) {
  41611. return "";
  41612. }
  41613. const program = print("program");
  41614. if (options.htmlWhitespaceSensitivity === "ignore") {
  41615. return indent$6([hardline$b, program]);
  41616. }
  41617. return indent$6(program);
  41618. }
  41619. function printInverse(path, print, options) {
  41620. const node = path.getValue();
  41621. const inverse = print("inverse");
  41622. const printed = options.htmlWhitespaceSensitivity === "ignore" ? [hardline$b, inverse] : inverse;
  41623. if (blockStatementHasElseIf(node)) {
  41624. return printed;
  41625. }
  41626. if (blockStatementHasElse(node)) {
  41627. return [printElseBlock(node, options), indent$6(printed)];
  41628. }
  41629. return "";
  41630. }
  41631. /* TextNode print helpers */
  41632. function getTextValueParts$3(value) {
  41633. return getDocParts$4(join$9(line$c, splitByHtmlWhitespace$1(value)));
  41634. }
  41635. function splitByHtmlWhitespace$1(string) {
  41636. return string.split(/[\t\n\f\r ]+/);
  41637. }
  41638. function getCurrentAttributeName(path) {
  41639. for (let depth = 0; depth < 2; depth++) {
  41640. const parentNode = path.getParentNode(depth);
  41641. if (parentNode && parentNode.type === "AttrNode") {
  41642. return parentNode.name.toLowerCase();
  41643. }
  41644. }
  41645. }
  41646. function countNewLines(string) {
  41647. /* istanbul ignore next */
  41648. string = typeof string === "string" ? string : "";
  41649. return string.split("\n").length - 1;
  41650. }
  41651. function countLeadingNewLines(string) {
  41652. /* istanbul ignore next */
  41653. string = typeof string === "string" ? string : "";
  41654. const newLines = (string.match(/^([^\S\n\r]*[\n\r])+/g) || [])[0] || "";
  41655. return countNewLines(newLines);
  41656. }
  41657. function countTrailingNewLines(string) {
  41658. /* istanbul ignore next */
  41659. string = typeof string === "string" ? string : "";
  41660. const newLines = (string.match(/([\n\r][^\S\n\r]*)+$/g) || [])[0] || "";
  41661. return countNewLines(newLines);
  41662. }
  41663. function generateHardlines(number = 0) {
  41664. return new Array(Math.min(number, NEWLINES_TO_PRESERVE_MAX)).fill(hardline$b);
  41665. }
  41666. /* StringLiteral print helpers */
  41667. /**
  41668. * Prints a string literal with the correct surrounding quotes based on
  41669. * `options.singleQuote` and the number of escaped quotes contained in
  41670. * the string literal. This function is the glimmer equivalent of `printString`
  41671. * in `common/util`, but has differences because of the way escaped characters
  41672. * are treated in hbs string literals.
  41673. * @param {string} stringLiteral - the string literal value
  41674. * @param {object} options - the prettier options object
  41675. */
  41676. function printStringLiteral(stringLiteral, options) {
  41677. const {
  41678. quote,
  41679. regex
  41680. } = chooseEnclosingQuote(options, stringLiteral);
  41681. return [quote, stringLiteral.replace(regex, `\\${quote}`), quote];
  41682. }
  41683. function chooseEnclosingQuote(options, stringLiteral) {
  41684. const double = {
  41685. quote: '"',
  41686. regex: /"/g
  41687. };
  41688. const single = {
  41689. quote: "'",
  41690. regex: /'/g
  41691. };
  41692. const preferred = options.singleQuote ? single : double;
  41693. const alternate = preferred === single ? double : single;
  41694. let shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
  41695. // enclosing the string, we might want to enclose with the alternate quote
  41696. // instead, to minimize the number of escaped quotes.
  41697. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
  41698. const numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
  41699. const numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
  41700. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  41701. }
  41702. return shouldUseAlternateQuote ? alternate : preferred;
  41703. }
  41704. /* SubExpression print helpers */
  41705. function printSubExpressionPathAndParams(path, print) {
  41706. const p = printPath(path, print);
  41707. const params = printParams(path, print);
  41708. if (!params) {
  41709. return p;
  41710. }
  41711. return indent$6([p, line$c, group$a(params)]);
  41712. }
  41713. /* misc. print helpers */
  41714. function printPathAndParams(path, print) {
  41715. const p = printPath(path, print);
  41716. const params = printParams(path, print);
  41717. if (!params) {
  41718. return p;
  41719. }
  41720. return [indent$6([p, line$c, params]), softline$9];
  41721. }
  41722. function printPath(path, print) {
  41723. return print("path");
  41724. }
  41725. function printParams(path, print) {
  41726. const node = path.getValue();
  41727. const parts = [];
  41728. if (node.params.length > 0) {
  41729. const params = path.map(print, "params");
  41730. parts.push(...params);
  41731. }
  41732. if (node.hash && node.hash.pairs.length > 0) {
  41733. const hash = print("hash");
  41734. parts.push(hash);
  41735. }
  41736. if (parts.length === 0) {
  41737. return "";
  41738. }
  41739. return join$9(line$c, parts);
  41740. }
  41741. function printBlockParams(node) {
  41742. return ["as |", node.blockParams.join(" "), "|"];
  41743. }
  41744. var printerGlimmer = {
  41745. print,
  41746. massageAstNode: clean_1$2
  41747. };
  41748. var parsers$4 = {
  41749. get glimmer() {
  41750. return require("./parser-glimmer.js").parsers.glimmer;
  41751. }
  41752. };
  41753. var name$5 = "Handlebars";
  41754. var type$5 = "markup";
  41755. var color$5 = "#f7931e";
  41756. var aliases$3 = [
  41757. "hbs",
  41758. "htmlbars"
  41759. ];
  41760. var extensions$5 = [
  41761. ".handlebars",
  41762. ".hbs"
  41763. ];
  41764. var tmScope$5 = "text.html.handlebars";
  41765. var aceMode$5 = "handlebars";
  41766. var languageId$5 = 155;
  41767. var require$$0$4 = {
  41768. name: name$5,
  41769. type: type$5,
  41770. color: color$5,
  41771. aliases: aliases$3,
  41772. extensions: extensions$5,
  41773. tmScope: tmScope$5,
  41774. aceMode: aceMode$5,
  41775. languageId: languageId$5
  41776. };
  41777. const languages$5 = [createLanguage(require$$0$4, () => ({
  41778. since: "2.3.0",
  41779. parsers: ["glimmer"],
  41780. vscodeLanguageIds: ["handlebars"]
  41781. }))];
  41782. const printers$3 = {
  41783. glimmer: printerGlimmer
  41784. };
  41785. var languageHandlebars = {
  41786. languages: languages$5,
  41787. printers: printers$3,
  41788. parsers: parsers$4
  41789. };
  41790. function hasPragma$2(text) {
  41791. return /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/.test(text);
  41792. }
  41793. function insertPragma$6(text) {
  41794. return "# @format\n\n" + text;
  41795. }
  41796. var pragma$3 = {
  41797. hasPragma: hasPragma$2,
  41798. insertPragma: insertPragma$6
  41799. };
  41800. function locStart$a(node) {
  41801. if (typeof node.start === "number") {
  41802. return node.start;
  41803. }
  41804. return node.loc && node.loc.start;
  41805. }
  41806. function locEnd$9(node) {
  41807. if (typeof node.end === "number") {
  41808. return node.end;
  41809. }
  41810. return node.loc && node.loc.end;
  41811. }
  41812. var loc$3 = {
  41813. locStart: locStart$a,
  41814. locEnd: locEnd$9
  41815. };
  41816. const {
  41817. builders: {
  41818. join: join$8,
  41819. hardline: hardline$a,
  41820. line: line$b,
  41821. softline: softline$8,
  41822. group: group$9,
  41823. indent: indent$5,
  41824. ifBreak: ifBreak$6
  41825. }
  41826. } = doc;
  41827. const {
  41828. isNextLineEmpty: isNextLineEmpty$2,
  41829. isNonEmptyArray: isNonEmptyArray$3
  41830. } = util$5;
  41831. const {
  41832. insertPragma: insertPragma$5
  41833. } = pragma$3;
  41834. const {
  41835. locStart: locStart$9,
  41836. locEnd: locEnd$8
  41837. } = loc$3;
  41838. function genericPrint$3(path, options, print) {
  41839. const node = path.getValue();
  41840. if (!node) {
  41841. return "";
  41842. }
  41843. if (typeof node === "string") {
  41844. return node;
  41845. }
  41846. switch (node.kind) {
  41847. case "Document":
  41848. {
  41849. const parts = [];
  41850. path.each((pathChild, index, definitions) => {
  41851. parts.push(print());
  41852. if (index !== definitions.length - 1) {
  41853. parts.push(hardline$a);
  41854. if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), locEnd$8)) {
  41855. parts.push(hardline$a);
  41856. }
  41857. }
  41858. }, "definitions");
  41859. return [...parts, hardline$a];
  41860. }
  41861. case "OperationDefinition":
  41862. {
  41863. const hasOperation = options.originalText[locStart$9(node)] !== "{";
  41864. const hasName = Boolean(node.name);
  41865. return [hasOperation ? node.operation : "", hasOperation && hasName ? [" ", print("name")] : "", hasOperation && !hasName && isNonEmptyArray$3(node.variableDefinitions) ? " " : "", isNonEmptyArray$3(node.variableDefinitions) ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.map(print, "variableDefinitions"))]), softline$8, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? !hasOperation && !hasName ? "" : " " : "", print("selectionSet")];
  41866. }
  41867. case "FragmentDefinition":
  41868. {
  41869. return ["fragment ", print("name"), isNonEmptyArray$3(node.variableDefinitions) ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.map(print, "variableDefinitions"))]), softline$8, ")"]) : "", " on ", print("typeCondition"), printDirectives(path, print, node), " ", print("selectionSet")];
  41870. }
  41871. case "SelectionSet":
  41872. {
  41873. return ["{", indent$5([hardline$a, join$8(hardline$a, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))]), hardline$a, "}"];
  41874. }
  41875. case "Field":
  41876. {
  41877. return group$9([node.alias ? [print("alias"), ": "] : "", print("name"), node.arguments.length > 0 ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$8, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? " " : "", print("selectionSet")]);
  41878. }
  41879. case "Name":
  41880. {
  41881. return node.value;
  41882. }
  41883. case "StringValue":
  41884. {
  41885. if (node.block) {
  41886. return ['"""', hardline$a, join$8(hardline$a, node.value.replace(/"""/g, "\\$&").split("\n")), hardline$a, '"""'];
  41887. }
  41888. return ['"', node.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"'];
  41889. }
  41890. case "IntValue":
  41891. case "FloatValue":
  41892. case "EnumValue":
  41893. {
  41894. return node.value;
  41895. }
  41896. case "BooleanValue":
  41897. {
  41898. return node.value ? "true" : "false";
  41899. }
  41900. case "NullValue":
  41901. {
  41902. return "null";
  41903. }
  41904. case "Variable":
  41905. {
  41906. return ["$", print("name")];
  41907. }
  41908. case "ListValue":
  41909. {
  41910. return group$9(["[", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.map(print, "values"))]), softline$8, "]"]);
  41911. }
  41912. case "ObjectValue":
  41913. {
  41914. return group$9(["{", options.bracketSpacing && node.fields.length > 0 ? " " : "", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.map(print, "fields"))]), softline$8, ifBreak$6("", options.bracketSpacing && node.fields.length > 0 ? " " : ""), "}"]);
  41915. }
  41916. case "ObjectField":
  41917. case "Argument":
  41918. {
  41919. return [print("name"), ": ", print("value")];
  41920. }
  41921. case "Directive":
  41922. {
  41923. return ["@", print("name"), node.arguments.length > 0 ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$8, ")"]) : ""];
  41924. }
  41925. case "NamedType":
  41926. {
  41927. return print("name");
  41928. }
  41929. case "VariableDefinition":
  41930. {
  41931. return [print("variable"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
  41932. }
  41933. case "ObjectTypeExtension":
  41934. case "ObjectTypeDefinition":
  41935. {
  41936. return [print("description"), node.description ? hardline$a : "", node.kind === "ObjectTypeExtension" ? "extend " : "", "type ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$5([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  41937. }
  41938. case "FieldDefinition":
  41939. {
  41940. return [print("description"), node.description ? hardline$a : "", print("name"), node.arguments.length > 0 ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$8, ")"]) : "", ": ", print("type"), printDirectives(path, print, node)];
  41941. }
  41942. case "DirectiveDefinition":
  41943. {
  41944. return [print("description"), node.description ? hardline$a : "", "directive ", "@", print("name"), node.arguments.length > 0 ? group$9(["(", indent$5([softline$8, join$8([ifBreak$6("", ", "), softline$8], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$8, ")"]) : "", node.repeatable ? " repeatable" : "", " on ", join$8(" | ", path.map(print, "locations"))];
  41945. }
  41946. case "EnumTypeExtension":
  41947. case "EnumTypeDefinition":
  41948. {
  41949. return [print("description"), node.description ? hardline$a : "", node.kind === "EnumTypeExtension" ? "extend " : "", "enum ", print("name"), printDirectives(path, print, node), node.values.length > 0 ? [" {", indent$5([hardline$a, join$8(hardline$a, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))]), hardline$a, "}"] : ""];
  41950. }
  41951. case "EnumValueDefinition":
  41952. {
  41953. return [print("description"), node.description ? hardline$a : "", print("name"), printDirectives(path, print, node)];
  41954. }
  41955. case "InputValueDefinition":
  41956. {
  41957. return [print("description"), node.description ? node.description.block ? hardline$a : line$b : "", print("name"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
  41958. }
  41959. case "InputObjectTypeExtension":
  41960. case "InputObjectTypeDefinition":
  41961. {
  41962. return [print("description"), node.description ? hardline$a : "", node.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", print("name"), printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$5([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  41963. }
  41964. case "SchemaDefinition":
  41965. {
  41966. return ["schema", printDirectives(path, print, node), " {", node.operationTypes.length > 0 ? indent$5([hardline$a, join$8(hardline$a, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))]) : "", hardline$a, "}"];
  41967. }
  41968. case "OperationTypeDefinition":
  41969. {
  41970. return [print("operation"), ": ", print("type")];
  41971. }
  41972. case "InterfaceTypeExtension":
  41973. case "InterfaceTypeDefinition":
  41974. {
  41975. return [print("description"), node.description ? hardline$a : "", node.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$5([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  41976. }
  41977. case "FragmentSpread":
  41978. {
  41979. return ["...", print("name"), printDirectives(path, print, node)];
  41980. }
  41981. case "InlineFragment":
  41982. {
  41983. return ["...", node.typeCondition ? [" on ", print("typeCondition")] : "", printDirectives(path, print, node), " ", print("selectionSet")];
  41984. }
  41985. case "UnionTypeExtension":
  41986. case "UnionTypeDefinition":
  41987. {
  41988. return group$9([print("description"), node.description ? hardline$a : "", group$9([node.kind === "UnionTypeExtension" ? "extend " : "", "union ", print("name"), printDirectives(path, print, node), node.types.length > 0 ? [" =", ifBreak$6("", " "), indent$5([ifBreak$6([line$b, " "]), join$8([line$b, "| "], path.map(print, "types"))])] : ""])]);
  41989. }
  41990. case "ScalarTypeExtension":
  41991. case "ScalarTypeDefinition":
  41992. {
  41993. return [print("description"), node.description ? hardline$a : "", node.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", print("name"), printDirectives(path, print, node)];
  41994. }
  41995. case "NonNullType":
  41996. {
  41997. return [print("type"), "!"];
  41998. }
  41999. case "ListType":
  42000. {
  42001. return ["[", print("type"), "]"];
  42002. }
  42003. default:
  42004. /* istanbul ignore next */
  42005. throw new Error("unknown graphql type: " + JSON.stringify(node.kind));
  42006. }
  42007. }
  42008. function printDirectives(path, print, node) {
  42009. if (node.directives.length === 0) {
  42010. return "";
  42011. }
  42012. const printed = join$8(line$b, path.map(print, "directives"));
  42013. if (node.kind === "FragmentDefinition" || node.kind === "OperationDefinition") {
  42014. return group$9([line$b, printed]);
  42015. }
  42016. return [" ", group$9(indent$5([softline$8, printed]))];
  42017. }
  42018. function printSequence(sequencePath, options, print) {
  42019. const count = sequencePath.getValue().length;
  42020. return sequencePath.map((path, i) => {
  42021. const printed = print();
  42022. if (isNextLineEmpty$2(options.originalText, path.getValue(), locEnd$8) && i < count - 1) {
  42023. return [printed, hardline$a];
  42024. }
  42025. return printed;
  42026. });
  42027. }
  42028. function canAttachComment(node) {
  42029. return node.kind && node.kind !== "Comment";
  42030. }
  42031. function printComment(commentPath) {
  42032. const comment = commentPath.getValue();
  42033. if (comment.kind === "Comment") {
  42034. return "#" + comment.value.trimEnd();
  42035. }
  42036. /* istanbul ignore next */
  42037. throw new Error("Not a comment: " + JSON.stringify(comment));
  42038. }
  42039. function printInterfaces(path, options, print) {
  42040. const node = path.getNode();
  42041. const parts = [];
  42042. const {
  42043. interfaces
  42044. } = node;
  42045. const printed = path.map(node => print(node), "interfaces");
  42046. for (let index = 0; index < interfaces.length; index++) {
  42047. const interfaceNode = interfaces[index];
  42048. parts.push(printed[index]);
  42049. const nextInterfaceNode = interfaces[index + 1];
  42050. if (nextInterfaceNode) {
  42051. const textBetween = options.originalText.slice(interfaceNode.loc.end, nextInterfaceNode.loc.start);
  42052. const hasComment = textBetween.includes("#");
  42053. const separator = textBetween.replace(/#.*/g, "").trim();
  42054. parts.push(separator === "," ? "," : " &", hasComment ? line$b : " ");
  42055. }
  42056. }
  42057. return parts;
  42058. }
  42059. function clean$3() {}
  42060. clean$3.ignoredProperties = new Set(["loc", "comments"]);
  42061. function hasPrettierIgnore$6(path) {
  42062. const node = path.getValue();
  42063. return node && Array.isArray(node.comments) && node.comments.some(comment => comment.value.trim() === "prettier-ignore");
  42064. }
  42065. var printerGraphql = {
  42066. print: genericPrint$3,
  42067. massageAstNode: clean$3,
  42068. hasPrettierIgnore: hasPrettierIgnore$6,
  42069. insertPragma: insertPragma$5,
  42070. printComment,
  42071. canAttachComment
  42072. };
  42073. var options$3 = {
  42074. bracketSpacing: commonOptions.bracketSpacing
  42075. };
  42076. var parsers$3 = {
  42077. get graphql() {
  42078. return require("./parser-graphql.js").parsers.graphql;
  42079. }
  42080. };
  42081. var name$4 = "GraphQL";
  42082. var type$4 = "data";
  42083. var color$4 = "#e10098";
  42084. var extensions$4 = [
  42085. ".graphql",
  42086. ".gql",
  42087. ".graphqls"
  42088. ];
  42089. var tmScope$4 = "source.graphql";
  42090. var aceMode$4 = "text";
  42091. var languageId$4 = 139;
  42092. var require$$0$3 = {
  42093. name: name$4,
  42094. type: type$4,
  42095. color: color$4,
  42096. extensions: extensions$4,
  42097. tmScope: tmScope$4,
  42098. aceMode: aceMode$4,
  42099. languageId: languageId$4
  42100. };
  42101. const languages$4 = [createLanguage(require$$0$3, () => ({
  42102. since: "1.5.0",
  42103. parsers: ["graphql"],
  42104. vscodeLanguageIds: ["graphql"]
  42105. }))];
  42106. const printers$2 = {
  42107. graphql: printerGraphql
  42108. };
  42109. var languageGraphql = {
  42110. languages: languages$4,
  42111. options: options$3,
  42112. printers: printers$2,
  42113. parsers: parsers$3
  42114. };
  42115. function locStart$8(node) {
  42116. return node.position.start.offset;
  42117. }
  42118. function locEnd$7(node) {
  42119. return node.position.end.offset;
  42120. }
  42121. var loc$2 = {
  42122. locStart: locStart$8,
  42123. locEnd: locEnd$7
  42124. };
  42125. var require$$2$1 = {
  42126. "cjkPattern": "(?:[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d])(?:[\\ufe00-\\ufe0f]|\\udb40[\\udd00-\\uddef])?",
  42127. "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",
  42128. "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
  42129. };
  42130. const {
  42131. getLast: getLast$3
  42132. } = util$5;
  42133. const {
  42134. locStart: locStart$7,
  42135. locEnd: locEnd$6
  42136. } = loc$2;
  42137. const {
  42138. cjkPattern,
  42139. kPattern,
  42140. punctuationPattern: punctuationPattern$1
  42141. } = require$$2$1;
  42142. const INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "wikiLink", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  42143. const INLINE_NODE_WRAPPER_TYPES$1 = [...INLINE_NODE_TYPES$1, "tableCell", "paragraph", "heading"];
  42144. const kRegex = new RegExp(kPattern);
  42145. const punctuationRegex = new RegExp(punctuationPattern$1);
  42146. /**
  42147. * split text into whitespaces and words
  42148. * @param {string} text
  42149. */
  42150. function splitText$2(text, options) {
  42151. const KIND_NON_CJK = "non-cjk";
  42152. const KIND_CJ_LETTER = "cj-letter";
  42153. const KIND_K_LETTER = "k-letter";
  42154. const KIND_CJK_PUNCTUATION = "cjk-punctuation";
  42155. /** @type {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} */
  42156. const nodes = [];
  42157. const tokens = (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([\t\n ]+)/);
  42158. for (const [index, token] of tokens.entries()) {
  42159. // whitespace
  42160. if (index % 2 === 1) {
  42161. nodes.push({
  42162. type: "whitespace",
  42163. value: /\n/.test(token) ? "\n" : " "
  42164. });
  42165. continue;
  42166. } // word separated by whitespace
  42167. if ((index === 0 || index === tokens.length - 1) && token === "") {
  42168. continue;
  42169. }
  42170. const innerTokens = token.split(new RegExp(`(${cjkPattern})`));
  42171. for (const [innerIndex, innerToken] of innerTokens.entries()) {
  42172. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  42173. continue;
  42174. } // non-CJK word
  42175. if (innerIndex % 2 === 0) {
  42176. if (innerToken !== "") {
  42177. appendNode({
  42178. type: "word",
  42179. value: innerToken,
  42180. kind: KIND_NON_CJK,
  42181. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  42182. hasTrailingPunctuation: punctuationRegex.test(getLast$3(innerToken))
  42183. });
  42184. }
  42185. continue;
  42186. } // CJK character
  42187. appendNode(punctuationRegex.test(innerToken) ? {
  42188. type: "word",
  42189. value: innerToken,
  42190. kind: KIND_CJK_PUNCTUATION,
  42191. hasLeadingPunctuation: true,
  42192. hasTrailingPunctuation: true
  42193. } : {
  42194. type: "word",
  42195. value: innerToken,
  42196. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  42197. hasLeadingPunctuation: false,
  42198. hasTrailingPunctuation: false
  42199. });
  42200. }
  42201. }
  42202. return nodes;
  42203. function appendNode(node) {
  42204. const lastNode = getLast$3(nodes);
  42205. if (lastNode && lastNode.type === "word") {
  42206. if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
  42207. nodes.push({
  42208. type: "whitespace",
  42209. value: " "
  42210. });
  42211. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  42212. ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
  42213. nodes.push({
  42214. type: "whitespace",
  42215. value: ""
  42216. });
  42217. }
  42218. }
  42219. nodes.push(node);
  42220. function isBetween(kind1, kind2) {
  42221. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  42222. }
  42223. }
  42224. }
  42225. function getOrderedListItemInfo$1(orderListItem, originalText) {
  42226. const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
  42227. return {
  42228. numberText,
  42229. marker,
  42230. leadingSpaces
  42231. };
  42232. }
  42233. function hasGitDiffFriendlyOrderedList$1(node, options) {
  42234. if (!node.ordered) {
  42235. return false;
  42236. }
  42237. if (node.children.length < 2) {
  42238. return false;
  42239. }
  42240. const firstNumber = Number(getOrderedListItemInfo$1(node.children[0], options.originalText).numberText);
  42241. const secondNumber = Number(getOrderedListItemInfo$1(node.children[1], options.originalText).numberText);
  42242. if (firstNumber === 0 && node.children.length > 2) {
  42243. const thirdNumber = Number(getOrderedListItemInfo$1(node.children[2], options.originalText).numberText);
  42244. return secondNumber === 1 && thirdNumber === 1;
  42245. }
  42246. return secondNumber === 1;
  42247. } // The final new line should not include in value
  42248. // https://github.com/remarkjs/remark/issues/512
  42249. function getFencedCodeBlockValue$2(node, originalText) {
  42250. const {
  42251. value
  42252. } = node;
  42253. if (node.position.end.offset === originalText.length && value.endsWith("\n") && // Code block has no end mark
  42254. originalText.endsWith("\n")) {
  42255. return value.slice(0, -1);
  42256. }
  42257. return value;
  42258. }
  42259. function mapAst$1(ast, handler) {
  42260. return function preorder(node, index, parentStack) {
  42261. const newNode = Object.assign({}, handler(node, index, parentStack));
  42262. if (newNode.children) {
  42263. newNode.children = newNode.children.map((child, index) => preorder(child, index, [newNode, ...parentStack]));
  42264. }
  42265. return newNode;
  42266. }(ast, null, []);
  42267. }
  42268. function isAutolink$1(node) {
  42269. if (!node || node.type !== "link" || node.children.length !== 1) {
  42270. return false;
  42271. }
  42272. const child = node.children[0];
  42273. return child && locStart$7(node) === locStart$7(child) && locEnd$6(node) === locEnd$6(child);
  42274. }
  42275. var utils$2 = {
  42276. mapAst: mapAst$1,
  42277. splitText: splitText$2,
  42278. punctuationPattern: punctuationPattern$1,
  42279. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  42280. getOrderedListItemInfo: getOrderedListItemInfo$1,
  42281. hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
  42282. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  42283. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1,
  42284. isAutolink: isAutolink$1
  42285. };
  42286. const {
  42287. inferParserByLanguage: inferParserByLanguage$1,
  42288. getMaxContinuousCount: getMaxContinuousCount$1
  42289. } = util$5;
  42290. const {
  42291. builders: {
  42292. hardline: hardline$9,
  42293. markAsRoot: markAsRoot$2
  42294. },
  42295. utils: {
  42296. replaceEndOfLine
  42297. }
  42298. } = doc;
  42299. const {
  42300. getFencedCodeBlockValue: getFencedCodeBlockValue$1
  42301. } = utils$2;
  42302. function embed$3(path, print, textToDoc, options) {
  42303. const node = path.getValue();
  42304. if (node.type === "code" && node.lang !== null) {
  42305. const parser = inferParserByLanguage$1(node.lang, options);
  42306. if (parser) {
  42307. const styleUnit = options.__inJsTemplate ? "~" : "`";
  42308. const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount$1(node.value, styleUnit) + 1));
  42309. const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
  42310. parser
  42311. }, {
  42312. stripTrailingHardline: true
  42313. });
  42314. return markAsRoot$2([style, node.lang, node.meta ? " " + node.meta : "", hardline$9, replaceEndOfLine(doc), hardline$9, style]);
  42315. }
  42316. }
  42317. switch (node.type) {
  42318. case "front-matter":
  42319. return print_1(node, textToDoc);
  42320. // MDX
  42321. case "importExport":
  42322. return [textToDoc(node.value, {
  42323. parser: "babel"
  42324. }, {
  42325. stripTrailingHardline: true
  42326. }), hardline$9];
  42327. case "jsx":
  42328. return textToDoc(`<$>${node.value}</$>`, {
  42329. parser: "__js_expression",
  42330. rootMarker: "mdx"
  42331. }, {
  42332. stripTrailingHardline: true
  42333. });
  42334. }
  42335. return null;
  42336. }
  42337. var embed_1$2 = embed$3;
  42338. const pragmas = ["format", "prettier"];
  42339. function startWithPragma$1(text) {
  42340. const pragma = `@(${pragmas.join("|")})`;
  42341. const regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
  42342. const matched = text.match(regex);
  42343. return matched && matched.index === 0;
  42344. }
  42345. var pragma$2 = {
  42346. startWithPragma: startWithPragma$1,
  42347. hasPragma: text => startWithPragma$1(parse_1(text).content.trimStart()),
  42348. insertPragma: text => {
  42349. const extracted = parse_1(text);
  42350. const pragma = `<!-- @${pragmas[0]} -->`;
  42351. return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
  42352. }
  42353. };
  42354. const {
  42355. getOrderedListItemInfo,
  42356. mapAst,
  42357. splitText: splitText$1
  42358. } = utils$2; // 0x0 ~ 0x10ffff
  42359. const isSingleCharRegex = /^.$/su;
  42360. function preprocess$2(ast, options) {
  42361. ast = restoreUnescapedCharacter(ast, options);
  42362. ast = mergeContinuousTexts(ast);
  42363. ast = transformInlineCode(ast);
  42364. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  42365. ast = markAlignedList(ast, options);
  42366. ast = splitTextIntoSentences(ast, options);
  42367. ast = transformImportExport(ast);
  42368. ast = mergeContinuousImportExport(ast);
  42369. return ast;
  42370. }
  42371. function transformImportExport(ast) {
  42372. return mapAst(ast, node => {
  42373. if (node.type !== "import" && node.type !== "export") {
  42374. return node;
  42375. }
  42376. return Object.assign(Object.assign({}, node), {}, {
  42377. type: "importExport"
  42378. });
  42379. });
  42380. }
  42381. function transformInlineCode(ast) {
  42382. return mapAst(ast, node => {
  42383. if (node.type !== "inlineCode") {
  42384. return node;
  42385. }
  42386. return Object.assign(Object.assign({}, node), {}, {
  42387. value: node.value.replace(/\s+/g, " ")
  42388. });
  42389. });
  42390. }
  42391. function restoreUnescapedCharacter(ast, options) {
  42392. return mapAst(ast, node => node.type !== "text" || node.value === "*" || node.value === "_" || // handle these cases in printer
  42393. !isSingleCharRegex.test(node.value) || node.position.end.offset - node.position.start.offset === node.value.length ? node : Object.assign(Object.assign({}, node), {}, {
  42394. value: options.originalText.slice(node.position.start.offset, node.position.end.offset)
  42395. }));
  42396. }
  42397. function mergeContinuousImportExport(ast) {
  42398. return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
  42399. type: "importExport",
  42400. value: prevNode.value + "\n\n" + node.value,
  42401. position: {
  42402. start: prevNode.position.start,
  42403. end: node.position.end
  42404. }
  42405. }));
  42406. }
  42407. function mergeChildren(ast, shouldMerge, mergeNode) {
  42408. return mapAst(ast, node => {
  42409. if (!node.children) {
  42410. return node;
  42411. }
  42412. const children = node.children.reduce((current, child) => {
  42413. const lastChild = getLast_1(current);
  42414. if (lastChild && shouldMerge(lastChild, child)) {
  42415. current.splice(-1, 1, mergeNode(lastChild, child));
  42416. } else {
  42417. current.push(child);
  42418. }
  42419. return current;
  42420. }, []);
  42421. return Object.assign(Object.assign({}, node), {}, {
  42422. children
  42423. });
  42424. });
  42425. }
  42426. function mergeContinuousTexts(ast) {
  42427. return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
  42428. type: "text",
  42429. value: prevNode.value + node.value,
  42430. position: {
  42431. start: prevNode.position.start,
  42432. end: node.position.end
  42433. }
  42434. }));
  42435. }
  42436. function splitTextIntoSentences(ast, options) {
  42437. return mapAst(ast, (node, index, [parentNode]) => {
  42438. if (node.type !== "text") {
  42439. return node;
  42440. }
  42441. let {
  42442. value
  42443. } = node;
  42444. if (parentNode.type === "paragraph") {
  42445. if (index === 0) {
  42446. value = value.trimStart();
  42447. }
  42448. if (index === parentNode.children.length - 1) {
  42449. value = value.trimEnd();
  42450. }
  42451. }
  42452. return {
  42453. type: "sentence",
  42454. position: node.position,
  42455. children: splitText$1(value, options)
  42456. };
  42457. });
  42458. }
  42459. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  42460. return mapAst(ast, (node, index, parentStack) => {
  42461. if (node.type === "code") {
  42462. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  42463. const isIndented = /^\n?(?: {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  42464. node.isIndented = isIndented;
  42465. if (isIndented) {
  42466. for (let i = 0; i < parentStack.length; i++) {
  42467. const parent = parentStack[i]; // no need to check checked items
  42468. if (parent.hasIndentedCodeblock) {
  42469. break;
  42470. }
  42471. if (parent.type === "list") {
  42472. parent.hasIndentedCodeblock = true;
  42473. }
  42474. }
  42475. }
  42476. }
  42477. return node;
  42478. });
  42479. }
  42480. function markAlignedList(ast, options) {
  42481. return mapAst(ast, (node, index, parentStack) => {
  42482. if (node.type === "list" && node.children.length > 0) {
  42483. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  42484. for (let i = 0; i < parentStack.length; i++) {
  42485. const parent = parentStack[i];
  42486. if (parent.type === "list" && !parent.isAligned) {
  42487. node.isAligned = false;
  42488. return node;
  42489. }
  42490. }
  42491. node.isAligned = isAligned(node);
  42492. }
  42493. return node;
  42494. });
  42495. function getListItemStart(listItem) {
  42496. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  42497. }
  42498. function isAligned(list) {
  42499. if (!list.ordered) {
  42500. /**
  42501. * - 123
  42502. * - 123
  42503. */
  42504. return true;
  42505. }
  42506. const [firstItem, secondItem] = list.children;
  42507. const firstInfo = getOrderedListItemInfo(firstItem, options.originalText);
  42508. if (firstInfo.leadingSpaces.length > 1) {
  42509. /**
  42510. * 1. 123
  42511. *
  42512. * 1. 123
  42513. * 1. 123
  42514. */
  42515. return true;
  42516. }
  42517. const firstStart = getListItemStart(firstItem);
  42518. if (firstStart === -1) {
  42519. /**
  42520. * 1.
  42521. *
  42522. * 1.
  42523. * 1.
  42524. */
  42525. return false;
  42526. }
  42527. if (list.children.length === 1) {
  42528. /**
  42529. * aligned:
  42530. *
  42531. * 11. 123
  42532. *
  42533. * not aligned:
  42534. *
  42535. * 1. 123
  42536. */
  42537. return firstStart % options.tabWidth === 0;
  42538. }
  42539. const secondStart = getListItemStart(secondItem);
  42540. if (firstStart !== secondStart) {
  42541. /**
  42542. * 11. 123
  42543. * 1. 123
  42544. *
  42545. * 1. 123
  42546. * 11. 123
  42547. */
  42548. return false;
  42549. }
  42550. if (firstStart % options.tabWidth === 0) {
  42551. /**
  42552. * 11. 123
  42553. * 12. 123
  42554. */
  42555. return true;
  42556. }
  42557. /**
  42558. * aligned:
  42559. *
  42560. * 11. 123
  42561. * 1. 123
  42562. *
  42563. * not aligned:
  42564. *
  42565. * 1. 123
  42566. * 2. 123
  42567. */
  42568. const secondInfo = getOrderedListItemInfo(secondItem, options.originalText);
  42569. return secondInfo.leadingSpaces.length > 1;
  42570. }
  42571. }
  42572. var printPreprocess$2 = preprocess$2;
  42573. const {
  42574. isFrontMatterNode: isFrontMatterNode$2
  42575. } = util$5;
  42576. const {
  42577. startWithPragma
  42578. } = pragma$2;
  42579. const ignoredProperties$1 = new Set(["position", "raw" // front-matter
  42580. ]);
  42581. function clean$2(ast, newObj, parent) {
  42582. // for codeblock
  42583. if (ast.type === "front-matter" || ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  42584. delete newObj.value;
  42585. }
  42586. if (ast.type === "list") {
  42587. delete newObj.isAligned;
  42588. }
  42589. if (ast.type === "list" || ast.type === "listItem") {
  42590. delete newObj.spread;
  42591. delete newObj.loose;
  42592. } // texts can be splitted or merged
  42593. if (ast.type === "text") {
  42594. return null;
  42595. }
  42596. if (ast.type === "inlineCode") {
  42597. newObj.value = ast.value.replace(/[\t\n ]+/g, " ");
  42598. }
  42599. if (ast.type === "wikiLink") {
  42600. newObj.value = ast.value.trim().replace(/[\t\n]+/g, " ");
  42601. }
  42602. if (ast.type === "definition" || ast.type === "linkReference") {
  42603. newObj.label = ast.label.trim().replace(/[\t\n ]+/g, " ").toLowerCase();
  42604. }
  42605. if ((ast.type === "definition" || ast.type === "link" || ast.type === "image") && ast.title) {
  42606. newObj.title = ast.title.replace(/\\(["')])/g, "$1");
  42607. } // for insert pragma
  42608. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || isFrontMatterNode$2(parent.children[0]) && parent.children[1] === ast) && ast.type === "html" && startWithPragma(ast.value)) {
  42609. return null;
  42610. }
  42611. }
  42612. clean$2.ignoredProperties = ignoredProperties$1;
  42613. var clean_1$1 = clean$2;
  42614. const {
  42615. getLast: getLast$2,
  42616. getMinNotPresentContinuousCount,
  42617. getMaxContinuousCount,
  42618. getStringWidth,
  42619. isNonEmptyArray: isNonEmptyArray$2
  42620. } = util$5;
  42621. const {
  42622. builders: {
  42623. breakParent: breakParent$4,
  42624. join: join$7,
  42625. line: line$a,
  42626. literalline: literalline$3,
  42627. markAsRoot: markAsRoot$1,
  42628. hardline: hardline$8,
  42629. softline: softline$7,
  42630. ifBreak: ifBreak$5,
  42631. fill: fill$4,
  42632. align: align$1,
  42633. indent: indent$4,
  42634. group: group$8,
  42635. hardlineWithoutBreakParent
  42636. },
  42637. utils: {
  42638. normalizeDoc,
  42639. replaceTextEndOfLine: replaceTextEndOfLine$7
  42640. },
  42641. printer: {
  42642. printDocToString
  42643. }
  42644. } = doc;
  42645. const {
  42646. insertPragma: insertPragma$4
  42647. } = pragma$2;
  42648. const {
  42649. locStart: locStart$6,
  42650. locEnd: locEnd$5
  42651. } = loc$2;
  42652. const {
  42653. getFencedCodeBlockValue,
  42654. hasGitDiffFriendlyOrderedList,
  42655. splitText,
  42656. punctuationPattern,
  42657. INLINE_NODE_TYPES,
  42658. INLINE_NODE_WRAPPER_TYPES,
  42659. isAutolink
  42660. } = utils$2;
  42661. /**
  42662. * @typedef {import("../document").Doc} Doc
  42663. */
  42664. const TRAILING_HARDLINE_NODES = new Set(["importExport"]);
  42665. const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link", "wikiLink"];
  42666. const SIBLING_NODE_TYPES = new Set(["listItem", "definition", "footnoteDefinition"]);
  42667. function genericPrint$2(path, options, print) {
  42668. const node = path.getValue();
  42669. if (shouldRemainTheSameContent(path)) {
  42670. return splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options));
  42671. }
  42672. switch (node.type) {
  42673. case "front-matter":
  42674. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  42675. case "root":
  42676. if (node.children.length === 0) {
  42677. return "";
  42678. }
  42679. return [normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.has(getLastDescendantNode$2(node).type) ? hardline$8 : ""];
  42680. case "paragraph":
  42681. return printChildren$4(path, options, print, {
  42682. postprocessor: fill$4
  42683. });
  42684. case "sentence":
  42685. return printChildren$4(path, options, print);
  42686. case "word":
  42687. {
  42688. let escapedValue = node.value.replace(/\*/g, "\\$&") // escape all `*`
  42689. .replace(new RegExp([`(^|${punctuationPattern})(_+)`, `(_+)(${punctuationPattern}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_")); // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  42690. const isFirstSentence = (node, name, index) => node.type === "sentence" && index === 0;
  42691. const isLastChildAutolink = (node, name, index) => isAutolink(node.children[index - 1]);
  42692. if (escapedValue !== node.value && (path.match(undefined, isFirstSentence, isLastChildAutolink) || path.match(undefined, isFirstSentence, (node, name, index) => node.type === "emphasis" && index === 0, isLastChildAutolink))) {
  42693. // backslash is parsed as part of autolinks, so we need to remove it
  42694. escapedValue = escapedValue.replace(/^(\\?[*_])+/, prefix => prefix.replace(/\\/g, ""));
  42695. }
  42696. return escapedValue;
  42697. }
  42698. case "whitespace":
  42699. {
  42700. const parentNode = path.getParentNode();
  42701. const index = parentNode.children.indexOf(node);
  42702. const nextNode = parentNode.children[index + 1];
  42703. const proseWrap = // leading char that may cause different syntax
  42704. nextNode && /^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(nextNode.value) ? "never" : options.proseWrap;
  42705. return printLine(path, node.value, {
  42706. proseWrap
  42707. });
  42708. }
  42709. case "emphasis":
  42710. {
  42711. let style;
  42712. if (isAutolink(node.children[0])) {
  42713. style = options.originalText[node.position.start.offset];
  42714. } else {
  42715. const parentNode = path.getParentNode();
  42716. const index = parentNode.children.indexOf(node);
  42717. const prevNode = parentNode.children[index - 1];
  42718. const nextNode = parentNode.children[index + 1];
  42719. const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
  42720. prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && getLast$2(prevNode.children).type === "word" && !getLast$2(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
  42721. style = hasPrevOrNextWord || getAncestorNode(path, "emphasis") ? "*" : "_";
  42722. }
  42723. return [style, printChildren$4(path, options, print), style];
  42724. }
  42725. case "strong":
  42726. return ["**", printChildren$4(path, options, print), "**"];
  42727. case "delete":
  42728. return ["~~", printChildren$4(path, options, print), "~~"];
  42729. case "inlineCode":
  42730. {
  42731. const backtickCount = getMinNotPresentContinuousCount(node.value, "`");
  42732. const style = "`".repeat(backtickCount || 1);
  42733. const gap = backtickCount && !/^\s/.test(node.value) ? " " : "";
  42734. return [style, gap, node.value, gap, style];
  42735. }
  42736. case "wikiLink":
  42737. {
  42738. let contents = "";
  42739. if (options.proseWrap === "preserve") {
  42740. contents = node.value;
  42741. } else {
  42742. contents = node.value.replace(/[\t\n]+/g, " ");
  42743. }
  42744. return ["[[", contents, "]]"];
  42745. }
  42746. case "link":
  42747. switch (options.originalText[node.position.start.offset]) {
  42748. case "<":
  42749. {
  42750. const mailto = "mailto:";
  42751. const url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  42752. node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
  42753. return ["<", url, ">"];
  42754. }
  42755. case "[":
  42756. return ["[", printChildren$4(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
  42757. default:
  42758. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  42759. }
  42760. case "image":
  42761. return ["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
  42762. case "blockquote":
  42763. return ["> ", align$1("> ", printChildren$4(path, options, print))];
  42764. case "heading":
  42765. return ["#".repeat(node.depth) + " ", printChildren$4(path, options, print)];
  42766. case "code":
  42767. {
  42768. if (node.isIndented) {
  42769. // indented code block
  42770. const alignment = " ".repeat(4);
  42771. return align$1(alignment, [alignment, ...replaceTextEndOfLine$7(node.value, hardline$8)]);
  42772. } // fenced code block
  42773. const styleUnit = options.__inJsTemplate ? "~" : "`";
  42774. const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount(node.value, styleUnit) + 1));
  42775. return [style, node.lang || "", node.meta ? " " + node.meta : "", hardline$8, ...replaceTextEndOfLine$7(getFencedCodeBlockValue(node, options.originalText), hardline$8), hardline$8, style];
  42776. }
  42777. case "html":
  42778. {
  42779. const parentNode = path.getParentNode();
  42780. const value = parentNode.type === "root" && getLast$2(parentNode.children) === node ? node.value.trimEnd() : node.value;
  42781. const isHtmlComment = /^<!--.*-->$/s.test(value);
  42782. return replaceTextEndOfLine$7(value, // @ts-expect-error
  42783. isHtmlComment ? hardline$8 : markAsRoot$1(literalline$3));
  42784. }
  42785. case "list":
  42786. {
  42787. const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
  42788. const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList(node, options);
  42789. return printChildren$4(path, options, print, {
  42790. processor: (childPath, index) => {
  42791. const prefix = getPrefix();
  42792. const childNode = childPath.getValue();
  42793. if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
  42794. return [prefix, printListItem(childPath, options, print, prefix)];
  42795. }
  42796. return [prefix, align$1(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))];
  42797. function getPrefix() {
  42798. const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  42799. return node.isAligned ||
  42800. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  42801. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  42802. }
  42803. }
  42804. });
  42805. }
  42806. case "thematicBreak":
  42807. {
  42808. const counter = getAncestorCounter(path, "list");
  42809. if (counter === -1) {
  42810. return "---";
  42811. }
  42812. const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
  42813. return nthSiblingIndex % 2 === 0 ? "***" : "---";
  42814. }
  42815. case "linkReference":
  42816. return ["[", printChildren$4(path, options, print), "]", node.referenceType === "full" ? ["[", node.identifier, "]"] : node.referenceType === "collapsed" ? "[]" : ""];
  42817. case "imageReference":
  42818. switch (node.referenceType) {
  42819. case "full":
  42820. return ["![", node.alt || "", "][", node.identifier, "]"];
  42821. default:
  42822. return ["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""];
  42823. }
  42824. case "definition":
  42825. {
  42826. const lineOrSpace = options.proseWrap === "always" ? line$a : " ";
  42827. return group$8(["[", node.identifier, "]:", indent$4([lineOrSpace, printUrl(node.url), node.title === null ? "" : [lineOrSpace, printTitle(node.title, options, false)]])]);
  42828. }
  42829. // `footnote` requires `.use(footnotes, {inlineNotes: true})`, we are not using this option
  42830. // https://github.com/remarkjs/remark-footnotes#optionsinlinenotes
  42831. /* istanbul ignore next */
  42832. case "footnote":
  42833. return ["[^", printChildren$4(path, options, print), "]"];
  42834. case "footnoteReference":
  42835. return ["[^", node.identifier, "]"];
  42836. case "footnoteDefinition":
  42837. {
  42838. const nextNode = path.getParentNode().children[path.getName() + 1];
  42839. const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
  42840. return ["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$4(path, options, print) : group$8([align$1(" ".repeat(4), printChildren$4(path, options, print, {
  42841. processor: (childPath, index) => index === 0 ? group$8([softline$7, print()]) : print()
  42842. })), nextNode && nextNode.type === "footnoteDefinition" ? softline$7 : ""])];
  42843. }
  42844. case "table":
  42845. return printTable(path, options, print);
  42846. case "tableCell":
  42847. return printChildren$4(path, options, print);
  42848. case "break":
  42849. return /\s/.test(options.originalText[node.position.start.offset]) ? [" ", markAsRoot$1(literalline$3)] : ["\\", hardline$8];
  42850. case "liquidNode":
  42851. return replaceTextEndOfLine$7(node.value, hardline$8);
  42852. // MDX
  42853. // fallback to the original text if multiparser failed
  42854. // or `embeddedLanguageFormatting: "off"`
  42855. case "importExport":
  42856. return [node.value, hardline$8];
  42857. case "jsx":
  42858. return node.value;
  42859. case "math":
  42860. return ["$$", hardline$8, node.value ? [...replaceTextEndOfLine$7(node.value, hardline$8), hardline$8] : "", "$$"];
  42861. case "inlineMath":
  42862. {
  42863. // remark-math trims content but we don't want to remove whitespaces
  42864. // since it's very possible that it's recognized as math accidentally
  42865. return options.originalText.slice(locStart$6(node), locEnd$5(node));
  42866. }
  42867. case "tableRow": // handled in "table"
  42868. case "listItem": // handled in "list"
  42869. default:
  42870. /* istanbul ignore next */
  42871. throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
  42872. }
  42873. }
  42874. function printListItem(path, options, print, listPrefix) {
  42875. const node = path.getValue();
  42876. const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  42877. return [prefix, printChildren$4(path, options, print, {
  42878. processor: (childPath, index) => {
  42879. if (index === 0 && childPath.getValue().type !== "list") {
  42880. return align$1(" ".repeat(prefix.length), print());
  42881. }
  42882. const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  42883. );
  42884. return [alignment, align$1(alignment, print())];
  42885. }
  42886. })];
  42887. }
  42888. function alignListPrefix(prefix, options) {
  42889. const additionalSpaces = getAdditionalSpaces();
  42890. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  42891. );
  42892. function getAdditionalSpaces() {
  42893. const restSpaces = prefix.length % options.tabWidth;
  42894. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  42895. }
  42896. }
  42897. function getNthListSiblingIndex(node, parentNode) {
  42898. return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
  42899. }
  42900. function getNthSiblingIndex(node, parentNode, condition) {
  42901. let index = -1;
  42902. for (const childNode of parentNode.children) {
  42903. if (childNode.type === node.type && condition(childNode)) {
  42904. index++;
  42905. } else {
  42906. index = -1;
  42907. }
  42908. if (childNode === node) {
  42909. return index;
  42910. }
  42911. }
  42912. }
  42913. function getAncestorCounter(path, typeOrTypes) {
  42914. const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
  42915. let counter = -1;
  42916. let ancestorNode;
  42917. while (ancestorNode = path.getParentNode(++counter)) {
  42918. if (types.includes(ancestorNode.type)) {
  42919. return counter;
  42920. }
  42921. }
  42922. return -1;
  42923. }
  42924. function getAncestorNode(path, typeOrTypes) {
  42925. const counter = getAncestorCounter(path, typeOrTypes);
  42926. return counter === -1 ? null : path.getParentNode(counter);
  42927. }
  42928. function printLine(path, value, options) {
  42929. if (options.proseWrap === "preserve" && value === "\n") {
  42930. return hardline$8;
  42931. }
  42932. const isBreakable = options.proseWrap === "always" && !getAncestorNode(path, SINGLE_LINE_NODE_TYPES);
  42933. return value !== "" ? isBreakable ? line$a : " " : isBreakable ? softline$7 : "";
  42934. }
  42935. function printTable(path, options, print) {
  42936. const node = path.getValue();
  42937. const columnMaxWidths = []; // { [rowIndex: number]: { [columnIndex: number]: {text: string, width: number} } }
  42938. const contents = path.map(rowPath => rowPath.map((cellPath, columnIndex) => {
  42939. const text = printDocToString(print(), options).formatted;
  42940. const width = getStringWidth(text);
  42941. columnMaxWidths[columnIndex] = Math.max(columnMaxWidths[columnIndex] || 3, // minimum width = 3 (---, :--, :-:, --:)
  42942. width);
  42943. return {
  42944. text,
  42945. width
  42946. };
  42947. }, "children"), "children");
  42948. const alignedTable = printTableContents(
  42949. /* isCompact */
  42950. false);
  42951. if (options.proseWrap !== "never") {
  42952. return [breakParent$4, alignedTable];
  42953. } // Only if the --prose-wrap never is set and it exceeds the print width.
  42954. const compactTable = printTableContents(
  42955. /* isCompact */
  42956. true);
  42957. return [breakParent$4, group$8(ifBreak$5(compactTable, alignedTable))];
  42958. function printTableContents(isCompact) {
  42959. /** @type{Doc[]} */
  42960. const parts = [printRow(contents[0], isCompact), printAlign(isCompact)];
  42961. if (contents.length > 1) {
  42962. parts.push(join$7(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents, isCompact))));
  42963. }
  42964. return join$7(hardlineWithoutBreakParent, parts);
  42965. }
  42966. function printAlign(isCompact) {
  42967. const align = columnMaxWidths.map((width, index) => {
  42968. const align = node.align[index];
  42969. const first = align === "center" || align === "left" ? ":" : "-";
  42970. const last = align === "center" || align === "right" ? ":" : "-";
  42971. const middle = isCompact ? "-" : "-".repeat(width - 2);
  42972. return `${first}${middle}${last}`;
  42973. });
  42974. return `| ${align.join(" | ")} |`;
  42975. }
  42976. function printRow(rowContents, isCompact) {
  42977. const columns = rowContents.map(({
  42978. text,
  42979. width
  42980. }, columnIndex) => {
  42981. if (isCompact) {
  42982. return text;
  42983. }
  42984. const spaces = columnMaxWidths[columnIndex] - width;
  42985. const align = node.align[columnIndex];
  42986. let before = 0;
  42987. if (align === "right") {
  42988. before = spaces;
  42989. } else if (align === "center") {
  42990. before = Math.floor(spaces / 2);
  42991. }
  42992. const after = spaces - before;
  42993. return `${" ".repeat(before)}${text}${" ".repeat(after)}`;
  42994. });
  42995. return `| ${columns.join(" | ")} |`;
  42996. }
  42997. }
  42998. function printRoot(path, options, print) {
  42999. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  43000. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  43001. const ignoreRanges = [];
  43002. /** @type {IgnorePosition | null} */
  43003. let ignoreStart = null;
  43004. const {
  43005. children
  43006. } = path.getValue();
  43007. for (const [index, childNode] of children.entries()) {
  43008. switch (isPrettierIgnore$2(childNode)) {
  43009. case "start":
  43010. if (ignoreStart === null) {
  43011. ignoreStart = {
  43012. index,
  43013. offset: childNode.position.end.offset
  43014. };
  43015. }
  43016. break;
  43017. case "end":
  43018. if (ignoreStart !== null) {
  43019. ignoreRanges.push({
  43020. start: ignoreStart,
  43021. end: {
  43022. index,
  43023. offset: childNode.position.start.offset
  43024. }
  43025. });
  43026. ignoreStart = null;
  43027. }
  43028. break;
  43029. }
  43030. }
  43031. return printChildren$4(path, options, print, {
  43032. processor: (childPath, index) => {
  43033. if (ignoreRanges.length > 0) {
  43034. const ignoreRange = ignoreRanges[0];
  43035. if (index === ignoreRange.start.index) {
  43036. return [children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value];
  43037. }
  43038. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  43039. return false;
  43040. }
  43041. if (index === ignoreRange.end.index) {
  43042. ignoreRanges.shift();
  43043. return false;
  43044. }
  43045. }
  43046. return print();
  43047. }
  43048. });
  43049. }
  43050. function printChildren$4(path, options, print, events = {}) {
  43051. const {
  43052. postprocessor
  43053. } = events;
  43054. const processor = events.processor || (() => print());
  43055. const node = path.getValue();
  43056. const parts = [];
  43057. let lastChildNode;
  43058. path.each((childPath, index) => {
  43059. const childNode = childPath.getValue();
  43060. const result = processor(childPath, index);
  43061. if (result !== false) {
  43062. const data = {
  43063. parts,
  43064. prevNode: lastChildNode,
  43065. parentNode: node,
  43066. options
  43067. };
  43068. if (shouldPrePrintHardline(childNode, data)) {
  43069. parts.push(hardline$8); // Can't find a case to pass `shouldPrePrintTripleHardline`
  43070. /* istanbul ignore next */
  43071. if (lastChildNode && TRAILING_HARDLINE_NODES.has(lastChildNode.type)) {
  43072. if (shouldPrePrintTripleHardline(childNode, data)) {
  43073. parts.push(hardline$8);
  43074. }
  43075. } else {
  43076. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  43077. parts.push(hardline$8);
  43078. }
  43079. if (shouldPrePrintTripleHardline(childNode, data)) {
  43080. parts.push(hardline$8);
  43081. }
  43082. }
  43083. }
  43084. parts.push(result);
  43085. lastChildNode = childNode;
  43086. }
  43087. }, "children");
  43088. return postprocessor ? postprocessor(parts) : parts;
  43089. }
  43090. function getLastDescendantNode$2(node) {
  43091. let current = node;
  43092. while (isNonEmptyArray$2(current.children)) {
  43093. current = getLast$2(current.children);
  43094. }
  43095. return current;
  43096. }
  43097. /** @return {false | 'next' | 'start' | 'end'} */
  43098. function isPrettierIgnore$2(node) {
  43099. if (node.type !== "html") {
  43100. return false;
  43101. }
  43102. const match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  43103. return match === null ? false : match[1] ? match[1] : "next";
  43104. }
  43105. function shouldPrePrintHardline(node, data) {
  43106. const isFirstNode = data.parts.length === 0;
  43107. const isInlineNode = INLINE_NODE_TYPES.includes(node.type);
  43108. const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.includes(data.parentNode.type);
  43109. return !isFirstNode && !isInlineNode && !isInlineHTML;
  43110. }
  43111. function shouldPrePrintDoubleHardline(node, data) {
  43112. const isSequence = (data.prevNode && data.prevNode.type) === node.type;
  43113. const isSiblingNode = isSequence && SIBLING_NODE_TYPES.has(node.type);
  43114. const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  43115. const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  43116. const isPrevNodePrettierIgnore = isPrettierIgnore$2(data.prevNode) === "next";
  43117. const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  43118. const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
  43119. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
  43120. }
  43121. function shouldPrePrintTripleHardline(node, data) {
  43122. const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  43123. const isIndentedCode = node.type === "code" && node.isIndented;
  43124. return isPrevNodeList && isIndentedCode;
  43125. }
  43126. function shouldRemainTheSameContent(path) {
  43127. const ancestorNode = getAncestorNode(path, ["linkReference", "imageReference"]);
  43128. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  43129. }
  43130. /**
  43131. * @param {string} url
  43132. * @param {string[] | string} [dangerousCharOrChars]
  43133. * @returns {string}
  43134. */
  43135. function printUrl(url, dangerousCharOrChars = []) {
  43136. const dangerousChars = [" ", ...(Array.isArray(dangerousCharOrChars) ? dangerousCharOrChars : [dangerousCharOrChars])];
  43137. return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
  43138. }
  43139. function printTitle(title, options, printSpace = true) {
  43140. if (!title) {
  43141. return "";
  43142. }
  43143. if (printSpace) {
  43144. return " " + printTitle(title, options, false);
  43145. } // title is escaped after `remark-parse` v7
  43146. title = title.replace(/\\(["')])/g, "$1");
  43147. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  43148. return `(${title})`; // avoid escaped quotes
  43149. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  43150. const singleCount = title.split("'").length - 1;
  43151. const doubleCount = title.split('"').length - 1;
  43152. const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  43153. title = title.replace(/\\/, "\\\\");
  43154. title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
  43155. return `${quote}${title}${quote}`;
  43156. }
  43157. function clamp(value, min, max) {
  43158. return value < min ? min : value > max ? max : value;
  43159. }
  43160. function hasPrettierIgnore$5(path) {
  43161. const index = Number(path.getName());
  43162. if (index === 0) {
  43163. return false;
  43164. }
  43165. const prevNode = path.getParentNode().children[index - 1];
  43166. return isPrettierIgnore$2(prevNode) === "next";
  43167. }
  43168. var printerMarkdown = {
  43169. preprocess: printPreprocess$2,
  43170. print: genericPrint$2,
  43171. embed: embed_1$2,
  43172. massageAstNode: clean_1$1,
  43173. hasPrettierIgnore: hasPrettierIgnore$5,
  43174. insertPragma: insertPragma$4
  43175. };
  43176. var options$2 = {
  43177. proseWrap: commonOptions.proseWrap,
  43178. singleQuote: commonOptions.singleQuote
  43179. };
  43180. var parsers$2 = {
  43181. /* istanbul ignore next */
  43182. get remark() {
  43183. return require("./parser-markdown.js").parsers.remark;
  43184. },
  43185. get markdown() {
  43186. return require("./parser-markdown.js").parsers.remark;
  43187. },
  43188. get mdx() {
  43189. return require("./parser-markdown.js").parsers.mdx;
  43190. }
  43191. };
  43192. var name$3 = "Markdown";
  43193. var type$3 = "prose";
  43194. var color$3 = "#083fa1";
  43195. var aliases$2 = [
  43196. "pandoc"
  43197. ];
  43198. var aceMode$3 = "markdown";
  43199. var codemirrorMode$2 = "gfm";
  43200. var codemirrorMimeType$2 = "text/x-gfm";
  43201. var wrap = true;
  43202. var extensions$3 = [
  43203. ".md",
  43204. ".markdown",
  43205. ".mdown",
  43206. ".mdwn",
  43207. ".mdx",
  43208. ".mkd",
  43209. ".mkdn",
  43210. ".mkdown",
  43211. ".ronn",
  43212. ".scd",
  43213. ".workbook"
  43214. ];
  43215. var filenames$1 = [
  43216. "contents.lr"
  43217. ];
  43218. var tmScope$3 = "source.gfm";
  43219. var languageId$3 = 222;
  43220. var require$$0$2 = {
  43221. name: name$3,
  43222. type: type$3,
  43223. color: color$3,
  43224. aliases: aliases$2,
  43225. aceMode: aceMode$3,
  43226. codemirrorMode: codemirrorMode$2,
  43227. codemirrorMimeType: codemirrorMimeType$2,
  43228. wrap: wrap,
  43229. extensions: extensions$3,
  43230. filenames: filenames$1,
  43231. tmScope: tmScope$3,
  43232. languageId: languageId$3
  43233. };
  43234. const languages$3 = [createLanguage(require$$0$2, data => ({
  43235. since: "1.8.0",
  43236. parsers: ["markdown"],
  43237. vscodeLanguageIds: ["markdown"],
  43238. filenames: [...data.filenames, "README"],
  43239. extensions: data.extensions.filter(extension => extension !== ".mdx")
  43240. })), createLanguage(require$$0$2, () => ({
  43241. name: "MDX",
  43242. since: "1.15.0",
  43243. parsers: ["mdx"],
  43244. vscodeLanguageIds: ["mdx"],
  43245. filenames: [],
  43246. extensions: [".mdx"]
  43247. }))];
  43248. const printers$1 = {
  43249. mdast: printerMarkdown
  43250. };
  43251. var languageMarkdown = {
  43252. languages: languages$3,
  43253. options: options$2,
  43254. printers: printers$1,
  43255. parsers: parsers$2
  43256. };
  43257. const {
  43258. isFrontMatterNode: isFrontMatterNode$1
  43259. } = util$5;
  43260. const ignoredProperties = new Set(["sourceSpan", "startSourceSpan", "endSourceSpan", "nameSpan", "valueSpan"]);
  43261. function clean$1(ast, newNode) {
  43262. if (ast.type === "text" || ast.type === "comment") {
  43263. return null;
  43264. } // may be formatted by multiparser
  43265. if (isFrontMatterNode$1(ast) || ast.type === "yaml" || ast.type === "toml") {
  43266. return null;
  43267. }
  43268. if (ast.type === "attribute") {
  43269. delete newNode.value;
  43270. }
  43271. if (ast.type === "docType") {
  43272. delete newNode.value;
  43273. }
  43274. }
  43275. clean$1.ignoredProperties = ignoredProperties;
  43276. var clean_1 = clean$1;
  43277. var htmlTagNames = [
  43278. "a",
  43279. "abbr",
  43280. "acronym",
  43281. "address",
  43282. "applet",
  43283. "area",
  43284. "article",
  43285. "aside",
  43286. "audio",
  43287. "b",
  43288. "base",
  43289. "basefont",
  43290. "bdi",
  43291. "bdo",
  43292. "bgsound",
  43293. "big",
  43294. "blink",
  43295. "blockquote",
  43296. "body",
  43297. "br",
  43298. "button",
  43299. "canvas",
  43300. "caption",
  43301. "center",
  43302. "cite",
  43303. "code",
  43304. "col",
  43305. "colgroup",
  43306. "command",
  43307. "content",
  43308. "data",
  43309. "datalist",
  43310. "dd",
  43311. "del",
  43312. "details",
  43313. "dfn",
  43314. "dialog",
  43315. "dir",
  43316. "div",
  43317. "dl",
  43318. "dt",
  43319. "element",
  43320. "em",
  43321. "embed",
  43322. "fieldset",
  43323. "figcaption",
  43324. "figure",
  43325. "font",
  43326. "footer",
  43327. "form",
  43328. "frame",
  43329. "frameset",
  43330. "h1",
  43331. "h2",
  43332. "h3",
  43333. "h4",
  43334. "h5",
  43335. "h6",
  43336. "head",
  43337. "header",
  43338. "hgroup",
  43339. "hr",
  43340. "html",
  43341. "i",
  43342. "iframe",
  43343. "image",
  43344. "img",
  43345. "input",
  43346. "ins",
  43347. "isindex",
  43348. "kbd",
  43349. "keygen",
  43350. "label",
  43351. "legend",
  43352. "li",
  43353. "link",
  43354. "listing",
  43355. "main",
  43356. "map",
  43357. "mark",
  43358. "marquee",
  43359. "math",
  43360. "menu",
  43361. "menuitem",
  43362. "meta",
  43363. "meter",
  43364. "multicol",
  43365. "nav",
  43366. "nextid",
  43367. "nobr",
  43368. "noembed",
  43369. "noframes",
  43370. "noscript",
  43371. "object",
  43372. "ol",
  43373. "optgroup",
  43374. "option",
  43375. "output",
  43376. "p",
  43377. "param",
  43378. "picture",
  43379. "plaintext",
  43380. "pre",
  43381. "progress",
  43382. "q",
  43383. "rb",
  43384. "rbc",
  43385. "rp",
  43386. "rt",
  43387. "rtc",
  43388. "ruby",
  43389. "s",
  43390. "samp",
  43391. "script",
  43392. "section",
  43393. "select",
  43394. "shadow",
  43395. "slot",
  43396. "small",
  43397. "source",
  43398. "spacer",
  43399. "span",
  43400. "strike",
  43401. "strong",
  43402. "style",
  43403. "sub",
  43404. "summary",
  43405. "sup",
  43406. "svg",
  43407. "table",
  43408. "tbody",
  43409. "td",
  43410. "template",
  43411. "textarea",
  43412. "tfoot",
  43413. "th",
  43414. "thead",
  43415. "time",
  43416. "title",
  43417. "tr",
  43418. "track",
  43419. "tt",
  43420. "u",
  43421. "ul",
  43422. "var",
  43423. "video",
  43424. "wbr",
  43425. "xmp"
  43426. ];
  43427. var a = [
  43428. "accesskey",
  43429. "charset",
  43430. "coords",
  43431. "download",
  43432. "href",
  43433. "hreflang",
  43434. "name",
  43435. "ping",
  43436. "referrerpolicy",
  43437. "rel",
  43438. "rev",
  43439. "shape",
  43440. "tabindex",
  43441. "target",
  43442. "type"
  43443. ];
  43444. var abbr = [
  43445. "title"
  43446. ];
  43447. var applet = [
  43448. "align",
  43449. "alt",
  43450. "archive",
  43451. "code",
  43452. "codebase",
  43453. "height",
  43454. "hspace",
  43455. "name",
  43456. "object",
  43457. "vspace",
  43458. "width"
  43459. ];
  43460. var area = [
  43461. "accesskey",
  43462. "alt",
  43463. "coords",
  43464. "download",
  43465. "href",
  43466. "hreflang",
  43467. "nohref",
  43468. "ping",
  43469. "referrerpolicy",
  43470. "rel",
  43471. "shape",
  43472. "tabindex",
  43473. "target",
  43474. "type"
  43475. ];
  43476. var audio = [
  43477. "autoplay",
  43478. "controls",
  43479. "crossorigin",
  43480. "loop",
  43481. "muted",
  43482. "preload",
  43483. "src"
  43484. ];
  43485. var base = [
  43486. "href",
  43487. "target"
  43488. ];
  43489. var basefont = [
  43490. "color",
  43491. "face",
  43492. "size"
  43493. ];
  43494. var bdo = [
  43495. "dir"
  43496. ];
  43497. var blockquote = [
  43498. "cite"
  43499. ];
  43500. var body = [
  43501. "alink",
  43502. "background",
  43503. "bgcolor",
  43504. "link",
  43505. "text",
  43506. "vlink"
  43507. ];
  43508. var br = [
  43509. "clear"
  43510. ];
  43511. var button = [
  43512. "accesskey",
  43513. "autofocus",
  43514. "disabled",
  43515. "form",
  43516. "formaction",
  43517. "formenctype",
  43518. "formmethod",
  43519. "formnovalidate",
  43520. "formtarget",
  43521. "name",
  43522. "tabindex",
  43523. "type",
  43524. "value"
  43525. ];
  43526. var canvas = [
  43527. "height",
  43528. "width"
  43529. ];
  43530. var caption = [
  43531. "align"
  43532. ];
  43533. var col = [
  43534. "align",
  43535. "char",
  43536. "charoff",
  43537. "span",
  43538. "valign",
  43539. "width"
  43540. ];
  43541. var colgroup = [
  43542. "align",
  43543. "char",
  43544. "charoff",
  43545. "span",
  43546. "valign",
  43547. "width"
  43548. ];
  43549. var data = [
  43550. "value"
  43551. ];
  43552. var del = [
  43553. "cite",
  43554. "datetime"
  43555. ];
  43556. var details = [
  43557. "open"
  43558. ];
  43559. var dfn = [
  43560. "title"
  43561. ];
  43562. var dialog = [
  43563. "open"
  43564. ];
  43565. var dir = [
  43566. "compact"
  43567. ];
  43568. var div = [
  43569. "align"
  43570. ];
  43571. var dl = [
  43572. "compact"
  43573. ];
  43574. var embed$2 = [
  43575. "height",
  43576. "src",
  43577. "type",
  43578. "width"
  43579. ];
  43580. var fieldset = [
  43581. "disabled",
  43582. "form",
  43583. "name"
  43584. ];
  43585. var font = [
  43586. "color",
  43587. "face",
  43588. "size"
  43589. ];
  43590. var form = [
  43591. "accept",
  43592. "accept-charset",
  43593. "action",
  43594. "autocomplete",
  43595. "enctype",
  43596. "method",
  43597. "name",
  43598. "novalidate",
  43599. "target"
  43600. ];
  43601. var frame = [
  43602. "frameborder",
  43603. "longdesc",
  43604. "marginheight",
  43605. "marginwidth",
  43606. "name",
  43607. "noresize",
  43608. "scrolling",
  43609. "src"
  43610. ];
  43611. var frameset = [
  43612. "cols",
  43613. "rows"
  43614. ];
  43615. var h1 = [
  43616. "align"
  43617. ];
  43618. var h2 = [
  43619. "align"
  43620. ];
  43621. var h3 = [
  43622. "align"
  43623. ];
  43624. var h4 = [
  43625. "align"
  43626. ];
  43627. var h5 = [
  43628. "align"
  43629. ];
  43630. var h6 = [
  43631. "align"
  43632. ];
  43633. var head = [
  43634. "profile"
  43635. ];
  43636. var hr = [
  43637. "align",
  43638. "noshade",
  43639. "size",
  43640. "width"
  43641. ];
  43642. var html = [
  43643. "manifest",
  43644. "version"
  43645. ];
  43646. var iframe = [
  43647. "align",
  43648. "allow",
  43649. "allowfullscreen",
  43650. "allowpaymentrequest",
  43651. "allowusermedia",
  43652. "frameborder",
  43653. "height",
  43654. "loading",
  43655. "longdesc",
  43656. "marginheight",
  43657. "marginwidth",
  43658. "name",
  43659. "referrerpolicy",
  43660. "sandbox",
  43661. "scrolling",
  43662. "src",
  43663. "srcdoc",
  43664. "width"
  43665. ];
  43666. var img = [
  43667. "align",
  43668. "alt",
  43669. "border",
  43670. "crossorigin",
  43671. "decoding",
  43672. "height",
  43673. "hspace",
  43674. "ismap",
  43675. "loading",
  43676. "longdesc",
  43677. "name",
  43678. "referrerpolicy",
  43679. "sizes",
  43680. "src",
  43681. "srcset",
  43682. "usemap",
  43683. "vspace",
  43684. "width"
  43685. ];
  43686. var input = [
  43687. "accept",
  43688. "accesskey",
  43689. "align",
  43690. "alt",
  43691. "autocomplete",
  43692. "autofocus",
  43693. "checked",
  43694. "dirname",
  43695. "disabled",
  43696. "form",
  43697. "formaction",
  43698. "formenctype",
  43699. "formmethod",
  43700. "formnovalidate",
  43701. "formtarget",
  43702. "height",
  43703. "ismap",
  43704. "list",
  43705. "max",
  43706. "maxlength",
  43707. "min",
  43708. "minlength",
  43709. "multiple",
  43710. "name",
  43711. "pattern",
  43712. "placeholder",
  43713. "readonly",
  43714. "required",
  43715. "size",
  43716. "src",
  43717. "step",
  43718. "tabindex",
  43719. "title",
  43720. "type",
  43721. "usemap",
  43722. "value",
  43723. "width"
  43724. ];
  43725. var ins = [
  43726. "cite",
  43727. "datetime"
  43728. ];
  43729. var isindex = [
  43730. "prompt"
  43731. ];
  43732. var label = [
  43733. "accesskey",
  43734. "for",
  43735. "form"
  43736. ];
  43737. var legend = [
  43738. "accesskey",
  43739. "align"
  43740. ];
  43741. var li = [
  43742. "type",
  43743. "value"
  43744. ];
  43745. var link = [
  43746. "as",
  43747. "charset",
  43748. "color",
  43749. "crossorigin",
  43750. "disabled",
  43751. "href",
  43752. "hreflang",
  43753. "imagesizes",
  43754. "imagesrcset",
  43755. "integrity",
  43756. "media",
  43757. "nonce",
  43758. "referrerpolicy",
  43759. "rel",
  43760. "rev",
  43761. "sizes",
  43762. "target",
  43763. "title",
  43764. "type"
  43765. ];
  43766. var map = [
  43767. "name"
  43768. ];
  43769. var menu = [
  43770. "compact"
  43771. ];
  43772. var meta = [
  43773. "charset",
  43774. "content",
  43775. "http-equiv",
  43776. "name",
  43777. "scheme"
  43778. ];
  43779. var meter = [
  43780. "high",
  43781. "low",
  43782. "max",
  43783. "min",
  43784. "optimum",
  43785. "value"
  43786. ];
  43787. var object = [
  43788. "align",
  43789. "archive",
  43790. "border",
  43791. "classid",
  43792. "codebase",
  43793. "codetype",
  43794. "data",
  43795. "declare",
  43796. "form",
  43797. "height",
  43798. "hspace",
  43799. "name",
  43800. "standby",
  43801. "tabindex",
  43802. "type",
  43803. "typemustmatch",
  43804. "usemap",
  43805. "vspace",
  43806. "width"
  43807. ];
  43808. var ol = [
  43809. "compact",
  43810. "reversed",
  43811. "start",
  43812. "type"
  43813. ];
  43814. var optgroup = [
  43815. "disabled",
  43816. "label"
  43817. ];
  43818. var option = [
  43819. "disabled",
  43820. "label",
  43821. "selected",
  43822. "value"
  43823. ];
  43824. var output = [
  43825. "for",
  43826. "form",
  43827. "name"
  43828. ];
  43829. var p = [
  43830. "align"
  43831. ];
  43832. var param = [
  43833. "name",
  43834. "type",
  43835. "value",
  43836. "valuetype"
  43837. ];
  43838. var pre = [
  43839. "width"
  43840. ];
  43841. var progress = [
  43842. "max",
  43843. "value"
  43844. ];
  43845. var q = [
  43846. "cite"
  43847. ];
  43848. var script = [
  43849. "async",
  43850. "charset",
  43851. "crossorigin",
  43852. "defer",
  43853. "integrity",
  43854. "language",
  43855. "nomodule",
  43856. "nonce",
  43857. "referrerpolicy",
  43858. "src",
  43859. "type"
  43860. ];
  43861. var select = [
  43862. "autocomplete",
  43863. "autofocus",
  43864. "disabled",
  43865. "form",
  43866. "multiple",
  43867. "name",
  43868. "required",
  43869. "size",
  43870. "tabindex"
  43871. ];
  43872. var slot = [
  43873. "name"
  43874. ];
  43875. var source = [
  43876. "media",
  43877. "sizes",
  43878. "src",
  43879. "srcset",
  43880. "type"
  43881. ];
  43882. var style = [
  43883. "media",
  43884. "nonce",
  43885. "title",
  43886. "type"
  43887. ];
  43888. var table = [
  43889. "align",
  43890. "bgcolor",
  43891. "border",
  43892. "cellpadding",
  43893. "cellspacing",
  43894. "frame",
  43895. "rules",
  43896. "summary",
  43897. "width"
  43898. ];
  43899. var tbody = [
  43900. "align",
  43901. "char",
  43902. "charoff",
  43903. "valign"
  43904. ];
  43905. var td = [
  43906. "abbr",
  43907. "align",
  43908. "axis",
  43909. "bgcolor",
  43910. "char",
  43911. "charoff",
  43912. "colspan",
  43913. "headers",
  43914. "height",
  43915. "nowrap",
  43916. "rowspan",
  43917. "scope",
  43918. "valign",
  43919. "width"
  43920. ];
  43921. var textarea = [
  43922. "accesskey",
  43923. "autocomplete",
  43924. "autofocus",
  43925. "cols",
  43926. "dirname",
  43927. "disabled",
  43928. "form",
  43929. "maxlength",
  43930. "minlength",
  43931. "name",
  43932. "placeholder",
  43933. "readonly",
  43934. "required",
  43935. "rows",
  43936. "tabindex",
  43937. "wrap"
  43938. ];
  43939. var tfoot = [
  43940. "align",
  43941. "char",
  43942. "charoff",
  43943. "valign"
  43944. ];
  43945. var th = [
  43946. "abbr",
  43947. "align",
  43948. "axis",
  43949. "bgcolor",
  43950. "char",
  43951. "charoff",
  43952. "colspan",
  43953. "headers",
  43954. "height",
  43955. "nowrap",
  43956. "rowspan",
  43957. "scope",
  43958. "valign",
  43959. "width"
  43960. ];
  43961. var thead = [
  43962. "align",
  43963. "char",
  43964. "charoff",
  43965. "valign"
  43966. ];
  43967. var time = [
  43968. "datetime"
  43969. ];
  43970. var tr = [
  43971. "align",
  43972. "bgcolor",
  43973. "char",
  43974. "charoff",
  43975. "valign"
  43976. ];
  43977. var track = [
  43978. "default",
  43979. "kind",
  43980. "label",
  43981. "src",
  43982. "srclang"
  43983. ];
  43984. var ul = [
  43985. "compact",
  43986. "type"
  43987. ];
  43988. var video = [
  43989. "autoplay",
  43990. "controls",
  43991. "crossorigin",
  43992. "height",
  43993. "loop",
  43994. "muted",
  43995. "playsinline",
  43996. "poster",
  43997. "preload",
  43998. "src",
  43999. "width"
  44000. ];
  44001. var htmlElementAttributes = {
  44002. "*": [
  44003. "accesskey",
  44004. "autocapitalize",
  44005. "autofocus",
  44006. "class",
  44007. "contenteditable",
  44008. "dir",
  44009. "draggable",
  44010. "enterkeyhint",
  44011. "hidden",
  44012. "id",
  44013. "inputmode",
  44014. "is",
  44015. "itemid",
  44016. "itemprop",
  44017. "itemref",
  44018. "itemscope",
  44019. "itemtype",
  44020. "lang",
  44021. "nonce",
  44022. "slot",
  44023. "spellcheck",
  44024. "style",
  44025. "tabindex",
  44026. "title",
  44027. "translate"
  44028. ],
  44029. a: a,
  44030. abbr: abbr,
  44031. applet: applet,
  44032. area: area,
  44033. audio: audio,
  44034. base: base,
  44035. basefont: basefont,
  44036. bdo: bdo,
  44037. blockquote: blockquote,
  44038. body: body,
  44039. br: br,
  44040. button: button,
  44041. canvas: canvas,
  44042. caption: caption,
  44043. col: col,
  44044. colgroup: colgroup,
  44045. data: data,
  44046. del: del,
  44047. details: details,
  44048. dfn: dfn,
  44049. dialog: dialog,
  44050. dir: dir,
  44051. div: div,
  44052. dl: dl,
  44053. embed: embed$2,
  44054. fieldset: fieldset,
  44055. font: font,
  44056. form: form,
  44057. frame: frame,
  44058. frameset: frameset,
  44059. h1: h1,
  44060. h2: h2,
  44061. h3: h3,
  44062. h4: h4,
  44063. h5: h5,
  44064. h6: h6,
  44065. head: head,
  44066. hr: hr,
  44067. html: html,
  44068. iframe: iframe,
  44069. img: img,
  44070. input: input,
  44071. ins: ins,
  44072. isindex: isindex,
  44073. label: label,
  44074. legend: legend,
  44075. li: li,
  44076. link: link,
  44077. map: map,
  44078. menu: menu,
  44079. meta: meta,
  44080. meter: meter,
  44081. object: object,
  44082. ol: ol,
  44083. optgroup: optgroup,
  44084. option: option,
  44085. output: output,
  44086. p: p,
  44087. param: param,
  44088. pre: pre,
  44089. progress: progress,
  44090. q: q,
  44091. script: script,
  44092. select: select,
  44093. slot: slot,
  44094. source: source,
  44095. style: style,
  44096. table: table,
  44097. tbody: tbody,
  44098. td: td,
  44099. textarea: textarea,
  44100. tfoot: tfoot,
  44101. th: th,
  44102. thead: thead,
  44103. time: time,
  44104. tr: tr,
  44105. track: track,
  44106. ul: ul,
  44107. video: video
  44108. };
  44109. var require$$2 = {
  44110. "CSS_DISPLAY_TAGS": {
  44111. "area": "none",
  44112. "base": "none",
  44113. "basefont": "none",
  44114. "datalist": "none",
  44115. "head": "none",
  44116. "link": "none",
  44117. "meta": "none",
  44118. "noembed": "none",
  44119. "noframes": "none",
  44120. "param": "block",
  44121. "rp": "none",
  44122. "script": "block",
  44123. "source": "block",
  44124. "style": "none",
  44125. "template": "inline",
  44126. "track": "block",
  44127. "title": "none",
  44128. "html": "block",
  44129. "body": "block",
  44130. "address": "block",
  44131. "blockquote": "block",
  44132. "center": "block",
  44133. "div": "block",
  44134. "figure": "block",
  44135. "figcaption": "block",
  44136. "footer": "block",
  44137. "form": "block",
  44138. "header": "block",
  44139. "hr": "block",
  44140. "legend": "block",
  44141. "listing": "block",
  44142. "main": "block",
  44143. "p": "block",
  44144. "plaintext": "block",
  44145. "pre": "block",
  44146. "xmp": "block",
  44147. "slot": "contents",
  44148. "ruby": "ruby",
  44149. "rt": "ruby-text",
  44150. "article": "block",
  44151. "aside": "block",
  44152. "h1": "block",
  44153. "h2": "block",
  44154. "h3": "block",
  44155. "h4": "block",
  44156. "h5": "block",
  44157. "h6": "block",
  44158. "hgroup": "block",
  44159. "nav": "block",
  44160. "section": "block",
  44161. "dir": "block",
  44162. "dd": "block",
  44163. "dl": "block",
  44164. "dt": "block",
  44165. "ol": "block",
  44166. "ul": "block",
  44167. "li": "list-item",
  44168. "table": "table",
  44169. "caption": "table-caption",
  44170. "colgroup": "table-column-group",
  44171. "col": "table-column",
  44172. "thead": "table-header-group",
  44173. "tbody": "table-row-group",
  44174. "tfoot": "table-footer-group",
  44175. "tr": "table-row",
  44176. "td": "table-cell",
  44177. "th": "table-cell",
  44178. "fieldset": "block",
  44179. "button": "inline-block",
  44180. "details": "block",
  44181. "summary": "block",
  44182. "dialog": "block",
  44183. "meter": "inline-block",
  44184. "progress": "inline-block",
  44185. "object": "inline-block",
  44186. "video": "inline-block",
  44187. "audio": "inline-block",
  44188. "select": "inline-block",
  44189. "option": "block",
  44190. "optgroup": "block"
  44191. },
  44192. "CSS_DISPLAY_DEFAULT": "inline",
  44193. "CSS_WHITE_SPACE_TAGS": {
  44194. "listing": "pre",
  44195. "plaintext": "pre",
  44196. "pre": "pre",
  44197. "xmp": "pre",
  44198. "nobr": "nowrap",
  44199. "table": "initial",
  44200. "textarea": "pre-wrap"
  44201. },
  44202. "CSS_WHITE_SPACE_DEFAULT": "normal"
  44203. };
  44204. /**
  44205. * @typedef {import("../common/ast-path")} AstPath
  44206. */
  44207. const {
  44208. inferParserByLanguage,
  44209. isFrontMatterNode
  44210. } = util$5;
  44211. const {
  44212. builders: {
  44213. line: line$9,
  44214. hardline: hardline$7,
  44215. join: join$6
  44216. },
  44217. utils: {
  44218. getDocParts: getDocParts$3,
  44219. replaceTextEndOfLine: replaceTextEndOfLine$6
  44220. }
  44221. } = doc;
  44222. const {
  44223. CSS_DISPLAY_TAGS,
  44224. CSS_DISPLAY_DEFAULT,
  44225. CSS_WHITE_SPACE_TAGS,
  44226. CSS_WHITE_SPACE_DEFAULT
  44227. } = require$$2;
  44228. const HTML_TAGS = arrayToMap(htmlTagNames);
  44229. const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes, arrayToMap); // https://infra.spec.whatwg.org/#ascii-whitespace
  44230. const HTML_WHITESPACE = new Set(["\t", "\n", "\f", "\r", " "]);
  44231. const htmlTrimStart = string => string.replace(/^[\t\n\f\r ]+/, "");
  44232. const htmlTrimEnd = string => string.replace(/[\t\n\f\r ]+$/, "");
  44233. const htmlTrim$1 = string => htmlTrimStart(htmlTrimEnd(string));
  44234. const htmlTrimLeadingBlankLines = string => string.replace(/^[\t\f\r ]*?\n/g, "");
  44235. const htmlTrimPreserveIndentation$1 = string => htmlTrimLeadingBlankLines(htmlTrimEnd(string));
  44236. const splitByHtmlWhitespace = string => string.split(/[\t\n\f\r ]+/);
  44237. const getLeadingHtmlWhitespace = string => string.match(/^[\t\n\f\r ]*/)[0];
  44238. const getLeadingAndTrailingHtmlWhitespace$1 = string => {
  44239. const [, leadingWhitespace, text, trailingWhitespace] = string.match(/^([\t\n\f\r ]*)(.*?)([\t\n\f\r ]*)$/s);
  44240. return {
  44241. leadingWhitespace,
  44242. trailingWhitespace,
  44243. text
  44244. };
  44245. };
  44246. const hasHtmlWhitespace$1 = string => /[\t\n\f\r ]/.test(string);
  44247. function arrayToMap(array) {
  44248. const map = Object.create(null);
  44249. for (const value of array) {
  44250. map[value] = true;
  44251. }
  44252. return map;
  44253. }
  44254. function mapObject(object, fn) {
  44255. const newObject = Object.create(null);
  44256. for (const [key, value] of Object.entries(object)) {
  44257. newObject[key] = fn(value, key);
  44258. }
  44259. return newObject;
  44260. }
  44261. function shouldPreserveContent$2(node, options) {
  44262. // unterminated node in ie conditional comment
  44263. // e.g. <!--[if lt IE 9]><html><![endif]-->
  44264. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  44265. return true;
  44266. } // incomplete html in ie conditional comment
  44267. // e.g. <!--[if lt IE 9]></div><![endif]-->
  44268. if (node.type === "ieConditionalComment" && !node.complete) {
  44269. return true;
  44270. } // TODO: handle non-text children in <pre>
  44271. if (isPreLikeNode$1(node) && node.children.some(child => child.type !== "text" && child.type !== "interpolation")) {
  44272. return true;
  44273. }
  44274. if (isVueNonHtmlBlock$1(node, options) && !isScriptLikeTag$2(node) && node.type !== "interpolation") {
  44275. return true;
  44276. }
  44277. return false;
  44278. }
  44279. function hasPrettierIgnore$4(node) {
  44280. /* istanbul ignore next */
  44281. if (node.type === "attribute") {
  44282. return false;
  44283. }
  44284. /* istanbul ignore next */
  44285. if (!node.parent) {
  44286. return false;
  44287. }
  44288. if (typeof node.index !== "number" || node.index === 0) {
  44289. return false;
  44290. }
  44291. const prevNode = node.parent.children[node.index - 1];
  44292. return isPrettierIgnore$1(prevNode);
  44293. }
  44294. function isPrettierIgnore$1(node) {
  44295. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  44296. }
  44297. /** there's no opening/closing tag or it's considered not breakable */
  44298. function isTextLikeNode$2(node) {
  44299. return node.type === "text" || node.type === "comment";
  44300. }
  44301. function isScriptLikeTag$2(node) {
  44302. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style" || isUnknownNamespace(node) && (node.name === "script" || node.name === "style"));
  44303. }
  44304. function canHaveInterpolation$1(node) {
  44305. return node.children && !isScriptLikeTag$2(node);
  44306. }
  44307. function isWhitespaceSensitiveNode$1(node) {
  44308. return isScriptLikeTag$2(node) || node.type === "interpolation" || isIndentationSensitiveNode$1(node);
  44309. }
  44310. function isIndentationSensitiveNode$1(node) {
  44311. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  44312. }
  44313. function isLeadingSpaceSensitiveNode$1(node, options) {
  44314. const isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  44315. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  44316. return node.type === "interpolation";
  44317. }
  44318. return isLeadingSpaceSensitive;
  44319. function _isLeadingSpaceSensitiveNode() {
  44320. if (isFrontMatterNode(node)) {
  44321. return false;
  44322. }
  44323. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  44324. return true;
  44325. }
  44326. if (!node.parent || node.parent.cssDisplay === "none") {
  44327. return false;
  44328. }
  44329. if (isPreLikeNode$1(node.parent)) {
  44330. return true;
  44331. }
  44332. if (!node.prev && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  44333. return false;
  44334. }
  44335. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  44336. return false;
  44337. }
  44338. return true;
  44339. }
  44340. }
  44341. function isTrailingSpaceSensitiveNode$1(node, options) {
  44342. if (isFrontMatterNode(node)) {
  44343. return false;
  44344. }
  44345. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  44346. return true;
  44347. }
  44348. if (!node.parent || node.parent.cssDisplay === "none") {
  44349. return false;
  44350. }
  44351. if (isPreLikeNode$1(node.parent)) {
  44352. return true;
  44353. }
  44354. if (!node.next && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  44355. return false;
  44356. }
  44357. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  44358. return false;
  44359. }
  44360. return true;
  44361. }
  44362. function isDanglingSpaceSensitiveNode$1(node) {
  44363. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$2(node);
  44364. }
  44365. function forceNextEmptyLine$1(node) {
  44366. return isFrontMatterNode(node) || node.next && node.sourceSpan.end && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  44367. }
  44368. /** firstChild leadingSpaces and lastChild trailingSpaces */
  44369. function forceBreakContent$1(node) {
  44370. return forceBreakChildren$1(node) || node.type === "element" && node.children.length > 0 && (["body", "script", "style"].includes(node.name) || node.children.some(child => hasNonTextChild(child))) || node.firstChild && node.firstChild === node.lastChild && node.firstChild.type !== "text" && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  44371. }
  44372. /** spaces between children */
  44373. function forceBreakChildren$1(node) {
  44374. return node.type === "element" && node.children.length > 0 && (["html", "head", "ul", "ol", "select"].includes(node.name) || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
  44375. }
  44376. function preferHardlineAsLeadingSpaces$1(node) {
  44377. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  44378. }
  44379. function preferHardlineAsTrailingSpaces(node) {
  44380. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  44381. }
  44382. function hasSurroundingLineBreak(node) {
  44383. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  44384. }
  44385. function hasLeadingLineBreak(node) {
  44386. return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line);
  44387. }
  44388. function hasTrailingLineBreak(node) {
  44389. return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan && node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
  44390. }
  44391. function preferHardlineAsSurroundingSpaces(node) {
  44392. switch (node.type) {
  44393. case "ieConditionalComment":
  44394. case "comment":
  44395. case "directive":
  44396. return true;
  44397. case "element":
  44398. return ["script", "select"].includes(node.name);
  44399. }
  44400. return false;
  44401. }
  44402. function getLastDescendant$1(node) {
  44403. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  44404. }
  44405. function hasNonTextChild(node) {
  44406. return node.children && node.children.some(child => child.type !== "text");
  44407. }
  44408. function _inferScriptParser(node) {
  44409. const {
  44410. type,
  44411. lang
  44412. } = node.attrMap;
  44413. if (type === "module" || type === "text/javascript" || type === "text/babel" || type === "application/javascript" || lang === "jsx") {
  44414. return "babel";
  44415. }
  44416. if (type === "application/x-typescript" || lang === "ts" || lang === "tsx") {
  44417. return "typescript";
  44418. }
  44419. if (type === "text/markdown") {
  44420. return "markdown";
  44421. }
  44422. if (type === "text/html") {
  44423. return "html";
  44424. }
  44425. if (type && (type.endsWith("json") || type.endsWith("importmap"))) {
  44426. return "json";
  44427. }
  44428. if (type === "text/x-handlebars-template") {
  44429. return "glimmer";
  44430. }
  44431. }
  44432. function inferStyleParser(node) {
  44433. const {
  44434. lang
  44435. } = node.attrMap;
  44436. if (!lang || lang === "postcss" || lang === "css") {
  44437. return "css";
  44438. }
  44439. if (lang === "scss") {
  44440. return "scss";
  44441. }
  44442. if (lang === "less") {
  44443. return "less";
  44444. }
  44445. }
  44446. function inferScriptParser$1(node, options) {
  44447. if (node.name === "script" && !node.attrMap.src) {
  44448. if (!node.attrMap.lang && !node.attrMap.type) {
  44449. return "babel";
  44450. }
  44451. return _inferScriptParser(node);
  44452. }
  44453. if (node.name === "style") {
  44454. return inferStyleParser(node);
  44455. }
  44456. if (options && isVueNonHtmlBlock$1(node, options)) {
  44457. return _inferScriptParser(node) || !("src" in node.attrMap) && inferParserByLanguage(node.attrMap.lang, options);
  44458. }
  44459. }
  44460. function isBlockLikeCssDisplay(cssDisplay) {
  44461. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  44462. }
  44463. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  44464. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  44465. }
  44466. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  44467. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  44468. }
  44469. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  44470. return !isBlockLikeCssDisplay(cssDisplay);
  44471. }
  44472. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  44473. return !isBlockLikeCssDisplay(cssDisplay);
  44474. }
  44475. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  44476. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  44477. }
  44478. function isPreLikeNode$1(node) {
  44479. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  44480. }
  44481. /**
  44482. * @param {AstPath} path
  44483. * @param {(any) => boolean} predicate
  44484. */
  44485. function countParents$1(path, predicate) {
  44486. let counter = 0;
  44487. for (let i = path.stack.length - 1; i >= 0; i--) {
  44488. const value = path.stack[i];
  44489. if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
  44490. counter++;
  44491. }
  44492. }
  44493. return counter;
  44494. }
  44495. function hasParent(node, fn) {
  44496. let current = node;
  44497. while (current) {
  44498. if (fn(current)) {
  44499. return true;
  44500. }
  44501. current = current.parent;
  44502. }
  44503. return false;
  44504. }
  44505. function getNodeCssStyleDisplay$1(node, options) {
  44506. if (node.prev && node.prev.type === "comment") {
  44507. // <!-- display: block -->
  44508. const match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  44509. if (match) {
  44510. return match[1];
  44511. }
  44512. }
  44513. let isInSvgForeignObject = false;
  44514. if (node.type === "element" && node.namespace === "svg") {
  44515. if (hasParent(node, parent => parent.fullName === "svg:foreignObject")) {
  44516. isInSvgForeignObject = true;
  44517. } else {
  44518. return node.name === "svg" ? "inline-block" : "block";
  44519. }
  44520. }
  44521. switch (options.htmlWhitespaceSensitivity) {
  44522. case "strict":
  44523. return "inline";
  44524. case "ignore":
  44525. return "block";
  44526. default:
  44527. {
  44528. // See https://github.com/prettier/prettier/issues/8151
  44529. if (options.parser === "vue" && node.parent && node.parent.type === "root") {
  44530. return "block";
  44531. }
  44532. return node.type === "element" && (!node.namespace || isInSvgForeignObject || isUnknownNamespace(node)) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  44533. }
  44534. }
  44535. }
  44536. function isUnknownNamespace(node) {
  44537. return node.type === "element" && !node.hasExplicitNamespace && !["html", "svg"].includes(node.namespace);
  44538. }
  44539. function getNodeCssStyleWhiteSpace(node) {
  44540. return node.type === "element" && (!node.namespace || isUnknownNamespace(node)) && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  44541. }
  44542. function getMinIndentation(text) {
  44543. let minIndentation = Number.POSITIVE_INFINITY;
  44544. for (const lineText of text.split("\n")) {
  44545. if (lineText.length === 0) {
  44546. continue;
  44547. }
  44548. if (!HTML_WHITESPACE.has(lineText[0])) {
  44549. return 0;
  44550. }
  44551. const indentation = getLeadingHtmlWhitespace(lineText).length;
  44552. if (lineText.length === indentation) {
  44553. continue;
  44554. }
  44555. if (indentation < minIndentation) {
  44556. minIndentation = indentation;
  44557. }
  44558. }
  44559. return minIndentation === Number.POSITIVE_INFINITY ? 0 : minIndentation;
  44560. }
  44561. function dedentString$1(text, minIndent = getMinIndentation(text)) {
  44562. return minIndent === 0 ? text : text.split("\n").map(lineText => lineText.slice(minIndent)).join("\n");
  44563. }
  44564. function countChars$1(text, char) {
  44565. let counter = 0;
  44566. for (let i = 0; i < text.length; i++) {
  44567. if (text[i] === char) {
  44568. counter++;
  44569. }
  44570. }
  44571. return counter;
  44572. }
  44573. function unescapeQuoteEntities$2(text) {
  44574. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  44575. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  44576. // See https://vue-loader.vuejs.org/spec.html for detail
  44577. const vueRootElementsSet = new Set(["template", "style", "script"]);
  44578. function isVueCustomBlock$1(node, options) {
  44579. return isVueSfcBlock(node, options) && !vueRootElementsSet.has(node.fullName);
  44580. }
  44581. function isVueSfcBlock(node, options) {
  44582. return options.parser === "vue" && node.type === "element" && node.parent.type === "root" && node.fullName.toLowerCase() !== "html";
  44583. }
  44584. function isVueNonHtmlBlock$1(node, options) {
  44585. return isVueSfcBlock(node, options) && (isVueCustomBlock$1(node, options) || node.attrMap.lang && node.attrMap.lang !== "html");
  44586. }
  44587. function isVueSlotAttribute$1(attribute) {
  44588. const attributeName = attribute.fullName;
  44589. return attributeName.charAt(0) === "#" || attributeName === "slot-scope" || attributeName === "v-slot" || attributeName.startsWith("v-slot:");
  44590. }
  44591. function isVueSfcBindingsAttribute$1(attribute, options) {
  44592. const element = attribute.parent;
  44593. if (!isVueSfcBlock(element, options)) {
  44594. return false;
  44595. }
  44596. const tagName = element.fullName;
  44597. const attributeName = attribute.fullName;
  44598. return (// https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md
  44599. tagName === "script" && attributeName === "setup" || tagName === "style" && attributeName === "vars"
  44600. );
  44601. }
  44602. function getTextValueParts$2(node, value = node.value) {
  44603. return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceTextEndOfLine$6(value) : replaceTextEndOfLine$6(dedentString$1(htmlTrimPreserveIndentation$1(value)), hardline$7) : getDocParts$3(join$6(line$9, splitByHtmlWhitespace(value)));
  44604. }
  44605. var utils$1 = {
  44606. HTML_ELEMENT_ATTRIBUTES,
  44607. HTML_TAGS,
  44608. htmlTrim: htmlTrim$1,
  44609. htmlTrimPreserveIndentation: htmlTrimPreserveIndentation$1,
  44610. hasHtmlWhitespace: hasHtmlWhitespace$1,
  44611. getLeadingAndTrailingHtmlWhitespace: getLeadingAndTrailingHtmlWhitespace$1,
  44612. canHaveInterpolation: canHaveInterpolation$1,
  44613. countChars: countChars$1,
  44614. countParents: countParents$1,
  44615. dedentString: dedentString$1,
  44616. forceBreakChildren: forceBreakChildren$1,
  44617. forceBreakContent: forceBreakContent$1,
  44618. forceNextEmptyLine: forceNextEmptyLine$1,
  44619. getLastDescendant: getLastDescendant$1,
  44620. getNodeCssStyleDisplay: getNodeCssStyleDisplay$1,
  44621. getNodeCssStyleWhiteSpace,
  44622. hasPrettierIgnore: hasPrettierIgnore$4,
  44623. inferScriptParser: inferScriptParser$1,
  44624. isVueCustomBlock: isVueCustomBlock$1,
  44625. isVueNonHtmlBlock: isVueNonHtmlBlock$1,
  44626. isVueSlotAttribute: isVueSlotAttribute$1,
  44627. isVueSfcBindingsAttribute: isVueSfcBindingsAttribute$1,
  44628. isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode$1,
  44629. isIndentationSensitiveNode: isIndentationSensitiveNode$1,
  44630. isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode$1,
  44631. isPreLikeNode: isPreLikeNode$1,
  44632. isScriptLikeTag: isScriptLikeTag$2,
  44633. isTextLikeNode: isTextLikeNode$2,
  44634. isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode$1,
  44635. isWhitespaceSensitiveNode: isWhitespaceSensitiveNode$1,
  44636. isUnknownNamespace,
  44637. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  44638. preferHardlineAsTrailingSpaces,
  44639. shouldPreserveContent: shouldPreserveContent$2,
  44640. unescapeQuoteEntities: unescapeQuoteEntities$2,
  44641. getTextValueParts: getTextValueParts$2
  44642. };
  44643. var chars = createCommonjsModule(function (module, exports) {
  44644. /**
  44645. * @license
  44646. * Copyright Google Inc. All Rights Reserved.
  44647. *
  44648. * Use of this source code is governed by an MIT-style license that can be
  44649. * found in the LICENSE file at https://angular.io/license
  44650. */
  44651. Object.defineProperty(exports, "__esModule", {
  44652. value: true
  44653. });
  44654. exports.$EOF = 0;
  44655. exports.$BSPACE = 8;
  44656. exports.$TAB = 9;
  44657. exports.$LF = 10;
  44658. exports.$VTAB = 11;
  44659. exports.$FF = 12;
  44660. exports.$CR = 13;
  44661. exports.$SPACE = 32;
  44662. exports.$BANG = 33;
  44663. exports.$DQ = 34;
  44664. exports.$HASH = 35;
  44665. exports.$$ = 36;
  44666. exports.$PERCENT = 37;
  44667. exports.$AMPERSAND = 38;
  44668. exports.$SQ = 39;
  44669. exports.$LPAREN = 40;
  44670. exports.$RPAREN = 41;
  44671. exports.$STAR = 42;
  44672. exports.$PLUS = 43;
  44673. exports.$COMMA = 44;
  44674. exports.$MINUS = 45;
  44675. exports.$PERIOD = 46;
  44676. exports.$SLASH = 47;
  44677. exports.$COLON = 58;
  44678. exports.$SEMICOLON = 59;
  44679. exports.$LT = 60;
  44680. exports.$EQ = 61;
  44681. exports.$GT = 62;
  44682. exports.$QUESTION = 63;
  44683. exports.$0 = 48;
  44684. exports.$7 = 55;
  44685. exports.$9 = 57;
  44686. exports.$A = 65;
  44687. exports.$E = 69;
  44688. exports.$F = 70;
  44689. exports.$X = 88;
  44690. exports.$Z = 90;
  44691. exports.$LBRACKET = 91;
  44692. exports.$BACKSLASH = 92;
  44693. exports.$RBRACKET = 93;
  44694. exports.$CARET = 94;
  44695. exports.$_ = 95;
  44696. exports.$a = 97;
  44697. exports.$b = 98;
  44698. exports.$e = 101;
  44699. exports.$f = 102;
  44700. exports.$n = 110;
  44701. exports.$r = 114;
  44702. exports.$t = 116;
  44703. exports.$u = 117;
  44704. exports.$v = 118;
  44705. exports.$x = 120;
  44706. exports.$z = 122;
  44707. exports.$LBRACE = 123;
  44708. exports.$BAR = 124;
  44709. exports.$RBRACE = 125;
  44710. exports.$NBSP = 160;
  44711. exports.$PIPE = 124;
  44712. exports.$TILDA = 126;
  44713. exports.$AT = 64;
  44714. exports.$BT = 96;
  44715. function isWhitespace(code) {
  44716. return code >= exports.$TAB && code <= exports.$SPACE || code == exports.$NBSP;
  44717. }
  44718. exports.isWhitespace = isWhitespace;
  44719. function isDigit(code) {
  44720. return exports.$0 <= code && code <= exports.$9;
  44721. }
  44722. exports.isDigit = isDigit;
  44723. function isAsciiLetter(code) {
  44724. return code >= exports.$a && code <= exports.$z || code >= exports.$A && code <= exports.$Z;
  44725. }
  44726. exports.isAsciiLetter = isAsciiLetter;
  44727. function isAsciiHexDigit(code) {
  44728. return code >= exports.$a && code <= exports.$f || code >= exports.$A && code <= exports.$F || isDigit(code);
  44729. }
  44730. exports.isAsciiHexDigit = isAsciiHexDigit;
  44731. function isNewLine(code) {
  44732. return code === exports.$LF || code === exports.$CR;
  44733. }
  44734. exports.isNewLine = isNewLine;
  44735. function isOctalDigit(code) {
  44736. return exports.$0 <= code && code <= exports.$7;
  44737. }
  44738. exports.isOctalDigit = isOctalDigit;
  44739. });
  44740. /**
  44741. * @license
  44742. * Copyright Google Inc. All Rights Reserved.
  44743. *
  44744. * Use of this source code is governed by an MIT-style license that can be
  44745. * found in the LICENSE file at https://angular.io/license
  44746. */
  44747. /**
  44748. * A token representing the a reference to a static type.
  44749. *
  44750. * This token is unique for a filePath and name and can be used as a hash table key.
  44751. */
  44752. class StaticSymbol {
  44753. constructor(filePath, name, members) {
  44754. this.filePath = filePath;
  44755. this.name = name;
  44756. this.members = members;
  44757. }
  44758. assertNoMembers() {
  44759. if (this.members.length) {
  44760. throw new Error(`Illegal state: symbol without members expected, but got ${JSON.stringify(this)}.`);
  44761. }
  44762. }
  44763. }
  44764. var StaticSymbol_1 = StaticSymbol;
  44765. /**
  44766. * A cache of static symbol used by the StaticReflector to return the same symbol for the
  44767. * same symbol values.
  44768. */
  44769. class StaticSymbolCache {
  44770. constructor() {
  44771. this.cache = new Map();
  44772. }
  44773. get(declarationFile, name, members) {
  44774. members = members || [];
  44775. const memberSuffix = members.length ? `.${members.join('.')}` : '';
  44776. const key = `"${declarationFile}".${name}${memberSuffix}`;
  44777. let result = this.cache.get(key);
  44778. if (!result) {
  44779. result = new StaticSymbol(declarationFile, name, members);
  44780. this.cache.set(key, result);
  44781. }
  44782. return result;
  44783. }
  44784. }
  44785. var StaticSymbolCache_1 = StaticSymbolCache;
  44786. var static_symbol = /*#__PURE__*/Object.defineProperty({
  44787. StaticSymbol: StaticSymbol_1,
  44788. StaticSymbolCache: StaticSymbolCache_1
  44789. }, '__esModule', {
  44790. value: true
  44791. });
  44792. /**
  44793. * @license
  44794. * Copyright Google Inc. All Rights Reserved.
  44795. *
  44796. * Use of this source code is governed by an MIT-style license that can be
  44797. * found in the LICENSE file at https://angular.io/license
  44798. */
  44799. const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  44800. function dashCaseToCamelCase(input) {
  44801. return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
  44802. }
  44803. var dashCaseToCamelCase_1 = dashCaseToCamelCase;
  44804. function splitAtColon(input, defaultValues) {
  44805. return _splitAt(input, ':', defaultValues);
  44806. }
  44807. var splitAtColon_1 = splitAtColon;
  44808. function splitAtPeriod(input, defaultValues) {
  44809. return _splitAt(input, '.', defaultValues);
  44810. }
  44811. var splitAtPeriod_1 = splitAtPeriod;
  44812. function _splitAt(input, character, defaultValues) {
  44813. const characterIndex = input.indexOf(character);
  44814. if (characterIndex == -1) return defaultValues;
  44815. return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
  44816. }
  44817. function visitValue(value, visitor, context) {
  44818. if (Array.isArray(value)) {
  44819. return visitor.visitArray(value, context);
  44820. }
  44821. if (isStrictStringMap(value)) {
  44822. return visitor.visitStringMap(value, context);
  44823. }
  44824. if (value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') {
  44825. return visitor.visitPrimitive(value, context);
  44826. }
  44827. return visitor.visitOther(value, context);
  44828. }
  44829. var visitValue_1 = visitValue;
  44830. function isDefined(val) {
  44831. return val !== null && val !== undefined;
  44832. }
  44833. var isDefined_1 = isDefined;
  44834. function noUndefined(val) {
  44835. return val === undefined ? null : val;
  44836. }
  44837. var noUndefined_1 = noUndefined;
  44838. class ValueTransformer {
  44839. visitArray(arr, context) {
  44840. return arr.map(value => visitValue(value, this, context));
  44841. }
  44842. visitStringMap(map, context) {
  44843. const result = {};
  44844. Object.keys(map).forEach(key => {
  44845. result[key] = visitValue(map[key], this, context);
  44846. });
  44847. return result;
  44848. }
  44849. visitPrimitive(value, context) {
  44850. return value;
  44851. }
  44852. visitOther(value, context) {
  44853. return value;
  44854. }
  44855. }
  44856. var ValueTransformer_1 = ValueTransformer;
  44857. var SyncAsync = {
  44858. assertSync: value => {
  44859. if (isPromise(value)) {
  44860. throw new Error(`Illegal state: value cannot be a promise`);
  44861. }
  44862. return value;
  44863. },
  44864. then: (value, cb) => {
  44865. return isPromise(value) ? value.then(cb) : cb(value);
  44866. },
  44867. all: syncAsyncValues => {
  44868. return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : syncAsyncValues;
  44869. }
  44870. };
  44871. function error(msg) {
  44872. throw new Error(`Internal Error: ${msg}`);
  44873. }
  44874. var error_1 = error;
  44875. function syntaxError(msg, parseErrors) {
  44876. const error = Error(msg);
  44877. error[ERROR_SYNTAX_ERROR] = true;
  44878. if (parseErrors) error[ERROR_PARSE_ERRORS] = parseErrors;
  44879. return error;
  44880. }
  44881. var syntaxError_1 = syntaxError;
  44882. const ERROR_SYNTAX_ERROR = 'ngSyntaxError';
  44883. const ERROR_PARSE_ERRORS = 'ngParseErrors';
  44884. function isSyntaxError(error) {
  44885. return error[ERROR_SYNTAX_ERROR];
  44886. }
  44887. var isSyntaxError_1 = isSyntaxError;
  44888. function getParseErrors(error) {
  44889. return error[ERROR_PARSE_ERRORS] || [];
  44890. }
  44891. var getParseErrors_1 = getParseErrors; // Escape characters that have a special meaning in Regular Expressions
  44892. function escapeRegExp(s) {
  44893. return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  44894. }
  44895. var escapeRegExp_1 = escapeRegExp;
  44896. const STRING_MAP_PROTO = Object.getPrototypeOf({});
  44897. function isStrictStringMap(obj) {
  44898. return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
  44899. }
  44900. function utf8Encode(str) {
  44901. let encoded = '';
  44902. for (let index = 0; index < str.length; index++) {
  44903. let codePoint = str.charCodeAt(index); // decode surrogate
  44904. // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  44905. if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > index + 1) {
  44906. const low = str.charCodeAt(index + 1);
  44907. if (low >= 0xdc00 && low <= 0xdfff) {
  44908. index++;
  44909. codePoint = (codePoint - 0xd800 << 10) + low - 0xdc00 + 0x10000;
  44910. }
  44911. }
  44912. if (codePoint <= 0x7f) {
  44913. encoded += String.fromCharCode(codePoint);
  44914. } else if (codePoint <= 0x7ff) {
  44915. encoded += String.fromCharCode(codePoint >> 6 & 0x1F | 0xc0, codePoint & 0x3f | 0x80);
  44916. } else if (codePoint <= 0xffff) {
  44917. encoded += String.fromCharCode(codePoint >> 12 | 0xe0, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
  44918. } else if (codePoint <= 0x1fffff) {
  44919. encoded += String.fromCharCode(codePoint >> 18 & 0x07 | 0xf0, codePoint >> 12 & 0x3f | 0x80, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
  44920. }
  44921. }
  44922. return encoded;
  44923. }
  44924. var utf8Encode_1 = utf8Encode;
  44925. function stringify(token) {
  44926. if (typeof token === 'string') {
  44927. return token;
  44928. }
  44929. if (token instanceof Array) {
  44930. return '[' + token.map(stringify).join(', ') + ']';
  44931. }
  44932. if (token == null) {
  44933. return '' + token;
  44934. }
  44935. if (token.overriddenName) {
  44936. return `${token.overriddenName}`;
  44937. }
  44938. if (token.name) {
  44939. return `${token.name}`;
  44940. }
  44941. if (!token.toString) {
  44942. return 'object';
  44943. } // WARNING: do not try to `JSON.stringify(token)` here
  44944. // see https://github.com/angular/angular/issues/23440
  44945. const res = token.toString();
  44946. if (res == null) {
  44947. return '' + res;
  44948. }
  44949. const newLineIndex = res.indexOf('\n');
  44950. return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
  44951. }
  44952. var stringify_1 = stringify;
  44953. /**
  44954. * Lazily retrieves the reference value from a forwardRef.
  44955. */
  44956. function resolveForwardRef(type) {
  44957. if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
  44958. return type();
  44959. } else {
  44960. return type;
  44961. }
  44962. }
  44963. var resolveForwardRef_1 = resolveForwardRef;
  44964. /**
  44965. * Determine if the argument is shaped like a Promise
  44966. */
  44967. function isPromise(obj) {
  44968. // allow any Promise/A+ compliant thenable.
  44969. // It's up to the caller to ensure that obj.then conforms to the spec
  44970. return !!obj && typeof obj.then === 'function';
  44971. }
  44972. var isPromise_1 = isPromise;
  44973. class Version {
  44974. constructor(full) {
  44975. this.full = full;
  44976. const splits = full.split('.');
  44977. this.major = splits[0];
  44978. this.minor = splits[1];
  44979. this.patch = splits.slice(2).join('.');
  44980. }
  44981. }
  44982. var Version_1 = Version;
  44983. const __window = typeof window !== 'undefined' && window;
  44984. const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self;
  44985. const __global = typeof global$1 !== 'undefined' && global$1; // Check __global first, because in Node tests both __global and __window may be defined and _global
  44986. // should be __global in that case.
  44987. const _global = __global || __window || __self;
  44988. var global$1 = _global;
  44989. var util = /*#__PURE__*/Object.defineProperty({
  44990. dashCaseToCamelCase: dashCaseToCamelCase_1,
  44991. splitAtColon: splitAtColon_1,
  44992. splitAtPeriod: splitAtPeriod_1,
  44993. visitValue: visitValue_1,
  44994. isDefined: isDefined_1,
  44995. noUndefined: noUndefined_1,
  44996. ValueTransformer: ValueTransformer_1,
  44997. SyncAsync: SyncAsync,
  44998. error: error_1,
  44999. syntaxError: syntaxError_1,
  45000. isSyntaxError: isSyntaxError_1,
  45001. getParseErrors: getParseErrors_1,
  45002. escapeRegExp: escapeRegExp_1,
  45003. utf8Encode: utf8Encode_1,
  45004. stringify: stringify_1,
  45005. resolveForwardRef: resolveForwardRef_1,
  45006. isPromise: isPromise_1,
  45007. Version: Version_1,
  45008. global: global$1
  45009. }, '__esModule', {
  45010. value: true
  45011. });
  45012. var compile_metadata = createCommonjsModule(function (module, exports) {
  45013. /**
  45014. * @license
  45015. * Copyright Google Inc. All Rights Reserved.
  45016. *
  45017. * Use of this source code is governed by an MIT-style license that can be
  45018. * found in the LICENSE file at https://angular.io/license
  45019. */
  45020. Object.defineProperty(exports, "__esModule", {
  45021. value: true
  45022. }); // group 0: "[prop] or (event) or @trigger"
  45023. // group 1: "prop" from "[prop]"
  45024. // group 2: "event" from "(event)"
  45025. // group 3: "@trigger" from "@trigger"
  45026. const HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
  45027. function sanitizeIdentifier(name) {
  45028. return name.replace(/\W/g, '_');
  45029. }
  45030. exports.sanitizeIdentifier = sanitizeIdentifier;
  45031. let _anonymousTypeIndex = 0;
  45032. function identifierName(compileIdentifier) {
  45033. if (!compileIdentifier || !compileIdentifier.reference) {
  45034. return null;
  45035. }
  45036. const ref = compileIdentifier.reference;
  45037. if (ref instanceof static_symbol.StaticSymbol) {
  45038. return ref.name;
  45039. }
  45040. if (ref['__anonymousType']) {
  45041. return ref['__anonymousType'];
  45042. }
  45043. let identifier = util.stringify(ref);
  45044. if (identifier.indexOf('(') >= 0) {
  45045. // case: anonymous functions!
  45046. identifier = `anonymous_${_anonymousTypeIndex++}`;
  45047. ref['__anonymousType'] = identifier;
  45048. } else {
  45049. identifier = sanitizeIdentifier(identifier);
  45050. }
  45051. return identifier;
  45052. }
  45053. exports.identifierName = identifierName;
  45054. function identifierModuleUrl(compileIdentifier) {
  45055. const ref = compileIdentifier.reference;
  45056. if (ref instanceof static_symbol.StaticSymbol) {
  45057. return ref.filePath;
  45058. } // Runtime type
  45059. return `./${util.stringify(ref)}`;
  45060. }
  45061. exports.identifierModuleUrl = identifierModuleUrl;
  45062. function viewClassName(compType, embeddedTemplateIndex) {
  45063. return `View_${identifierName({
  45064. reference: compType
  45065. })}_${embeddedTemplateIndex}`;
  45066. }
  45067. exports.viewClassName = viewClassName;
  45068. function rendererTypeName(compType) {
  45069. return `RenderType_${identifierName({
  45070. reference: compType
  45071. })}`;
  45072. }
  45073. exports.rendererTypeName = rendererTypeName;
  45074. function hostViewClassName(compType) {
  45075. return `HostView_${identifierName({
  45076. reference: compType
  45077. })}`;
  45078. }
  45079. exports.hostViewClassName = hostViewClassName;
  45080. function componentFactoryName(compType) {
  45081. return `${identifierName({
  45082. reference: compType
  45083. })}NgFactory`;
  45084. }
  45085. exports.componentFactoryName = componentFactoryName;
  45086. var CompileSummaryKind;
  45087. (function (CompileSummaryKind) {
  45088. CompileSummaryKind[CompileSummaryKind["Pipe"] = 0] = "Pipe";
  45089. CompileSummaryKind[CompileSummaryKind["Directive"] = 1] = "Directive";
  45090. CompileSummaryKind[CompileSummaryKind["NgModule"] = 2] = "NgModule";
  45091. CompileSummaryKind[CompileSummaryKind["Injectable"] = 3] = "Injectable";
  45092. })(CompileSummaryKind = exports.CompileSummaryKind || (exports.CompileSummaryKind = {}));
  45093. function tokenName(token) {
  45094. return token.value != null ? sanitizeIdentifier(token.value) : identifierName(token.identifier);
  45095. }
  45096. exports.tokenName = tokenName;
  45097. function tokenReference(token) {
  45098. if (token.identifier != null) {
  45099. return token.identifier.reference;
  45100. } else {
  45101. return token.value;
  45102. }
  45103. }
  45104. exports.tokenReference = tokenReference;
  45105. /**
  45106. * Metadata about a stylesheet
  45107. */
  45108. class CompileStylesheetMetadata {
  45109. constructor({
  45110. moduleUrl,
  45111. styles,
  45112. styleUrls
  45113. } = {}) {
  45114. this.moduleUrl = moduleUrl || null;
  45115. this.styles = _normalizeArray(styles);
  45116. this.styleUrls = _normalizeArray(styleUrls);
  45117. }
  45118. }
  45119. exports.CompileStylesheetMetadata = CompileStylesheetMetadata;
  45120. /**
  45121. * Metadata regarding compilation of a template.
  45122. */
  45123. class CompileTemplateMetadata {
  45124. constructor({
  45125. encapsulation,
  45126. template,
  45127. templateUrl,
  45128. htmlAst,
  45129. styles,
  45130. styleUrls,
  45131. externalStylesheets,
  45132. animations,
  45133. ngContentSelectors,
  45134. interpolation,
  45135. isInline,
  45136. preserveWhitespaces
  45137. }) {
  45138. this.encapsulation = encapsulation;
  45139. this.template = template;
  45140. this.templateUrl = templateUrl;
  45141. this.htmlAst = htmlAst;
  45142. this.styles = _normalizeArray(styles);
  45143. this.styleUrls = _normalizeArray(styleUrls);
  45144. this.externalStylesheets = _normalizeArray(externalStylesheets);
  45145. this.animations = animations ? flatten(animations) : [];
  45146. this.ngContentSelectors = ngContentSelectors || [];
  45147. if (interpolation && interpolation.length != 2) {
  45148. throw new Error(`'interpolation' should have a start and an end symbol.`);
  45149. }
  45150. this.interpolation = interpolation;
  45151. this.isInline = isInline;
  45152. this.preserveWhitespaces = preserveWhitespaces;
  45153. }
  45154. toSummary() {
  45155. return {
  45156. ngContentSelectors: this.ngContentSelectors,
  45157. encapsulation: this.encapsulation,
  45158. styles: this.styles,
  45159. animations: this.animations
  45160. };
  45161. }
  45162. }
  45163. exports.CompileTemplateMetadata = CompileTemplateMetadata;
  45164. /**
  45165. * Metadata regarding compilation of a directive.
  45166. */
  45167. class CompileDirectiveMetadata {
  45168. static create({
  45169. isHost,
  45170. type,
  45171. isComponent,
  45172. selector,
  45173. exportAs,
  45174. changeDetection,
  45175. inputs,
  45176. outputs,
  45177. host,
  45178. providers,
  45179. viewProviders,
  45180. queries,
  45181. guards,
  45182. viewQueries,
  45183. entryComponents,
  45184. template,
  45185. componentViewType,
  45186. rendererType,
  45187. componentFactory
  45188. }) {
  45189. const hostListeners = {};
  45190. const hostProperties = {};
  45191. const hostAttributes = {};
  45192. if (host != null) {
  45193. Object.keys(host).forEach(key => {
  45194. const value = host[key];
  45195. const matches = key.match(HOST_REG_EXP);
  45196. if (matches === null) {
  45197. hostAttributes[key] = value;
  45198. } else if (matches[1] != null) {
  45199. hostProperties[matches[1]] = value;
  45200. } else if (matches[2] != null) {
  45201. hostListeners[matches[2]] = value;
  45202. }
  45203. });
  45204. }
  45205. const inputsMap = {};
  45206. if (inputs != null) {
  45207. inputs.forEach(bindConfig => {
  45208. // canonical syntax: `dirProp: elProp`
  45209. // if there is no `:`, use dirProp = elProp
  45210. const parts = util.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  45211. inputsMap[parts[0]] = parts[1];
  45212. });
  45213. }
  45214. const outputsMap = {};
  45215. if (outputs != null) {
  45216. outputs.forEach(bindConfig => {
  45217. // canonical syntax: `dirProp: elProp`
  45218. // if there is no `:`, use dirProp = elProp
  45219. const parts = util.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  45220. outputsMap[parts[0]] = parts[1];
  45221. });
  45222. }
  45223. return new CompileDirectiveMetadata({
  45224. isHost,
  45225. type,
  45226. isComponent: !!isComponent,
  45227. selector,
  45228. exportAs,
  45229. changeDetection,
  45230. inputs: inputsMap,
  45231. outputs: outputsMap,
  45232. hostListeners,
  45233. hostProperties,
  45234. hostAttributes,
  45235. providers,
  45236. viewProviders,
  45237. queries,
  45238. guards,
  45239. viewQueries,
  45240. entryComponents,
  45241. template,
  45242. componentViewType,
  45243. rendererType,
  45244. componentFactory
  45245. });
  45246. }
  45247. constructor({
  45248. isHost,
  45249. type,
  45250. isComponent,
  45251. selector,
  45252. exportAs,
  45253. changeDetection,
  45254. inputs,
  45255. outputs,
  45256. hostListeners,
  45257. hostProperties,
  45258. hostAttributes,
  45259. providers,
  45260. viewProviders,
  45261. queries,
  45262. guards,
  45263. viewQueries,
  45264. entryComponents,
  45265. template,
  45266. componentViewType,
  45267. rendererType,
  45268. componentFactory
  45269. }) {
  45270. this.isHost = !!isHost;
  45271. this.type = type;
  45272. this.isComponent = isComponent;
  45273. this.selector = selector;
  45274. this.exportAs = exportAs;
  45275. this.changeDetection = changeDetection;
  45276. this.inputs = inputs;
  45277. this.outputs = outputs;
  45278. this.hostListeners = hostListeners;
  45279. this.hostProperties = hostProperties;
  45280. this.hostAttributes = hostAttributes;
  45281. this.providers = _normalizeArray(providers);
  45282. this.viewProviders = _normalizeArray(viewProviders);
  45283. this.queries = _normalizeArray(queries);
  45284. this.guards = guards;
  45285. this.viewQueries = _normalizeArray(viewQueries);
  45286. this.entryComponents = _normalizeArray(entryComponents);
  45287. this.template = template;
  45288. this.componentViewType = componentViewType;
  45289. this.rendererType = rendererType;
  45290. this.componentFactory = componentFactory;
  45291. }
  45292. toSummary() {
  45293. return {
  45294. summaryKind: CompileSummaryKind.Directive,
  45295. type: this.type,
  45296. isComponent: this.isComponent,
  45297. selector: this.selector,
  45298. exportAs: this.exportAs,
  45299. inputs: this.inputs,
  45300. outputs: this.outputs,
  45301. hostListeners: this.hostListeners,
  45302. hostProperties: this.hostProperties,
  45303. hostAttributes: this.hostAttributes,
  45304. providers: this.providers,
  45305. viewProviders: this.viewProviders,
  45306. queries: this.queries,
  45307. guards: this.guards,
  45308. viewQueries: this.viewQueries,
  45309. entryComponents: this.entryComponents,
  45310. changeDetection: this.changeDetection,
  45311. template: this.template && this.template.toSummary(),
  45312. componentViewType: this.componentViewType,
  45313. rendererType: this.rendererType,
  45314. componentFactory: this.componentFactory
  45315. };
  45316. }
  45317. }
  45318. exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
  45319. class CompilePipeMetadata {
  45320. constructor({
  45321. type,
  45322. name,
  45323. pure
  45324. }) {
  45325. this.type = type;
  45326. this.name = name;
  45327. this.pure = !!pure;
  45328. }
  45329. toSummary() {
  45330. return {
  45331. summaryKind: CompileSummaryKind.Pipe,
  45332. type: this.type,
  45333. name: this.name,
  45334. pure: this.pure
  45335. };
  45336. }
  45337. }
  45338. exports.CompilePipeMetadata = CompilePipeMetadata;
  45339. class CompileShallowModuleMetadata {}
  45340. exports.CompileShallowModuleMetadata = CompileShallowModuleMetadata;
  45341. /**
  45342. * Metadata regarding compilation of a module.
  45343. */
  45344. class CompileNgModuleMetadata {
  45345. constructor({
  45346. type,
  45347. providers,
  45348. declaredDirectives,
  45349. exportedDirectives,
  45350. declaredPipes,
  45351. exportedPipes,
  45352. entryComponents,
  45353. bootstrapComponents,
  45354. importedModules,
  45355. exportedModules,
  45356. schemas,
  45357. transitiveModule,
  45358. id
  45359. }) {
  45360. this.type = type || null;
  45361. this.declaredDirectives = _normalizeArray(declaredDirectives);
  45362. this.exportedDirectives = _normalizeArray(exportedDirectives);
  45363. this.declaredPipes = _normalizeArray(declaredPipes);
  45364. this.exportedPipes = _normalizeArray(exportedPipes);
  45365. this.providers = _normalizeArray(providers);
  45366. this.entryComponents = _normalizeArray(entryComponents);
  45367. this.bootstrapComponents = _normalizeArray(bootstrapComponents);
  45368. this.importedModules = _normalizeArray(importedModules);
  45369. this.exportedModules = _normalizeArray(exportedModules);
  45370. this.schemas = _normalizeArray(schemas);
  45371. this.id = id || null;
  45372. this.transitiveModule = transitiveModule || null;
  45373. }
  45374. toSummary() {
  45375. const module = this.transitiveModule;
  45376. return {
  45377. summaryKind: CompileSummaryKind.NgModule,
  45378. type: this.type,
  45379. entryComponents: module.entryComponents,
  45380. providers: module.providers,
  45381. modules: module.modules,
  45382. exportedDirectives: module.exportedDirectives,
  45383. exportedPipes: module.exportedPipes
  45384. };
  45385. }
  45386. }
  45387. exports.CompileNgModuleMetadata = CompileNgModuleMetadata;
  45388. class TransitiveCompileNgModuleMetadata {
  45389. constructor() {
  45390. this.directivesSet = new Set();
  45391. this.directives = [];
  45392. this.exportedDirectivesSet = new Set();
  45393. this.exportedDirectives = [];
  45394. this.pipesSet = new Set();
  45395. this.pipes = [];
  45396. this.exportedPipesSet = new Set();
  45397. this.exportedPipes = [];
  45398. this.modulesSet = new Set();
  45399. this.modules = [];
  45400. this.entryComponentsSet = new Set();
  45401. this.entryComponents = [];
  45402. this.providers = [];
  45403. }
  45404. addProvider(provider, module) {
  45405. this.providers.push({
  45406. provider: provider,
  45407. module: module
  45408. });
  45409. }
  45410. addDirective(id) {
  45411. if (!this.directivesSet.has(id.reference)) {
  45412. this.directivesSet.add(id.reference);
  45413. this.directives.push(id);
  45414. }
  45415. }
  45416. addExportedDirective(id) {
  45417. if (!this.exportedDirectivesSet.has(id.reference)) {
  45418. this.exportedDirectivesSet.add(id.reference);
  45419. this.exportedDirectives.push(id);
  45420. }
  45421. }
  45422. addPipe(id) {
  45423. if (!this.pipesSet.has(id.reference)) {
  45424. this.pipesSet.add(id.reference);
  45425. this.pipes.push(id);
  45426. }
  45427. }
  45428. addExportedPipe(id) {
  45429. if (!this.exportedPipesSet.has(id.reference)) {
  45430. this.exportedPipesSet.add(id.reference);
  45431. this.exportedPipes.push(id);
  45432. }
  45433. }
  45434. addModule(id) {
  45435. if (!this.modulesSet.has(id.reference)) {
  45436. this.modulesSet.add(id.reference);
  45437. this.modules.push(id);
  45438. }
  45439. }
  45440. addEntryComponent(ec) {
  45441. if (!this.entryComponentsSet.has(ec.componentType)) {
  45442. this.entryComponentsSet.add(ec.componentType);
  45443. this.entryComponents.push(ec);
  45444. }
  45445. }
  45446. }
  45447. exports.TransitiveCompileNgModuleMetadata = TransitiveCompileNgModuleMetadata;
  45448. function _normalizeArray(obj) {
  45449. return obj || [];
  45450. }
  45451. class ProviderMeta {
  45452. constructor(token, {
  45453. useClass,
  45454. useValue,
  45455. useExisting,
  45456. useFactory,
  45457. deps,
  45458. multi
  45459. }) {
  45460. this.token = token;
  45461. this.useClass = useClass || null;
  45462. this.useValue = useValue;
  45463. this.useExisting = useExisting;
  45464. this.useFactory = useFactory || null;
  45465. this.dependencies = deps || null;
  45466. this.multi = !!multi;
  45467. }
  45468. }
  45469. exports.ProviderMeta = ProviderMeta;
  45470. function flatten(list) {
  45471. return list.reduce((flat, item) => {
  45472. const flatItem = Array.isArray(item) ? flatten(item) : item;
  45473. return flat.concat(flatItem);
  45474. }, []);
  45475. }
  45476. exports.flatten = flatten;
  45477. function jitSourceUrl(url) {
  45478. // Note: We need 3 "/" so that ng shows up as a separate domain
  45479. // in the chrome dev tools.
  45480. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
  45481. }
  45482. function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
  45483. let url;
  45484. if (templateMeta.isInline) {
  45485. if (compMeta.type.reference instanceof static_symbol.StaticSymbol) {
  45486. // Note: a .ts file might contain multiple components with inline templates,
  45487. // so we need to give them unique urls, as these will be used for sourcemaps.
  45488. url = `${compMeta.type.reference.filePath}.${compMeta.type.reference.name}.html`;
  45489. } else {
  45490. url = `${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.html`;
  45491. }
  45492. } else {
  45493. url = templateMeta.templateUrl;
  45494. }
  45495. return compMeta.type.reference instanceof static_symbol.StaticSymbol ? url : jitSourceUrl(url);
  45496. }
  45497. exports.templateSourceUrl = templateSourceUrl;
  45498. function sharedStylesheetJitUrl(meta, id) {
  45499. const pathParts = meta.moduleUrl.split(/\/\\/g);
  45500. const baseName = pathParts[pathParts.length - 1];
  45501. return jitSourceUrl(`css/${id}${baseName}.ngstyle.js`);
  45502. }
  45503. exports.sharedStylesheetJitUrl = sharedStylesheetJitUrl;
  45504. function ngModuleJitUrl(moduleMeta) {
  45505. return jitSourceUrl(`${identifierName(moduleMeta.type)}/module.ngfactory.js`);
  45506. }
  45507. exports.ngModuleJitUrl = ngModuleJitUrl;
  45508. function templateJitUrl(ngModuleType, compMeta) {
  45509. return jitSourceUrl(`${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.ngfactory.js`);
  45510. }
  45511. exports.templateJitUrl = templateJitUrl;
  45512. });
  45513. var parse_util = createCommonjsModule(function (module, exports) {
  45514. Object.defineProperty(exports, "__esModule", {
  45515. value: true
  45516. });
  45517. /**
  45518. * @license
  45519. * Copyright Google Inc. All Rights Reserved.
  45520. *
  45521. * Use of this source code is governed by an MIT-style license that can be
  45522. * found in the LICENSE file at https://angular.io/license
  45523. */
  45524. class ParseLocation {
  45525. constructor(file, offset, line, col) {
  45526. this.file = file;
  45527. this.offset = offset;
  45528. this.line = line;
  45529. this.col = col;
  45530. }
  45531. toString() {
  45532. return this.offset != null ? `${this.file.url}@${this.line}:${this.col}` : this.file.url;
  45533. }
  45534. moveBy(delta) {
  45535. const source = this.file.content;
  45536. const len = source.length;
  45537. let offset = this.offset;
  45538. let line = this.line;
  45539. let col = this.col;
  45540. while (offset > 0 && delta < 0) {
  45541. offset--;
  45542. delta++;
  45543. const ch = source.charCodeAt(offset);
  45544. if (ch == chars.$LF) {
  45545. line--;
  45546. const priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode(chars.$LF));
  45547. col = priorLine > 0 ? offset - priorLine : offset;
  45548. } else {
  45549. col--;
  45550. }
  45551. }
  45552. while (offset < len && delta > 0) {
  45553. const ch = source.charCodeAt(offset);
  45554. offset++;
  45555. delta--;
  45556. if (ch == chars.$LF) {
  45557. line++;
  45558. col = 0;
  45559. } else {
  45560. col++;
  45561. }
  45562. }
  45563. return new ParseLocation(this.file, offset, line, col);
  45564. } // Return the source around the location
  45565. // Up to `maxChars` or `maxLines` on each side of the location
  45566. getContext(maxChars, maxLines) {
  45567. const content = this.file.content;
  45568. let startOffset = this.offset;
  45569. if (startOffset != null) {
  45570. if (startOffset > content.length - 1) {
  45571. startOffset = content.length - 1;
  45572. }
  45573. let endOffset = startOffset;
  45574. let ctxChars = 0;
  45575. let ctxLines = 0;
  45576. while (ctxChars < maxChars && startOffset > 0) {
  45577. startOffset--;
  45578. ctxChars++;
  45579. if (content[startOffset] == '\n') {
  45580. if (++ctxLines == maxLines) {
  45581. break;
  45582. }
  45583. }
  45584. }
  45585. ctxChars = 0;
  45586. ctxLines = 0;
  45587. while (ctxChars < maxChars && endOffset < content.length - 1) {
  45588. endOffset++;
  45589. ctxChars++;
  45590. if (content[endOffset] == '\n') {
  45591. if (++ctxLines == maxLines) {
  45592. break;
  45593. }
  45594. }
  45595. }
  45596. return {
  45597. before: content.substring(startOffset, this.offset),
  45598. after: content.substring(this.offset, endOffset + 1)
  45599. };
  45600. }
  45601. return null;
  45602. }
  45603. }
  45604. exports.ParseLocation = ParseLocation;
  45605. class ParseSourceFile {
  45606. constructor(content, url) {
  45607. this.content = content;
  45608. this.url = url;
  45609. }
  45610. }
  45611. exports.ParseSourceFile = ParseSourceFile;
  45612. class ParseSourceSpan {
  45613. constructor(start, end, details = null) {
  45614. this.start = start;
  45615. this.end = end;
  45616. this.details = details;
  45617. }
  45618. toString() {
  45619. return this.start.file.content.substring(this.start.offset, this.end.offset);
  45620. }
  45621. }
  45622. exports.ParseSourceSpan = ParseSourceSpan;
  45623. exports.EMPTY_PARSE_LOCATION = new ParseLocation(new ParseSourceFile('', ''), 0, 0, 0);
  45624. exports.EMPTY_SOURCE_SPAN = new ParseSourceSpan(exports.EMPTY_PARSE_LOCATION, exports.EMPTY_PARSE_LOCATION);
  45625. var ParseErrorLevel;
  45626. (function (ParseErrorLevel) {
  45627. ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
  45628. ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR";
  45629. })(ParseErrorLevel = exports.ParseErrorLevel || (exports.ParseErrorLevel = {}));
  45630. class ParseError {
  45631. constructor(span, msg, level = ParseErrorLevel.ERROR) {
  45632. this.span = span;
  45633. this.msg = msg;
  45634. this.level = level;
  45635. }
  45636. contextualMessage() {
  45637. const ctx = this.span.start.getContext(100, 3);
  45638. return ctx ? `${this.msg} ("${ctx.before}[${ParseErrorLevel[this.level]} ->]${ctx.after}")` : this.msg;
  45639. }
  45640. toString() {
  45641. const details = this.span.details ? `, ${this.span.details}` : '';
  45642. return `${this.contextualMessage()}: ${this.span.start}${details}`;
  45643. }
  45644. }
  45645. exports.ParseError = ParseError;
  45646. function typeSourceSpan(kind, type) {
  45647. const moduleUrl = compile_metadata.identifierModuleUrl(type);
  45648. const sourceFileName = moduleUrl != null ? `in ${kind} ${compile_metadata.identifierName(type)} in ${moduleUrl}` : `in ${kind} ${compile_metadata.identifierName(type)}`;
  45649. const sourceFile = new ParseSourceFile('', sourceFileName);
  45650. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  45651. }
  45652. exports.typeSourceSpan = typeSourceSpan;
  45653. /**
  45654. * Generates Source Span object for a given R3 Type for JIT mode.
  45655. *
  45656. * @param kind Component or Directive.
  45657. * @param typeName name of the Component or Directive.
  45658. * @param sourceUrl reference to Component or Directive source.
  45659. * @returns instance of ParseSourceSpan that represent a given Component or Directive.
  45660. */
  45661. function r3JitTypeSourceSpan(kind, typeName, sourceUrl) {
  45662. const sourceFileName = `in ${kind} ${typeName} in ${sourceUrl}`;
  45663. const sourceFile = new ParseSourceFile('', sourceFileName);
  45664. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  45665. }
  45666. exports.r3JitTypeSourceSpan = r3JitTypeSourceSpan;
  45667. });
  45668. const {
  45669. ParseSourceSpan
  45670. } = parse_util;
  45671. const {
  45672. htmlTrim,
  45673. getLeadingAndTrailingHtmlWhitespace,
  45674. hasHtmlWhitespace,
  45675. canHaveInterpolation,
  45676. getNodeCssStyleDisplay,
  45677. isDanglingSpaceSensitiveNode,
  45678. isIndentationSensitiveNode,
  45679. isLeadingSpaceSensitiveNode,
  45680. isTrailingSpaceSensitiveNode,
  45681. isWhitespaceSensitiveNode
  45682. } = utils$1;
  45683. const PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  45684. function preprocess$1(ast, options) {
  45685. const res = ast.map(node => node);
  45686. for (const fn of PREPROCESS_PIPELINE) {
  45687. fn(res, options);
  45688. }
  45689. return res;
  45690. }
  45691. function removeIgnorableFirstLf(ast
  45692. /*, options */
  45693. ) {
  45694. ast.walk(node => {
  45695. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length > 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  45696. const [text, ...rest] = node.children;
  45697. node.setChildren(text.value.length === 1 ? rest : [text.clone({
  45698. value: text.value.slice(1)
  45699. }), ...rest]);
  45700. }
  45701. });
  45702. }
  45703. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  45704. /*, options */
  45705. ) {
  45706. /**
  45707. * <!--[if ...]><!--><target><!--<![endif]-->
  45708. */
  45709. const isTarget = node => node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
  45710. ast.walk(node => {
  45711. if (node.children) {
  45712. const isTargetResults = node.children.map(isTarget);
  45713. if (isTargetResults.some(Boolean)) {
  45714. const newChildren = [];
  45715. for (let i = 0; i < node.children.length; i++) {
  45716. const child = node.children[i];
  45717. if (isTargetResults[i + 1]) {
  45718. // ieConditionalStartComment
  45719. continue;
  45720. }
  45721. if (isTargetResults[i]) {
  45722. const ieConditionalStartComment = child.prev;
  45723. const ieConditionalEndComment = child.firstChild;
  45724. const startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  45725. const sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  45726. newChildren.push(child.clone({
  45727. condition: ieConditionalStartComment.condition,
  45728. sourceSpan,
  45729. startSourceSpan,
  45730. children: child.children.slice(1)
  45731. }));
  45732. continue;
  45733. }
  45734. newChildren.push(child);
  45735. }
  45736. node.setChildren(newChildren);
  45737. }
  45738. }
  45739. });
  45740. }
  45741. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  45742. ast.walk(node => {
  45743. if (node.children) {
  45744. const shouldMergeResults = node.children.map(shouldMerge);
  45745. if (shouldMergeResults.some(Boolean)) {
  45746. const newChildren = [];
  45747. for (let i = 0; i < node.children.length; i++) {
  45748. const child = node.children[i];
  45749. if (child.type !== "text" && !shouldMergeResults[i]) {
  45750. newChildren.push(child);
  45751. continue;
  45752. }
  45753. const newChild = child.type === "text" ? child : child.clone({
  45754. type: "text",
  45755. value: getValue(child)
  45756. });
  45757. if (newChildren.length === 0 || getLast_1(newChildren).type !== "text") {
  45758. newChildren.push(newChild);
  45759. continue;
  45760. }
  45761. const lastChild = newChildren.pop();
  45762. newChildren.push(lastChild.clone({
  45763. value: lastChild.value + newChild.value,
  45764. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  45765. }));
  45766. }
  45767. node.setChildren(newChildren);
  45768. }
  45769. }
  45770. });
  45771. }
  45772. function mergeCdataIntoText(ast
  45773. /*, options */
  45774. ) {
  45775. return mergeNodeIntoText(ast, node => node.type === "cdata", node => `<![CDATA[${node.value}]]>`);
  45776. }
  45777. function mergeSimpleElementIntoText(ast
  45778. /*, options */
  45779. ) {
  45780. const isSimpleElement = node => node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && !hasHtmlWhitespace(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
  45781. ast.walk(node => {
  45782. if (node.children) {
  45783. const isSimpleElementResults = node.children.map(isSimpleElement);
  45784. if (isSimpleElementResults.some(Boolean)) {
  45785. const newChildren = [];
  45786. for (let i = 0; i < node.children.length; i++) {
  45787. const child = node.children[i];
  45788. if (isSimpleElementResults[i]) {
  45789. const lastChild = newChildren.pop();
  45790. const nextChild = node.children[++i];
  45791. const {
  45792. isTrailingSpaceSensitive,
  45793. hasTrailingSpaces
  45794. } = nextChild;
  45795. newChildren.push(lastChild.clone({
  45796. value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
  45797. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  45798. isTrailingSpaceSensitive,
  45799. hasTrailingSpaces
  45800. }));
  45801. } else {
  45802. newChildren.push(child);
  45803. }
  45804. }
  45805. node.setChildren(newChildren);
  45806. }
  45807. }
  45808. });
  45809. }
  45810. function extractInterpolation(ast, options) {
  45811. if (options.parser === "html") {
  45812. return;
  45813. }
  45814. const interpolationRegex = /{{(.+?)}}/s;
  45815. ast.walk(node => {
  45816. if (!canHaveInterpolation(node)) {
  45817. return;
  45818. }
  45819. const newChildren = [];
  45820. for (const child of node.children) {
  45821. if (child.type !== "text") {
  45822. newChildren.push(child);
  45823. continue;
  45824. }
  45825. let startSourceSpan = child.sourceSpan.start;
  45826. let endSourceSpan = null;
  45827. const components = child.value.split(interpolationRegex);
  45828. for (let i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  45829. const value = components[i];
  45830. if (i % 2 === 0) {
  45831. endSourceSpan = startSourceSpan.moveBy(value.length);
  45832. if (value.length > 0) {
  45833. newChildren.push({
  45834. type: "text",
  45835. value,
  45836. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  45837. });
  45838. }
  45839. continue;
  45840. }
  45841. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  45842. newChildren.push({
  45843. type: "interpolation",
  45844. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  45845. children: value.length === 0 ? [] : [{
  45846. type: "text",
  45847. value,
  45848. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  45849. }]
  45850. });
  45851. }
  45852. }
  45853. node.setChildren(newChildren);
  45854. });
  45855. }
  45856. /**
  45857. * - add `hasLeadingSpaces` field
  45858. * - add `hasTrailingSpaces` field
  45859. * - add `hasDanglingSpaces` field for parent nodes
  45860. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  45861. * - remove insensitive whitespaces
  45862. */
  45863. const WHITESPACE_NODE = {
  45864. type: "whitespace"
  45865. };
  45866. function extractWhitespaces(ast
  45867. /*, options*/
  45868. ) {
  45869. ast.walk(node => {
  45870. if (!node.children) {
  45871. return;
  45872. }
  45873. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && htmlTrim(node.children[0].value).length === 0) {
  45874. node.hasDanglingSpaces = node.children.length > 0;
  45875. node.children = [];
  45876. return;
  45877. }
  45878. const isWhitespaceSensitive = isWhitespaceSensitiveNode(node);
  45879. const isIndentationSensitive = isIndentationSensitiveNode(node);
  45880. node.setChildren(node.children // extract whitespace nodes
  45881. .flatMap(child => {
  45882. if (child.type !== "text" || isWhitespaceSensitive) {
  45883. return child;
  45884. }
  45885. const localChildren = [];
  45886. const {
  45887. leadingWhitespace,
  45888. text,
  45889. trailingWhitespace
  45890. } = getLeadingAndTrailingHtmlWhitespace(child.value);
  45891. if (leadingWhitespace) {
  45892. localChildren.push(WHITESPACE_NODE);
  45893. }
  45894. if (text) {
  45895. localChildren.push({
  45896. type: "text",
  45897. value: text,
  45898. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingWhitespace.length), child.sourceSpan.end.moveBy(-trailingWhitespace.length))
  45899. });
  45900. }
  45901. if (trailingWhitespace) {
  45902. localChildren.push(WHITESPACE_NODE);
  45903. }
  45904. return localChildren;
  45905. }) // set hasLeadingSpaces/hasTrailingSpaces
  45906. .map((child, index, children) => {
  45907. if (child === WHITESPACE_NODE) {
  45908. return;
  45909. }
  45910. return Object.assign(Object.assign({}, child), {}, {
  45911. hasLeadingSpaces: children[index - 1] === WHITESPACE_NODE,
  45912. hasTrailingSpaces: children[index + 1] === WHITESPACE_NODE
  45913. });
  45914. }) // filter whitespace nodes
  45915. .filter(Boolean));
  45916. node.isWhitespaceSensitive = isWhitespaceSensitive;
  45917. node.isIndentationSensitive = isIndentationSensitive;
  45918. });
  45919. }
  45920. function addIsSelfClosing(ast
  45921. /*, options */
  45922. ) {
  45923. ast.walk(node => Object.assign(node, {
  45924. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  45925. node.startSourceSpan === node.endSourceSpan)
  45926. }));
  45927. }
  45928. function addHasHtmComponentClosingTag(ast, options) {
  45929. ast.walk(node => node.type !== "element" ? node : Object.assign(node, {
  45930. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  45931. }));
  45932. }
  45933. function addCssDisplay(ast, options) {
  45934. ast.walk(node => Object.assign(node, {
  45935. cssDisplay: getNodeCssStyleDisplay(node, options)
  45936. }));
  45937. }
  45938. /**
  45939. * - add `isLeadingSpaceSensitive` field
  45940. * - add `isTrailingSpaceSensitive` field
  45941. * - add `isDanglingSpaceSensitive` field for parent nodes
  45942. */
  45943. function addIsSpaceSensitive(ast, options) {
  45944. ast.walk(node => {
  45945. if (!node.children) {
  45946. return;
  45947. }
  45948. if (node.children.length === 0) {
  45949. node.isDanglingSpaceSensitive = isDanglingSpaceSensitiveNode(node);
  45950. return;
  45951. }
  45952. node.setChildren(node.children.map(child => Object.assign(Object.assign({}, child), {}, {
  45953. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode(child, options),
  45954. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode(child, options)
  45955. })).map((child, index, children) => Object.assign(Object.assign({}, child), {}, {
  45956. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  45957. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  45958. })));
  45959. });
  45960. }
  45961. var printPreprocess$1 = preprocess$1;
  45962. function hasPragma$1(text) {
  45963. return /^\s*<!--\s*@(?:format|prettier)\s*-->/.test(text);
  45964. }
  45965. function insertPragma$3(text) {
  45966. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  45967. }
  45968. var pragma$1 = {
  45969. hasPragma: hasPragma$1,
  45970. insertPragma: insertPragma$3
  45971. };
  45972. function locStart$5(node) {
  45973. return node.sourceSpan.start.offset;
  45974. }
  45975. function locEnd$4(node) {
  45976. return node.sourceSpan.end.offset;
  45977. }
  45978. var loc$1 = {
  45979. locStart: locStart$5,
  45980. locEnd: locEnd$4
  45981. };
  45982. /**
  45983. * @typedef {import("../../document").Doc} Doc
  45984. */
  45985. const {
  45986. isNonEmptyArray: isNonEmptyArray$1
  45987. } = util$5;
  45988. const {
  45989. builders: {
  45990. indent: indent$3,
  45991. join: join$5,
  45992. line: line$8,
  45993. softline: softline$6
  45994. },
  45995. utils: {
  45996. replaceTextEndOfLine: replaceTextEndOfLine$5
  45997. }
  45998. } = doc;
  45999. const {
  46000. locStart: locStart$4,
  46001. locEnd: locEnd$3
  46002. } = loc$1;
  46003. const {
  46004. isTextLikeNode: isTextLikeNode$1,
  46005. getLastDescendant,
  46006. isPreLikeNode,
  46007. hasPrettierIgnore: hasPrettierIgnore$3,
  46008. shouldPreserveContent: shouldPreserveContent$1
  46009. } = utils$1;
  46010. function printClosingTag$2(node, options) {
  46011. return [node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd$1(node, options)];
  46012. }
  46013. function printClosingTagStart(node, options) {
  46014. return node.lastChild && needsToBorrowParentClosingTagStartMarker$2(node.lastChild) ? "" : [printClosingTagPrefix(node, options), printClosingTagStartMarker$1(node, options)];
  46015. }
  46016. function printClosingTagEnd$1(node, options) {
  46017. return (node.next ? needsToBorrowPrevClosingTagEndMarker$3(node.next) : needsToBorrowLastChildClosingTagEndMarker$2(node.parent)) ? "" : [printClosingTagEndMarker$2(node, options), printClosingTagSuffix$4(node, options)];
  46018. }
  46019. function printClosingTagPrefix(node, options) {
  46020. return needsToBorrowLastChildClosingTagEndMarker$2(node) ? printClosingTagEndMarker$2(node.lastChild, options) : "";
  46021. }
  46022. function printClosingTagSuffix$4(node, options) {
  46023. return needsToBorrowParentClosingTagStartMarker$2(node) ? printClosingTagStartMarker$1(node.parent, options) : needsToBorrowNextOpeningTagStartMarker$1(node) ? printOpeningTagStartMarker$1(node.next) : "";
  46024. }
  46025. function printClosingTagStartMarker$1(node, options) {
  46026. assert__default['default'](!node.isSelfClosing);
  46027. /* istanbul ignore next */
  46028. if (shouldNotPrintClosingTag(node, options)) {
  46029. return "";
  46030. }
  46031. switch (node.type) {
  46032. case "ieConditionalComment":
  46033. return "<!";
  46034. case "element":
  46035. if (node.hasHtmComponentClosingTag) {
  46036. return "<//";
  46037. }
  46038. // fall through
  46039. default:
  46040. return `</${node.rawName}`;
  46041. }
  46042. }
  46043. function printClosingTagEndMarker$2(node, options) {
  46044. if (shouldNotPrintClosingTag(node, options)) {
  46045. return "";
  46046. }
  46047. switch (node.type) {
  46048. case "ieConditionalComment":
  46049. case "ieConditionalEndComment":
  46050. return "[endif]-->";
  46051. case "ieConditionalStartComment":
  46052. return "]><!-->";
  46053. case "interpolation":
  46054. return "}}";
  46055. case "element":
  46056. if (node.isSelfClosing) {
  46057. return "/>";
  46058. }
  46059. // fall through
  46060. default:
  46061. return ">";
  46062. }
  46063. }
  46064. function shouldNotPrintClosingTag(node, options) {
  46065. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
  46066. }
  46067. function needsToBorrowPrevClosingTagEndMarker$3(node) {
  46068. /**
  46069. * <p></p
  46070. * >123
  46071. * ^
  46072. *
  46073. * <p></p
  46074. * ><a
  46075. * ^
  46076. */
  46077. return node.prev && node.prev.type !== "docType" && !isTextLikeNode$1(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  46078. }
  46079. function needsToBorrowLastChildClosingTagEndMarker$2(node) {
  46080. /**
  46081. * <p
  46082. * ><a></a
  46083. * ></p
  46084. * ^
  46085. * >
  46086. */
  46087. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode$1(getLastDescendant(node.lastChild)) && !isPreLikeNode(node);
  46088. }
  46089. function needsToBorrowParentClosingTagStartMarker$2(node) {
  46090. /**
  46091. * <p>
  46092. * 123</p
  46093. * ^^^
  46094. * >
  46095. *
  46096. * 123</b
  46097. * ></a
  46098. * ^^^
  46099. * >
  46100. */
  46101. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode$1(getLastDescendant(node));
  46102. }
  46103. function needsToBorrowNextOpeningTagStartMarker$1(node) {
  46104. /**
  46105. * 123<p
  46106. * ^^
  46107. * >
  46108. */
  46109. return node.next && !isTextLikeNode$1(node.next) && isTextLikeNode$1(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  46110. }
  46111. function getPrettierIgnoreAttributeCommentData(value) {
  46112. const match = value.trim().match(/^prettier-ignore-attribute(?:\s+(.+))?$/s);
  46113. if (!match) {
  46114. return false;
  46115. }
  46116. if (!match[1]) {
  46117. return true;
  46118. }
  46119. return match[1].split(/\s+/);
  46120. }
  46121. function needsToBorrowParentOpeningTagEndMarker$1(node) {
  46122. /**
  46123. * <p
  46124. * >123
  46125. * ^
  46126. *
  46127. * <p
  46128. * ><a
  46129. * ^
  46130. */
  46131. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  46132. }
  46133. function printAttributes(path, options, print) {
  46134. const node = path.getValue();
  46135. if (!isNonEmptyArray$1(node.attrs)) {
  46136. return node.isSelfClosing ?
  46137. /**
  46138. * <br />
  46139. * ^
  46140. */
  46141. " " : "";
  46142. }
  46143. const ignoreAttributeData = node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value);
  46144. const hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? () => ignoreAttributeData : Array.isArray(ignoreAttributeData) ? attribute => ignoreAttributeData.includes(attribute.rawName) : () => false;
  46145. const printedAttributes = path.map(attributePath => {
  46146. const attribute = attributePath.getValue();
  46147. return hasPrettierIgnoreAttribute(attribute) ? replaceTextEndOfLine$5(options.originalText.slice(locStart$4(attribute), locEnd$3(attribute))) : print();
  46148. }, "attrs");
  46149. const forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  46150. /** @type {Doc[]} */
  46151. const parts = [indent$3([forceNotToBreakAttrContent ? " " : line$8, join$5(line$8, printedAttributes)])];
  46152. if (
  46153. /**
  46154. * 123<a
  46155. * attr
  46156. * ~
  46157. * >456
  46158. */
  46159. node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) || node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker$2(node.parent) || forceNotToBreakAttrContent) {
  46160. parts.push(node.isSelfClosing ? " " : "");
  46161. } else {
  46162. parts.push(options.bracketSameLine ? node.isSelfClosing ? " " : "" : node.isSelfClosing ? line$8 : softline$6);
  46163. }
  46164. return parts;
  46165. }
  46166. function printOpeningTagEnd(node) {
  46167. return node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) ? "" : printOpeningTagEndMarker$1(node);
  46168. }
  46169. function printOpeningTag$2(path, options, print) {
  46170. const node = path.getValue();
  46171. return [printOpeningTagStart$1(node, options), printAttributes(path, options, print), node.isSelfClosing ? "" : printOpeningTagEnd(node)];
  46172. }
  46173. function printOpeningTagStart$1(node, options) {
  46174. return node.prev && needsToBorrowNextOpeningTagStartMarker$1(node.prev) ? "" : [printOpeningTagPrefix$4(node, options), printOpeningTagStartMarker$1(node)];
  46175. }
  46176. function printOpeningTagPrefix$4(node, options) {
  46177. return needsToBorrowParentOpeningTagEndMarker$1(node) ? printOpeningTagEndMarker$1(node.parent) : needsToBorrowPrevClosingTagEndMarker$3(node) ? printClosingTagEndMarker$2(node.prev, options) : "";
  46178. }
  46179. function printOpeningTagStartMarker$1(node) {
  46180. switch (node.type) {
  46181. case "ieConditionalComment":
  46182. case "ieConditionalStartComment":
  46183. return `<!--[if ${node.condition}`;
  46184. case "ieConditionalEndComment":
  46185. return "<!--<!";
  46186. case "interpolation":
  46187. return "{{";
  46188. case "docType":
  46189. return "<!DOCTYPE";
  46190. case "element":
  46191. if (node.condition) {
  46192. return `<!--[if ${node.condition}]><!--><${node.rawName}`;
  46193. }
  46194. // fall through
  46195. default:
  46196. return `<${node.rawName}`;
  46197. }
  46198. }
  46199. function printOpeningTagEndMarker$1(node) {
  46200. assert__default['default'](!node.isSelfClosing);
  46201. switch (node.type) {
  46202. case "ieConditionalComment":
  46203. return "]>";
  46204. case "element":
  46205. if (node.condition) {
  46206. return "><!--<![endif]-->";
  46207. }
  46208. // fall through
  46209. default:
  46210. return ">";
  46211. }
  46212. }
  46213. var tag = {
  46214. printClosingTag: printClosingTag$2,
  46215. printClosingTagStart,
  46216. printClosingTagStartMarker: printClosingTagStartMarker$1,
  46217. printClosingTagEndMarker: printClosingTagEndMarker$2,
  46218. printClosingTagSuffix: printClosingTagSuffix$4,
  46219. printClosingTagEnd: printClosingTagEnd$1,
  46220. needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$2,
  46221. needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$2,
  46222. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$3,
  46223. printOpeningTag: printOpeningTag$2,
  46224. printOpeningTagStart: printOpeningTagStart$1,
  46225. printOpeningTagPrefix: printOpeningTagPrefix$4,
  46226. printOpeningTagStartMarker: printOpeningTagStartMarker$1,
  46227. printOpeningTagEndMarker: printOpeningTagEndMarker$1,
  46228. needsToBorrowNextOpeningTagStartMarker: needsToBorrowNextOpeningTagStartMarker$1,
  46229. needsToBorrowParentOpeningTagEndMarker: needsToBorrowParentOpeningTagEndMarker$1
  46230. };
  46231. /**
  46232. * Srcset Parser
  46233. *
  46234. * By Alex Bell | MIT License
  46235. *
  46236. * JS Parser for the string value that appears in markup <img srcset="here">
  46237. *
  46238. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  46239. *
  46240. * Based super duper closely on the reference algorithm at:
  46241. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  46242. *
  46243. * Most comments are copied in directly from the spec
  46244. * (except for comments in parens).
  46245. */
  46246. var parseSrcset = createCommonjsModule(function (module) {
  46247. (function (root, factory) {
  46248. if (module.exports) {
  46249. // Node. Does not work with strict CommonJS, but
  46250. // only CommonJS-like environments that support module.exports,
  46251. // like Node.
  46252. module.exports = factory();
  46253. } else {
  46254. // Browser globals (root is window)
  46255. root.parseSrcset = factory();
  46256. }
  46257. })(this, function () {
  46258. // 1. Let input be the value passed to this algorithm.
  46259. return function (input, options) {
  46260. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  46261. // Manual is faster than RegEx
  46262. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  46263. // http://jsperf.com/whitespace-character/5
  46264. function isSpace(c) {
  46265. return c === "\u0020" || // space
  46266. c === "\u0009" || // horizontal tab
  46267. c === "\u000A" || // new line
  46268. c === "\u000C" || // form feed
  46269. c === "\u000D"; // carriage return
  46270. }
  46271. function collectCharacters(regEx) {
  46272. var chars,
  46273. match = regEx.exec(input.substring(pos));
  46274. if (match) {
  46275. chars = match[0];
  46276. pos += chars.length;
  46277. return chars;
  46278. }
  46279. }
  46280. var inputLength = input.length,
  46281. // (Don't use \s, to avoid matching non-breaking space)
  46282. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  46283. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  46284. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  46285. regexTrailingCommas = /[,]+$/,
  46286. regexNonNegativeInteger = /^\d+$/,
  46287. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  46288. // Must include at least one digit.
  46289. // According to spec tests any decimal point must be followed by a digit.
  46290. // No leading plus sign is allowed.)
  46291. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  46292. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  46293. url,
  46294. descriptors,
  46295. currentDescriptor,
  46296. state,
  46297. c,
  46298. // 2. Let position be a pointer into input, initially pointing at the start
  46299. // of the string.
  46300. pos = 0,
  46301. // 3. Let candidates be an initially empty source set.
  46302. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  46303. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  46304. // were collected, that is a parse error.
  46305. while (true) {
  46306. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  46307. if (pos >= inputLength) {
  46308. return candidates; // (we're done, this is the sole return path)
  46309. } // 6. Collect a sequence of characters that are not space characters,
  46310. // and let that be url.
  46311. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  46312. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  46313. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  46314. // more than one character, that is a parse error.
  46315. if (url.slice(-1) === ",") {
  46316. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  46317. parseDescriptors(); // Otherwise, follow these substeps:
  46318. } else {
  46319. tokenize();
  46320. } // (close else of step 8)
  46321. // 16. Return to the step labeled splitting loop.
  46322. } // (Close of big while loop.)
  46323. /**
  46324. * Tokenizes descriptor properties prior to parsing
  46325. * Returns undefined.
  46326. */
  46327. function tokenize() {
  46328. // 8.1. Descriptor tokeniser: Skip whitespace
  46329. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  46330. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  46331. state = "in descriptor";
  46332. while (true) {
  46333. // 8.4. Let c be the character at position.
  46334. c = input.charAt(pos); // Do the following depending on the value of state.
  46335. // For the purpose of this step, "EOF" is a special character representing
  46336. // that position is past the end of input.
  46337. // In descriptor
  46338. if (state === "in descriptor") {
  46339. // Do the following, depending on the value of c:
  46340. // Space character
  46341. // If current descriptor is not empty, append current descriptor to
  46342. // descriptors and let current descriptor be the empty string.
  46343. // Set state to after descriptor.
  46344. if (isSpace(c)) {
  46345. if (currentDescriptor) {
  46346. descriptors.push(currentDescriptor);
  46347. currentDescriptor = "";
  46348. state = "after descriptor";
  46349. } // U+002C COMMA (,)
  46350. // Advance position to the next character in input. If current descriptor
  46351. // is not empty, append current descriptor to descriptors. Jump to the step
  46352. // labeled descriptor parser.
  46353. } else if (c === ",") {
  46354. pos += 1;
  46355. if (currentDescriptor) {
  46356. descriptors.push(currentDescriptor);
  46357. }
  46358. parseDescriptors();
  46359. return; // U+0028 LEFT PARENTHESIS (()
  46360. // Append c to current descriptor. Set state to in parens.
  46361. } else if (c === "\u0028") {
  46362. currentDescriptor = currentDescriptor + c;
  46363. state = "in parens"; // EOF
  46364. // If current descriptor is not empty, append current descriptor to
  46365. // descriptors. Jump to the step labeled descriptor parser.
  46366. } else if (c === "") {
  46367. if (currentDescriptor) {
  46368. descriptors.push(currentDescriptor);
  46369. }
  46370. parseDescriptors();
  46371. return; // Anything else
  46372. // Append c to current descriptor.
  46373. } else {
  46374. currentDescriptor = currentDescriptor + c;
  46375. } // (end "in descriptor"
  46376. // In parens
  46377. } else if (state === "in parens") {
  46378. // U+0029 RIGHT PARENTHESIS ())
  46379. // Append c to current descriptor. Set state to in descriptor.
  46380. if (c === ")") {
  46381. currentDescriptor = currentDescriptor + c;
  46382. state = "in descriptor"; // EOF
  46383. // Append current descriptor to descriptors. Jump to the step labeled
  46384. // descriptor parser.
  46385. } else if (c === "") {
  46386. descriptors.push(currentDescriptor);
  46387. parseDescriptors();
  46388. return; // Anything else
  46389. // Append c to current descriptor.
  46390. } else {
  46391. currentDescriptor = currentDescriptor + c;
  46392. } // After descriptor
  46393. } else if (state === "after descriptor") {
  46394. // Do the following, depending on the value of c:
  46395. // Space character: Stay in this state.
  46396. if (isSpace(c)) ; else if (c === "") {
  46397. parseDescriptors();
  46398. return; // Anything else
  46399. // Set state to in descriptor. Set position to the previous character in input.
  46400. } else {
  46401. state = "in descriptor";
  46402. pos -= 1;
  46403. }
  46404. } // Advance position to the next character in input.
  46405. pos += 1; // Repeat this step.
  46406. } // (close while true loop)
  46407. }
  46408. /**
  46409. * Adds descriptor properties to a candidate, pushes to the candidates array
  46410. * @return undefined
  46411. */
  46412. // Declared outside of the while loop so that it's only created once.
  46413. function parseDescriptors() {
  46414. // 9. Descriptor parser: Let error be no.
  46415. var pError = false,
  46416. // 10. Let width be absent.
  46417. // 11. Let density be absent.
  46418. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  46419. w,
  46420. d,
  46421. h,
  46422. i,
  46423. candidate = {},
  46424. desc,
  46425. lastChar,
  46426. value,
  46427. intVal,
  46428. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  46429. // from the following list:
  46430. for (i = 0; i < descriptors.length; i++) {
  46431. desc = descriptors[i];
  46432. lastChar = desc[desc.length - 1];
  46433. value = desc.substring(0, desc.length - 1);
  46434. intVal = parseInt(value, 10);
  46435. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  46436. // a U+0077 LATIN SMALL LETTER W character
  46437. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  46438. // If width and density are not both absent, then let error be yes.
  46439. if (w || d) {
  46440. pError = true;
  46441. } // Apply the rules for parsing non-negative integers to the descriptor.
  46442. // If the result is zero, let error be yes.
  46443. // Otherwise, let width be the result.
  46444. if (intVal === 0) {
  46445. pError = true;
  46446. } else {
  46447. w = intVal;
  46448. } // If the descriptor consists of a valid floating-point number followed by
  46449. // a U+0078 LATIN SMALL LETTER X character
  46450. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  46451. // If width, density and future-compat-h are not all absent, then let error
  46452. // be yes.
  46453. if (w || d || h) {
  46454. pError = true;
  46455. } // Apply the rules for parsing floating-point number values to the descriptor.
  46456. // If the result is less than zero, let error be yes. Otherwise, let density
  46457. // be the result.
  46458. if (floatVal < 0) {
  46459. pError = true;
  46460. } else {
  46461. d = floatVal;
  46462. } // If the descriptor consists of a valid non-negative integer followed by
  46463. // a U+0068 LATIN SMALL LETTER H character
  46464. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  46465. // If height and density are not both absent, then let error be yes.
  46466. if (h || d) {
  46467. pError = true;
  46468. } // Apply the rules for parsing non-negative integers to the descriptor.
  46469. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  46470. // be the result.
  46471. if (intVal === 0) {
  46472. pError = true;
  46473. } else {
  46474. h = intVal;
  46475. } // Anything else, Let error be yes.
  46476. } else {
  46477. pError = true;
  46478. }
  46479. } // (close step 13 for loop)
  46480. // 15. If error is still no, then append a new image source to candidates whose
  46481. // URL is url, associated with a width width if not absent and a pixel
  46482. // density density if not absent. Otherwise, there is a parse error.
  46483. if (!pError) {
  46484. candidate.url = url;
  46485. if (w) {
  46486. candidate.w = w;
  46487. }
  46488. if (d) {
  46489. candidate.d = d;
  46490. }
  46491. if (h) {
  46492. candidate.h = h;
  46493. }
  46494. candidates.push(candidate);
  46495. } else if (logger && logger.error) {
  46496. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  46497. }
  46498. } // (close parseDescriptors fn)
  46499. };
  46500. });
  46501. });
  46502. const {
  46503. builders: {
  46504. group: group$7,
  46505. ifBreak: ifBreak$4,
  46506. indent: indent$2,
  46507. join: join$4,
  46508. line: line$7,
  46509. softline: softline$5
  46510. }
  46511. } = doc;
  46512. function printImgSrcset$1(value) {
  46513. const srcset = parseSrcset(value, {
  46514. logger: {
  46515. error(message) {
  46516. throw new Error(message);
  46517. }
  46518. }
  46519. });
  46520. const hasW = srcset.some(({
  46521. w
  46522. }) => w);
  46523. const hasH = srcset.some(({
  46524. h
  46525. }) => h);
  46526. const hasX = srcset.some(({
  46527. d
  46528. }) => d);
  46529. if (hasW + hasH + hasX > 1) {
  46530. throw new Error("Mixed descriptor in srcset is not supported");
  46531. }
  46532. const key = hasW ? "w" : hasH ? "h" : "d";
  46533. const unit = hasW ? "w" : hasH ? "h" : "x";
  46534. const getMax = values => Math.max(...values);
  46535. const urls = srcset.map(src => src.url);
  46536. const maxUrlLength = getMax(urls.map(url => url.length));
  46537. const descriptors = srcset.map(src => src[key]).map(descriptor => descriptor ? descriptor.toString() : "");
  46538. const descriptorLeftLengths = descriptors.map(descriptor => {
  46539. const index = descriptor.indexOf(".");
  46540. return index === -1 ? descriptor.length : index;
  46541. });
  46542. const maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  46543. return join$4([",", line$7], urls.map((url, index) => {
  46544. const parts = [url];
  46545. const descriptor = descriptors[index];
  46546. if (descriptor) {
  46547. const urlPadding = maxUrlLength - url.length + 1;
  46548. const descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  46549. const alignment = " ".repeat(urlPadding + descriptorPadding);
  46550. parts.push(ifBreak$4(alignment, " "), descriptor + unit);
  46551. }
  46552. return parts;
  46553. }));
  46554. }
  46555. const prefixDelimiters = [":", "__", "--", "_", "-"];
  46556. function getClassPrefix(className) {
  46557. const startIndex = className.search(/[^_-]/);
  46558. if (startIndex !== -1) {
  46559. for (const delimiter of prefixDelimiters) {
  46560. const delimiterIndex = className.indexOf(delimiter, startIndex);
  46561. if (delimiterIndex !== -1) {
  46562. return className.slice(0, delimiterIndex);
  46563. }
  46564. }
  46565. }
  46566. return className;
  46567. }
  46568. function printClassNames$1(value) {
  46569. const classNames = value.trim().split(/\s+/); // Try keeping consecutive classes with the same prefix on one line.
  46570. const groupedByPrefix = [];
  46571. let previousPrefix;
  46572. for (let i = 0; i < classNames.length; i++) {
  46573. const prefix = getClassPrefix(classNames[i]);
  46574. if (prefix !== previousPrefix && // "home-link" and "home-link_blue_yes" should be considered same-prefix
  46575. prefix !== classNames[i - 1]) {
  46576. groupedByPrefix.push([]);
  46577. }
  46578. getLast_1(groupedByPrefix).push(classNames[i]);
  46579. previousPrefix = prefix;
  46580. }
  46581. return [indent$2([softline$5, join$4(line$7, groupedByPrefix.map(classNames => group$7(join$4(line$7, classNames))))]), softline$5];
  46582. }
  46583. var syntaxAttribute = {
  46584. printImgSrcset: printImgSrcset$1,
  46585. printClassNames: printClassNames$1
  46586. };
  46587. const {
  46588. builders: {
  46589. group: group$6
  46590. }
  46591. } = doc;
  46592. /**
  46593. * v-for="... in ..."
  46594. * v-for="... of ..."
  46595. * v-for="(..., ...) in ..."
  46596. * v-for="(..., ...) of ..."
  46597. */
  46598. function printVueFor$1(value, textToDoc) {
  46599. const {
  46600. left,
  46601. operator,
  46602. right
  46603. } = parseVueFor(value);
  46604. return [group$6(textToDoc(`function _(${left}) {}`, {
  46605. parser: "babel",
  46606. __isVueForBindingLeft: true
  46607. })), " ", operator, " ", textToDoc(right, {
  46608. parser: "__js_expression"
  46609. }, {
  46610. stripTrailingHardline: true
  46611. })];
  46612. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  46613. function parseVueFor(value) {
  46614. const forAliasRE = /(.*?)\s+(in|of)\s+(.*)/s;
  46615. const forIteratorRE = /,([^,\]}]*)(?:,([^,\]}]*))?$/;
  46616. const stripParensRE = /^\(|\)$/g;
  46617. const inMatch = value.match(forAliasRE);
  46618. if (!inMatch) {
  46619. return;
  46620. }
  46621. const res = {};
  46622. res.for = inMatch[3].trim();
  46623. const alias = inMatch[1].trim().replace(stripParensRE, "");
  46624. const iteratorMatch = alias.match(forIteratorRE);
  46625. if (iteratorMatch) {
  46626. res.alias = alias.replace(forIteratorRE, "");
  46627. res.iterator1 = iteratorMatch[1].trim();
  46628. if (iteratorMatch[2]) {
  46629. res.iterator2 = iteratorMatch[2].trim();
  46630. }
  46631. } else {
  46632. res.alias = alias;
  46633. }
  46634. return {
  46635. left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
  46636. operator: inMatch[2],
  46637. right: res.for
  46638. };
  46639. }
  46640. function printVueBindings$1(value, textToDoc) {
  46641. return textToDoc(`function _(${value}) {}`, {
  46642. parser: "babel",
  46643. __isVueBindings: true
  46644. });
  46645. }
  46646. function isVueEventBindingExpression$1(eventBindingValue) {
  46647. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  46648. // arrow function or anonymous function
  46649. const fnExpRE = /^(?:[\w$]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  46650. const simplePathRE = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
  46651. const value = eventBindingValue.trim();
  46652. return fnExpRE.test(value) || simplePathRE.test(value);
  46653. }
  46654. var syntaxVue = {
  46655. isVueEventBindingExpression: isVueEventBindingExpression$1,
  46656. printVueFor: printVueFor$1,
  46657. printVueBindings: printVueBindings$1
  46658. };
  46659. const {
  46660. needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$1,
  46661. printClosingTagStartMarker,
  46662. needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$1,
  46663. printClosingTagEndMarker: printClosingTagEndMarker$1,
  46664. needsToBorrowParentOpeningTagEndMarker,
  46665. printOpeningTagEndMarker
  46666. } = tag;
  46667. function getNodeContent(node, options) {
  46668. let start = node.startSourceSpan.end.offset;
  46669. if (node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild)) {
  46670. start -= printOpeningTagEndMarker(node).length;
  46671. }
  46672. let end = node.endSourceSpan.start.offset;
  46673. if (node.lastChild && needsToBorrowParentClosingTagStartMarker$1(node.lastChild)) {
  46674. end += printClosingTagStartMarker(node, options).length;
  46675. } else if (needsToBorrowLastChildClosingTagEndMarker$1(node)) {
  46676. end -= printClosingTagEndMarker$1(node.lastChild, options).length;
  46677. }
  46678. return options.originalText.slice(start, end);
  46679. }
  46680. var getNodeContent_1 = getNodeContent;
  46681. const {
  46682. builders: {
  46683. breakParent: breakParent$3,
  46684. group: group$5,
  46685. hardline: hardline$6,
  46686. indent: indent$1,
  46687. line: line$6,
  46688. fill: fill$3,
  46689. softline: softline$4
  46690. },
  46691. utils: {
  46692. mapDoc,
  46693. replaceTextEndOfLine: replaceTextEndOfLine$4
  46694. }
  46695. } = doc;
  46696. const {
  46697. printClosingTag: printClosingTag$1,
  46698. printClosingTagSuffix: printClosingTagSuffix$3,
  46699. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$2,
  46700. printOpeningTagPrefix: printOpeningTagPrefix$3,
  46701. printOpeningTag: printOpeningTag$1
  46702. } = tag;
  46703. const {
  46704. printImgSrcset,
  46705. printClassNames
  46706. } = syntaxAttribute;
  46707. const {
  46708. printVueFor,
  46709. printVueBindings,
  46710. isVueEventBindingExpression
  46711. } = syntaxVue;
  46712. const {
  46713. isScriptLikeTag: isScriptLikeTag$1,
  46714. isVueNonHtmlBlock,
  46715. inferScriptParser,
  46716. htmlTrimPreserveIndentation,
  46717. dedentString,
  46718. unescapeQuoteEntities: unescapeQuoteEntities$1,
  46719. isVueSlotAttribute,
  46720. isVueSfcBindingsAttribute,
  46721. getTextValueParts: getTextValueParts$1
  46722. } = utils$1;
  46723. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  46724. const isKeyMatched = patterns => new RegExp(patterns.join("|")).test(node.fullName);
  46725. const getValue = () => unescapeQuoteEntities$1(node.value);
  46726. let shouldHug = false;
  46727. const __onHtmlBindingRoot = (root, options) => {
  46728. const rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
  46729. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression" || options.parser === "__vue_expression" && (rootNode.type === "TemplateLiteral" || rootNode.type === "StringLiteral"))) {
  46730. shouldHug = true;
  46731. }
  46732. };
  46733. const printHug = doc => group$5(doc);
  46734. const printExpand = (doc, canHaveTrailingWhitespace = true) => group$5([indent$1([softline$4, doc]), canHaveTrailingWhitespace ? softline$4 : ""]);
  46735. const printMaybeHug = doc => shouldHug ? printHug(doc) : printExpand(doc);
  46736. const attributeTextToDoc = (code, opts) => originalTextToDoc(code, Object.assign({
  46737. __onHtmlBindingRoot,
  46738. __embeddedInHtml: true
  46739. }, opts), {
  46740. stripTrailingHardline: true
  46741. });
  46742. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  46743. return printExpand(printImgSrcset(getValue()));
  46744. }
  46745. if (node.fullName === "class" && !options.parentParser) {
  46746. const value = getValue();
  46747. if (!value.includes("{{")) {
  46748. return printClassNames(value);
  46749. }
  46750. }
  46751. if (node.fullName === "style" && !options.parentParser) {
  46752. const value = getValue();
  46753. if (!value.includes("{{")) {
  46754. return printExpand(attributeTextToDoc(value, {
  46755. parser: "css",
  46756. __isHTMLStyleAttribute: true
  46757. }));
  46758. }
  46759. }
  46760. if (options.parser === "vue") {
  46761. if (node.fullName === "v-for") {
  46762. return printVueFor(getValue(), attributeTextToDoc);
  46763. }
  46764. if (isVueSlotAttribute(node) || isVueSfcBindingsAttribute(node, options)) {
  46765. return printVueBindings(getValue(), attributeTextToDoc);
  46766. }
  46767. /**
  46768. * @click="jsStatement"
  46769. * @click="jsExpression"
  46770. * v-on:click="jsStatement"
  46771. * v-on:click="jsExpression"
  46772. */
  46773. const vueEventBindingPatterns = ["^@", "^v-on:"];
  46774. /**
  46775. * :class="vueExpression"
  46776. * v-bind:id="vueExpression"
  46777. */
  46778. const vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  46779. /**
  46780. * v-if="jsExpression"
  46781. */
  46782. const jsExpressionBindingPatterns = ["^v-"];
  46783. if (isKeyMatched(vueEventBindingPatterns)) {
  46784. const value = getValue();
  46785. return printMaybeHug(attributeTextToDoc(value, {
  46786. parser: isVueEventBindingExpression(value) ? "__js_expression" : "__vue_event_binding"
  46787. }));
  46788. }
  46789. if (isKeyMatched(vueExpressionBindingPatterns)) {
  46790. return printMaybeHug(attributeTextToDoc(getValue(), {
  46791. parser: "__vue_expression"
  46792. }));
  46793. }
  46794. if (isKeyMatched(jsExpressionBindingPatterns)) {
  46795. return printMaybeHug(attributeTextToDoc(getValue(), {
  46796. parser: "__js_expression"
  46797. }));
  46798. }
  46799. }
  46800. if (options.parser === "angular") {
  46801. const ngTextToDoc = (code, opts) => // angular does not allow trailing comma
  46802. attributeTextToDoc(code, Object.assign(Object.assign({}, opts), {}, {
  46803. trailingComma: "none"
  46804. }));
  46805. /**
  46806. * *directive="angularDirective"
  46807. */
  46808. const ngDirectiveBindingPatterns = ["^\\*"];
  46809. /**
  46810. * (click)="angularStatement"
  46811. * on-click="angularStatement"
  46812. */
  46813. const ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  46814. /**
  46815. * [target]="angularExpression"
  46816. * bind-target="angularExpression"
  46817. * [(target)]="angularExpression"
  46818. * bindon-target="angularExpression"
  46819. */
  46820. const ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-", // Unofficial rudimentary support for some of the most used directives of AngularJS 1.x
  46821. "^ng-(if|show|hide|class|style)$"];
  46822. /**
  46823. * i18n="longDescription"
  46824. * i18n-attr="longDescription"
  46825. */
  46826. const ngI18nPatterns = ["^i18n(-.+)?$"];
  46827. if (isKeyMatched(ngStatementBindingPatterns)) {
  46828. return printMaybeHug(ngTextToDoc(getValue(), {
  46829. parser: "__ng_action"
  46830. }));
  46831. }
  46832. if (isKeyMatched(ngExpressionBindingPatterns)) {
  46833. return printMaybeHug(ngTextToDoc(getValue(), {
  46834. parser: "__ng_binding"
  46835. }));
  46836. }
  46837. if (isKeyMatched(ngI18nPatterns)) {
  46838. const value = getValue().trim();
  46839. return printExpand(fill$3(getTextValueParts$1(node, value)), !value.includes("@@"));
  46840. }
  46841. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  46842. return printMaybeHug(ngTextToDoc(getValue(), {
  46843. parser: "__ng_directive"
  46844. }));
  46845. }
  46846. const interpolationRegex = /{{(.+?)}}/s;
  46847. const value = getValue();
  46848. if (interpolationRegex.test(value)) {
  46849. const parts = [];
  46850. for (const [index, part] of value.split(interpolationRegex).entries()) {
  46851. if (index % 2 === 0) {
  46852. parts.push(replaceTextEndOfLine$4(part));
  46853. } else {
  46854. try {
  46855. parts.push(group$5(["{{", indent$1([line$6, ngTextToDoc(part, {
  46856. parser: "__ng_interpolation",
  46857. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  46858. })]), line$6, "}}"]));
  46859. } catch {
  46860. parts.push("{{", replaceTextEndOfLine$4(part), "}}");
  46861. }
  46862. }
  46863. }
  46864. return group$5(parts);
  46865. }
  46866. }
  46867. return null;
  46868. }
  46869. function embed$1(path, print, textToDoc, options) {
  46870. const node = path.getValue();
  46871. switch (node.type) {
  46872. case "element":
  46873. {
  46874. if (isScriptLikeTag$1(node) || node.type === "interpolation") {
  46875. // Fall through to "text"
  46876. return;
  46877. }
  46878. if (!node.isSelfClosing && isVueNonHtmlBlock(node, options)) {
  46879. const parser = inferScriptParser(node, options);
  46880. if (!parser) {
  46881. return;
  46882. }
  46883. const content = getNodeContent_1(node, options);
  46884. let isEmpty = /^\s*$/.test(content);
  46885. let doc = "";
  46886. if (!isEmpty) {
  46887. doc = textToDoc(htmlTrimPreserveIndentation(content), {
  46888. parser,
  46889. __embeddedInHtml: true
  46890. }, {
  46891. stripTrailingHardline: true
  46892. });
  46893. isEmpty = doc === "";
  46894. }
  46895. return [printOpeningTagPrefix$3(node, options), group$5(printOpeningTag$1(path, options, print)), isEmpty ? "" : hardline$6, doc, isEmpty ? "" : hardline$6, printClosingTag$1(node, options), printClosingTagSuffix$3(node, options)];
  46896. }
  46897. break;
  46898. }
  46899. case "text":
  46900. {
  46901. if (isScriptLikeTag$1(node.parent)) {
  46902. const parser = inferScriptParser(node.parent);
  46903. if (parser) {
  46904. const value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  46905. const textToDocOptions = {
  46906. parser,
  46907. __embeddedInHtml: true
  46908. };
  46909. if (options.parser === "html" && parser === "babel") {
  46910. let sourceType = "script";
  46911. const {
  46912. attrMap
  46913. } = node.parent;
  46914. if (attrMap && (attrMap.type === "module" || attrMap.type === "text/babel" && attrMap["data-type"] === "module")) {
  46915. sourceType = "module";
  46916. }
  46917. textToDocOptions.__babelSourceType = sourceType;
  46918. }
  46919. return [breakParent$3, printOpeningTagPrefix$3(node, options), textToDoc(value, textToDocOptions, {
  46920. stripTrailingHardline: true
  46921. }), printClosingTagSuffix$3(node, options)];
  46922. }
  46923. } else if (node.parent.type === "interpolation") {
  46924. const textToDocOptions = {
  46925. __isInHtmlInterpolation: true,
  46926. // to avoid unexpected `}}`
  46927. __embeddedInHtml: true
  46928. };
  46929. if (options.parser === "angular") {
  46930. textToDocOptions.parser = "__ng_interpolation";
  46931. textToDocOptions.trailingComma = "none";
  46932. } else if (options.parser === "vue") {
  46933. textToDocOptions.parser = "__vue_expression";
  46934. } else {
  46935. textToDocOptions.parser = "__js_expression";
  46936. }
  46937. return [indent$1([line$6, textToDoc(node.value, textToDocOptions, {
  46938. stripTrailingHardline: true
  46939. })]), node.parent.next && needsToBorrowPrevClosingTagEndMarker$2(node.parent.next) ? " " : line$6];
  46940. }
  46941. break;
  46942. }
  46943. case "attribute":
  46944. {
  46945. if (!node.value) {
  46946. break;
  46947. } // lit-html: html`<my-element obj=${obj}></my-element>`
  46948. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  46949. return [node.rawName, "=", node.value];
  46950. } // lwc: html`<my-element data-for={value}></my-element>`
  46951. if (options.parser === "lwc") {
  46952. const interpolationRegex = /^{.*}$/s;
  46953. if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  46954. return [node.rawName, "=", node.value];
  46955. }
  46956. }
  46957. const embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, (code, opts) => // strictly prefer single quote to avoid unnecessary html entity escape
  46958. textToDoc(code, Object.assign({
  46959. __isInHtmlAttribute: true,
  46960. __embeddedInHtml: true
  46961. }, opts), {
  46962. stripTrailingHardline: true
  46963. }), options);
  46964. if (embeddedAttributeValueDoc) {
  46965. return [node.rawName, '="', group$5(mapDoc(embeddedAttributeValueDoc, doc => typeof doc === "string" ? doc.replace(/"/g, "&quot;") : doc)), '"'];
  46966. }
  46967. break;
  46968. }
  46969. case "front-matter":
  46970. return print_1(node, textToDoc);
  46971. }
  46972. }
  46973. var embed_1$1 = embed$1;
  46974. const {
  46975. builders: {
  46976. breakParent: breakParent$2,
  46977. group: group$4,
  46978. ifBreak: ifBreak$3,
  46979. line: line$5,
  46980. softline: softline$3,
  46981. hardline: hardline$5
  46982. },
  46983. utils: {
  46984. replaceTextEndOfLine: replaceTextEndOfLine$3
  46985. }
  46986. } = doc;
  46987. const {
  46988. locStart: locStart$3,
  46989. locEnd: locEnd$2
  46990. } = loc$1;
  46991. const {
  46992. forceBreakChildren,
  46993. forceNextEmptyLine,
  46994. isTextLikeNode,
  46995. hasPrettierIgnore: hasPrettierIgnore$2,
  46996. preferHardlineAsLeadingSpaces
  46997. } = utils$1;
  46998. const {
  46999. printOpeningTagPrefix: printOpeningTagPrefix$2,
  47000. needsToBorrowNextOpeningTagStartMarker,
  47001. printOpeningTagStartMarker,
  47002. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$1,
  47003. printClosingTagEndMarker,
  47004. printClosingTagSuffix: printClosingTagSuffix$2,
  47005. needsToBorrowParentClosingTagStartMarker
  47006. } = tag;
  47007. function printChild(childPath, options, print) {
  47008. const child = childPath.getValue();
  47009. if (hasPrettierIgnore$2(child)) {
  47010. return [printOpeningTagPrefix$2(child, options), ...replaceTextEndOfLine$3(options.originalText.slice(locStart$3(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), locEnd$2(child) - (child.next && needsToBorrowPrevClosingTagEndMarker$1(child.next) ? printClosingTagEndMarker(child, options).length : 0))), printClosingTagSuffix$2(child, options)];
  47011. }
  47012. return print();
  47013. }
  47014. function printBetweenLine(prevNode, nextNode) {
  47015. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : line$5 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : softline$3 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (hasPrettierIgnore$2(nextNode) ||
  47016. /**
  47017. * 123<a
  47018. * ~
  47019. * ><b>
  47020. */
  47021. nextNode.firstChild ||
  47022. /**
  47023. * 123<!--
  47024. * ~
  47025. * -->
  47026. */
  47027. nextNode.isSelfClosing || nextNode.type === "element" && nextNode.attrs.length > 0) || prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker$1(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) || needsToBorrowPrevClosingTagEndMarker$1(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$5 : nextNode.hasLeadingSpaces ? line$5 : softline$3;
  47028. }
  47029. function printChildren$3(path, options, print) {
  47030. const node = path.getValue();
  47031. if (forceBreakChildren(node)) {
  47032. return [breakParent$2, ...path.map(childPath => {
  47033. const childNode = childPath.getValue();
  47034. const prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  47035. return [!prevBetweenLine ? "" : [prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$5 : ""], printChild(childPath, options, print)];
  47036. }, "children")];
  47037. }
  47038. const groupIds = node.children.map(() => Symbol(""));
  47039. return path.map((childPath, childIndex) => {
  47040. const childNode = childPath.getValue();
  47041. if (isTextLikeNode(childNode)) {
  47042. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  47043. const prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  47044. if (prevBetweenLine) {
  47045. if (forceNextEmptyLine(childNode.prev)) {
  47046. return [hardline$5, hardline$5, printChild(childPath, options, print)];
  47047. }
  47048. return [prevBetweenLine, printChild(childPath, options, print)];
  47049. }
  47050. }
  47051. return printChild(childPath, options, print);
  47052. }
  47053. const prevParts = [];
  47054. const leadingParts = [];
  47055. const trailingParts = [];
  47056. const nextParts = [];
  47057. const prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  47058. const nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  47059. if (prevBetweenLine) {
  47060. if (forceNextEmptyLine(childNode.prev)) {
  47061. prevParts.push(hardline$5, hardline$5);
  47062. } else if (prevBetweenLine === hardline$5) {
  47063. prevParts.push(hardline$5);
  47064. } else {
  47065. if (isTextLikeNode(childNode.prev)) {
  47066. leadingParts.push(prevBetweenLine);
  47067. } else {
  47068. leadingParts.push(ifBreak$3("", softline$3, {
  47069. groupId: groupIds[childIndex - 1]
  47070. }));
  47071. }
  47072. }
  47073. }
  47074. if (nextBetweenLine) {
  47075. if (forceNextEmptyLine(childNode)) {
  47076. if (isTextLikeNode(childNode.next)) {
  47077. nextParts.push(hardline$5, hardline$5);
  47078. }
  47079. } else if (nextBetweenLine === hardline$5) {
  47080. if (isTextLikeNode(childNode.next)) {
  47081. nextParts.push(hardline$5);
  47082. }
  47083. } else {
  47084. trailingParts.push(nextBetweenLine);
  47085. }
  47086. }
  47087. return [...prevParts, group$4([...leadingParts, group$4([printChild(childPath, options, print), ...trailingParts], {
  47088. id: groupIds[childIndex]
  47089. })]), ...nextParts];
  47090. }, "children");
  47091. }
  47092. var children = {
  47093. printChildren: printChildren$3
  47094. };
  47095. const {
  47096. builders: {
  47097. breakParent: breakParent$1,
  47098. dedentToRoot: dedentToRoot$1,
  47099. group: group$3,
  47100. ifBreak: ifBreak$2,
  47101. indentIfBreak,
  47102. indent,
  47103. line: line$4,
  47104. softline: softline$2
  47105. },
  47106. utils: {
  47107. replaceTextEndOfLine: replaceTextEndOfLine$2
  47108. }
  47109. } = doc;
  47110. const {
  47111. shouldPreserveContent,
  47112. isScriptLikeTag,
  47113. isVueCustomBlock,
  47114. countParents,
  47115. forceBreakContent
  47116. } = utils$1;
  47117. const {
  47118. printOpeningTagPrefix: printOpeningTagPrefix$1,
  47119. printOpeningTag,
  47120. printClosingTagSuffix: printClosingTagSuffix$1,
  47121. printClosingTag,
  47122. needsToBorrowPrevClosingTagEndMarker,
  47123. needsToBorrowLastChildClosingTagEndMarker
  47124. } = tag;
  47125. const {
  47126. printChildren: printChildren$2
  47127. } = children;
  47128. function printElement$1(path, options, print) {
  47129. const node = path.getValue();
  47130. if (shouldPreserveContent(node, options)) {
  47131. return [printOpeningTagPrefix$1(node, options), group$3(printOpeningTag(path, options, print)), ...replaceTextEndOfLine$2(getNodeContent_1(node, options)), ...printClosingTag(node, options), printClosingTagSuffix$1(node, options)];
  47132. }
  47133. /**
  47134. * do not break:
  47135. *
  47136. * <div>{{
  47137. * ~
  47138. * interpolation
  47139. * }}</div>
  47140. * ~
  47141. *
  47142. * exception: break if the opening tag breaks
  47143. *
  47144. * <div
  47145. * long
  47146. * ~
  47147. * >{{
  47148. * interpolation
  47149. * }}</div
  47150. * ~
  47151. * >
  47152. */
  47153. const shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  47154. const attrGroupId = Symbol("element-attr-group-id");
  47155. const printTag = doc => group$3([group$3(printOpeningTag(path, options, print), {
  47156. id: attrGroupId
  47157. }), doc, printClosingTag(node, options)]);
  47158. const printChildrenDoc = childrenDoc => {
  47159. if (shouldHugContent) {
  47160. return indentIfBreak(childrenDoc, {
  47161. groupId: attrGroupId
  47162. });
  47163. }
  47164. if ((isScriptLikeTag(node) || isVueCustomBlock(node, options)) && node.parent.type === "root" && options.parser === "vue" && !options.vueIndentScriptAndStyle) {
  47165. return childrenDoc;
  47166. }
  47167. return indent(childrenDoc);
  47168. };
  47169. const printLineBeforeChildren = () => {
  47170. if (shouldHugContent) {
  47171. return ifBreak$2(softline$2, "", {
  47172. groupId: attrGroupId
  47173. });
  47174. }
  47175. if (node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive) {
  47176. return line$4;
  47177. }
  47178. if (node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) {
  47179. return dedentToRoot$1(softline$2);
  47180. }
  47181. return softline$2;
  47182. };
  47183. const printLineAfterChildren = () => {
  47184. const needsToBorrow = node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent);
  47185. if (needsToBorrow) {
  47186. if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
  47187. return " ";
  47188. }
  47189. return "";
  47190. }
  47191. if (shouldHugContent) {
  47192. return ifBreak$2(softline$2, "", {
  47193. groupId: attrGroupId
  47194. });
  47195. }
  47196. if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
  47197. return line$4;
  47198. }
  47199. if ((node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n[\\t ]{${options.tabWidth * countParents(path, node => node.parent && node.parent.type !== "root")}}$`).test(node.lastChild.value)) {
  47200. return "";
  47201. }
  47202. return softline$2;
  47203. };
  47204. if (node.children.length === 0) {
  47205. return printTag(node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$4 : "");
  47206. }
  47207. return printTag([forceBreakContent(node) ? breakParent$1 : "", printChildrenDoc([printLineBeforeChildren(), printChildren$2(path, options, print)]), printLineAfterChildren()]);
  47208. }
  47209. var element = {
  47210. printElement: printElement$1
  47211. };
  47212. /**
  47213. * @typedef {import("../document").Doc} Doc
  47214. */
  47215. const {
  47216. builders: {
  47217. fill: fill$2,
  47218. group: group$2,
  47219. hardline: hardline$4,
  47220. literalline: literalline$2
  47221. },
  47222. utils: {
  47223. cleanDoc,
  47224. getDocParts: getDocParts$2,
  47225. isConcat,
  47226. replaceTextEndOfLine: replaceTextEndOfLine$1
  47227. }
  47228. } = doc;
  47229. const {
  47230. countChars,
  47231. unescapeQuoteEntities,
  47232. getTextValueParts
  47233. } = utils$1;
  47234. const {
  47235. insertPragma: insertPragma$2
  47236. } = pragma$1;
  47237. const {
  47238. locStart: locStart$2,
  47239. locEnd: locEnd$1
  47240. } = loc$1;
  47241. const {
  47242. printClosingTagSuffix,
  47243. printClosingTagEnd,
  47244. printOpeningTagPrefix,
  47245. printOpeningTagStart
  47246. } = tag;
  47247. const {
  47248. printElement
  47249. } = element;
  47250. const {
  47251. printChildren: printChildren$1
  47252. } = children;
  47253. function genericPrint$1(path, options, print) {
  47254. const node = path.getValue();
  47255. switch (node.type) {
  47256. case "front-matter":
  47257. return replaceTextEndOfLine$1(node.raw);
  47258. case "root":
  47259. if (options.__onHtmlRoot) {
  47260. options.__onHtmlRoot(node);
  47261. } // use original concat to not break stripTrailingHardline
  47262. return [group$2(printChildren$1(path, options, print)), hardline$4];
  47263. case "element":
  47264. case "ieConditionalComment":
  47265. {
  47266. return printElement(path, options, print);
  47267. }
  47268. case "ieConditionalStartComment":
  47269. case "ieConditionalEndComment":
  47270. return [printOpeningTagStart(node), printClosingTagEnd(node)];
  47271. case "interpolation":
  47272. return [printOpeningTagStart(node, options), ...path.map(print, "children"), printClosingTagEnd(node, options)];
  47273. case "text":
  47274. {
  47275. if (node.parent.type === "interpolation") {
  47276. // replace the trailing literalline with hardline for better readability
  47277. const trailingNewlineRegex = /\n[^\S\n]*?$/;
  47278. const hasTrailingNewline = trailingNewlineRegex.test(node.value);
  47279. const value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  47280. return [...replaceTextEndOfLine$1(value), hasTrailingNewline ? hardline$4 : ""];
  47281. }
  47282. const printed = cleanDoc([printOpeningTagPrefix(node, options), ...getTextValueParts(node), printClosingTagSuffix(node, options)]);
  47283. if (isConcat(printed) || printed.type === "fill") {
  47284. return fill$2(getDocParts$2(printed));
  47285. }
  47286. /* istanbul ignore next */
  47287. return printed;
  47288. }
  47289. case "docType":
  47290. return [group$2([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")]), printClosingTagEnd(node, options)];
  47291. case "comment":
  47292. {
  47293. return [printOpeningTagPrefix(node, options), ...replaceTextEndOfLine$1(options.originalText.slice(locStart$2(node), locEnd$1(node)), literalline$2), printClosingTagSuffix(node, options)];
  47294. }
  47295. case "attribute":
  47296. {
  47297. if (node.value === null) {
  47298. return node.rawName;
  47299. }
  47300. const value = unescapeQuoteEntities(node.value);
  47301. const singleQuoteCount = countChars(value, "'");
  47302. const doubleQuoteCount = countChars(value, '"');
  47303. const quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  47304. return [node.rawName, "=", quote, ...replaceTextEndOfLine$1(quote === '"' ? value.replace(/"/g, "&quot;") : value.replace(/'/g, "&apos;")), quote];
  47305. }
  47306. default:
  47307. /* istanbul ignore next */
  47308. throw new Error(`Unexpected node type ${node.type}`);
  47309. }
  47310. }
  47311. var printerHtml = {
  47312. preprocess: printPreprocess$1,
  47313. print: genericPrint$1,
  47314. insertPragma: insertPragma$2,
  47315. massageAstNode: clean_1,
  47316. embed: embed_1$1
  47317. };
  47318. const CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  47319. var options$1 = {
  47320. bracketSameLine: commonOptions.bracketSameLine,
  47321. htmlWhitespaceSensitivity: {
  47322. since: "1.15.0",
  47323. category: CATEGORY_HTML,
  47324. type: "choice",
  47325. default: "css",
  47326. description: "How to handle whitespaces in HTML.",
  47327. choices: [{
  47328. value: "css",
  47329. description: "Respect the default value of CSS display property."
  47330. }, {
  47331. value: "strict",
  47332. description: "Whitespaces are considered sensitive."
  47333. }, {
  47334. value: "ignore",
  47335. description: "Whitespaces are considered insensitive."
  47336. }]
  47337. },
  47338. vueIndentScriptAndStyle: {
  47339. since: "1.19.0",
  47340. category: CATEGORY_HTML,
  47341. type: "boolean",
  47342. default: false,
  47343. description: "Indent script and style tags in Vue files."
  47344. }
  47345. };
  47346. var parsers$1 = {
  47347. // HTML
  47348. get html() {
  47349. return require("./parser-html.js").parsers.html;
  47350. },
  47351. // Vue
  47352. get vue() {
  47353. return require("./parser-html.js").parsers.vue;
  47354. },
  47355. // Angular
  47356. get angular() {
  47357. return require("./parser-html.js").parsers.angular;
  47358. },
  47359. // Lightning Web Components
  47360. get lwc() {
  47361. return require("./parser-html.js").parsers.lwc;
  47362. }
  47363. };
  47364. var name$2 = "HTML";
  47365. var type$2 = "markup";
  47366. var tmScope$2 = "text.html.basic";
  47367. var aceMode$2 = "html";
  47368. var codemirrorMode$1 = "htmlmixed";
  47369. var codemirrorMimeType$1 = "text/html";
  47370. var color$2 = "#e34c26";
  47371. var aliases$1 = [
  47372. "xhtml"
  47373. ];
  47374. var extensions$2 = [
  47375. ".html",
  47376. ".htm",
  47377. ".html.hl",
  47378. ".inc",
  47379. ".xht",
  47380. ".xhtml"
  47381. ];
  47382. var languageId$2 = 146;
  47383. var require$$0$1 = {
  47384. name: name$2,
  47385. type: type$2,
  47386. tmScope: tmScope$2,
  47387. aceMode: aceMode$2,
  47388. codemirrorMode: codemirrorMode$1,
  47389. codemirrorMimeType: codemirrorMimeType$1,
  47390. color: color$2,
  47391. aliases: aliases$1,
  47392. extensions: extensions$2,
  47393. languageId: languageId$2
  47394. };
  47395. var name$1 = "Vue";
  47396. var type$1 = "markup";
  47397. var color$1 = "#41b883";
  47398. var extensions$1 = [
  47399. ".vue"
  47400. ];
  47401. var tmScope$1 = "text.html.vue";
  47402. var aceMode$1 = "html";
  47403. var languageId$1 = 391;
  47404. var require$$1 = {
  47405. name: name$1,
  47406. type: type$1,
  47407. color: color$1,
  47408. extensions: extensions$1,
  47409. tmScope: tmScope$1,
  47410. aceMode: aceMode$1,
  47411. languageId: languageId$1
  47412. };
  47413. const languages$2 = [createLanguage(require$$0$1, () => ({
  47414. name: "Angular",
  47415. since: "1.15.0",
  47416. parsers: ["angular"],
  47417. vscodeLanguageIds: ["html"],
  47418. extensions: [".component.html"],
  47419. filenames: []
  47420. })), createLanguage(require$$0$1, data => ({
  47421. since: "1.15.0",
  47422. parsers: ["html"],
  47423. vscodeLanguageIds: ["html"],
  47424. extensions: [...data.extensions, ".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  47425. ]
  47426. })), createLanguage(require$$0$1, () => ({
  47427. name: "Lightning Web Components",
  47428. since: "1.17.0",
  47429. parsers: ["lwc"],
  47430. vscodeLanguageIds: ["html"],
  47431. extensions: [],
  47432. filenames: []
  47433. })), createLanguage(require$$1, () => ({
  47434. since: "1.10.0",
  47435. parsers: ["vue"],
  47436. vscodeLanguageIds: ["vue"]
  47437. }))];
  47438. const printers = {
  47439. html: printerHtml
  47440. };
  47441. var languageHtml = {
  47442. languages: languages$2,
  47443. printers,
  47444. options: options$1,
  47445. parsers: parsers$1
  47446. };
  47447. function isPragma$1(text) {
  47448. return /^\s*@(?:prettier|format)\s*$/.test(text);
  47449. }
  47450. function hasPragma(text) {
  47451. return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(text);
  47452. }
  47453. function insertPragma$1(text) {
  47454. return `# @format\n\n${text}`;
  47455. }
  47456. var pragma = {
  47457. isPragma: isPragma$1,
  47458. hasPragma,
  47459. insertPragma: insertPragma$1
  47460. };
  47461. function locStart$1(node) {
  47462. return node.position.start.offset;
  47463. }
  47464. function locEnd(node) {
  47465. return node.position.end.offset;
  47466. }
  47467. var loc = {
  47468. locStart: locStart$1,
  47469. locEnd
  47470. };
  47471. function embed(path, print, textToDoc, options) {
  47472. const node = path.getValue(); // Try to format `.prettierrc` and `.stylelintrc` as `json` first
  47473. if (node.type === "root" && options.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint)rc$/.test(options.filepath)) {
  47474. return textToDoc(options.originalText, Object.assign(Object.assign({}, options), {}, {
  47475. parser: "json"
  47476. }));
  47477. }
  47478. }
  47479. var embed_1 = embed;
  47480. const {
  47481. getLast: getLast$1,
  47482. isNonEmptyArray
  47483. } = util$5;
  47484. function getAncestorCount$1(path, filter) {
  47485. let counter = 0;
  47486. const pathStackLength = path.stack.length - 1;
  47487. for (let i = 0; i < pathStackLength; i++) {
  47488. const value = path.stack[i];
  47489. if (isNode$4(value) && filter(value)) {
  47490. counter++;
  47491. }
  47492. }
  47493. return counter;
  47494. }
  47495. /**
  47496. * @param {any} value
  47497. * @param {string[]=} types
  47498. */
  47499. function isNode$4(value, types) {
  47500. return value && typeof value.type === "string" && (!types || types.includes(value.type));
  47501. }
  47502. function mapNode$1(node, callback, parent) {
  47503. return callback("children" in node ? Object.assign(Object.assign({}, node), {}, {
  47504. children: node.children.map(childNode => mapNode$1(childNode, callback, node))
  47505. }) : node, parent);
  47506. }
  47507. function defineShortcut$1(x, key, getter) {
  47508. Object.defineProperty(x, key, {
  47509. get: getter,
  47510. enumerable: false
  47511. });
  47512. }
  47513. function isNextLineEmpty$1(node, text) {
  47514. let newlineCount = 0;
  47515. const textLength = text.length;
  47516. for (let i = node.position.end.offset - 1; i < textLength; i++) {
  47517. const char = text[i];
  47518. if (char === "\n") {
  47519. newlineCount++;
  47520. }
  47521. if (newlineCount === 1 && /\S/.test(char)) {
  47522. return false;
  47523. }
  47524. if (newlineCount === 2) {
  47525. return true;
  47526. }
  47527. }
  47528. return false;
  47529. }
  47530. function isLastDescendantNode$2(path) {
  47531. const node = path.getValue();
  47532. switch (node.type) {
  47533. case "tag":
  47534. case "anchor":
  47535. case "comment":
  47536. return false;
  47537. }
  47538. const pathStackLength = path.stack.length;
  47539. for (let i = 1; i < pathStackLength; i++) {
  47540. const item = path.stack[i];
  47541. const parentItem = path.stack[i - 1];
  47542. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  47543. return false;
  47544. }
  47545. }
  47546. return true;
  47547. }
  47548. function getLastDescendantNode$1(node) {
  47549. return isNonEmptyArray(node.children) ? getLastDescendantNode$1(getLast$1(node.children)) : node;
  47550. }
  47551. function isPrettierIgnore(comment) {
  47552. return comment.value.trim() === "prettier-ignore";
  47553. }
  47554. function hasPrettierIgnore$1(path) {
  47555. const node = path.getValue();
  47556. if (node.type === "documentBody") {
  47557. const document = path.getParentNode();
  47558. return hasEndComments$4(document.head) && isPrettierIgnore(getLast$1(document.head.endComments));
  47559. }
  47560. return hasLeadingComments$2(node) && isPrettierIgnore(getLast$1(node.leadingComments));
  47561. }
  47562. function isEmptyNode$2(node) {
  47563. return !isNonEmptyArray(node.children) && !hasComments(node);
  47564. }
  47565. function hasComments(node) {
  47566. return hasLeadingComments$2(node) || hasMiddleComments$2(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$4(node);
  47567. }
  47568. function hasLeadingComments$2(node) {
  47569. return node && isNonEmptyArray(node.leadingComments);
  47570. }
  47571. function hasMiddleComments$2(node) {
  47572. return node && isNonEmptyArray(node.middleComments);
  47573. }
  47574. function hasIndicatorComment$1(node) {
  47575. return node && node.indicatorComment;
  47576. }
  47577. function hasTrailingComment$2(node) {
  47578. return node && node.trailingComment;
  47579. }
  47580. function hasEndComments$4(node) {
  47581. return node && isNonEmptyArray(node.endComments);
  47582. }
  47583. /**
  47584. * " a b c d e f " -> [" a b", "c d", "e f "]
  47585. */
  47586. function splitWithSingleSpace(text) {
  47587. const parts = [];
  47588. let lastPart;
  47589. for (const part of text.split(/( +)/)) {
  47590. /* istanbul ignore else */
  47591. if (part !== " ") {
  47592. if (lastPart === " ") {
  47593. parts.push(part);
  47594. } else {
  47595. parts.push((parts.pop() || "") + part);
  47596. }
  47597. } else if (lastPart === undefined) {
  47598. parts.unshift("");
  47599. }
  47600. lastPart = part;
  47601. }
  47602. /* istanbul ignore next */
  47603. if (lastPart === " ") {
  47604. parts.push((parts.pop() || "") + " ");
  47605. }
  47606. if (parts[0] === "") {
  47607. parts.shift();
  47608. parts.unshift(" " + (parts.shift() || ""));
  47609. }
  47610. return parts;
  47611. }
  47612. function getFlowScalarLineContents$1(nodeType, content, options) {
  47613. const rawLineContents = content.split("\n").map((lineContent, index, lineContents) => index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimEnd() : lineContent.trimStart());
  47614. if (options.proseWrap === "preserve") {
  47615. return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]);
  47616. }
  47617. return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !(nodeType === "quoteDouble" && getLast$1(getLast$1(reduced)).endsWith("\\")) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords);
  47618. }
  47619. function getBlockValueLineContents$1(node, {
  47620. parentIndent,
  47621. isLastDescendant,
  47622. options
  47623. }) {
  47624. const content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
  47625. .match(/^[^\n]*?\n(.*)$/s)[1];
  47626. const leadingSpaceCount = node.indent === null ? (match => match ? match[1].length : Number.POSITIVE_INFINITY)(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  47627. const rawLineContents = content.split("\n").map(lineContent => lineContent.slice(leadingSpaceCount));
  47628. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  47629. return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]));
  47630. }
  47631. return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => lineContentWords.reduce((reduced, word) => // disallow trailing spaces
  47632. reduced.length > 0 && /\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), getLast$1(reduced) + " " + word] : [...reduced, word], [])).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords));
  47633. function removeUnnecessaryTrailingNewlines(lineContents) {
  47634. if (node.chomping === "keep") {
  47635. return getLast$1(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  47636. }
  47637. let trailingNewlineCount = 0;
  47638. for (let i = lineContents.length - 1; i >= 0; i--) {
  47639. if (lineContents[i].length === 0) {
  47640. trailingNewlineCount++;
  47641. } else {
  47642. break;
  47643. }
  47644. }
  47645. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  47646. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  47647. }
  47648. }
  47649. function isInlineNode$2(node) {
  47650. /* istanbul ignore next */
  47651. if (!node) {
  47652. return true;
  47653. }
  47654. switch (node.type) {
  47655. case "plain":
  47656. case "quoteDouble":
  47657. case "quoteSingle":
  47658. case "alias":
  47659. case "flowMapping":
  47660. case "flowSequence":
  47661. return true;
  47662. default:
  47663. return false;
  47664. }
  47665. }
  47666. var utils = {
  47667. getLast: getLast$1,
  47668. getAncestorCount: getAncestorCount$1,
  47669. isNode: isNode$4,
  47670. isEmptyNode: isEmptyNode$2,
  47671. isInlineNode: isInlineNode$2,
  47672. mapNode: mapNode$1,
  47673. defineShortcut: defineShortcut$1,
  47674. isNextLineEmpty: isNextLineEmpty$1,
  47675. isLastDescendantNode: isLastDescendantNode$2,
  47676. getBlockValueLineContents: getBlockValueLineContents$1,
  47677. getFlowScalarLineContents: getFlowScalarLineContents$1,
  47678. getLastDescendantNode: getLastDescendantNode$1,
  47679. hasPrettierIgnore: hasPrettierIgnore$1,
  47680. hasLeadingComments: hasLeadingComments$2,
  47681. hasMiddleComments: hasMiddleComments$2,
  47682. hasIndicatorComment: hasIndicatorComment$1,
  47683. hasTrailingComment: hasTrailingComment$2,
  47684. hasEndComments: hasEndComments$4
  47685. };
  47686. const {
  47687. defineShortcut,
  47688. mapNode
  47689. } = utils;
  47690. function preprocess(ast) {
  47691. return mapNode(ast, defineShortcuts);
  47692. }
  47693. function defineShortcuts(node) {
  47694. switch (node.type) {
  47695. case "document":
  47696. defineShortcut(node, "head", () => node.children[0]);
  47697. defineShortcut(node, "body", () => node.children[1]);
  47698. break;
  47699. case "documentBody":
  47700. case "sequenceItem":
  47701. case "flowSequenceItem":
  47702. case "mappingKey":
  47703. case "mappingValue":
  47704. defineShortcut(node, "content", () => node.children[0]);
  47705. break;
  47706. case "mappingItem":
  47707. case "flowMappingItem":
  47708. defineShortcut(node, "key", () => node.children[0]);
  47709. defineShortcut(node, "value", () => node.children[1]);
  47710. break;
  47711. }
  47712. return node;
  47713. }
  47714. var printPreprocess = preprocess;
  47715. const {
  47716. builders: {
  47717. softline: softline$1,
  47718. align
  47719. }
  47720. } = doc;
  47721. const {
  47722. hasEndComments: hasEndComments$3,
  47723. isNextLineEmpty,
  47724. isNode: isNode$3
  47725. } = utils;
  47726. const printedEmptyLineCache = new WeakMap();
  47727. function printNextEmptyLine$2(path, originalText) {
  47728. const node = path.getValue();
  47729. const root = path.stack[0];
  47730. let isNextEmptyLinePrintedSet;
  47731. if (printedEmptyLineCache.has(root)) {
  47732. isNextEmptyLinePrintedSet = printedEmptyLineCache.get(root);
  47733. } else {
  47734. isNextEmptyLinePrintedSet = new Set();
  47735. printedEmptyLineCache.set(root, isNextEmptyLinePrintedSet);
  47736. }
  47737. if (!isNextEmptyLinePrintedSet.has(node.position.end.line)) {
  47738. isNextEmptyLinePrintedSet.add(node.position.end.line);
  47739. if (isNextLineEmpty(node, originalText) && !shouldPrintEndComments$1(path.getParentNode())) {
  47740. return softline$1;
  47741. }
  47742. }
  47743. return "";
  47744. }
  47745. function shouldPrintEndComments$1(node) {
  47746. return hasEndComments$3(node) && !isNode$3(node, ["documentHead", "documentBody", "flowMapping", "flowSequence"]);
  47747. }
  47748. function alignWithSpaces$4(width, doc) {
  47749. return align(" ".repeat(width), doc);
  47750. }
  47751. var misc = {
  47752. alignWithSpaces: alignWithSpaces$4,
  47753. shouldPrintEndComments: shouldPrintEndComments$1,
  47754. printNextEmptyLine: printNextEmptyLine$2
  47755. };
  47756. const {
  47757. builders: {
  47758. ifBreak: ifBreak$1,
  47759. line: line$3,
  47760. softline,
  47761. hardline: hardline$3,
  47762. join: join$3
  47763. }
  47764. } = doc;
  47765. const {
  47766. isEmptyNode: isEmptyNode$1,
  47767. getLast,
  47768. hasEndComments: hasEndComments$2
  47769. } = utils;
  47770. const {
  47771. printNextEmptyLine: printNextEmptyLine$1,
  47772. alignWithSpaces: alignWithSpaces$3
  47773. } = misc;
  47774. function printFlowMapping$1(path, print, options) {
  47775. const node = path.getValue();
  47776. const isMapping = node.type === "flowMapping";
  47777. const openMarker = isMapping ? "{" : "[";
  47778. const closeMarker = isMapping ? "}" : "]";
  47779. /** @type {softline | line} */
  47780. let bracketSpacing = softline;
  47781. if (isMapping && node.children.length > 0 && options.bracketSpacing) {
  47782. bracketSpacing = line$3;
  47783. }
  47784. const lastItem = getLast(node.children);
  47785. const isLastItemEmptyMappingItem = lastItem && lastItem.type === "flowMappingItem" && isEmptyNode$1(lastItem.key) && isEmptyNode$1(lastItem.value);
  47786. return [openMarker, alignWithSpaces$3(options.tabWidth, [bracketSpacing, printChildren(path, print, options), options.trailingComma === "none" ? "" : ifBreak$1(","), hasEndComments$2(node) ? [hardline$3, join$3(hardline$3, path.map(print, "endComments"))] : ""]), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker];
  47787. }
  47788. function printChildren(path, print, options) {
  47789. const node = path.getValue();
  47790. const parts = path.map((childPath, index) => [print(), index === node.children.length - 1 ? "" : [",", line$3, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine$1(childPath, options.originalText) : ""]], "children");
  47791. return parts;
  47792. }
  47793. var flowMappingSequence = {
  47794. printFlowMapping: printFlowMapping$1,
  47795. // Alias
  47796. printFlowSequence: printFlowMapping$1
  47797. };
  47798. /** @typedef {import("../../document").Doc} Doc */
  47799. const {
  47800. builders: {
  47801. conditionalGroup,
  47802. group: group$1,
  47803. hardline: hardline$2,
  47804. ifBreak,
  47805. join: join$2,
  47806. line: line$2
  47807. }
  47808. } = doc;
  47809. const {
  47810. hasLeadingComments: hasLeadingComments$1,
  47811. hasMiddleComments: hasMiddleComments$1,
  47812. hasTrailingComment: hasTrailingComment$1,
  47813. hasEndComments: hasEndComments$1,
  47814. isNode: isNode$2,
  47815. isEmptyNode,
  47816. isInlineNode: isInlineNode$1
  47817. } = utils;
  47818. const {
  47819. alignWithSpaces: alignWithSpaces$2
  47820. } = misc;
  47821. function printMappingItem(node, parentNode, path, print, options) {
  47822. const {
  47823. key,
  47824. value
  47825. } = node;
  47826. const isEmptyMappingKey = isEmptyNode(key);
  47827. const isEmptyMappingValue = isEmptyNode(value);
  47828. if (isEmptyMappingKey && isEmptyMappingValue) {
  47829. return ": ";
  47830. }
  47831. const printedKey = print("key");
  47832. const spaceBeforeColon = needsSpaceInFrontOfMappingValue(node) ? " " : "";
  47833. if (isEmptyMappingValue) {
  47834. if (node.type === "flowMappingItem" && parentNode.type === "flowMapping") {
  47835. return printedKey;
  47836. }
  47837. if (node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasTrailingComment$1(key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set")) {
  47838. return [printedKey, spaceBeforeColon, ":"];
  47839. }
  47840. return ["? ", alignWithSpaces$2(2, printedKey)];
  47841. }
  47842. const printedValue = print("value");
  47843. if (isEmptyMappingKey) {
  47844. return [": ", alignWithSpaces$2(2, printedValue)];
  47845. } // force explicit Key
  47846. if (hasLeadingComments$1(value) || !isInlineNode$1(key.content)) {
  47847. return ["? ", alignWithSpaces$2(2, printedKey), hardline$2, join$2("", path.map(print, "value", "leadingComments").map(comment => [comment, hardline$2])), ": ", alignWithSpaces$2(2, printedValue)];
  47848. } // force singleline
  47849. if (isSingleLineNode(key.content) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasTrailingComment$1(key.content) && !hasEndComments$1(key) && !hasLeadingComments$1(value.content) && !hasMiddleComments$1(value.content) && !hasEndComments$1(value) && isAbsolutelyPrintedAsSingleLineNode(value.content, options)) {
  47850. return [printedKey, spaceBeforeColon, ": ", printedValue];
  47851. }
  47852. const groupId = Symbol("mappingKey");
  47853. const groupedKey = group$1([ifBreak("? "), group$1(alignWithSpaces$2(2, printedKey), {
  47854. id: groupId
  47855. })]); // Construct both explicit and implicit mapping values.
  47856. const explicitMappingValue = [hardline$2, ": ", alignWithSpaces$2(2, printedValue)];
  47857. /** @type {Doc[]} */
  47858. // In the implicit case, it's convenient to treat everything from the key's colon
  47859. // as part of the mapping value
  47860. const implicitMappingValueParts = [spaceBeforeColon, ":"];
  47861. if (hasLeadingComments$1(value.content) || hasEndComments$1(value) && value.content && !isNode$2(value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(key.content) && isInlineNode$1(value.content) || isNode$2(value.content, ["mapping", "sequence"]) && value.content.tag === null && value.content.anchor === null) {
  47862. implicitMappingValueParts.push(hardline$2);
  47863. } else if (value.content) {
  47864. implicitMappingValueParts.push(line$2);
  47865. }
  47866. implicitMappingValueParts.push(printedValue);
  47867. const implicitMappingValue = alignWithSpaces$2(options.tabWidth, implicitMappingValueParts); // If a key is definitely single-line, forcibly use implicit style to avoid edge cases (very long
  47868. // keys) that would otherwise trigger explicit style as if it was multiline.
  47869. // In those cases, explicit style makes the line even longer and causes confusion.
  47870. if (isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasEndComments$1(key)) {
  47871. return conditionalGroup([[printedKey, implicitMappingValue]]);
  47872. } // Use explicit mapping syntax if the key breaks, implicit otherwise
  47873. return conditionalGroup([[groupedKey, ifBreak(explicitMappingValue, implicitMappingValue, {
  47874. groupId
  47875. })]]);
  47876. }
  47877. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  47878. if (!node) {
  47879. return true;
  47880. }
  47881. switch (node.type) {
  47882. case "plain":
  47883. case "quoteSingle":
  47884. case "quoteDouble":
  47885. break;
  47886. case "alias":
  47887. return true;
  47888. default:
  47889. return false;
  47890. }
  47891. if (options.proseWrap === "preserve") {
  47892. return node.position.start.line === node.position.end.line;
  47893. }
  47894. if ( // backslash-newline
  47895. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  47896. return false;
  47897. }
  47898. switch (options.proseWrap) {
  47899. case "never":
  47900. return !node.value.includes("\n");
  47901. case "always":
  47902. return !/[\n ]/.test(node.value);
  47903. // istanbul ignore next
  47904. default:
  47905. return false;
  47906. }
  47907. }
  47908. function needsSpaceInFrontOfMappingValue(node) {
  47909. return node.key.content && node.key.content.type === "alias";
  47910. }
  47911. function isSingleLineNode(node) {
  47912. /* istanbul ignore next */
  47913. if (!node) {
  47914. return true;
  47915. }
  47916. switch (node.type) {
  47917. case "plain":
  47918. case "quoteDouble":
  47919. case "quoteSingle":
  47920. return node.position.start.line === node.position.end.line;
  47921. case "alias":
  47922. return true;
  47923. default:
  47924. return false;
  47925. }
  47926. }
  47927. var mappingItem = printMappingItem;
  47928. /** @typedef {import("../../document").Doc} Doc */
  47929. const {
  47930. builders: {
  47931. dedent,
  47932. dedentToRoot,
  47933. fill: fill$1,
  47934. hardline: hardline$1,
  47935. join: join$1,
  47936. line: line$1,
  47937. literalline: literalline$1,
  47938. markAsRoot
  47939. },
  47940. utils: {
  47941. getDocParts: getDocParts$1
  47942. }
  47943. } = doc;
  47944. const {
  47945. getAncestorCount,
  47946. getBlockValueLineContents,
  47947. hasIndicatorComment,
  47948. isLastDescendantNode: isLastDescendantNode$1,
  47949. isNode: isNode$1
  47950. } = utils;
  47951. const {
  47952. alignWithSpaces: alignWithSpaces$1
  47953. } = misc;
  47954. function printBlock(path, print, options) {
  47955. const node = path.getValue();
  47956. const parentIndent = getAncestorCount(path, ancestorNode => isNode$1(ancestorNode, ["sequence", "mapping"]));
  47957. const isLastDescendant = isLastDescendantNode$1(path);
  47958. /** @type {Doc[]} */
  47959. const parts = [node.type === "blockFolded" ? ">" : "|"];
  47960. if (node.indent !== null) {
  47961. parts.push(node.indent.toString());
  47962. }
  47963. if (node.chomping !== "clip") {
  47964. parts.push(node.chomping === "keep" ? "+" : "-");
  47965. }
  47966. if (hasIndicatorComment(node)) {
  47967. parts.push(" ", print("indicatorComment"));
  47968. }
  47969. const lineContents = getBlockValueLineContents(node, {
  47970. parentIndent,
  47971. isLastDescendant,
  47972. options
  47973. });
  47974. /** @type {Doc[]} */
  47975. const contentsParts = [];
  47976. for (const [index, lineWords] of lineContents.entries()) {
  47977. if (index === 0) {
  47978. contentsParts.push(hardline$1);
  47979. }
  47980. contentsParts.push(fill$1(getDocParts$1(join$1(line$1, lineWords))));
  47981. if (index !== lineContents.length - 1) {
  47982. contentsParts.push(lineWords.length === 0 ? hardline$1 : markAsRoot(literalline$1));
  47983. } else if (node.chomping === "keep" && isLastDescendant) {
  47984. contentsParts.push(dedentToRoot(lineWords.length === 0 ? hardline$1 : literalline$1));
  47985. }
  47986. }
  47987. if (node.indent === null) {
  47988. parts.push(dedent(alignWithSpaces$1(options.tabWidth, contentsParts)));
  47989. } else {
  47990. parts.push(dedentToRoot(alignWithSpaces$1(node.indent - 1 + parentIndent, contentsParts)));
  47991. }
  47992. return parts;
  47993. }
  47994. var block = printBlock;
  47995. /** @typedef {import("../document").Doc} Doc */
  47996. const {
  47997. builders: {
  47998. breakParent,
  47999. fill,
  48000. group,
  48001. hardline,
  48002. join,
  48003. line,
  48004. lineSuffix,
  48005. literalline
  48006. },
  48007. utils: {
  48008. getDocParts,
  48009. replaceTextEndOfLine
  48010. }
  48011. } = doc;
  48012. const {
  48013. isPreviousLineEmpty
  48014. } = util$5;
  48015. const {
  48016. insertPragma,
  48017. isPragma
  48018. } = pragma;
  48019. const {
  48020. locStart
  48021. } = loc;
  48022. const {
  48023. getFlowScalarLineContents,
  48024. getLastDescendantNode,
  48025. hasLeadingComments,
  48026. hasMiddleComments,
  48027. hasTrailingComment,
  48028. hasEndComments,
  48029. hasPrettierIgnore,
  48030. isLastDescendantNode,
  48031. isNode,
  48032. isInlineNode
  48033. } = utils;
  48034. const {
  48035. alignWithSpaces,
  48036. printNextEmptyLine,
  48037. shouldPrintEndComments
  48038. } = misc;
  48039. const {
  48040. printFlowMapping,
  48041. printFlowSequence
  48042. } = flowMappingSequence;
  48043. function genericPrint(path, options, print) {
  48044. const node = path.getValue();
  48045. /** @type {Doc[]} */
  48046. const parts = [];
  48047. if (node.type !== "mappingValue" && hasLeadingComments(node)) {
  48048. parts.push([join(hardline, path.map(print, "leadingComments")), hardline]);
  48049. }
  48050. const {
  48051. tag,
  48052. anchor
  48053. } = node;
  48054. if (tag) {
  48055. parts.push(print("tag"));
  48056. }
  48057. if (tag && anchor) {
  48058. parts.push(" ");
  48059. }
  48060. if (anchor) {
  48061. parts.push(print("anchor"));
  48062. }
  48063. /** @type {Doc} */
  48064. let nextEmptyLine = "";
  48065. if (isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path)) {
  48066. nextEmptyLine = printNextEmptyLine(path, options.originalText);
  48067. }
  48068. if (tag || anchor) {
  48069. if (isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node)) {
  48070. parts.push(hardline);
  48071. } else {
  48072. parts.push(" ");
  48073. }
  48074. }
  48075. if (hasMiddleComments(node)) {
  48076. parts.push([node.middleComments.length === 1 ? "" : hardline, join(hardline, path.map(print, "middleComments")), hardline]);
  48077. }
  48078. const parentNode = path.getParentNode();
  48079. if (hasPrettierIgnore(path)) {
  48080. parts.push(replaceTextEndOfLine(options.originalText.slice(node.position.start.offset, node.position.end.offset).trimEnd(), literalline));
  48081. } else {
  48082. parts.push(group(printNode(node, parentNode, path, options, print)));
  48083. }
  48084. if (hasTrailingComment(node) && !isNode(node, ["document", "documentHead"])) {
  48085. parts.push(lineSuffix([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent, print("trailingComment")]));
  48086. }
  48087. if (shouldPrintEndComments(node)) {
  48088. parts.push(alignWithSpaces(node.type === "sequenceItem" ? 2 : 0, [hardline, join(hardline, path.map(path => [isPreviousLineEmpty(options.originalText, path.getValue(), locStart) ? hardline : "", print()], "endComments"))]));
  48089. }
  48090. parts.push(nextEmptyLine);
  48091. return parts;
  48092. }
  48093. function printNode(node, parentNode, path, options, print) {
  48094. switch (node.type) {
  48095. case "root":
  48096. {
  48097. const {
  48098. children
  48099. } = node;
  48100. const parts = [];
  48101. path.each((childPath, index) => {
  48102. const document = children[index];
  48103. const nextDocument = children[index + 1];
  48104. if (index !== 0) {
  48105. parts.push(hardline);
  48106. }
  48107. parts.push(print());
  48108. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  48109. parts.push(hardline, "...");
  48110. if (hasTrailingComment(document)) {
  48111. parts.push(" ", print("trailingComment"));
  48112. }
  48113. } else if (nextDocument && !hasTrailingComment(nextDocument.head)) {
  48114. parts.push(hardline, "---");
  48115. }
  48116. }, "children");
  48117. const lastDescendantNode = getLastDescendantNode(node);
  48118. if (!isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) || lastDescendantNode.chomping !== "keep") {
  48119. parts.push(hardline);
  48120. }
  48121. return parts;
  48122. }
  48123. case "document":
  48124. {
  48125. const nextDocument = parentNode.children[path.getName() + 1];
  48126. const parts = [];
  48127. if (shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head") {
  48128. if (node.head.children.length > 0 || node.head.endComments.length > 0) {
  48129. parts.push(print("head"));
  48130. }
  48131. if (hasTrailingComment(node.head)) {
  48132. parts.push(["---", " ", print(["head", "trailingComment"])]);
  48133. } else {
  48134. parts.push("---");
  48135. }
  48136. }
  48137. if (shouldPrintDocumentBody(node)) {
  48138. parts.push(print("body"));
  48139. }
  48140. return join(hardline, parts);
  48141. }
  48142. case "documentHead":
  48143. return join(hardline, [...path.map(print, "children"), ...path.map(print, "endComments")]);
  48144. case "documentBody":
  48145. {
  48146. const {
  48147. children,
  48148. endComments
  48149. } = node;
  48150. /** @type {Doc} */
  48151. let separator = "";
  48152. if (children.length > 0 && endComments.length > 0) {
  48153. const lastDescendantNode = getLastDescendantNode(node); // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  48154. if (isNode(lastDescendantNode, ["blockFolded", "blockLiteral"])) {
  48155. // an extra newline for better readability
  48156. if (lastDescendantNode.chomping !== "keep") {
  48157. separator = [hardline, hardline];
  48158. }
  48159. } else {
  48160. separator = hardline;
  48161. }
  48162. }
  48163. return [join(hardline, path.map(print, "children")), separator, join(hardline, path.map(print, "endComments"))];
  48164. }
  48165. case "directive":
  48166. return ["%", join(" ", [node.name, ...node.parameters])];
  48167. case "comment":
  48168. return ["#", node.value];
  48169. case "alias":
  48170. return ["*", node.value];
  48171. case "tag":
  48172. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  48173. case "anchor":
  48174. return ["&", node.value];
  48175. case "plain":
  48176. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  48177. case "quoteDouble":
  48178. case "quoteSingle":
  48179. {
  48180. const singleQuote = "'";
  48181. const doubleQuote = '"';
  48182. const raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  48183. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  48184. // only quoteDouble can use escape chars
  48185. // and quoteSingle do not need to escape backslashes
  48186. const originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  48187. return [originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote];
  48188. }
  48189. if (raw.includes(doubleQuote)) {
  48190. return [singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  48191. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote];
  48192. }
  48193. if (raw.includes(singleQuote)) {
  48194. return [doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  48195. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote];
  48196. }
  48197. const quote = options.singleQuote ? singleQuote : doubleQuote;
  48198. return [quote, printFlowScalarContent(node.type, raw, options), quote];
  48199. }
  48200. case "blockFolded":
  48201. case "blockLiteral":
  48202. {
  48203. return block(path, print, options);
  48204. }
  48205. case "mapping":
  48206. case "sequence":
  48207. return join(hardline, path.map(print, "children"));
  48208. case "sequenceItem":
  48209. return ["- ", alignWithSpaces(2, !node.content ? "" : print("content"))];
  48210. case "mappingKey":
  48211. case "mappingValue":
  48212. return !node.content ? "" : print("content");
  48213. case "mappingItem":
  48214. case "flowMappingItem":
  48215. {
  48216. return mappingItem(node, parentNode, path, print, options);
  48217. }
  48218. case "flowMapping":
  48219. return printFlowMapping(path, print, options);
  48220. case "flowSequence":
  48221. return printFlowSequence(path, print, options);
  48222. case "flowSequenceItem":
  48223. return print("content");
  48224. // istanbul ignore next
  48225. default:
  48226. throw new Error(`Unexpected node type ${node.type}`);
  48227. }
  48228. }
  48229. function shouldPrintDocumentBody(document) {
  48230. return document.body.children.length > 0 || hasEndComments(document.body);
  48231. }
  48232. function shouldPrintDocumentEndMarker(document, nextDocument) {
  48233. return (
  48234. /**
  48235. *... # trailingComment
  48236. */
  48237. hasTrailingComment(document) || nextDocument && (nextDocument.head.children.length > 0 ||
  48238. /**
  48239. * ...
  48240. * # endComment
  48241. * ---
  48242. */
  48243. hasEndComments(nextDocument.head))
  48244. );
  48245. }
  48246. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  48247. if (
  48248. /**
  48249. * ---
  48250. * preserve the first document head end marker
  48251. */
  48252. root.children[0] === document && /---(?:\s|$)/.test(options.originalText.slice(locStart(document), locStart(document) + 4)) ||
  48253. /**
  48254. * %DIRECTIVE
  48255. * ---
  48256. */
  48257. document.head.children.length > 0 ||
  48258. /**
  48259. * # end comment
  48260. * ---
  48261. */
  48262. hasEndComments(document.head) ||
  48263. /**
  48264. * --- # trailing comment
  48265. */
  48266. hasTrailingComment(document.head)) {
  48267. return "head";
  48268. }
  48269. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  48270. return false;
  48271. }
  48272. return nextDocument ? "root" : false;
  48273. }
  48274. function printFlowScalarContent(nodeType, content, options) {
  48275. const lineContents = getFlowScalarLineContents(nodeType, content, options);
  48276. return join(hardline, lineContents.map(lineContentWords => fill(getDocParts(join(line, lineContentWords)))));
  48277. }
  48278. function clean(node, newNode
  48279. /*, parent */
  48280. ) {
  48281. if (isNode(newNode)) {
  48282. delete newNode.position;
  48283. switch (newNode.type) {
  48284. case "comment":
  48285. // insert pragma
  48286. if (isPragma(newNode.value)) {
  48287. return null;
  48288. }
  48289. break;
  48290. case "quoteDouble":
  48291. case "quoteSingle":
  48292. newNode.type = "quote";
  48293. break;
  48294. }
  48295. }
  48296. }
  48297. var printerYaml = {
  48298. preprocess: printPreprocess,
  48299. embed: embed_1,
  48300. print: genericPrint,
  48301. massageAstNode: clean,
  48302. insertPragma
  48303. };
  48304. var options = {
  48305. bracketSpacing: commonOptions.bracketSpacing,
  48306. singleQuote: commonOptions.singleQuote,
  48307. proseWrap: commonOptions.proseWrap
  48308. };
  48309. var parsers = {
  48310. get yaml() {
  48311. return require("./parser-yaml.js").parsers.yaml;
  48312. }
  48313. };
  48314. var name = "YAML";
  48315. var type = "data";
  48316. var color = "#cb171e";
  48317. var tmScope = "source.yaml";
  48318. var aliases = [
  48319. "yml"
  48320. ];
  48321. var extensions = [
  48322. ".yml",
  48323. ".mir",
  48324. ".reek",
  48325. ".rviz",
  48326. ".sublime-syntax",
  48327. ".syntax",
  48328. ".yaml",
  48329. ".yaml-tmlanguage",
  48330. ".yaml.sed",
  48331. ".yml.mysql"
  48332. ];
  48333. var filenames = [
  48334. ".clang-format",
  48335. ".clang-tidy",
  48336. ".gemrc",
  48337. "glide.lock",
  48338. "yarn.lock"
  48339. ];
  48340. var aceMode = "yaml";
  48341. var codemirrorMode = "yaml";
  48342. var codemirrorMimeType = "text/x-yaml";
  48343. var languageId = 407;
  48344. var require$$0 = {
  48345. name: name,
  48346. type: type,
  48347. color: color,
  48348. tmScope: tmScope,
  48349. aliases: aliases,
  48350. extensions: extensions,
  48351. filenames: filenames,
  48352. aceMode: aceMode,
  48353. codemirrorMode: codemirrorMode,
  48354. codemirrorMimeType: codemirrorMimeType,
  48355. languageId: languageId
  48356. };
  48357. const languages$1 = [createLanguage(require$$0, data => ({
  48358. since: "1.14.0",
  48359. parsers: ["yaml"],
  48360. vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
  48361. // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629
  48362. filenames: [...data.filenames.filter(filename => filename !== "yarn.lock"), ".prettierrc", ".stylelintrc"]
  48363. }))];
  48364. var languageYaml = {
  48365. languages: languages$1,
  48366. printers: {
  48367. yaml: printerYaml
  48368. },
  48369. options,
  48370. parsers
  48371. };
  48372. var languages = [// JS
  48373. languageJs, // CSS
  48374. languageCss, // Handlebars
  48375. languageHandlebars, // GraphQL
  48376. languageGraphql, // Markdown
  48377. languageMarkdown, // HTML
  48378. languageHtml, // YAML
  48379. languageYaml];
  48380. const memoizedLoad = dist$1(load, {
  48381. cacheKey: JSON.stringify
  48382. });
  48383. const memoizedSearch = dist$1(findPluginsInNodeModules);
  48384. const clearCache = () => {
  48385. dist$1.clear(memoizedLoad);
  48386. dist$1.clear(memoizedSearch);
  48387. };
  48388. function load(plugins, pluginSearchDirs) {
  48389. if (!plugins) {
  48390. plugins = [];
  48391. }
  48392. if (!pluginSearchDirs) {
  48393. pluginSearchDirs = [];
  48394. } // unless pluginSearchDirs are provided, auto-load plugins from node_modules that are parent to Prettier
  48395. if (pluginSearchDirs.length === 0) {
  48396. const autoLoadDir = thirdParty.findParentDir(__dirname, "node_modules");
  48397. if (autoLoadDir) {
  48398. pluginSearchDirs = [autoLoadDir];
  48399. }
  48400. }
  48401. const [externalPluginNames, externalPluginInstances] = partition_1(plugins, plugin => typeof plugin === "string");
  48402. const externalManualLoadPluginInfos = externalPluginNames.map(pluginName => {
  48403. let requirePath;
  48404. try {
  48405. // try local files
  48406. requirePath = resolve_1(path__default['default'].resolve(process.cwd(), pluginName));
  48407. } catch {
  48408. // try node modules
  48409. requirePath = resolve_1(pluginName, {
  48410. paths: [process.cwd()]
  48411. });
  48412. }
  48413. return {
  48414. name: pluginName,
  48415. requirePath
  48416. };
  48417. });
  48418. const externalAutoLoadPluginInfos = pluginSearchDirs.flatMap(pluginSearchDir => {
  48419. const resolvedPluginSearchDir = path__default['default'].resolve(process.cwd(), pluginSearchDir);
  48420. const nodeModulesDir = path__default['default'].resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
  48421. // isDirectory(resolvedPluginSearchDir) check might be false even though
  48422. // the node_modules actually exists.
  48423. if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
  48424. throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
  48425. }
  48426. return memoizedSearch(nodeModulesDir).map(pluginName => ({
  48427. name: pluginName,
  48428. requirePath: resolve_1(pluginName, {
  48429. paths: [resolvedPluginSearchDir]
  48430. })
  48431. }));
  48432. });
  48433. const externalPlugins = [...uniqBy_1([...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos], "requirePath").map(externalPluginInfo => Object.assign({
  48434. name: externalPluginInfo.name
  48435. }, require(externalPluginInfo.requirePath))), ...externalPluginInstances];
  48436. return [...languages, ...externalPlugins];
  48437. }
  48438. function findPluginsInNodeModules(nodeModulesDir) {
  48439. const pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
  48440. cwd: nodeModulesDir,
  48441. expandDirectories: false
  48442. });
  48443. return pluginPackageJsonPaths.map(path__default['default'].dirname);
  48444. }
  48445. function isDirectory(dir) {
  48446. try {
  48447. return fs__default['default'].statSync(dir).isDirectory();
  48448. } catch {
  48449. return false;
  48450. }
  48451. }
  48452. var loadPlugins = {
  48453. loadPlugins: memoizedLoad,
  48454. clearCache
  48455. };
  48456. const {
  48457. version
  48458. } = require$$0$9;
  48459. const {
  48460. getSupportInfo
  48461. } = support;
  48462. function _withPlugins(fn, optsArgIdx = 1 // Usually `opts` is the 2nd argument
  48463. ) {
  48464. return (...args) => {
  48465. const opts = args[optsArgIdx] || {};
  48466. args[optsArgIdx] = Object.assign(Object.assign({}, opts), {}, {
  48467. plugins: loadPlugins.loadPlugins(opts.plugins, opts.pluginSearchDirs)
  48468. });
  48469. return fn(...args);
  48470. };
  48471. }
  48472. function withPlugins(fn, optsArgIdx) {
  48473. const resultingFn = _withPlugins(fn, optsArgIdx);
  48474. if (fn.sync) {
  48475. // @ts-expect-error
  48476. resultingFn.sync = _withPlugins(fn.sync, optsArgIdx);
  48477. }
  48478. return resultingFn;
  48479. }
  48480. const formatWithCursor = withPlugins(core$1.formatWithCursor);
  48481. var src = {
  48482. formatWithCursor,
  48483. format(text, opts) {
  48484. return formatWithCursor(text, opts).formatted;
  48485. },
  48486. check(text, opts) {
  48487. const {
  48488. formatted
  48489. } = formatWithCursor(text, opts);
  48490. return formatted === text;
  48491. },
  48492. doc,
  48493. resolveConfig: resolveConfig_1.resolveConfig,
  48494. resolveConfigFile: resolveConfig_1.resolveConfigFile,
  48495. clearConfigCache() {
  48496. resolveConfig_1.clearCache();
  48497. loadPlugins.clearCache();
  48498. },
  48499. /** @type {typeof getFileInfo} */
  48500. getFileInfo: withPlugins(getFileInfo_1),
  48501. /** @type {typeof getSupportInfo} */
  48502. getSupportInfo: withPlugins(getSupportInfo, 0),
  48503. version,
  48504. util: utilShared,
  48505. // Internal shared
  48506. __internal: {
  48507. errors: errors,
  48508. coreOptions: coreOptions$1,
  48509. createIgnorer: createIgnorer_1,
  48510. optionsModule: options$6,
  48511. optionsNormalizer: optionsNormalizer,
  48512. utils: {
  48513. arrayify: arrayify
  48514. }
  48515. },
  48516. /* istanbul ignore next */
  48517. __debug: {
  48518. parse: withPlugins(core$1.parse),
  48519. formatAST: withPlugins(core$1.formatAST),
  48520. formatDoc: withPlugins(core$1.formatDoc),
  48521. printToDoc: withPlugins(core$1.printToDoc),
  48522. printDocToString: withPlugins(core$1.printDocToString)
  48523. }
  48524. };
  48525. module.exports = src;