index.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803
  1. 'use strict';
  2. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  3. var fs = _interopDefault(require('fs'));
  4. var os = _interopDefault(require('os'));
  5. var path = _interopDefault(require('path'));
  6. var assert = _interopDefault(require('assert'));
  7. var util = _interopDefault(require('util'));
  8. var events = _interopDefault(require('events'));
  9. var thirdParty = require('./third-party');
  10. var thirdParty__default = thirdParty['default'];
  11. var name = "prettier";
  12. var version$1 = "1.18.2";
  13. var description = "Prettier is an opinionated code formatter";
  14. var bin = {
  15. "prettier": "./bin/prettier.js"
  16. };
  17. var repository = "prettier/prettier";
  18. var homepage = "https://prettier.io";
  19. var author = "James Long";
  20. var license = "MIT";
  21. var main = "./index.js";
  22. var engines = {
  23. "node": ">=6"
  24. };
  25. var dependencies = {
  26. "@angular/compiler": "7.2.9",
  27. "@babel/code-frame": "7.0.0",
  28. "@babel/parser": "7.2.0",
  29. "@glimmer/syntax": "0.38.4",
  30. "@iarna/toml": "2.2.3",
  31. "@typescript-eslint/typescript-estree": "1.6.0",
  32. "angular-estree-parser": "1.1.5",
  33. "angular-html-parser": "1.2.0",
  34. "camelcase": "4.1.0",
  35. "chalk": "2.1.0",
  36. "cjk-regex": "2.0.0",
  37. "cosmiconfig": "5.0.7",
  38. "dashify": "0.2.2",
  39. "dedent": "0.7.0",
  40. "diff": "3.2.0",
  41. "editorconfig": "0.15.2",
  42. "editorconfig-to-prettier": "0.1.1",
  43. "escape-string-regexp": "1.0.5",
  44. "esutils": "2.0.2",
  45. "find-parent-dir": "0.3.0",
  46. "find-project-root": "1.1.1",
  47. "flow-parser": "0.84.0",
  48. "get-stream": "3.0.0",
  49. "globby": "6.1.0",
  50. "graphql": "14.2.0",
  51. "html-element-attributes": "2.0.0",
  52. "html-styles": "1.0.0",
  53. "html-tag-names": "1.1.2",
  54. "ignore": "4.0.6",
  55. "is-ci": "2.0.0",
  56. "jest-docblock": "23.2.0",
  57. "json-stable-stringify": "1.0.1",
  58. "leven": "2.1.0",
  59. "lines-and-columns": "1.1.6",
  60. "linguist-languages": "6.2.1-dev.20180706",
  61. "lodash.uniqby": "4.7.0",
  62. "mem": "1.1.0",
  63. "minimatch": "3.0.4",
  64. "minimist": "1.2.0",
  65. "n-readlines": "1.0.0",
  66. "normalize-path": "3.0.0",
  67. "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
  68. "postcss-less": "1.1.5",
  69. "postcss-media-query-parser": "0.2.3",
  70. "postcss-scss": "2.0.0",
  71. "postcss-selector-parser": "2.2.3",
  72. "postcss-values-parser": "1.5.0",
  73. "regexp-util": "1.2.2",
  74. "remark-math": "1.0.4",
  75. "remark-parse": "5.0.0",
  76. "resolve": "1.5.0",
  77. "semver": "5.4.1",
  78. "string-width": "3.0.0",
  79. "typescript": "3.4.1",
  80. "unicode-regex": "2.0.0",
  81. "unified": "6.1.6",
  82. "vnopts": "1.0.2",
  83. "yaml": "1.0.2",
  84. "yaml-unist-parser": "1.0.0"
  85. };
  86. var devDependencies = {
  87. "@babel/cli": "7.2.0",
  88. "@babel/core": "7.2.0",
  89. "@babel/preset-env": "7.2.0",
  90. "babel-loader": "8.0.4",
  91. "benchmark": "2.1.4",
  92. "builtin-modules": "2.0.0",
  93. "codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0",
  94. "cross-env": "5.0.5",
  95. "eslint": "4.18.2",
  96. "eslint-config-prettier": "2.9.0",
  97. "eslint-friendly-formatter": "3.0.0",
  98. "eslint-plugin-import": "2.9.0",
  99. "eslint-plugin-prettier": "2.6.0",
  100. "eslint-plugin-react": "7.7.0",
  101. "execa": "0.10.0",
  102. "jest": "23.3.0",
  103. "jest-junit": "5.0.0",
  104. "jest-snapshot-serializer-ansi": "1.0.0",
  105. "jest-snapshot-serializer-raw": "1.1.0",
  106. "jest-watch-typeahead": "0.1.0",
  107. "mkdirp": "0.5.1",
  108. "prettier": "1.18.0",
  109. "prettylint": "1.0.0",
  110. "rimraf": "2.6.2",
  111. "rollup": "0.47.6",
  112. "rollup-plugin-alias": "1.4.0",
  113. "rollup-plugin-babel": "4.0.0-beta.4",
  114. "rollup-plugin-commonjs": "8.2.6",
  115. "rollup-plugin-json": "2.1.1",
  116. "rollup-plugin-node-builtins": "2.0.0",
  117. "rollup-plugin-node-globals": "1.1.0",
  118. "rollup-plugin-node-resolve": "2.0.0",
  119. "rollup-plugin-replace": "1.2.1",
  120. "rollup-plugin-uglify": "3.0.0",
  121. "shelljs": "0.8.1",
  122. "snapshot-diff": "0.4.0",
  123. "strip-ansi": "4.0.0",
  124. "tempy": "0.2.1",
  125. "webpack": "3.12.0"
  126. };
  127. var scripts = {
  128. "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
  129. "prepare-release": "yarn && yarn build && yarn test:dist",
  130. "test": "jest",
  131. "test:dist": "node ./scripts/test-dist.js",
  132. "test-integration": "jest tests_integration",
  133. "perf-repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  134. "perf-repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  135. "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  136. "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
  137. "lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
  138. "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
  139. "build": "node --max-old-space-size=2048 ./scripts/build/build.js",
  140. "build-docs": "node ./scripts/build-docs.js",
  141. "check-deps": "node ./scripts/check-deps.js"
  142. };
  143. var _package = {
  144. name: name,
  145. version: version$1,
  146. description: description,
  147. bin: bin,
  148. repository: repository,
  149. homepage: homepage,
  150. author: author,
  151. license: license,
  152. main: main,
  153. engines: engines,
  154. dependencies: dependencies,
  155. devDependencies: devDependencies,
  156. scripts: scripts
  157. };
  158. var _package$1 = Object.freeze({
  159. name: name,
  160. version: version$1,
  161. description: description,
  162. bin: bin,
  163. repository: repository,
  164. homepage: homepage,
  165. author: author,
  166. license: license,
  167. main: main,
  168. engines: engines,
  169. dependencies: dependencies,
  170. devDependencies: devDependencies,
  171. scripts: scripts,
  172. default: _package
  173. });
  174. function unwrapExports (x) {
  175. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  176. }
  177. function createCommonjsModule(fn, module) {
  178. return module = { exports: {} }, fn(module, module.exports), module.exports;
  179. }
  180. var base = createCommonjsModule(function (module, exports) {
  181. /*istanbul ignore start*/
  182. 'use strict';
  183. exports.__esModule = true;
  184. exports['default'] =
  185. /*istanbul ignore end*/
  186. Diff;
  187. function Diff() {}
  188. Diff.prototype = {
  189. /*istanbul ignore start*/
  190. /*istanbul ignore end*/
  191. diff: function diff(oldString, newString) {
  192. /*istanbul ignore start*/
  193. var
  194. /*istanbul ignore end*/
  195. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  196. var callback = options.callback;
  197. if (typeof options === 'function') {
  198. callback = options;
  199. options = {};
  200. }
  201. this.options = options;
  202. var self = this;
  203. function done(value) {
  204. if (callback) {
  205. setTimeout(function () {
  206. callback(undefined, value);
  207. }, 0);
  208. return true;
  209. } else {
  210. return value;
  211. }
  212. } // Allow subclasses to massage the input prior to running
  213. oldString = this.castInput(oldString);
  214. newString = this.castInput(newString);
  215. oldString = this.removeEmpty(this.tokenize(oldString));
  216. newString = this.removeEmpty(this.tokenize(newString));
  217. var newLen = newString.length,
  218. oldLen = oldString.length;
  219. var editLength = 1;
  220. var maxEditLength = newLen + oldLen;
  221. var bestPath = [{
  222. newPos: -1,
  223. components: []
  224. }]; // Seed editLength = 0, i.e. the content starts with the same values
  225. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  226. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  227. // Identity per the equality and tokenizer
  228. return done([{
  229. value: this.join(newString),
  230. count: newString.length
  231. }]);
  232. } // Main worker method. checks all permutations of a given edit length for acceptance.
  233. function execEditLength() {
  234. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  235. var basePath =
  236. /*istanbul ignore start*/
  237. void 0;
  238. var addPath = bestPath[diagonalPath - 1],
  239. removePath = bestPath[diagonalPath + 1],
  240. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  241. if (addPath) {
  242. // No one else is going to attempt to use this value, clear it
  243. bestPath[diagonalPath - 1] = undefined;
  244. }
  245. var canAdd = addPath && addPath.newPos + 1 < newLen,
  246. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  247. if (!canAdd && !canRemove) {
  248. // If this path is a terminal then prune
  249. bestPath[diagonalPath] = undefined;
  250. continue;
  251. } // Select the diagonal that we want to branch from. We select the prior
  252. // path whose position in the new string is the farthest from the origin
  253. // and does not pass the bounds of the diff graph
  254. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  255. basePath = clonePath(removePath);
  256. self.pushComponent(basePath.components, undefined, true);
  257. } else {
  258. basePath = addPath; // No need to clone, we've pulled it from the list
  259. basePath.newPos++;
  260. self.pushComponent(basePath.components, true, undefined);
  261. }
  262. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  263. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  264. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  265. } else {
  266. // Otherwise track this path as a potential candidate and continue.
  267. bestPath[diagonalPath] = basePath;
  268. }
  269. }
  270. editLength++;
  271. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  272. // sync and async mode which is never fun. Loops over execEditLength until a value
  273. // is produced.
  274. if (callback) {
  275. (function exec() {
  276. setTimeout(function () {
  277. // This should not happen, but we want to be safe.
  278. /* istanbul ignore next */
  279. if (editLength > maxEditLength) {
  280. return callback();
  281. }
  282. if (!execEditLength()) {
  283. exec();
  284. }
  285. }, 0);
  286. })();
  287. } else {
  288. while (editLength <= maxEditLength) {
  289. var ret = execEditLength();
  290. if (ret) {
  291. return ret;
  292. }
  293. }
  294. }
  295. },
  296. /*istanbul ignore start*/
  297. /*istanbul ignore end*/
  298. pushComponent: function pushComponent(components, added, removed) {
  299. var last = components[components.length - 1];
  300. if (last && last.added === added && last.removed === removed) {
  301. // We need to clone here as the component clone operation is just
  302. // as shallow array clone
  303. components[components.length - 1] = {
  304. count: last.count + 1,
  305. added: added,
  306. removed: removed
  307. };
  308. } else {
  309. components.push({
  310. count: 1,
  311. added: added,
  312. removed: removed
  313. });
  314. }
  315. },
  316. /*istanbul ignore start*/
  317. /*istanbul ignore end*/
  318. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  319. var newLen = newString.length,
  320. oldLen = oldString.length,
  321. newPos = basePath.newPos,
  322. oldPos = newPos - diagonalPath,
  323. commonCount = 0;
  324. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  325. newPos++;
  326. oldPos++;
  327. commonCount++;
  328. }
  329. if (commonCount) {
  330. basePath.components.push({
  331. count: commonCount
  332. });
  333. }
  334. basePath.newPos = newPos;
  335. return oldPos;
  336. },
  337. /*istanbul ignore start*/
  338. /*istanbul ignore end*/
  339. equals: function equals(left, right) {
  340. return left === right;
  341. },
  342. /*istanbul ignore start*/
  343. /*istanbul ignore end*/
  344. removeEmpty: function removeEmpty(array) {
  345. var ret = [];
  346. for (var i = 0; i < array.length; i++) {
  347. if (array[i]) {
  348. ret.push(array[i]);
  349. }
  350. }
  351. return ret;
  352. },
  353. /*istanbul ignore start*/
  354. /*istanbul ignore end*/
  355. castInput: function castInput(value) {
  356. return value;
  357. },
  358. /*istanbul ignore start*/
  359. /*istanbul ignore end*/
  360. tokenize: function tokenize(value) {
  361. return value.split('');
  362. },
  363. /*istanbul ignore start*/
  364. /*istanbul ignore end*/
  365. join: function join(chars) {
  366. return chars.join('');
  367. }
  368. };
  369. function buildValues(diff, components, newString, oldString, useLongestToken) {
  370. var componentPos = 0,
  371. componentLen = components.length,
  372. newPos = 0,
  373. oldPos = 0;
  374. for (; componentPos < componentLen; componentPos++) {
  375. var component = components[componentPos];
  376. if (!component.removed) {
  377. if (!component.added && useLongestToken) {
  378. var value = newString.slice(newPos, newPos + component.count);
  379. value = value.map(function (value, i) {
  380. var oldValue = oldString[oldPos + i];
  381. return oldValue.length > value.length ? oldValue : value;
  382. });
  383. component.value = diff.join(value);
  384. } else {
  385. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  386. }
  387. newPos += component.count; // Common case
  388. if (!component.added) {
  389. oldPos += component.count;
  390. }
  391. } else {
  392. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  393. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  394. // The diffing algorithm is tied to add then remove output and this is the simplest
  395. // route to get the desired output with minimal overhead.
  396. if (componentPos && components[componentPos - 1].added) {
  397. var tmp = components[componentPos - 1];
  398. components[componentPos - 1] = components[componentPos];
  399. components[componentPos] = tmp;
  400. }
  401. }
  402. } // Special case handle for when one terminal is ignored. For this case we merge the
  403. // terminal into the prior string and drop the change.
  404. var lastComponent = components[componentLen - 1];
  405. if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  406. components[componentLen - 2].value += lastComponent.value;
  407. components.pop();
  408. }
  409. return components;
  410. }
  411. function clonePath(path$$1) {
  412. return {
  413. newPos: path$$1.newPos,
  414. components: path$$1.components.slice(0)
  415. };
  416. }
  417. });
  418. unwrapExports(base);
  419. var character = createCommonjsModule(function (module, exports) {
  420. /*istanbul ignore start*/
  421. 'use strict';
  422. exports.__esModule = true;
  423. exports.characterDiff = undefined;
  424. exports.
  425. /*istanbul ignore end*/
  426. diffChars = diffChars;
  427. /*istanbul ignore start*/
  428. var _base2 = _interopRequireDefault(base);
  429. function _interopRequireDefault(obj) {
  430. return obj && obj.__esModule ? obj : {
  431. 'default': obj
  432. };
  433. }
  434. /*istanbul ignore end*/
  435. var characterDiff =
  436. /*istanbul ignore start*/
  437. exports.
  438. /*istanbul ignore end*/
  439. characterDiff = new
  440. /*istanbul ignore start*/
  441. _base2['default']();
  442. function diffChars(oldStr, newStr, callback) {
  443. return characterDiff.diff(oldStr, newStr, callback);
  444. }
  445. });
  446. unwrapExports(character);
  447. var params = createCommonjsModule(function (module, exports) {
  448. /*istanbul ignore start*/
  449. 'use strict';
  450. exports.__esModule = true;
  451. exports.
  452. /*istanbul ignore end*/
  453. generateOptions = generateOptions;
  454. function generateOptions(options, defaults) {
  455. if (typeof options === 'function') {
  456. defaults.callback = options;
  457. } else if (options) {
  458. for (var name in options) {
  459. /* istanbul ignore else */
  460. if (options.hasOwnProperty(name)) {
  461. defaults[name] = options[name];
  462. }
  463. }
  464. }
  465. return defaults;
  466. }
  467. });
  468. unwrapExports(params);
  469. var word = createCommonjsModule(function (module, exports) {
  470. /*istanbul ignore start*/
  471. 'use strict';
  472. exports.__esModule = true;
  473. exports.wordDiff = undefined;
  474. exports.
  475. /*istanbul ignore end*/
  476. diffWords = diffWords;
  477. /*istanbul ignore start*/
  478. exports.
  479. /*istanbul ignore end*/
  480. diffWordsWithSpace = diffWordsWithSpace;
  481. /*istanbul ignore start*/
  482. var _base2 = _interopRequireDefault(base);
  483. /*istanbul ignore end*/
  484. /*istanbul ignore start*/
  485. function _interopRequireDefault(obj) {
  486. return obj && obj.__esModule ? obj : {
  487. 'default': obj
  488. };
  489. }
  490. /*istanbul ignore end*/
  491. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  492. //
  493. // Ranges and exceptions:
  494. // Latin-1 Supplement, 0080–00FF
  495. // - U+00D7 × Multiplication sign
  496. // - U+00F7 ÷ Division sign
  497. // Latin Extended-A, 0100–017F
  498. // Latin Extended-B, 0180–024F
  499. // IPA Extensions, 0250–02AF
  500. // Spacing Modifier Letters, 02B0–02FF
  501. // - U+02C7 ˇ &#711; Caron
  502. // - U+02D8 ˘ &#728; Breve
  503. // - U+02D9 ˙ &#729; Dot Above
  504. // - U+02DA ˚ &#730; Ring Above
  505. // - U+02DB ˛ &#731; Ogonek
  506. // - U+02DC ˜ &#732; Small Tilde
  507. // - U+02DD ˝ &#733; Double Acute Accent
  508. // Latin Extended Additional, 1E00–1EFF
  509. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  510. var reWhitespace = /\S/;
  511. var wordDiff =
  512. /*istanbul ignore start*/
  513. exports.
  514. /*istanbul ignore end*/
  515. wordDiff = new
  516. /*istanbul ignore start*/
  517. _base2['default']();
  518. wordDiff.equals = function (left, right) {
  519. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  520. };
  521. wordDiff.tokenize = function (value) {
  522. var tokens = value.split(/(\s+|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  523. for (var i = 0; i < tokens.length - 1; i++) {
  524. // If we have an empty string in the next field and we have only word chars before and after, merge
  525. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  526. tokens[i] += tokens[i + 2];
  527. tokens.splice(i + 1, 2);
  528. i--;
  529. }
  530. }
  531. return tokens;
  532. };
  533. function diffWords(oldStr, newStr, callback) {
  534. var options =
  535. /*istanbul ignore start*/
  536. (0, params.generateOptions
  537. /*istanbul ignore end*/
  538. )(callback, {
  539. ignoreWhitespace: true
  540. });
  541. return wordDiff.diff(oldStr, newStr, options);
  542. }
  543. function diffWordsWithSpace(oldStr, newStr, callback) {
  544. return wordDiff.diff(oldStr, newStr, callback);
  545. }
  546. });
  547. unwrapExports(word);
  548. var line = createCommonjsModule(function (module, exports) {
  549. /*istanbul ignore start*/
  550. 'use strict';
  551. exports.__esModule = true;
  552. exports.lineDiff = undefined;
  553. exports.
  554. /*istanbul ignore end*/
  555. diffLines = diffLines;
  556. /*istanbul ignore start*/
  557. exports.
  558. /*istanbul ignore end*/
  559. diffTrimmedLines = diffTrimmedLines;
  560. /*istanbul ignore start*/
  561. var _base2 = _interopRequireDefault(base);
  562. /*istanbul ignore end*/
  563. /*istanbul ignore start*/
  564. function _interopRequireDefault(obj) {
  565. return obj && obj.__esModule ? obj : {
  566. 'default': obj
  567. };
  568. }
  569. /*istanbul ignore end*/
  570. var lineDiff =
  571. /*istanbul ignore start*/
  572. exports.
  573. /*istanbul ignore end*/
  574. lineDiff = new
  575. /*istanbul ignore start*/
  576. _base2['default']();
  577. lineDiff.tokenize = function (value) {
  578. var retLines = [],
  579. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  580. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  581. linesAndNewlines.pop();
  582. } // Merge the content and line separators into single tokens
  583. for (var i = 0; i < linesAndNewlines.length; i++) {
  584. var line = linesAndNewlines[i];
  585. if (i % 2 && !this.options.newlineIsToken) {
  586. retLines[retLines.length - 1] += line;
  587. } else {
  588. if (this.options.ignoreWhitespace) {
  589. line = line.trim();
  590. }
  591. retLines.push(line);
  592. }
  593. }
  594. return retLines;
  595. };
  596. function diffLines(oldStr, newStr, callback) {
  597. return lineDiff.diff(oldStr, newStr, callback);
  598. }
  599. function diffTrimmedLines(oldStr, newStr, callback) {
  600. var options =
  601. /*istanbul ignore start*/
  602. (0, params.generateOptions
  603. /*istanbul ignore end*/
  604. )(callback, {
  605. ignoreWhitespace: true
  606. });
  607. return lineDiff.diff(oldStr, newStr, options);
  608. }
  609. });
  610. unwrapExports(line);
  611. var sentence = createCommonjsModule(function (module, exports) {
  612. /*istanbul ignore start*/
  613. 'use strict';
  614. exports.__esModule = true;
  615. exports.sentenceDiff = undefined;
  616. exports.
  617. /*istanbul ignore end*/
  618. diffSentences = diffSentences;
  619. /*istanbul ignore start*/
  620. var _base2 = _interopRequireDefault(base);
  621. function _interopRequireDefault(obj) {
  622. return obj && obj.__esModule ? obj : {
  623. 'default': obj
  624. };
  625. }
  626. /*istanbul ignore end*/
  627. var sentenceDiff =
  628. /*istanbul ignore start*/
  629. exports.
  630. /*istanbul ignore end*/
  631. sentenceDiff = new
  632. /*istanbul ignore start*/
  633. _base2['default']();
  634. sentenceDiff.tokenize = function (value) {
  635. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  636. };
  637. function diffSentences(oldStr, newStr, callback) {
  638. return sentenceDiff.diff(oldStr, newStr, callback);
  639. }
  640. });
  641. unwrapExports(sentence);
  642. var css = createCommonjsModule(function (module, exports) {
  643. /*istanbul ignore start*/
  644. 'use strict';
  645. exports.__esModule = true;
  646. exports.cssDiff = undefined;
  647. exports.
  648. /*istanbul ignore end*/
  649. diffCss = diffCss;
  650. /*istanbul ignore start*/
  651. var _base2 = _interopRequireDefault(base);
  652. function _interopRequireDefault(obj) {
  653. return obj && obj.__esModule ? obj : {
  654. 'default': obj
  655. };
  656. }
  657. /*istanbul ignore end*/
  658. var cssDiff =
  659. /*istanbul ignore start*/
  660. exports.
  661. /*istanbul ignore end*/
  662. cssDiff = new
  663. /*istanbul ignore start*/
  664. _base2['default']();
  665. cssDiff.tokenize = function (value) {
  666. return value.split(/([{}:;,]|\s+)/);
  667. };
  668. function diffCss(oldStr, newStr, callback) {
  669. return cssDiff.diff(oldStr, newStr, callback);
  670. }
  671. });
  672. unwrapExports(css);
  673. var json = createCommonjsModule(function (module, exports) {
  674. /*istanbul ignore start*/
  675. 'use strict';
  676. exports.__esModule = true;
  677. exports.jsonDiff = undefined;
  678. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  679. return typeof obj;
  680. } : function (obj) {
  681. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
  682. };
  683. exports.
  684. /*istanbul ignore end*/
  685. diffJson = diffJson;
  686. /*istanbul ignore start*/
  687. exports.
  688. /*istanbul ignore end*/
  689. canonicalize = canonicalize;
  690. /*istanbul ignore start*/
  691. var _base2 = _interopRequireDefault(base);
  692. /*istanbul ignore end*/
  693. /*istanbul ignore start*/
  694. function _interopRequireDefault(obj) {
  695. return obj && obj.__esModule ? obj : {
  696. 'default': obj
  697. };
  698. }
  699. /*istanbul ignore end*/
  700. var objectPrototypeToString = Object.prototype.toString;
  701. var jsonDiff =
  702. /*istanbul ignore start*/
  703. exports.
  704. /*istanbul ignore end*/
  705. jsonDiff = new
  706. /*istanbul ignore start*/
  707. _base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  708. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  709. jsonDiff.useLongestToken = true;
  710. jsonDiff.tokenize =
  711. /*istanbul ignore start*/
  712. line.lineDiff.
  713. /*istanbul ignore end*/
  714. tokenize;
  715. jsonDiff.castInput = function (value) {
  716. /*istanbul ignore start*/
  717. var
  718. /*istanbul ignore end*/
  719. undefinedReplacement = this.options.undefinedReplacement;
  720. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
  721. if (typeof v === 'undefined') {
  722. return undefinedReplacement;
  723. }
  724. return v;
  725. }, ' ');
  726. };
  727. jsonDiff.equals = function (left, right) {
  728. return (
  729. /*istanbul ignore start*/
  730. _base2['default'].
  731. /*istanbul ignore end*/
  732. prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  733. );
  734. };
  735. function diffJson(oldObj, newObj, options) {
  736. return jsonDiff.diff(oldObj, newObj, options);
  737. } // This function handles the presence of circular references by bailing out when encountering an
  738. // object that is already on the "stack" of items being processed.
  739. function canonicalize(obj, stack, replacementStack) {
  740. stack = stack || [];
  741. replacementStack = replacementStack || [];
  742. var i =
  743. /*istanbul ignore start*/
  744. void 0;
  745. for (i = 0; i < stack.length; i += 1) {
  746. if (stack[i] === obj) {
  747. return replacementStack[i];
  748. }
  749. }
  750. var canonicalizedObj =
  751. /*istanbul ignore start*/
  752. void 0;
  753. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  754. stack.push(obj);
  755. canonicalizedObj = new Array(obj.length);
  756. replacementStack.push(canonicalizedObj);
  757. for (i = 0; i < obj.length; i += 1) {
  758. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
  759. }
  760. stack.pop();
  761. replacementStack.pop();
  762. return canonicalizedObj;
  763. }
  764. if (obj && obj.toJSON) {
  765. obj = obj.toJSON();
  766. }
  767. if (
  768. /*istanbul ignore start*/
  769. (typeof
  770. /*istanbul ignore end*/
  771. obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
  772. stack.push(obj);
  773. canonicalizedObj = {};
  774. replacementStack.push(canonicalizedObj);
  775. var sortedKeys = [],
  776. key =
  777. /*istanbul ignore start*/
  778. void 0;
  779. for (key in obj) {
  780. /* istanbul ignore else */
  781. if (obj.hasOwnProperty(key)) {
  782. sortedKeys.push(key);
  783. }
  784. }
  785. sortedKeys.sort();
  786. for (i = 0; i < sortedKeys.length; i += 1) {
  787. key = sortedKeys[i];
  788. canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
  789. }
  790. stack.pop();
  791. replacementStack.pop();
  792. } else {
  793. canonicalizedObj = obj;
  794. }
  795. return canonicalizedObj;
  796. }
  797. });
  798. unwrapExports(json);
  799. var array = createCommonjsModule(function (module, exports) {
  800. /*istanbul ignore start*/
  801. 'use strict';
  802. exports.__esModule = true;
  803. exports.arrayDiff = undefined;
  804. exports.
  805. /*istanbul ignore end*/
  806. diffArrays = diffArrays;
  807. /*istanbul ignore start*/
  808. var _base2 = _interopRequireDefault(base);
  809. function _interopRequireDefault(obj) {
  810. return obj && obj.__esModule ? obj : {
  811. 'default': obj
  812. };
  813. }
  814. /*istanbul ignore end*/
  815. var arrayDiff =
  816. /*istanbul ignore start*/
  817. exports.
  818. /*istanbul ignore end*/
  819. arrayDiff = new
  820. /*istanbul ignore start*/
  821. _base2['default']();
  822. arrayDiff.tokenize = arrayDiff.join = function (value) {
  823. return value.slice();
  824. };
  825. function diffArrays(oldArr, newArr, callback) {
  826. return arrayDiff.diff(oldArr, newArr, callback);
  827. }
  828. });
  829. unwrapExports(array);
  830. var parse = createCommonjsModule(function (module, exports) {
  831. /*istanbul ignore start*/
  832. 'use strict';
  833. exports.__esModule = true;
  834. exports.
  835. /*istanbul ignore end*/
  836. parsePatch = parsePatch;
  837. function parsePatch(uniDiff) {
  838. /*istanbul ignore start*/
  839. var
  840. /*istanbul ignore end*/
  841. options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  842. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  843. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  844. list = [],
  845. i = 0;
  846. function parseIndex() {
  847. var index = {};
  848. list.push(index); // Parse diff metadata
  849. while (i < diffstr.length) {
  850. var line = diffstr[i]; // File header found, end parsing diff metadata
  851. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  852. break;
  853. } // Diff index
  854. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  855. if (header) {
  856. index.index = header[1];
  857. }
  858. i++;
  859. } // Parse file headers if they are defined. Unified diff requires them, but
  860. // there's no technical issues to have an isolated hunk without file header
  861. parseFileHeader(index);
  862. parseFileHeader(index); // Parse hunks
  863. index.hunks = [];
  864. while (i < diffstr.length) {
  865. var _line = diffstr[i];
  866. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  867. break;
  868. } else if (/^@@/.test(_line)) {
  869. index.hunks.push(parseHunk());
  870. } else if (_line && options.strict) {
  871. // Ignore unexpected content unless in strict mode
  872. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  873. } else {
  874. i++;
  875. }
  876. }
  877. } // Parses the --- and +++ headers, if none are found, no lines
  878. // are consumed.
  879. function parseFileHeader(index) {
  880. var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
  881. var fileHeader = headerPattern.exec(diffstr[i]);
  882. if (fileHeader) {
  883. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  884. index[keyPrefix + 'FileName'] = fileHeader[2];
  885. index[keyPrefix + 'Header'] = fileHeader[3];
  886. i++;
  887. }
  888. } // Parses a hunk
  889. // This assumes that we are at the start of a hunk.
  890. function parseHunk() {
  891. var chunkHeaderIndex = i,
  892. chunkHeaderLine = diffstr[i++],
  893. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  894. var hunk = {
  895. oldStart: +chunkHeader[1],
  896. oldLines: +chunkHeader[2] || 1,
  897. newStart: +chunkHeader[3],
  898. newLines: +chunkHeader[4] || 1,
  899. lines: [],
  900. linedelimiters: []
  901. };
  902. var addCount = 0,
  903. removeCount = 0;
  904. for (; i < diffstr.length; i++) {
  905. // Lines starting with '---' could be mistaken for the "remove line" operation
  906. // But they could be the header for the next file. Therefore prune such cases out.
  907. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  908. break;
  909. }
  910. var operation = diffstr[i][0];
  911. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  912. hunk.lines.push(diffstr[i]);
  913. hunk.linedelimiters.push(delimiters[i] || '\n');
  914. if (operation === '+') {
  915. addCount++;
  916. } else if (operation === '-') {
  917. removeCount++;
  918. } else if (operation === ' ') {
  919. addCount++;
  920. removeCount++;
  921. }
  922. } else {
  923. break;
  924. }
  925. } // Handle the empty block count case
  926. if (!addCount && hunk.newLines === 1) {
  927. hunk.newLines = 0;
  928. }
  929. if (!removeCount && hunk.oldLines === 1) {
  930. hunk.oldLines = 0;
  931. } // Perform optional sanity checking
  932. if (options.strict) {
  933. if (addCount !== hunk.newLines) {
  934. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  935. }
  936. if (removeCount !== hunk.oldLines) {
  937. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  938. }
  939. }
  940. return hunk;
  941. }
  942. while (i < diffstr.length) {
  943. parseIndex();
  944. }
  945. return list;
  946. }
  947. });
  948. unwrapExports(parse);
  949. var distanceIterator = createCommonjsModule(function (module, exports) {
  950. /*istanbul ignore start*/
  951. "use strict";
  952. exports.__esModule = true;
  953. exports["default"] =
  954. /*istanbul ignore end*/
  955. function (start, minLine, maxLine) {
  956. var wantForward = true,
  957. backwardExhausted = false,
  958. forwardExhausted = false,
  959. localOffset = 1;
  960. return function iterator() {
  961. if (wantForward && !forwardExhausted) {
  962. if (backwardExhausted) {
  963. localOffset++;
  964. } else {
  965. wantForward = false;
  966. } // Check if trying to fit beyond text length, and if not, check it fits
  967. // after offset location (or desired location on first iteration)
  968. if (start + localOffset <= maxLine) {
  969. return localOffset;
  970. }
  971. forwardExhausted = true;
  972. }
  973. if (!backwardExhausted) {
  974. if (!forwardExhausted) {
  975. wantForward = true;
  976. } // Check if trying to fit before text beginning, and if not, check it fits
  977. // before offset location
  978. if (minLine <= start - localOffset) {
  979. return -localOffset++;
  980. }
  981. backwardExhausted = true;
  982. return iterator();
  983. } // We tried to fit hunk before text beginning and beyond text lenght, then
  984. // hunk can't fit on the text. Return undefined
  985. };
  986. };
  987. });
  988. unwrapExports(distanceIterator);
  989. var apply = createCommonjsModule(function (module, exports) {
  990. /*istanbul ignore start*/
  991. 'use strict';
  992. exports.__esModule = true;
  993. exports.
  994. /*istanbul ignore end*/
  995. applyPatch = applyPatch;
  996. /*istanbul ignore start*/
  997. exports.
  998. /*istanbul ignore end*/
  999. applyPatches = applyPatches;
  1000. /*istanbul ignore start*/
  1001. var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  1002. function _interopRequireDefault(obj) {
  1003. return obj && obj.__esModule ? obj : {
  1004. 'default': obj
  1005. };
  1006. }
  1007. /*istanbul ignore end*/
  1008. function applyPatch(source, uniDiff) {
  1009. /*istanbul ignore start*/
  1010. var
  1011. /*istanbul ignore end*/
  1012. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  1013. if (typeof uniDiff === 'string') {
  1014. uniDiff =
  1015. /*istanbul ignore start*/
  1016. (0, parse.parsePatch
  1017. /*istanbul ignore end*/
  1018. )(uniDiff);
  1019. }
  1020. if (Array.isArray(uniDiff)) {
  1021. if (uniDiff.length > 1) {
  1022. throw new Error('applyPatch only works with a single input.');
  1023. }
  1024. uniDiff = uniDiff[0];
  1025. } // Apply the diff to the input
  1026. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1027. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1028. hunks = uniDiff.hunks,
  1029. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1030. /*istanbul ignore start*/
  1031. {
  1032. return (
  1033. /*istanbul ignore end*/
  1034. line === patchContent
  1035. );
  1036. },
  1037. errorCount = 0,
  1038. fuzzFactor = options.fuzzFactor || 0,
  1039. minLine = 0,
  1040. offset = 0,
  1041. removeEOFNL =
  1042. /*istanbul ignore start*/
  1043. void 0
  1044. /*istanbul ignore end*/
  1045. ,
  1046. addEOFNL =
  1047. /*istanbul ignore start*/
  1048. void 0;
  1049. /**
  1050. * Checks if the hunk exactly fits on the provided location
  1051. */
  1052. function hunkFits(hunk, toPos) {
  1053. for (var j = 0; j < hunk.lines.length; j++) {
  1054. var line = hunk.lines[j],
  1055. operation = line[0],
  1056. content = line.substr(1);
  1057. if (operation === ' ' || operation === '-') {
  1058. // Context sanity check
  1059. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1060. errorCount++;
  1061. if (errorCount > fuzzFactor) {
  1062. return false;
  1063. }
  1064. }
  1065. toPos++;
  1066. }
  1067. }
  1068. return true;
  1069. } // Search best fit offsets for each hunk based on the previous ones
  1070. for (var i = 0; i < hunks.length; i++) {
  1071. var hunk = hunks[i],
  1072. maxLine = lines.length - hunk.oldLines,
  1073. localOffset = 0,
  1074. toPos = offset + hunk.oldStart - 1;
  1075. var iterator =
  1076. /*istanbul ignore start*/
  1077. (0, _distanceIterator2['default']
  1078. /*istanbul ignore end*/
  1079. )(toPos, minLine, maxLine);
  1080. for (; localOffset !== undefined; localOffset = iterator()) {
  1081. if (hunkFits(hunk, toPos + localOffset)) {
  1082. hunk.offset = offset += localOffset;
  1083. break;
  1084. }
  1085. }
  1086. if (localOffset === undefined) {
  1087. return false;
  1088. } // Set lower text limit to end of the current hunk, so next ones don't try
  1089. // to fit over already patched text
  1090. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1091. } // Apply patch hunks
  1092. for (var _i = 0; _i < hunks.length; _i++) {
  1093. var _hunk = hunks[_i],
  1094. _toPos = _hunk.offset + _hunk.newStart - 1;
  1095. if (_hunk.newLines == 0) {
  1096. _toPos++;
  1097. }
  1098. for (var j = 0; j < _hunk.lines.length; j++) {
  1099. var line = _hunk.lines[j],
  1100. operation = line[0],
  1101. content = line.substr(1),
  1102. delimiter = _hunk.linedelimiters[j];
  1103. if (operation === ' ') {
  1104. _toPos++;
  1105. } else if (operation === '-') {
  1106. lines.splice(_toPos, 1);
  1107. delimiters.splice(_toPos, 1);
  1108. /* istanbul ignore else */
  1109. } else if (operation === '+') {
  1110. lines.splice(_toPos, 0, content);
  1111. delimiters.splice(_toPos, 0, delimiter);
  1112. _toPos++;
  1113. } else if (operation === '\\') {
  1114. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1115. if (previousOperation === '+') {
  1116. removeEOFNL = true;
  1117. } else if (previousOperation === '-') {
  1118. addEOFNL = true;
  1119. }
  1120. }
  1121. }
  1122. } // Handle EOFNL insertion/removal
  1123. if (removeEOFNL) {
  1124. while (!lines[lines.length - 1]) {
  1125. lines.pop();
  1126. delimiters.pop();
  1127. }
  1128. } else if (addEOFNL) {
  1129. lines.push('');
  1130. delimiters.push('\n');
  1131. }
  1132. for (var _k = 0; _k < lines.length - 1; _k++) {
  1133. lines[_k] = lines[_k] + delimiters[_k];
  1134. }
  1135. return lines.join('');
  1136. } // Wrapper that supports multiple file patches via callbacks.
  1137. function applyPatches(uniDiff, options) {
  1138. if (typeof uniDiff === 'string') {
  1139. uniDiff =
  1140. /*istanbul ignore start*/
  1141. (0, parse.parsePatch
  1142. /*istanbul ignore end*/
  1143. )(uniDiff);
  1144. }
  1145. var currentIndex = 0;
  1146. function processIndex() {
  1147. var index = uniDiff[currentIndex++];
  1148. if (!index) {
  1149. return options.complete();
  1150. }
  1151. options.loadFile(index, function (err, data) {
  1152. if (err) {
  1153. return options.complete(err);
  1154. }
  1155. var updatedContent = applyPatch(data, index, options);
  1156. options.patched(index, updatedContent, function (err) {
  1157. if (err) {
  1158. return options.complete(err);
  1159. }
  1160. processIndex();
  1161. });
  1162. });
  1163. }
  1164. processIndex();
  1165. }
  1166. });
  1167. unwrapExports(apply);
  1168. var create = createCommonjsModule(function (module, exports) {
  1169. /*istanbul ignore start*/
  1170. 'use strict';
  1171. exports.__esModule = true;
  1172. exports.
  1173. /*istanbul ignore end*/
  1174. structuredPatch = structuredPatch;
  1175. /*istanbul ignore start*/
  1176. exports.
  1177. /*istanbul ignore end*/
  1178. createTwoFilesPatch = createTwoFilesPatch;
  1179. /*istanbul ignore start*/
  1180. exports.
  1181. /*istanbul ignore end*/
  1182. createPatch = createPatch;
  1183. /*istanbul ignore start*/
  1184. function _toConsumableArray(arr) {
  1185. if (Array.isArray(arr)) {
  1186. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1187. arr2[i] = arr[i];
  1188. }
  1189. return arr2;
  1190. } else {
  1191. return Array.from(arr);
  1192. }
  1193. }
  1194. /*istanbul ignore end*/
  1195. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1196. if (!options) {
  1197. options = {};
  1198. }
  1199. if (typeof options.context === 'undefined') {
  1200. options.context = 4;
  1201. }
  1202. var diff =
  1203. /*istanbul ignore start*/
  1204. (0, line.diffLines
  1205. /*istanbul ignore end*/
  1206. )(oldStr, newStr, options);
  1207. diff.push({
  1208. value: '',
  1209. lines: []
  1210. }); // Append an empty value to make cleanup easier
  1211. function contextLines(lines) {
  1212. return lines.map(function (entry) {
  1213. return ' ' + entry;
  1214. });
  1215. }
  1216. var hunks = [];
  1217. var oldRangeStart = 0,
  1218. newRangeStart = 0,
  1219. curRange = [],
  1220. oldLine = 1,
  1221. newLine = 1;
  1222. /*istanbul ignore start*/
  1223. var _loop = function _loop(
  1224. /*istanbul ignore end*/
  1225. i) {
  1226. var current = diff[i],
  1227. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1228. current.lines = lines;
  1229. if (current.added || current.removed) {
  1230. /*istanbul ignore start*/
  1231. var _curRange;
  1232. /*istanbul ignore end*/
  1233. // If we have previous context, start with that
  1234. if (!oldRangeStart) {
  1235. var prev = diff[i - 1];
  1236. oldRangeStart = oldLine;
  1237. newRangeStart = newLine;
  1238. if (prev) {
  1239. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1240. oldRangeStart -= curRange.length;
  1241. newRangeStart -= curRange.length;
  1242. }
  1243. } // Output our changes
  1244. /*istanbul ignore start*/
  1245. (_curRange =
  1246. /*istanbul ignore end*/
  1247. curRange).push.
  1248. /*istanbul ignore start*/
  1249. apply
  1250. /*istanbul ignore end*/
  1251. (
  1252. /*istanbul ignore start*/
  1253. _curRange
  1254. /*istanbul ignore end*/
  1255. ,
  1256. /*istanbul ignore start*/
  1257. _toConsumableArray(
  1258. /*istanbul ignore end*/
  1259. lines.map(function (entry) {
  1260. return (current.added ? '+' : '-') + entry;
  1261. }))); // Track the updated file position
  1262. if (current.added) {
  1263. newLine += lines.length;
  1264. } else {
  1265. oldLine += lines.length;
  1266. }
  1267. } else {
  1268. // Identical context lines. Track line changes
  1269. if (oldRangeStart) {
  1270. // Close out any changes that have been output (or join overlapping)
  1271. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1272. /*istanbul ignore start*/
  1273. var _curRange2;
  1274. /*istanbul ignore end*/
  1275. // Overlapping
  1276. /*istanbul ignore start*/
  1277. (_curRange2 =
  1278. /*istanbul ignore end*/
  1279. curRange).push.
  1280. /*istanbul ignore start*/
  1281. apply
  1282. /*istanbul ignore end*/
  1283. (
  1284. /*istanbul ignore start*/
  1285. _curRange2
  1286. /*istanbul ignore end*/
  1287. ,
  1288. /*istanbul ignore start*/
  1289. _toConsumableArray(
  1290. /*istanbul ignore end*/
  1291. contextLines(lines)));
  1292. } else {
  1293. /*istanbul ignore start*/
  1294. var _curRange3;
  1295. /*istanbul ignore end*/
  1296. // end the range and output
  1297. var contextSize = Math.min(lines.length, options.context);
  1298. /*istanbul ignore start*/
  1299. (_curRange3 =
  1300. /*istanbul ignore end*/
  1301. curRange).push.
  1302. /*istanbul ignore start*/
  1303. apply
  1304. /*istanbul ignore end*/
  1305. (
  1306. /*istanbul ignore start*/
  1307. _curRange3
  1308. /*istanbul ignore end*/
  1309. ,
  1310. /*istanbul ignore start*/
  1311. _toConsumableArray(
  1312. /*istanbul ignore end*/
  1313. contextLines(lines.slice(0, contextSize))));
  1314. var hunk = {
  1315. oldStart: oldRangeStart,
  1316. oldLines: oldLine - oldRangeStart + contextSize,
  1317. newStart: newRangeStart,
  1318. newLines: newLine - newRangeStart + contextSize,
  1319. lines: curRange
  1320. };
  1321. if (i >= diff.length - 2 && lines.length <= options.context) {
  1322. // EOF is inside this hunk
  1323. var oldEOFNewline = /\n$/.test(oldStr);
  1324. var newEOFNewline = /\n$/.test(newStr);
  1325. if (lines.length == 0 && !oldEOFNewline) {
  1326. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1327. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1328. } else if (!oldEOFNewline || !newEOFNewline) {
  1329. curRange.push('\\ No newline at end of file');
  1330. }
  1331. }
  1332. hunks.push(hunk);
  1333. oldRangeStart = 0;
  1334. newRangeStart = 0;
  1335. curRange = [];
  1336. }
  1337. }
  1338. oldLine += lines.length;
  1339. newLine += lines.length;
  1340. }
  1341. };
  1342. for (var i = 0; i < diff.length; i++) {
  1343. /*istanbul ignore start*/
  1344. _loop(
  1345. /*istanbul ignore end*/
  1346. i);
  1347. }
  1348. return {
  1349. oldFileName: oldFileName,
  1350. newFileName: newFileName,
  1351. oldHeader: oldHeader,
  1352. newHeader: newHeader,
  1353. hunks: hunks
  1354. };
  1355. }
  1356. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1357. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  1358. var ret = [];
  1359. if (oldFileName == newFileName) {
  1360. ret.push('Index: ' + oldFileName);
  1361. }
  1362. ret.push('===================================================================');
  1363. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1364. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1365. for (var i = 0; i < diff.hunks.length; i++) {
  1366. var hunk = diff.hunks[i];
  1367. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1368. ret.push.apply(ret, hunk.lines);
  1369. }
  1370. return ret.join('\n') + '\n';
  1371. }
  1372. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1373. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1374. }
  1375. });
  1376. unwrapExports(create);
  1377. var dmp = createCommonjsModule(function (module, exports) {
  1378. /*istanbul ignore start*/
  1379. "use strict";
  1380. exports.__esModule = true;
  1381. exports.
  1382. /*istanbul ignore end*/
  1383. convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  1384. function convertChangesToDMP(changes) {
  1385. var ret = [],
  1386. change =
  1387. /*istanbul ignore start*/
  1388. void 0
  1389. /*istanbul ignore end*/
  1390. ,
  1391. operation =
  1392. /*istanbul ignore start*/
  1393. void 0;
  1394. for (var i = 0; i < changes.length; i++) {
  1395. change = changes[i];
  1396. if (change.added) {
  1397. operation = 1;
  1398. } else if (change.removed) {
  1399. operation = -1;
  1400. } else {
  1401. operation = 0;
  1402. }
  1403. ret.push([operation, change.value]);
  1404. }
  1405. return ret;
  1406. }
  1407. });
  1408. unwrapExports(dmp);
  1409. var xml = createCommonjsModule(function (module, exports) {
  1410. /*istanbul ignore start*/
  1411. 'use strict';
  1412. exports.__esModule = true;
  1413. exports.
  1414. /*istanbul ignore end*/
  1415. convertChangesToXML = convertChangesToXML;
  1416. function convertChangesToXML(changes) {
  1417. var ret = [];
  1418. for (var i = 0; i < changes.length; i++) {
  1419. var change = changes[i];
  1420. if (change.added) {
  1421. ret.push('<ins>');
  1422. } else if (change.removed) {
  1423. ret.push('<del>');
  1424. }
  1425. ret.push(escapeHTML(change.value));
  1426. if (change.added) {
  1427. ret.push('</ins>');
  1428. } else if (change.removed) {
  1429. ret.push('</del>');
  1430. }
  1431. }
  1432. return ret.join('');
  1433. }
  1434. function escapeHTML(s) {
  1435. var n = s;
  1436. n = n.replace(/&/g, '&amp;');
  1437. n = n.replace(/</g, '&lt;');
  1438. n = n.replace(/>/g, '&gt;');
  1439. n = n.replace(/"/g, '&quot;');
  1440. return n;
  1441. }
  1442. });
  1443. unwrapExports(xml);
  1444. var lib = createCommonjsModule(function (module, exports) {
  1445. /*istanbul ignore start*/
  1446. 'use strict';
  1447. exports.__esModule = true;
  1448. exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined;
  1449. /*istanbul ignore end*/
  1450. /*istanbul ignore start*/
  1451. var _base2 = _interopRequireDefault(base);
  1452. /*istanbul ignore end*/
  1453. /*istanbul ignore start*/
  1454. function _interopRequireDefault(obj) {
  1455. return obj && obj.__esModule ? obj : {
  1456. 'default': obj
  1457. };
  1458. }
  1459. exports.
  1460. /*istanbul ignore end*/
  1461. Diff = _base2['default'];
  1462. /*istanbul ignore start*/
  1463. exports.
  1464. /*istanbul ignore end*/
  1465. diffChars = character.diffChars;
  1466. /*istanbul ignore start*/
  1467. exports.
  1468. /*istanbul ignore end*/
  1469. diffWords = word.diffWords;
  1470. /*istanbul ignore start*/
  1471. exports.
  1472. /*istanbul ignore end*/
  1473. diffWordsWithSpace = word.diffWordsWithSpace;
  1474. /*istanbul ignore start*/
  1475. exports.
  1476. /*istanbul ignore end*/
  1477. diffLines = line.diffLines;
  1478. /*istanbul ignore start*/
  1479. exports.
  1480. /*istanbul ignore end*/
  1481. diffTrimmedLines = line.diffTrimmedLines;
  1482. /*istanbul ignore start*/
  1483. exports.
  1484. /*istanbul ignore end*/
  1485. diffSentences = sentence.diffSentences;
  1486. /*istanbul ignore start*/
  1487. exports.
  1488. /*istanbul ignore end*/
  1489. diffCss = css.diffCss;
  1490. /*istanbul ignore start*/
  1491. exports.
  1492. /*istanbul ignore end*/
  1493. diffJson = json.diffJson;
  1494. /*istanbul ignore start*/
  1495. exports.
  1496. /*istanbul ignore end*/
  1497. diffArrays = array.diffArrays;
  1498. /*istanbul ignore start*/
  1499. exports.
  1500. /*istanbul ignore end*/
  1501. structuredPatch = create.structuredPatch;
  1502. /*istanbul ignore start*/
  1503. exports.
  1504. /*istanbul ignore end*/
  1505. createTwoFilesPatch = create.createTwoFilesPatch;
  1506. /*istanbul ignore start*/
  1507. exports.
  1508. /*istanbul ignore end*/
  1509. createPatch = create.createPatch;
  1510. /*istanbul ignore start*/
  1511. exports.
  1512. /*istanbul ignore end*/
  1513. applyPatch = apply.applyPatch;
  1514. /*istanbul ignore start*/
  1515. exports.
  1516. /*istanbul ignore end*/
  1517. applyPatches = apply.applyPatches;
  1518. /*istanbul ignore start*/
  1519. exports.
  1520. /*istanbul ignore end*/
  1521. parsePatch = parse.parsePatch;
  1522. /*istanbul ignore start*/
  1523. exports.
  1524. /*istanbul ignore end*/
  1525. convertChangesToDMP = dmp.convertChangesToDMP;
  1526. /*istanbul ignore start*/
  1527. exports.
  1528. /*istanbul ignore end*/
  1529. convertChangesToXML = xml.convertChangesToXML;
  1530. /*istanbul ignore start*/
  1531. exports.
  1532. /*istanbul ignore end*/
  1533. canonicalize = json.canonicalize;
  1534. /* See LICENSE file for terms of use */
  1535. /*
  1536. * Text diff implementation.
  1537. *
  1538. * This library supports the following APIS:
  1539. * JsDiff.diffChars: Character by character diff
  1540. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  1541. * JsDiff.diffLines: Line based diff
  1542. *
  1543. * JsDiff.diffCss: Diff targeted at CSS content
  1544. *
  1545. * These methods are based on the implementation proposed in
  1546. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  1547. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  1548. */
  1549. });
  1550. unwrapExports(lib);
  1551. /*!
  1552. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  1553. *
  1554. * Copyright (c) 2014-2018, Jon Schlinkert.
  1555. * Released under the MIT License.
  1556. */
  1557. var normalizePath = function normalizePath(path$$1, stripTrailing) {
  1558. if (typeof path$$1 !== 'string') {
  1559. throw new TypeError('expected path to be a string');
  1560. }
  1561. if (path$$1 === '\\' || path$$1 === '/') return '/';
  1562. var len = path$$1.length;
  1563. if (len <= 1) return path$$1; // ensure that win32 namespaces has two leading slashes, so that the path is
  1564. // handled properly by the win32 version of path.parse() after being normalized
  1565. // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
  1566. var prefix = '';
  1567. if (len > 4 && path$$1[3] === '\\') {
  1568. var ch = path$$1[2];
  1569. if ((ch === '?' || ch === '.') && path$$1.slice(0, 2) === '\\\\') {
  1570. path$$1 = path$$1.slice(2);
  1571. prefix = '//';
  1572. }
  1573. }
  1574. var segs = path$$1.split(/[/\\]+/);
  1575. if (stripTrailing !== false && segs[segs.length - 1] === '') {
  1576. segs.pop();
  1577. }
  1578. return prefix + segs.join('/');
  1579. };
  1580. function _classCallCheck(instance, Constructor) {
  1581. if (!(instance instanceof Constructor)) {
  1582. throw new TypeError("Cannot call a class as a function");
  1583. }
  1584. }
  1585. function _defineProperties(target, props) {
  1586. for (var i = 0; i < props.length; i++) {
  1587. var descriptor = props[i];
  1588. descriptor.enumerable = descriptor.enumerable || false;
  1589. descriptor.configurable = true;
  1590. if ("value" in descriptor) descriptor.writable = true;
  1591. Object.defineProperty(target, descriptor.key, descriptor);
  1592. }
  1593. }
  1594. function _createClass(Constructor, protoProps, staticProps) {
  1595. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1596. if (staticProps) _defineProperties(Constructor, staticProps);
  1597. return Constructor;
  1598. }
  1599. function _inherits(subClass, superClass) {
  1600. if (typeof superClass !== "function" && superClass !== null) {
  1601. throw new TypeError("Super expression must either be null or a function");
  1602. }
  1603. subClass.prototype = Object.create(superClass && superClass.prototype, {
  1604. constructor: {
  1605. value: subClass,
  1606. writable: true,
  1607. configurable: true
  1608. }
  1609. });
  1610. if (superClass) _setPrototypeOf(subClass, superClass);
  1611. }
  1612. function _getPrototypeOf(o) {
  1613. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  1614. return o.__proto__ || Object.getPrototypeOf(o);
  1615. };
  1616. return _getPrototypeOf(o);
  1617. }
  1618. function _setPrototypeOf(o, p) {
  1619. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  1620. o.__proto__ = p;
  1621. return o;
  1622. };
  1623. return _setPrototypeOf(o, p);
  1624. }
  1625. function isNativeReflectConstruct() {
  1626. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  1627. if (Reflect.construct.sham) return false;
  1628. if (typeof Proxy === "function") return true;
  1629. try {
  1630. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  1631. return true;
  1632. } catch (e) {
  1633. return false;
  1634. }
  1635. }
  1636. function _construct(Parent, args, Class) {
  1637. if (isNativeReflectConstruct()) {
  1638. _construct = Reflect.construct;
  1639. } else {
  1640. _construct = function _construct(Parent, args, Class) {
  1641. var a = [null];
  1642. a.push.apply(a, args);
  1643. var Constructor = Function.bind.apply(Parent, a);
  1644. var instance = new Constructor();
  1645. if (Class) _setPrototypeOf(instance, Class.prototype);
  1646. return instance;
  1647. };
  1648. }
  1649. return _construct.apply(null, arguments);
  1650. }
  1651. function _isNativeFunction(fn) {
  1652. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  1653. }
  1654. function _wrapNativeSuper(Class) {
  1655. var _cache = typeof Map === "function" ? new Map() : undefined;
  1656. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  1657. if (Class === null || !_isNativeFunction(Class)) return Class;
  1658. if (typeof Class !== "function") {
  1659. throw new TypeError("Super expression must either be null or a function");
  1660. }
  1661. if (typeof _cache !== "undefined") {
  1662. if (_cache.has(Class)) return _cache.get(Class);
  1663. _cache.set(Class, Wrapper);
  1664. }
  1665. function Wrapper() {
  1666. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  1667. }
  1668. Wrapper.prototype = Object.create(Class.prototype, {
  1669. constructor: {
  1670. value: Wrapper,
  1671. enumerable: false,
  1672. writable: true,
  1673. configurable: true
  1674. }
  1675. });
  1676. return _setPrototypeOf(Wrapper, Class);
  1677. };
  1678. return _wrapNativeSuper(Class);
  1679. }
  1680. function _assertThisInitialized(self) {
  1681. if (self === void 0) {
  1682. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1683. }
  1684. return self;
  1685. }
  1686. function _possibleConstructorReturn(self, call) {
  1687. if (call && (typeof call === "object" || typeof call === "function")) {
  1688. return call;
  1689. }
  1690. return _assertThisInitialized(self);
  1691. }
  1692. function _superPropBase(object, property) {
  1693. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  1694. object = _getPrototypeOf(object);
  1695. if (object === null) break;
  1696. }
  1697. return object;
  1698. }
  1699. function _get(target, property, receiver) {
  1700. if (typeof Reflect !== "undefined" && Reflect.get) {
  1701. _get = Reflect.get;
  1702. } else {
  1703. _get = function _get(target, property, receiver) {
  1704. var base = _superPropBase(target, property);
  1705. if (!base) return;
  1706. var desc = Object.getOwnPropertyDescriptor(base, property);
  1707. if (desc.get) {
  1708. return desc.get.call(receiver);
  1709. }
  1710. return desc.value;
  1711. };
  1712. }
  1713. return _get(target, property, receiver || target);
  1714. }
  1715. function _slicedToArray(arr, i) {
  1716. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  1717. }
  1718. function _toArray(arr) {
  1719. return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
  1720. }
  1721. function _toConsumableArray(arr) {
  1722. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  1723. }
  1724. function _arrayWithoutHoles(arr) {
  1725. if (Array.isArray(arr)) {
  1726. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  1727. return arr2;
  1728. }
  1729. }
  1730. function _arrayWithHoles(arr) {
  1731. if (Array.isArray(arr)) return arr;
  1732. }
  1733. function _iterableToArray(iter) {
  1734. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  1735. }
  1736. function _iterableToArrayLimit(arr, i) {
  1737. var _arr = [];
  1738. var _n = true;
  1739. var _d = false;
  1740. var _e = undefined;
  1741. try {
  1742. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  1743. _arr.push(_s.value);
  1744. if (i && _arr.length === i) break;
  1745. }
  1746. } catch (err) {
  1747. _d = true;
  1748. _e = err;
  1749. } finally {
  1750. try {
  1751. if (!_n && _i["return"] != null) _i["return"]();
  1752. } finally {
  1753. if (_d) throw _e;
  1754. }
  1755. }
  1756. return _arr;
  1757. }
  1758. function _nonIterableSpread() {
  1759. throw new TypeError("Invalid attempt to spread non-iterable instance");
  1760. }
  1761. function _nonIterableRest() {
  1762. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  1763. }
  1764. function _toPrimitive(input, hint) {
  1765. if (typeof input !== "object" || input === null) return input;
  1766. var prim = input[Symbol.toPrimitive];
  1767. if (prim !== undefined) {
  1768. var res = prim.call(input, hint || "default");
  1769. if (typeof res !== "object") return res;
  1770. throw new TypeError("@@toPrimitive must return a primitive value.");
  1771. }
  1772. return (hint === "string" ? String : Number)(input);
  1773. }
  1774. function _toPropertyKey(arg) {
  1775. var key = _toPrimitive(arg, "string");
  1776. return typeof key === "symbol" ? key : String(key);
  1777. }
  1778. function _addElementPlacement(element, placements, silent) {
  1779. var keys = placements[element.placement];
  1780. if (!silent && keys.indexOf(element.key) !== -1) {
  1781. throw new TypeError("Duplicated element (" + element.key + ")");
  1782. }
  1783. keys.push(element.key);
  1784. }
  1785. function _fromElementDescriptor(element) {
  1786. var obj = {
  1787. kind: element.kind,
  1788. key: element.key,
  1789. placement: element.placement,
  1790. descriptor: element.descriptor
  1791. };
  1792. var desc = {
  1793. value: "Descriptor",
  1794. configurable: true
  1795. };
  1796. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1797. if (element.kind === "field") obj.initializer = element.initializer;
  1798. return obj;
  1799. }
  1800. function _toElementDescriptors(elementObjects) {
  1801. if (elementObjects === undefined) return;
  1802. return _toArray(elementObjects).map(function (elementObject) {
  1803. var element = _toElementDescriptor(elementObject);
  1804. _disallowProperty(elementObject, "finisher", "An element descriptor");
  1805. _disallowProperty(elementObject, "extras", "An element descriptor");
  1806. return element;
  1807. });
  1808. }
  1809. function _toElementDescriptor(elementObject) {
  1810. var kind = String(elementObject.kind);
  1811. if (kind !== "method" && kind !== "field") {
  1812. throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
  1813. }
  1814. var key = _toPropertyKey(elementObject.key);
  1815. var placement = String(elementObject.placement);
  1816. if (placement !== "static" && placement !== "prototype" && placement !== "own") {
  1817. throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
  1818. }
  1819. var descriptor = elementObject.descriptor;
  1820. _disallowProperty(elementObject, "elements", "An element descriptor");
  1821. var element = {
  1822. kind: kind,
  1823. key: key,
  1824. placement: placement,
  1825. descriptor: Object.assign({}, descriptor)
  1826. };
  1827. if (kind !== "field") {
  1828. _disallowProperty(elementObject, "initializer", "A method descriptor");
  1829. } else {
  1830. _disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
  1831. _disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
  1832. _disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
  1833. element.initializer = elementObject.initializer;
  1834. }
  1835. return element;
  1836. }
  1837. function _toElementFinisherExtras(elementObject) {
  1838. var element = _toElementDescriptor(elementObject);
  1839. var finisher = _optionalCallableProperty(elementObject, "finisher");
  1840. var extras = _toElementDescriptors(elementObject.extras);
  1841. return {
  1842. element: element,
  1843. finisher: finisher,
  1844. extras: extras
  1845. };
  1846. }
  1847. function _fromClassDescriptor(elements) {
  1848. var obj = {
  1849. kind: "class",
  1850. elements: elements.map(_fromElementDescriptor)
  1851. };
  1852. var desc = {
  1853. value: "Descriptor",
  1854. configurable: true
  1855. };
  1856. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1857. return obj;
  1858. }
  1859. function _toClassDescriptor(obj) {
  1860. var kind = String(obj.kind);
  1861. if (kind !== "class") {
  1862. throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
  1863. }
  1864. _disallowProperty(obj, "key", "A class descriptor");
  1865. _disallowProperty(obj, "placement", "A class descriptor");
  1866. _disallowProperty(obj, "descriptor", "A class descriptor");
  1867. _disallowProperty(obj, "initializer", "A class descriptor");
  1868. _disallowProperty(obj, "extras", "A class descriptor");
  1869. var finisher = _optionalCallableProperty(obj, "finisher");
  1870. var elements = _toElementDescriptors(obj.elements);
  1871. return {
  1872. elements: elements,
  1873. finisher: finisher
  1874. };
  1875. }
  1876. function _disallowProperty(obj, name, objectType) {
  1877. if (obj[name] !== undefined) {
  1878. throw new TypeError(objectType + " can't have a ." + name + " property.");
  1879. }
  1880. }
  1881. function _optionalCallableProperty(obj, name) {
  1882. var value = obj[name];
  1883. if (value !== undefined && typeof value !== "function") {
  1884. throw new TypeError("Expected '" + name + "' to be a function");
  1885. }
  1886. return value;
  1887. }
  1888. /**
  1889. * @class
  1890. */
  1891. var LineByLine =
  1892. /*#__PURE__*/
  1893. function () {
  1894. function LineByLine(file, options) {
  1895. _classCallCheck(this, LineByLine);
  1896. options = options || {};
  1897. if (!options.readChunk) options.readChunk = 1024;
  1898. if (!options.newLineCharacter) {
  1899. options.newLineCharacter = 0x0a; //linux line ending
  1900. } else {
  1901. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  1902. }
  1903. if (typeof file === 'number') {
  1904. this.fd = file;
  1905. } else {
  1906. this.fd = fs.openSync(file, 'r');
  1907. }
  1908. this.options = options;
  1909. this.newLineCharacter = options.newLineCharacter;
  1910. this.reset();
  1911. }
  1912. _createClass(LineByLine, [{
  1913. key: "_searchInBuffer",
  1914. value: function _searchInBuffer(buffer, hexNeedle) {
  1915. var found = -1;
  1916. for (var i = 0; i <= buffer.length; i++) {
  1917. var b_byte = buffer[i];
  1918. if (b_byte === hexNeedle) {
  1919. found = i;
  1920. break;
  1921. }
  1922. }
  1923. return found;
  1924. }
  1925. }, {
  1926. key: "reset",
  1927. value: function reset() {
  1928. this.eofReached = false;
  1929. this.linesCache = [];
  1930. this.fdPosition = 0;
  1931. }
  1932. }, {
  1933. key: "close",
  1934. value: function close() {
  1935. fs.closeSync(this.fd);
  1936. this.fd = null;
  1937. }
  1938. }, {
  1939. key: "_extractLines",
  1940. value: function _extractLines(buffer) {
  1941. var line;
  1942. var lines = [];
  1943. var bufferPosition = 0;
  1944. var lastNewLineBufferPosition = 0;
  1945. while (true) {
  1946. var bufferPositionValue = buffer[bufferPosition++];
  1947. if (bufferPositionValue === this.newLineCharacter) {
  1948. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  1949. lines.push(line);
  1950. lastNewLineBufferPosition = bufferPosition;
  1951. } else if (!bufferPositionValue) {
  1952. break;
  1953. }
  1954. }
  1955. var leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  1956. if (leftovers.length) {
  1957. lines.push(leftovers);
  1958. }
  1959. return lines;
  1960. }
  1961. }, {
  1962. key: "_readChunk",
  1963. value: function _readChunk(lineLeftovers) {
  1964. var totalBytesRead = 0;
  1965. var bytesRead;
  1966. var buffers = [];
  1967. do {
  1968. var readBuffer = new Buffer(this.options.readChunk);
  1969. bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  1970. totalBytesRead = totalBytesRead + bytesRead;
  1971. this.fdPosition = this.fdPosition + bytesRead;
  1972. buffers.push(readBuffer);
  1973. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  1974. var bufferData = Buffer.concat(buffers);
  1975. if (bytesRead < this.options.readChunk) {
  1976. this.eofReached = true;
  1977. bufferData = bufferData.slice(0, totalBytesRead);
  1978. }
  1979. if (totalBytesRead) {
  1980. this.linesCache = this._extractLines(bufferData);
  1981. if (lineLeftovers) {
  1982. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  1983. }
  1984. }
  1985. return totalBytesRead;
  1986. }
  1987. }, {
  1988. key: "next",
  1989. value: function next() {
  1990. if (!this.fd) return false;
  1991. var line = false;
  1992. if (this.eofReached && this.linesCache.length === 0) {
  1993. return line;
  1994. }
  1995. var bytesRead;
  1996. if (!this.linesCache.length) {
  1997. bytesRead = this._readChunk();
  1998. }
  1999. if (this.linesCache.length) {
  2000. line = this.linesCache.shift();
  2001. var lastLineCharacter = line[line.length - 1];
  2002. if (lastLineCharacter !== 0x0a) {
  2003. bytesRead = this._readChunk(line);
  2004. if (bytesRead) {
  2005. line = this.linesCache.shift();
  2006. }
  2007. }
  2008. }
  2009. if (this.eofReached && this.linesCache.length === 0) {
  2010. this.close();
  2011. }
  2012. if (line && line[line.length - 1] === this.newLineCharacter) {
  2013. line = line.slice(0, line.length - 1);
  2014. }
  2015. return line;
  2016. }
  2017. }]);
  2018. return LineByLine;
  2019. }();
  2020. var readlines = LineByLine;
  2021. var ConfigError =
  2022. /*#__PURE__*/
  2023. function (_Error) {
  2024. _inherits(ConfigError, _Error);
  2025. function ConfigError() {
  2026. _classCallCheck(this, ConfigError);
  2027. return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments));
  2028. }
  2029. return ConfigError;
  2030. }(_wrapNativeSuper(Error));
  2031. var DebugError =
  2032. /*#__PURE__*/
  2033. function (_Error2) {
  2034. _inherits(DebugError, _Error2);
  2035. function DebugError() {
  2036. _classCallCheck(this, DebugError);
  2037. return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments));
  2038. }
  2039. return DebugError;
  2040. }(_wrapNativeSuper(Error));
  2041. var UndefinedParserError$1 =
  2042. /*#__PURE__*/
  2043. function (_Error3) {
  2044. _inherits(UndefinedParserError, _Error3);
  2045. function UndefinedParserError() {
  2046. _classCallCheck(this, UndefinedParserError);
  2047. return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments));
  2048. }
  2049. return UndefinedParserError;
  2050. }(_wrapNativeSuper(Error));
  2051. var errors = {
  2052. ConfigError,
  2053. DebugError,
  2054. UndefinedParserError: UndefinedParserError$1
  2055. };
  2056. var semver = createCommonjsModule(function (module, exports) {
  2057. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  2058. /* nomin */
  2059. var debug;
  2060. /* nomin */
  2061. if (typeof process === 'object' &&
  2062. /* nomin */
  2063. process.env &&
  2064. /* nomin */
  2065. process.env.NODE_DEBUG &&
  2066. /* nomin */
  2067. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  2068. /* nomin */
  2069. debug = function debug() {
  2070. /* nomin */
  2071. var args = Array.prototype.slice.call(arguments, 0);
  2072. /* nomin */
  2073. args.unshift('SEMVER');
  2074. /* nomin */
  2075. console.log.apply(console, args);
  2076. /* nomin */
  2077. };
  2078. /* nomin */
  2079. else
  2080. /* nomin */
  2081. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  2082. // Not necessarily the package version of this code.
  2083. exports.SEMVER_SPEC_VERSION = '2.0.0';
  2084. var MAX_LENGTH = 256;
  2085. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // The actual regexps go on exports.re
  2086. var re = exports.re = [];
  2087. var src = exports.src = [];
  2088. var R = 0; // The following Regular Expressions can be used for tokenizing,
  2089. // validating, and parsing SemVer version strings.
  2090. // ## Numeric Identifier
  2091. // A single `0`, or a non-zero digit followed by zero or more digits.
  2092. var NUMERICIDENTIFIER = R++;
  2093. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  2094. var NUMERICIDENTIFIERLOOSE = R++;
  2095. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  2096. // Zero or more digits, followed by a letter or hyphen, and then zero or
  2097. // more letters, digits, or hyphens.
  2098. var NONNUMERICIDENTIFIER = R++;
  2099. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  2100. // Three dot-separated numeric identifiers.
  2101. var MAINVERSION = R++;
  2102. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  2103. var MAINVERSIONLOOSE = R++;
  2104. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  2105. // A numeric identifier, or a non-numeric identifier.
  2106. var PRERELEASEIDENTIFIER = R++;
  2107. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  2108. var PRERELEASEIDENTIFIERLOOSE = R++;
  2109. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  2110. // Hyphen, followed by one or more dot-separated pre-release version
  2111. // identifiers.
  2112. var PRERELEASE = R++;
  2113. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  2114. var PRERELEASELOOSE = R++;
  2115. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  2116. // Any combination of digits, letters, or hyphens.
  2117. var BUILDIDENTIFIER = R++;
  2118. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  2119. // Plus sign, followed by one or more period-separated build metadata
  2120. // identifiers.
  2121. var BUILD = R++;
  2122. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  2123. // A main version, followed optionally by a pre-release version and
  2124. // build metadata.
  2125. // Note that the only major, minor, patch, and pre-release sections of
  2126. // the version string are capturing groups. The build metadata is not a
  2127. // capturing group, because it should not ever be used in version
  2128. // comparison.
  2129. var FULL = R++;
  2130. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  2131. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  2132. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  2133. // common in the npm registry.
  2134. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  2135. var LOOSE = R++;
  2136. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  2137. var GTLT = R++;
  2138. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  2139. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  2140. // Only the first item is strictly required.
  2141. var XRANGEIDENTIFIERLOOSE = R++;
  2142. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  2143. var XRANGEIDENTIFIER = R++;
  2144. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  2145. var XRANGEPLAIN = R++;
  2146. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  2147. var XRANGEPLAINLOOSE = R++;
  2148. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  2149. var XRANGE = R++;
  2150. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  2151. var XRANGELOOSE = R++;
  2152. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Tilde ranges.
  2153. // Meaning is "reasonably at or greater than"
  2154. var LONETILDE = R++;
  2155. src[LONETILDE] = '(?:~>?)';
  2156. var TILDETRIM = R++;
  2157. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  2158. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  2159. var tildeTrimReplace = '$1~';
  2160. var TILDE = R++;
  2161. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  2162. var TILDELOOSE = R++;
  2163. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  2164. // Meaning is "at least and backwards compatible with"
  2165. var LONECARET = R++;
  2166. src[LONECARET] = '(?:\\^)';
  2167. var CARETTRIM = R++;
  2168. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  2169. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  2170. var caretTrimReplace = '$1^';
  2171. var CARET = R++;
  2172. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  2173. var CARETLOOSE = R++;
  2174. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  2175. var COMPARATORLOOSE = R++;
  2176. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  2177. var COMPARATOR = R++;
  2178. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  2179. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  2180. var COMPARATORTRIM = R++;
  2181. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  2182. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  2183. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  2184. // Note that these all use the loose form, because they'll be
  2185. // checked against either the strict or loose comparator form
  2186. // later.
  2187. var HYPHENRANGE = R++;
  2188. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  2189. var HYPHENRANGELOOSE = R++;
  2190. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  2191. var STAR = R++;
  2192. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  2193. // All are flag-free, unless they were created above with a flag.
  2194. for (var i = 0; i < R; i++) {
  2195. debug(i, src[i]);
  2196. if (!re[i]) re[i] = new RegExp(src[i]);
  2197. }
  2198. exports.parse = parse;
  2199. function parse(version, loose) {
  2200. if (version instanceof SemVer) return version;
  2201. if (typeof version !== 'string') return null;
  2202. if (version.length > MAX_LENGTH) return null;
  2203. var r = loose ? re[LOOSE] : re[FULL];
  2204. if (!r.test(version)) return null;
  2205. try {
  2206. return new SemVer(version, loose);
  2207. } catch (er) {
  2208. return null;
  2209. }
  2210. }
  2211. exports.valid = valid;
  2212. function valid(version, loose) {
  2213. var v = parse(version, loose);
  2214. return v ? v.version : null;
  2215. }
  2216. exports.clean = clean;
  2217. function clean(version, loose) {
  2218. var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
  2219. return s ? s.version : null;
  2220. }
  2221. exports.SemVer = SemVer;
  2222. function SemVer(version, loose) {
  2223. if (version instanceof SemVer) {
  2224. if (version.loose === loose) return version;else version = version.version;
  2225. } else if (typeof version !== 'string') {
  2226. throw new TypeError('Invalid Version: ' + version);
  2227. }
  2228. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  2229. if (!(this instanceof SemVer)) return new SemVer(version, loose);
  2230. debug('SemVer', version, loose);
  2231. this.loose = loose;
  2232. var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
  2233. if (!m) throw new TypeError('Invalid Version: ' + version);
  2234. this.raw = version; // these are actually numbers
  2235. this.major = +m[1];
  2236. this.minor = +m[2];
  2237. this.patch = +m[3];
  2238. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  2239. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  2240. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  2241. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  2242. if (/^[0-9]+$/.test(id)) {
  2243. var num = +id;
  2244. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  2245. }
  2246. return id;
  2247. });
  2248. this.build = m[5] ? m[5].split('.') : [];
  2249. this.format();
  2250. }
  2251. SemVer.prototype.format = function () {
  2252. this.version = this.major + '.' + this.minor + '.' + this.patch;
  2253. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  2254. return this.version;
  2255. };
  2256. SemVer.prototype.toString = function () {
  2257. return this.version;
  2258. };
  2259. SemVer.prototype.compare = function (other) {
  2260. debug('SemVer.compare', this.version, this.loose, other);
  2261. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2262. return this.compareMain(other) || this.comparePre(other);
  2263. };
  2264. SemVer.prototype.compareMain = function (other) {
  2265. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2266. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  2267. };
  2268. SemVer.prototype.comparePre = function (other) {
  2269. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose); // NOT having a prerelease is > having one
  2270. if (this.prerelease.length && !other.prerelease.length) return -1;else if (!this.prerelease.length && other.prerelease.length) return 1;else if (!this.prerelease.length && !other.prerelease.length) return 0;
  2271. var i = 0;
  2272. do {
  2273. var a = this.prerelease[i];
  2274. var b = other.prerelease[i];
  2275. debug('prerelease compare', i, a, b);
  2276. if (a === undefined && b === undefined) return 0;else if (b === undefined) return 1;else if (a === undefined) return -1;else if (a === b) continue;else return compareIdentifiers(a, b);
  2277. } while (++i);
  2278. }; // preminor will bump the version up to the next minor release, and immediately
  2279. // down to pre-release. premajor and prepatch work the same way.
  2280. SemVer.prototype.inc = function (release, identifier) {
  2281. switch (release) {
  2282. case 'premajor':
  2283. this.prerelease.length = 0;
  2284. this.patch = 0;
  2285. this.minor = 0;
  2286. this.major++;
  2287. this.inc('pre', identifier);
  2288. break;
  2289. case 'preminor':
  2290. this.prerelease.length = 0;
  2291. this.patch = 0;
  2292. this.minor++;
  2293. this.inc('pre', identifier);
  2294. break;
  2295. case 'prepatch':
  2296. // If this is already a prerelease, it will bump to the next version
  2297. // drop any prereleases that might already exist, since they are not
  2298. // relevant at this point.
  2299. this.prerelease.length = 0;
  2300. this.inc('patch', identifier);
  2301. this.inc('pre', identifier);
  2302. break;
  2303. // If the input is a non-prerelease version, this acts the same as
  2304. // prepatch.
  2305. case 'prerelease':
  2306. if (this.prerelease.length === 0) this.inc('patch', identifier);
  2307. this.inc('pre', identifier);
  2308. break;
  2309. case 'major':
  2310. // If this is a pre-major version, bump up to the same major version.
  2311. // Otherwise increment major.
  2312. // 1.0.0-5 bumps to 1.0.0
  2313. // 1.1.0 bumps to 2.0.0
  2314. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  2315. this.minor = 0;
  2316. this.patch = 0;
  2317. this.prerelease = [];
  2318. break;
  2319. case 'minor':
  2320. // If this is a pre-minor version, bump up to the same minor version.
  2321. // Otherwise increment minor.
  2322. // 1.2.0-5 bumps to 1.2.0
  2323. // 1.2.1 bumps to 1.3.0
  2324. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  2325. this.patch = 0;
  2326. this.prerelease = [];
  2327. break;
  2328. case 'patch':
  2329. // If this is not a pre-release version, it will increment the patch.
  2330. // If it is a pre-release it will bump up to the same patch version.
  2331. // 1.2.0-5 patches to 1.2.0
  2332. // 1.2.0 patches to 1.2.1
  2333. if (this.prerelease.length === 0) this.patch++;
  2334. this.prerelease = [];
  2335. break;
  2336. // This probably shouldn't be used publicly.
  2337. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  2338. case 'pre':
  2339. if (this.prerelease.length === 0) this.prerelease = [0];else {
  2340. var i = this.prerelease.length;
  2341. while (--i >= 0) {
  2342. if (typeof this.prerelease[i] === 'number') {
  2343. this.prerelease[i]++;
  2344. i = -2;
  2345. }
  2346. }
  2347. if (i === -1) // didn't increment anything
  2348. this.prerelease.push(0);
  2349. }
  2350. if (identifier) {
  2351. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  2352. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  2353. if (this.prerelease[0] === identifier) {
  2354. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  2355. } else this.prerelease = [identifier, 0];
  2356. }
  2357. break;
  2358. default:
  2359. throw new Error('invalid increment argument: ' + release);
  2360. }
  2361. this.format();
  2362. this.raw = this.version;
  2363. return this;
  2364. };
  2365. exports.inc = inc;
  2366. function inc(version, release, loose, identifier) {
  2367. if (typeof loose === 'string') {
  2368. identifier = loose;
  2369. loose = undefined;
  2370. }
  2371. try {
  2372. return new SemVer(version, loose).inc(release, identifier).version;
  2373. } catch (er) {
  2374. return null;
  2375. }
  2376. }
  2377. exports.diff = diff;
  2378. function diff(version1, version2) {
  2379. if (eq(version1, version2)) {
  2380. return null;
  2381. } else {
  2382. var v1 = parse(version1);
  2383. var v2 = parse(version2);
  2384. if (v1.prerelease.length || v2.prerelease.length) {
  2385. for (var key in v1) {
  2386. if (key === 'major' || key === 'minor' || key === 'patch') {
  2387. if (v1[key] !== v2[key]) {
  2388. return 'pre' + key;
  2389. }
  2390. }
  2391. }
  2392. return 'prerelease';
  2393. }
  2394. for (var key in v1) {
  2395. if (key === 'major' || key === 'minor' || key === 'patch') {
  2396. if (v1[key] !== v2[key]) {
  2397. return key;
  2398. }
  2399. }
  2400. }
  2401. }
  2402. }
  2403. exports.compareIdentifiers = compareIdentifiers;
  2404. var numeric = /^[0-9]+$/;
  2405. function compareIdentifiers(a, b) {
  2406. var anum = numeric.test(a);
  2407. var bnum = numeric.test(b);
  2408. if (anum && bnum) {
  2409. a = +a;
  2410. b = +b;
  2411. }
  2412. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  2413. }
  2414. exports.rcompareIdentifiers = rcompareIdentifiers;
  2415. function rcompareIdentifiers(a, b) {
  2416. return compareIdentifiers(b, a);
  2417. }
  2418. exports.major = major;
  2419. function major(a, loose) {
  2420. return new SemVer(a, loose).major;
  2421. }
  2422. exports.minor = minor;
  2423. function minor(a, loose) {
  2424. return new SemVer(a, loose).minor;
  2425. }
  2426. exports.patch = patch;
  2427. function patch(a, loose) {
  2428. return new SemVer(a, loose).patch;
  2429. }
  2430. exports.compare = compare;
  2431. function compare(a, b, loose) {
  2432. return new SemVer(a, loose).compare(new SemVer(b, loose));
  2433. }
  2434. exports.compareLoose = compareLoose;
  2435. function compareLoose(a, b) {
  2436. return compare(a, b, true);
  2437. }
  2438. exports.rcompare = rcompare;
  2439. function rcompare(a, b, loose) {
  2440. return compare(b, a, loose);
  2441. }
  2442. exports.sort = sort;
  2443. function sort(list, loose) {
  2444. return list.sort(function (a, b) {
  2445. return exports.compare(a, b, loose);
  2446. });
  2447. }
  2448. exports.rsort = rsort;
  2449. function rsort(list, loose) {
  2450. return list.sort(function (a, b) {
  2451. return exports.rcompare(a, b, loose);
  2452. });
  2453. }
  2454. exports.gt = gt;
  2455. function gt(a, b, loose) {
  2456. return compare(a, b, loose) > 0;
  2457. }
  2458. exports.lt = lt;
  2459. function lt(a, b, loose) {
  2460. return compare(a, b, loose) < 0;
  2461. }
  2462. exports.eq = eq;
  2463. function eq(a, b, loose) {
  2464. return compare(a, b, loose) === 0;
  2465. }
  2466. exports.neq = neq;
  2467. function neq(a, b, loose) {
  2468. return compare(a, b, loose) !== 0;
  2469. }
  2470. exports.gte = gte;
  2471. function gte(a, b, loose) {
  2472. return compare(a, b, loose) >= 0;
  2473. }
  2474. exports.lte = lte;
  2475. function lte(a, b, loose) {
  2476. return compare(a, b, loose) <= 0;
  2477. }
  2478. exports.cmp = cmp;
  2479. function cmp(a, op, b, loose) {
  2480. var ret;
  2481. switch (op) {
  2482. case '===':
  2483. if (typeof a === 'object') a = a.version;
  2484. if (typeof b === 'object') b = b.version;
  2485. ret = a === b;
  2486. break;
  2487. case '!==':
  2488. if (typeof a === 'object') a = a.version;
  2489. if (typeof b === 'object') b = b.version;
  2490. ret = a !== b;
  2491. break;
  2492. case '':
  2493. case '=':
  2494. case '==':
  2495. ret = eq(a, b, loose);
  2496. break;
  2497. case '!=':
  2498. ret = neq(a, b, loose);
  2499. break;
  2500. case '>':
  2501. ret = gt(a, b, loose);
  2502. break;
  2503. case '>=':
  2504. ret = gte(a, b, loose);
  2505. break;
  2506. case '<':
  2507. ret = lt(a, b, loose);
  2508. break;
  2509. case '<=':
  2510. ret = lte(a, b, loose);
  2511. break;
  2512. default:
  2513. throw new TypeError('Invalid operator: ' + op);
  2514. }
  2515. return ret;
  2516. }
  2517. exports.Comparator = Comparator;
  2518. function Comparator(comp, loose) {
  2519. if (comp instanceof Comparator) {
  2520. if (comp.loose === loose) return comp;else comp = comp.value;
  2521. }
  2522. if (!(this instanceof Comparator)) return new Comparator(comp, loose);
  2523. debug('comparator', comp, loose);
  2524. this.loose = loose;
  2525. this.parse(comp);
  2526. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  2527. debug('comp', this);
  2528. }
  2529. var ANY = {};
  2530. Comparator.prototype.parse = function (comp) {
  2531. var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2532. var m = comp.match(r);
  2533. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  2534. this.operator = m[1];
  2535. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  2536. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.loose);
  2537. };
  2538. Comparator.prototype.toString = function () {
  2539. return this.value;
  2540. };
  2541. Comparator.prototype.test = function (version) {
  2542. debug('Comparator.test', version, this.loose);
  2543. if (this.semver === ANY) return true;
  2544. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2545. return cmp(version, this.operator, this.semver, this.loose);
  2546. };
  2547. Comparator.prototype.intersects = function (comp, loose) {
  2548. if (!(comp instanceof Comparator)) {
  2549. throw new TypeError('a Comparator is required');
  2550. }
  2551. var rangeTmp;
  2552. if (this.operator === '') {
  2553. rangeTmp = new Range(comp.value, loose);
  2554. return satisfies(this.value, rangeTmp, loose);
  2555. } else if (comp.operator === '') {
  2556. rangeTmp = new Range(this.value, loose);
  2557. return satisfies(comp.semver, rangeTmp, loose);
  2558. }
  2559. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  2560. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  2561. var sameSemVer = this.semver.version === comp.semver.version;
  2562. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  2563. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, loose) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  2564. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, loose) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  2565. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  2566. };
  2567. exports.Range = Range;
  2568. function Range(range, loose) {
  2569. if (range instanceof Range) {
  2570. if (range.loose === loose) {
  2571. return range;
  2572. } else {
  2573. return new Range(range.raw, loose);
  2574. }
  2575. }
  2576. if (range instanceof Comparator) {
  2577. return new Range(range.value, loose);
  2578. }
  2579. if (!(this instanceof Range)) return new Range(range, loose);
  2580. this.loose = loose; // First, split based on boolean or ||
  2581. this.raw = range;
  2582. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  2583. return this.parseRange(range.trim());
  2584. }, this).filter(function (c) {
  2585. // throw out any that are not relevant for whatever reason
  2586. return c.length;
  2587. });
  2588. if (!this.set.length) {
  2589. throw new TypeError('Invalid SemVer Range: ' + range);
  2590. }
  2591. this.format();
  2592. }
  2593. Range.prototype.format = function () {
  2594. this.range = this.set.map(function (comps) {
  2595. return comps.join(' ').trim();
  2596. }).join('||').trim();
  2597. return this.range;
  2598. };
  2599. Range.prototype.toString = function () {
  2600. return this.range;
  2601. };
  2602. Range.prototype.parseRange = function (range) {
  2603. var loose = this.loose;
  2604. range = range.trim();
  2605. debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  2606. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  2607. range = range.replace(hr, hyphenReplace);
  2608. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  2609. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  2610. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  2611. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  2612. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  2613. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  2614. // ready to be split into comparators.
  2615. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2616. var set = range.split(' ').map(function (comp) {
  2617. return parseComparator(comp, loose);
  2618. }).join(' ').split(/\s+/);
  2619. if (this.loose) {
  2620. // in loose mode, throw out any that are not valid comparators
  2621. set = set.filter(function (comp) {
  2622. return !!comp.match(compRe);
  2623. });
  2624. }
  2625. set = set.map(function (comp) {
  2626. return new Comparator(comp, loose);
  2627. });
  2628. return set;
  2629. };
  2630. Range.prototype.intersects = function (range, loose) {
  2631. if (!(range instanceof Range)) {
  2632. throw new TypeError('a Range is required');
  2633. }
  2634. return this.set.some(function (thisComparators) {
  2635. return thisComparators.every(function (thisComparator) {
  2636. return range.set.some(function (rangeComparators) {
  2637. return rangeComparators.every(function (rangeComparator) {
  2638. return thisComparator.intersects(rangeComparator, loose);
  2639. });
  2640. });
  2641. });
  2642. });
  2643. }; // Mostly just for testing and legacy API reasons
  2644. exports.toComparators = toComparators;
  2645. function toComparators(range, loose) {
  2646. return new Range(range, loose).set.map(function (comp) {
  2647. return comp.map(function (c) {
  2648. return c.value;
  2649. }).join(' ').trim().split(' ');
  2650. });
  2651. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  2652. // already replaced the hyphen ranges
  2653. // turn into a set of JUST comparators.
  2654. function parseComparator(comp, loose) {
  2655. debug('comp', comp);
  2656. comp = replaceCarets(comp, loose);
  2657. debug('caret', comp);
  2658. comp = replaceTildes(comp, loose);
  2659. debug('tildes', comp);
  2660. comp = replaceXRanges(comp, loose);
  2661. debug('xrange', comp);
  2662. comp = replaceStars(comp, loose);
  2663. debug('stars', comp);
  2664. return comp;
  2665. }
  2666. function isX(id) {
  2667. return !id || id.toLowerCase() === 'x' || id === '*';
  2668. } // ~, ~> --> * (any, kinda silly)
  2669. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  2670. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  2671. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  2672. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  2673. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  2674. function replaceTildes(comp, loose) {
  2675. return comp.trim().split(/\s+/).map(function (comp) {
  2676. return replaceTilde(comp, loose);
  2677. }).join(' ');
  2678. }
  2679. function replaceTilde(comp, loose) {
  2680. var r = loose ? re[TILDELOOSE] : re[TILDE];
  2681. return comp.replace(r, function (_, M, m, p, pr) {
  2682. debug('tilde', comp, _, M, m, p, pr);
  2683. var ret;
  2684. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) // ~1.2 == >=1.2.0 <1.3.0
  2685. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  2686. debug('replaceTilde pr', pr);
  2687. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2688. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2689. } else // ~1.2.3 == >=1.2.3 <1.3.0
  2690. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2691. debug('tilde return', ret);
  2692. return ret;
  2693. });
  2694. } // ^ --> * (any, kinda silly)
  2695. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  2696. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  2697. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  2698. // ^1.2.3 --> >=1.2.3 <2.0.0
  2699. // ^1.2.0 --> >=1.2.0 <2.0.0
  2700. function replaceCarets(comp, loose) {
  2701. return comp.trim().split(/\s+/).map(function (comp) {
  2702. return replaceCaret(comp, loose);
  2703. }).join(' ');
  2704. }
  2705. function replaceCaret(comp, loose) {
  2706. debug('caret', comp, loose);
  2707. var r = loose ? re[CARETLOOSE] : re[CARET];
  2708. return comp.replace(r, function (_, M, m, p, pr) {
  2709. debug('caret', comp, _, M, m, p, pr);
  2710. var ret;
  2711. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  2712. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  2713. } else if (pr) {
  2714. debug('replaceCaret pr', pr);
  2715. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2716. if (M === '0') {
  2717. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2718. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  2719. } else {
  2720. debug('no pr');
  2721. if (M === '0') {
  2722. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2723. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  2724. }
  2725. debug('caret return', ret);
  2726. return ret;
  2727. });
  2728. }
  2729. function replaceXRanges(comp, loose) {
  2730. debug('replaceXRanges', comp, loose);
  2731. return comp.split(/\s+/).map(function (comp) {
  2732. return replaceXRange(comp, loose);
  2733. }).join(' ');
  2734. }
  2735. function replaceXRange(comp, loose) {
  2736. comp = comp.trim();
  2737. var r = loose ? re[XRANGELOOSE] : re[XRANGE];
  2738. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  2739. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  2740. var xM = isX(M);
  2741. var xm = xM || isX(m);
  2742. var xp = xm || isX(p);
  2743. var anyX = xp;
  2744. if (gtlt === '=' && anyX) gtlt = '';
  2745. if (xM) {
  2746. if (gtlt === '>' || gtlt === '<') {
  2747. // nothing is allowed
  2748. ret = '<0.0.0';
  2749. } else {
  2750. // nothing is forbidden
  2751. ret = '*';
  2752. }
  2753. } else if (gtlt && anyX) {
  2754. // replace X with 0
  2755. if (xm) m = 0;
  2756. if (xp) p = 0;
  2757. if (gtlt === '>') {
  2758. // >1 => >=2.0.0
  2759. // >1.2 => >=1.3.0
  2760. // >1.2.3 => >= 1.2.4
  2761. gtlt = '>=';
  2762. if (xm) {
  2763. M = +M + 1;
  2764. m = 0;
  2765. p = 0;
  2766. } else if (xp) {
  2767. m = +m + 1;
  2768. p = 0;
  2769. }
  2770. } else if (gtlt === '<=') {
  2771. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  2772. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  2773. gtlt = '<';
  2774. if (xm) M = +M + 1;else m = +m + 1;
  2775. }
  2776. ret = gtlt + M + '.' + m + '.' + p;
  2777. } else if (xm) {
  2778. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  2779. } else if (xp) {
  2780. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  2781. }
  2782. debug('xRange return', ret);
  2783. return ret;
  2784. });
  2785. } // Because * is AND-ed with everything else in the comparator,
  2786. // and '' means "any version", just remove the *s entirely.
  2787. function replaceStars(comp, loose) {
  2788. debug('replaceStars', comp, loose); // Looseness is ignored here. star is always as loose as it gets!
  2789. return comp.trim().replace(re[STAR], '');
  2790. } // This function is passed to string.replace(re[HYPHENRANGE])
  2791. // M, m, patch, prerelease, build
  2792. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  2793. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  2794. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  2795. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  2796. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  2797. if (isX(tM)) to = '';else if (isX(tm)) to = '<' + (+tM + 1) + '.0.0';else if (isX(tp)) to = '<' + tM + '.' + (+tm + 1) + '.0';else if (tpr) to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;else to = '<=' + to;
  2798. return (from + ' ' + to).trim();
  2799. } // if ANY of the sets match ALL of its comparators, then pass
  2800. Range.prototype.test = function (version) {
  2801. if (!version) return false;
  2802. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2803. for (var i = 0; i < this.set.length; i++) {
  2804. if (testSet(this.set[i], version)) return true;
  2805. }
  2806. return false;
  2807. };
  2808. function testSet(set, version) {
  2809. for (var i = 0; i < set.length; i++) {
  2810. if (!set[i].test(version)) return false;
  2811. }
  2812. if (version.prerelease.length) {
  2813. // Find the set of versions that are allowed to have prereleases
  2814. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  2815. // That should allow `1.2.3-pr.2` to pass.
  2816. // However, `1.2.4-alpha.notready` should NOT be allowed,
  2817. // even though it's within the range set by the comparators.
  2818. for (var i = 0; i < set.length; i++) {
  2819. debug(set[i].semver);
  2820. if (set[i].semver === ANY) continue;
  2821. if (set[i].semver.prerelease.length > 0) {
  2822. var allowed = set[i].semver;
  2823. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  2824. }
  2825. } // Version has a -pre, but it's not one of the ones we like.
  2826. return false;
  2827. }
  2828. return true;
  2829. }
  2830. exports.satisfies = satisfies;
  2831. function satisfies(version, range, loose) {
  2832. try {
  2833. range = new Range(range, loose);
  2834. } catch (er) {
  2835. return false;
  2836. }
  2837. return range.test(version);
  2838. }
  2839. exports.maxSatisfying = maxSatisfying;
  2840. function maxSatisfying(versions, range, loose) {
  2841. var max = null;
  2842. var maxSV = null;
  2843. try {
  2844. var rangeObj = new Range(range, loose);
  2845. } catch (er) {
  2846. return null;
  2847. }
  2848. versions.forEach(function (v) {
  2849. if (rangeObj.test(v)) {
  2850. // satisfies(v, range, loose)
  2851. if (!max || maxSV.compare(v) === -1) {
  2852. // compare(max, v, true)
  2853. max = v;
  2854. maxSV = new SemVer(max, loose);
  2855. }
  2856. }
  2857. });
  2858. return max;
  2859. }
  2860. exports.minSatisfying = minSatisfying;
  2861. function minSatisfying(versions, range, loose) {
  2862. var min = null;
  2863. var minSV = null;
  2864. try {
  2865. var rangeObj = new Range(range, loose);
  2866. } catch (er) {
  2867. return null;
  2868. }
  2869. versions.forEach(function (v) {
  2870. if (rangeObj.test(v)) {
  2871. // satisfies(v, range, loose)
  2872. if (!min || minSV.compare(v) === 1) {
  2873. // compare(min, v, true)
  2874. min = v;
  2875. minSV = new SemVer(min, loose);
  2876. }
  2877. }
  2878. });
  2879. return min;
  2880. }
  2881. exports.validRange = validRange;
  2882. function validRange(range, loose) {
  2883. try {
  2884. // Return '*' instead of '' so that truthiness works.
  2885. // This will throw if it's invalid anyway
  2886. return new Range(range, loose).range || '*';
  2887. } catch (er) {
  2888. return null;
  2889. }
  2890. } // Determine if version is less than all the versions possible in the range
  2891. exports.ltr = ltr;
  2892. function ltr(version, range, loose) {
  2893. return outside(version, range, '<', loose);
  2894. } // Determine if version is greater than all the versions possible in the range.
  2895. exports.gtr = gtr;
  2896. function gtr(version, range, loose) {
  2897. return outside(version, range, '>', loose);
  2898. }
  2899. exports.outside = outside;
  2900. function outside(version, range, hilo, loose) {
  2901. version = new SemVer(version, loose);
  2902. range = new Range(range, loose);
  2903. var gtfn, ltefn, ltfn, comp, ecomp;
  2904. switch (hilo) {
  2905. case '>':
  2906. gtfn = gt;
  2907. ltefn = lte;
  2908. ltfn = lt;
  2909. comp = '>';
  2910. ecomp = '>=';
  2911. break;
  2912. case '<':
  2913. gtfn = lt;
  2914. ltefn = gte;
  2915. ltfn = gt;
  2916. comp = '<';
  2917. ecomp = '<=';
  2918. break;
  2919. default:
  2920. throw new TypeError('Must provide a hilo val of "<" or ">"');
  2921. } // If it satisifes the range it is not outside
  2922. if (satisfies(version, range, loose)) {
  2923. return false;
  2924. } // From now on, variable terms are as if we're in "gtr" mode.
  2925. // but note that everything is flipped for the "ltr" function.
  2926. for (var i = 0; i < range.set.length; ++i) {
  2927. var comparators = range.set[i];
  2928. var high = null;
  2929. var low = null;
  2930. comparators.forEach(function (comparator) {
  2931. if (comparator.semver === ANY) {
  2932. comparator = new Comparator('>=0.0.0');
  2933. }
  2934. high = high || comparator;
  2935. low = low || comparator;
  2936. if (gtfn(comparator.semver, high.semver, loose)) {
  2937. high = comparator;
  2938. } else if (ltfn(comparator.semver, low.semver, loose)) {
  2939. low = comparator;
  2940. }
  2941. }); // If the edge version comparator has a operator then our version
  2942. // isn't outside it
  2943. if (high.operator === comp || high.operator === ecomp) {
  2944. return false;
  2945. } // If the lowest version comparator has an operator and our version
  2946. // is less than it then it isn't higher than the range
  2947. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  2948. return false;
  2949. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  2950. return false;
  2951. }
  2952. }
  2953. return true;
  2954. }
  2955. exports.prerelease = prerelease;
  2956. function prerelease(version, loose) {
  2957. var parsed = parse(version, loose);
  2958. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  2959. }
  2960. exports.intersects = intersects;
  2961. function intersects(r1, r2, loose) {
  2962. r1 = new Range(r1, loose);
  2963. r2 = new Range(r2, loose);
  2964. return r1.intersects(r2);
  2965. }
  2966. });
  2967. var arrayify = function arrayify(object, keyName) {
  2968. return Object.keys(object).reduce(function (array, key) {
  2969. return array.concat(Object.assign({
  2970. [keyName]: key
  2971. }, object[key]));
  2972. }, []);
  2973. };
  2974. var dedent_1 = createCommonjsModule(function (module) {
  2975. "use strict";
  2976. function dedent(strings) {
  2977. var raw = void 0;
  2978. if (typeof strings === "string") {
  2979. // dedent can be used as a plain function
  2980. raw = [strings];
  2981. } else {
  2982. raw = strings.raw;
  2983. } // first, perform interpolation
  2984. var result = "";
  2985. for (var i = 0; i < raw.length; i++) {
  2986. result += raw[i]. // join lines when there is a suppressed newline
  2987. replace(/\\\n[ \t]*/g, ""). // handle escaped backticks
  2988. replace(/\\`/g, "`");
  2989. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  2990. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  2991. }
  2992. } // now strip indentation
  2993. var lines = result.split("\n");
  2994. var mindent = null;
  2995. lines.forEach(function (l) {
  2996. var m = l.match(/^(\s+)\S+/);
  2997. if (m) {
  2998. var indent = m[1].length;
  2999. if (!mindent) {
  3000. // this is the first indented line
  3001. mindent = indent;
  3002. } else {
  3003. mindent = Math.min(mindent, indent);
  3004. }
  3005. }
  3006. });
  3007. if (mindent !== null) {
  3008. result = lines.map(function (l) {
  3009. return l[0] === " " ? l.slice(mindent) : l;
  3010. }).join("\n");
  3011. } // dedent eats leading and trailing whitespace too
  3012. result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too
  3013. return result.replace(/\\n/g, "\n");
  3014. }
  3015. {
  3016. module.exports = dedent;
  3017. }
  3018. });
  3019. var CATEGORY_CONFIG = "Config";
  3020. var CATEGORY_EDITOR = "Editor";
  3021. var CATEGORY_FORMAT = "Format";
  3022. var CATEGORY_OTHER = "Other";
  3023. var CATEGORY_OUTPUT = "Output";
  3024. var CATEGORY_GLOBAL = "Global";
  3025. var CATEGORY_SPECIAL = "Special";
  3026. /**
  3027. * @typedef {Object} OptionInfo
  3028. * @property {string} since - available since version
  3029. * @property {string} category
  3030. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  3031. * @property {boolean} array - indicate it's an array of the specified type
  3032. * @property {boolean?} deprecated - deprecated since version
  3033. * @property {OptionRedirectInfo?} redirect - redirect deprecated option
  3034. * @property {string} description
  3035. * @property {string?} oppositeDescription - for `false` option
  3036. * @property {OptionValueInfo} default
  3037. * @property {OptionRangeInfo?} range - for type int
  3038. * @property {OptionChoiceInfo?} choices - for type choice
  3039. * @property {(value: any) => boolean} exception
  3040. *
  3041. * @typedef {number | boolean | string} OptionValue
  3042. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  3043. *
  3044. * @typedef {Object} OptionRedirectInfo
  3045. * @property {string} option
  3046. * @property {OptionValue} value
  3047. *
  3048. * @typedef {Object} OptionRangeInfo
  3049. * @property {number} start - recommended range start
  3050. * @property {number} end - recommended range end
  3051. * @property {number} step - recommended range step
  3052. *
  3053. * @typedef {Object} OptionChoiceInfo
  3054. * @property {boolean | string} value - boolean for the option that is originally boolean type
  3055. * @property {string?} description - undefined if redirect
  3056. * @property {string?} since - undefined if available since the first version of the option
  3057. * @property {string?} deprecated - deprecated since version
  3058. * @property {OptionValueInfo?} redirect - redirect deprecated value
  3059. *
  3060. * @property {string?} cliName
  3061. * @property {string?} cliCategory
  3062. * @property {string?} cliDescription
  3063. */
  3064. /** @type {{ [name: string]: OptionInfo } */
  3065. var options$2 = {
  3066. cursorOffset: {
  3067. since: "1.4.0",
  3068. category: CATEGORY_SPECIAL,
  3069. type: "int",
  3070. default: -1,
  3071. range: {
  3072. start: -1,
  3073. end: Infinity,
  3074. step: 1
  3075. },
  3076. description: dedent_1`
  3077. Print (to stderr) where a cursor at the given position would move to after formatting.
  3078. This option cannot be used with --range-start and --range-end.
  3079. `,
  3080. cliCategory: CATEGORY_EDITOR
  3081. },
  3082. endOfLine: {
  3083. since: "1.15.0",
  3084. category: CATEGORY_GLOBAL,
  3085. type: "choice",
  3086. default: "auto",
  3087. description: "Which end of line characters to apply.",
  3088. choices: [{
  3089. value: "auto",
  3090. description: dedent_1`
  3091. Maintain existing
  3092. (mixed values within one file are normalised by looking at what's used after the first line)
  3093. `
  3094. }, {
  3095. value: "lf",
  3096. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  3097. }, {
  3098. value: "crlf",
  3099. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  3100. }, {
  3101. value: "cr",
  3102. description: "Carriage Return character only (\\r), used very rarely"
  3103. }]
  3104. },
  3105. filepath: {
  3106. since: "1.4.0",
  3107. category: CATEGORY_SPECIAL,
  3108. type: "path",
  3109. description: "Specify the input filepath. This will be used to do parser inference.",
  3110. cliName: "stdin-filepath",
  3111. cliCategory: CATEGORY_OTHER,
  3112. cliDescription: "Path to the file to pretend that stdin comes from."
  3113. },
  3114. insertPragma: {
  3115. since: "1.8.0",
  3116. category: CATEGORY_SPECIAL,
  3117. type: "boolean",
  3118. default: false,
  3119. description: "Insert @format pragma into file's first docblock comment.",
  3120. cliCategory: CATEGORY_OTHER
  3121. },
  3122. parser: {
  3123. since: "0.0.10",
  3124. category: CATEGORY_GLOBAL,
  3125. type: "choice",
  3126. default: [{
  3127. since: "0.0.10",
  3128. value: "babylon"
  3129. }, {
  3130. since: "1.13.0",
  3131. value: undefined
  3132. }],
  3133. description: "Which parser to use.",
  3134. exception: function exception(value) {
  3135. return typeof value === "string" || typeof value === "function";
  3136. },
  3137. choices: [{
  3138. value: "flow",
  3139. description: "Flow"
  3140. }, {
  3141. value: "babylon",
  3142. description: "JavaScript",
  3143. deprecated: "1.16.0",
  3144. redirect: "babel"
  3145. }, {
  3146. value: "babel",
  3147. since: "1.16.0",
  3148. description: "JavaScript"
  3149. }, {
  3150. value: "babel-flow",
  3151. since: "1.16.0",
  3152. description: "Flow"
  3153. }, {
  3154. value: "typescript",
  3155. since: "1.4.0",
  3156. description: "TypeScript"
  3157. }, {
  3158. value: "css",
  3159. since: "1.7.1",
  3160. description: "CSS"
  3161. }, {
  3162. value: "postcss",
  3163. since: "1.4.0",
  3164. description: "CSS/Less/SCSS",
  3165. deprecated: "1.7.1",
  3166. redirect: "css"
  3167. }, {
  3168. value: "less",
  3169. since: "1.7.1",
  3170. description: "Less"
  3171. }, {
  3172. value: "scss",
  3173. since: "1.7.1",
  3174. description: "SCSS"
  3175. }, {
  3176. value: "json",
  3177. since: "1.5.0",
  3178. description: "JSON"
  3179. }, {
  3180. value: "json5",
  3181. since: "1.13.0",
  3182. description: "JSON5"
  3183. }, {
  3184. value: "json-stringify",
  3185. since: "1.13.0",
  3186. description: "JSON.stringify"
  3187. }, {
  3188. value: "graphql",
  3189. since: "1.5.0",
  3190. description: "GraphQL"
  3191. }, {
  3192. value: "markdown",
  3193. since: "1.8.0",
  3194. description: "Markdown"
  3195. }, {
  3196. value: "mdx",
  3197. since: "1.15.0",
  3198. description: "MDX"
  3199. }, {
  3200. value: "vue",
  3201. since: "1.10.0",
  3202. description: "Vue"
  3203. }, {
  3204. value: "yaml",
  3205. since: "1.14.0",
  3206. description: "YAML"
  3207. }, {
  3208. value: "glimmer",
  3209. since: null,
  3210. description: "Handlebars"
  3211. }, {
  3212. value: "html",
  3213. since: "1.15.0",
  3214. description: "HTML"
  3215. }, {
  3216. value: "angular",
  3217. since: "1.15.0",
  3218. description: "Angular"
  3219. }, {
  3220. value: "lwc",
  3221. since: "1.17.0",
  3222. description: "Lightning Web Components"
  3223. }]
  3224. },
  3225. plugins: {
  3226. since: "1.10.0",
  3227. type: "path",
  3228. array: true,
  3229. default: [{
  3230. value: []
  3231. }],
  3232. category: CATEGORY_GLOBAL,
  3233. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  3234. exception: function exception(value) {
  3235. return typeof value === "string" || typeof value === "object";
  3236. },
  3237. cliName: "plugin",
  3238. cliCategory: CATEGORY_CONFIG
  3239. },
  3240. pluginSearchDirs: {
  3241. since: "1.13.0",
  3242. type: "path",
  3243. array: true,
  3244. default: [{
  3245. value: []
  3246. }],
  3247. category: CATEGORY_GLOBAL,
  3248. description: dedent_1`
  3249. Custom directory that contains prettier plugins in node_modules subdirectory.
  3250. Overrides default behavior when plugins are searched relatively to the location of Prettier.
  3251. Multiple values are accepted.
  3252. `,
  3253. exception: function exception(value) {
  3254. return typeof value === "string" || typeof value === "object";
  3255. },
  3256. cliName: "plugin-search-dir",
  3257. cliCategory: CATEGORY_CONFIG
  3258. },
  3259. printWidth: {
  3260. since: "0.0.0",
  3261. category: CATEGORY_GLOBAL,
  3262. type: "int",
  3263. default: 80,
  3264. description: "The line length where Prettier will try wrap.",
  3265. range: {
  3266. start: 0,
  3267. end: Infinity,
  3268. step: 1
  3269. }
  3270. },
  3271. rangeEnd: {
  3272. since: "1.4.0",
  3273. category: CATEGORY_SPECIAL,
  3274. type: "int",
  3275. default: Infinity,
  3276. range: {
  3277. start: 0,
  3278. end: Infinity,
  3279. step: 1
  3280. },
  3281. description: dedent_1`
  3282. Format code ending at a given character offset (exclusive).
  3283. The range will extend forwards to the end of the selected statement.
  3284. This option cannot be used with --cursor-offset.
  3285. `,
  3286. cliCategory: CATEGORY_EDITOR
  3287. },
  3288. rangeStart: {
  3289. since: "1.4.0",
  3290. category: CATEGORY_SPECIAL,
  3291. type: "int",
  3292. default: 0,
  3293. range: {
  3294. start: 0,
  3295. end: Infinity,
  3296. step: 1
  3297. },
  3298. description: dedent_1`
  3299. Format code starting at a given character offset.
  3300. The range will extend backwards to the start of the first line containing the selected statement.
  3301. This option cannot be used with --cursor-offset.
  3302. `,
  3303. cliCategory: CATEGORY_EDITOR
  3304. },
  3305. requirePragma: {
  3306. since: "1.7.0",
  3307. category: CATEGORY_SPECIAL,
  3308. type: "boolean",
  3309. default: false,
  3310. description: dedent_1`
  3311. Require either '@prettier' or '@format' to be present in the file's first docblock comment
  3312. in order for it to be formatted.
  3313. `,
  3314. cliCategory: CATEGORY_OTHER
  3315. },
  3316. tabWidth: {
  3317. type: "int",
  3318. category: CATEGORY_GLOBAL,
  3319. default: 2,
  3320. description: "Number of spaces per indentation level.",
  3321. range: {
  3322. start: 0,
  3323. end: Infinity,
  3324. step: 1
  3325. }
  3326. },
  3327. useFlowParser: {
  3328. since: "0.0.0",
  3329. category: CATEGORY_GLOBAL,
  3330. type: "boolean",
  3331. default: [{
  3332. since: "0.0.0",
  3333. value: false
  3334. }, {
  3335. since: "1.15.0",
  3336. value: undefined
  3337. }],
  3338. deprecated: "0.0.10",
  3339. description: "Use flow parser.",
  3340. redirect: {
  3341. option: "parser",
  3342. value: "flow"
  3343. },
  3344. cliName: "flow-parser"
  3345. },
  3346. useTabs: {
  3347. since: "1.0.0",
  3348. category: CATEGORY_GLOBAL,
  3349. type: "boolean",
  3350. default: false,
  3351. description: "Indent with tabs instead of spaces."
  3352. }
  3353. };
  3354. var coreOptions$1 = {
  3355. CATEGORY_CONFIG,
  3356. CATEGORY_EDITOR,
  3357. CATEGORY_FORMAT,
  3358. CATEGORY_OTHER,
  3359. CATEGORY_OUTPUT,
  3360. CATEGORY_GLOBAL,
  3361. CATEGORY_SPECIAL,
  3362. options: options$2
  3363. };
  3364. var require$$0 = ( _package$1 && _package ) || _package$1;
  3365. var currentVersion = require$$0.version;
  3366. var coreOptions = coreOptions$1.options;
  3367. function getSupportInfo$2(version, opts) {
  3368. opts = Object.assign({
  3369. plugins: [],
  3370. showUnreleased: false,
  3371. showDeprecated: false,
  3372. showInternal: false
  3373. }, opts);
  3374. if (!version) {
  3375. // pre-release version is smaller than the normal version in semver,
  3376. // we need to treat it as the normal one so as to test new features.
  3377. version = currentVersion.split("-", 1)[0];
  3378. }
  3379. var plugins = opts.plugins;
  3380. var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) {
  3381. return Object.assign(currentOptions, plugin.options);
  3382. }, {}), coreOptions), "name").sort(function (a, b) {
  3383. return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
  3384. }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) {
  3385. var newOption = Object.assign({}, option);
  3386. if (Array.isArray(newOption.default)) {
  3387. newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) {
  3388. return semver.compare(info2.since, info1.since);
  3389. })[0].value;
  3390. }
  3391. if (Array.isArray(newOption.choices)) {
  3392. newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated);
  3393. }
  3394. return newOption;
  3395. }).map(function (option) {
  3396. var filteredPlugins = plugins.filter(function (plugin) {
  3397. return plugin.defaultOptions && plugin.defaultOptions[option.name];
  3398. });
  3399. var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) {
  3400. reduced[plugin.name] = plugin.defaultOptions[option.name];
  3401. return reduced;
  3402. }, {});
  3403. return Object.assign(option, {
  3404. pluginDefaults
  3405. });
  3406. });
  3407. var usePostCssParser = semver.lt(version, "1.7.1");
  3408. var useBabylonParser = semver.lt(version, "1.16.0");
  3409. var languages = plugins.reduce(function (all, plugin) {
  3410. return all.concat(plugin.languages || []);
  3411. }, []).filter(filterSince).map(function (language) {
  3412. // Prevent breaking changes
  3413. if (language.name === "Markdown") {
  3414. return Object.assign({}, language, {
  3415. parsers: ["markdown"]
  3416. });
  3417. }
  3418. if (language.name === "TypeScript") {
  3419. return Object.assign({}, language, {
  3420. parsers: ["typescript"]
  3421. });
  3422. } // "babylon" was renamed to "babel" in 1.16.0
  3423. if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
  3424. return Object.assign({}, language, {
  3425. parsers: language.parsers.map(function (parser) {
  3426. return parser === "babel" ? "babylon" : parser;
  3427. })
  3428. });
  3429. }
  3430. if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
  3431. return Object.assign({}, language, {
  3432. parsers: ["postcss"]
  3433. });
  3434. }
  3435. return language;
  3436. });
  3437. return {
  3438. languages,
  3439. options
  3440. };
  3441. function filterSince(object) {
  3442. return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
  3443. }
  3444. function filterDeprecated(object) {
  3445. return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
  3446. }
  3447. function mapDeprecated(object) {
  3448. if (!object.deprecated || opts.showDeprecated) {
  3449. return object;
  3450. }
  3451. var newObject = Object.assign({}, object);
  3452. delete newObject.deprecated;
  3453. delete newObject.redirect;
  3454. return newObject;
  3455. }
  3456. function mapInternal(object) {
  3457. if (opts.showInternal) {
  3458. return object;
  3459. }
  3460. var newObject = Object.assign({}, object);
  3461. delete newObject.cliName;
  3462. delete newObject.cliCategory;
  3463. delete newObject.cliDescription;
  3464. return newObject;
  3465. }
  3466. }
  3467. var support = {
  3468. getSupportInfo: getSupportInfo$2
  3469. };
  3470. /*! *****************************************************************************
  3471. Copyright (c) Microsoft Corporation. All rights reserved.
  3472. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  3473. this file except in compliance with the License. You may obtain a copy of the
  3474. License at http://www.apache.org/licenses/LICENSE-2.0
  3475. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3476. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  3477. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  3478. MERCHANTABLITY OR NON-INFRINGEMENT.
  3479. See the Apache Version 2.0 License for specific language governing permissions
  3480. and limitations under the License.
  3481. ***************************************************************************** */
  3482. /* global Reflect, Promise */
  3483. var _extendStatics = function extendStatics(d, b) {
  3484. _extendStatics = Object.setPrototypeOf || {
  3485. __proto__: []
  3486. } instanceof Array && function (d, b) {
  3487. d.__proto__ = b;
  3488. } || function (d, b) {
  3489. for (var p in b) {
  3490. if (b.hasOwnProperty(p)) d[p] = b[p];
  3491. }
  3492. };
  3493. return _extendStatics(d, b);
  3494. };
  3495. function __extends(d, b) {
  3496. _extendStatics(d, b);
  3497. function __() {
  3498. this.constructor = d;
  3499. }
  3500. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3501. }
  3502. var _assign = function __assign() {
  3503. _assign = Object.assign || function __assign(t) {
  3504. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3505. s = arguments[i];
  3506. for (var p in s) {
  3507. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  3508. }
  3509. }
  3510. return t;
  3511. };
  3512. return _assign.apply(this, arguments);
  3513. };
  3514. function __rest(s, e) {
  3515. var t = {};
  3516. for (var p in s) {
  3517. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  3518. }
  3519. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  3520. if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
  3521. }
  3522. return t;
  3523. }
  3524. function __decorate(decorators, target, key, desc) {
  3525. var c = arguments.length,
  3526. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  3527. d;
  3528. 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--) {
  3529. if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3530. }
  3531. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3532. }
  3533. function __param(paramIndex, decorator) {
  3534. return function (target, key) {
  3535. decorator(target, key, paramIndex);
  3536. };
  3537. }
  3538. function __metadata(metadataKey, metadataValue) {
  3539. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  3540. }
  3541. function __awaiter(thisArg, _arguments, P, generator) {
  3542. return new (P || (P = Promise))(function (resolve, reject) {
  3543. function fulfilled(value) {
  3544. try {
  3545. step(generator.next(value));
  3546. } catch (e) {
  3547. reject(e);
  3548. }
  3549. }
  3550. function rejected(value) {
  3551. try {
  3552. step(generator["throw"](value));
  3553. } catch (e) {
  3554. reject(e);
  3555. }
  3556. }
  3557. function step(result) {
  3558. result.done ? resolve(result.value) : new P(function (resolve) {
  3559. resolve(result.value);
  3560. }).then(fulfilled, rejected);
  3561. }
  3562. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3563. });
  3564. }
  3565. function __generator(thisArg, body) {
  3566. var _ = {
  3567. label: 0,
  3568. sent: function sent() {
  3569. if (t[0] & 1) throw t[1];
  3570. return t[1];
  3571. },
  3572. trys: [],
  3573. ops: []
  3574. },
  3575. f,
  3576. y,
  3577. t,
  3578. g;
  3579. return g = {
  3580. next: verb(0),
  3581. "throw": verb(1),
  3582. "return": verb(2)
  3583. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  3584. return this;
  3585. }), g;
  3586. function verb(n) {
  3587. return function (v) {
  3588. return step([n, v]);
  3589. };
  3590. }
  3591. function step(op) {
  3592. if (f) throw new TypeError("Generator is already executing.");
  3593. while (_) {
  3594. try {
  3595. 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;
  3596. if (y = 0, t) op = [op[0] & 2, t.value];
  3597. switch (op[0]) {
  3598. case 0:
  3599. case 1:
  3600. t = op;
  3601. break;
  3602. case 4:
  3603. _.label++;
  3604. return {
  3605. value: op[1],
  3606. done: false
  3607. };
  3608. case 5:
  3609. _.label++;
  3610. y = op[1];
  3611. op = [0];
  3612. continue;
  3613. case 7:
  3614. op = _.ops.pop();
  3615. _.trys.pop();
  3616. continue;
  3617. default:
  3618. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  3619. _ = 0;
  3620. continue;
  3621. }
  3622. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  3623. _.label = op[1];
  3624. break;
  3625. }
  3626. if (op[0] === 6 && _.label < t[1]) {
  3627. _.label = t[1];
  3628. t = op;
  3629. break;
  3630. }
  3631. if (t && _.label < t[2]) {
  3632. _.label = t[2];
  3633. _.ops.push(op);
  3634. break;
  3635. }
  3636. if (t[2]) _.ops.pop();
  3637. _.trys.pop();
  3638. continue;
  3639. }
  3640. op = body.call(thisArg, _);
  3641. } catch (e) {
  3642. op = [6, e];
  3643. y = 0;
  3644. } finally {
  3645. f = t = 0;
  3646. }
  3647. }
  3648. if (op[0] & 5) throw op[1];
  3649. return {
  3650. value: op[0] ? op[1] : void 0,
  3651. done: true
  3652. };
  3653. }
  3654. }
  3655. function __exportStar(m, exports) {
  3656. for (var p in m) {
  3657. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3658. }
  3659. }
  3660. function __values(o) {
  3661. var m = typeof Symbol === "function" && o[Symbol.iterator],
  3662. i = 0;
  3663. if (m) return m.call(o);
  3664. return {
  3665. next: function next() {
  3666. if (o && i >= o.length) o = void 0;
  3667. return {
  3668. value: o && o[i++],
  3669. done: !o
  3670. };
  3671. }
  3672. };
  3673. }
  3674. function __read(o, n) {
  3675. var m = typeof Symbol === "function" && o[Symbol.iterator];
  3676. if (!m) return o;
  3677. var i = m.call(o),
  3678. r,
  3679. ar = [],
  3680. e;
  3681. try {
  3682. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  3683. ar.push(r.value);
  3684. }
  3685. } catch (error) {
  3686. e = {
  3687. error: error
  3688. };
  3689. } finally {
  3690. try {
  3691. if (r && !r.done && (m = i["return"])) m.call(i);
  3692. } finally {
  3693. if (e) throw e.error;
  3694. }
  3695. }
  3696. return ar;
  3697. }
  3698. function __spread() {
  3699. for (var ar = [], i = 0; i < arguments.length; i++) {
  3700. ar = ar.concat(__read(arguments[i]));
  3701. }
  3702. return ar;
  3703. }
  3704. function __await(v) {
  3705. return this instanceof __await ? (this.v = v, this) : new __await(v);
  3706. }
  3707. function __asyncGenerator(thisArg, _arguments, generator) {
  3708. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  3709. var g = generator.apply(thisArg, _arguments || []),
  3710. i,
  3711. q = [];
  3712. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  3713. return this;
  3714. }, i;
  3715. function verb(n) {
  3716. if (g[n]) i[n] = function (v) {
  3717. return new Promise(function (a, b) {
  3718. q.push([n, v, a, b]) > 1 || resume(n, v);
  3719. });
  3720. };
  3721. }
  3722. function resume(n, v) {
  3723. try {
  3724. step(g[n](v));
  3725. } catch (e) {
  3726. settle(q[0][3], e);
  3727. }
  3728. }
  3729. function step(r) {
  3730. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  3731. }
  3732. function fulfill(value) {
  3733. resume("next", value);
  3734. }
  3735. function reject(value) {
  3736. resume("throw", value);
  3737. }
  3738. function settle(f, v) {
  3739. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  3740. }
  3741. }
  3742. function __asyncDelegator(o) {
  3743. var i, p;
  3744. return i = {}, verb("next"), verb("throw", function (e) {
  3745. throw e;
  3746. }), verb("return"), i[Symbol.iterator] = function () {
  3747. return this;
  3748. }, i;
  3749. function verb(n, f) {
  3750. i[n] = o[n] ? function (v) {
  3751. return (p = !p) ? {
  3752. value: __await(o[n](v)),
  3753. done: n === "return"
  3754. } : f ? f(v) : v;
  3755. } : f;
  3756. }
  3757. }
  3758. function __asyncValues(o) {
  3759. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  3760. var m = o[Symbol.asyncIterator],
  3761. i;
  3762. 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 () {
  3763. return this;
  3764. }, i);
  3765. function verb(n) {
  3766. i[n] = o[n] && function (v) {
  3767. return new Promise(function (resolve, reject) {
  3768. v = o[n](v), settle(resolve, reject, v.done, v.value);
  3769. });
  3770. };
  3771. }
  3772. function settle(resolve, reject, d, v) {
  3773. Promise.resolve(v).then(function (v) {
  3774. resolve({
  3775. value: v,
  3776. done: d
  3777. });
  3778. }, reject);
  3779. }
  3780. }
  3781. function __makeTemplateObject(cooked, raw) {
  3782. if (Object.defineProperty) {
  3783. Object.defineProperty(cooked, "raw", {
  3784. value: raw
  3785. });
  3786. } else {
  3787. cooked.raw = raw;
  3788. }
  3789. return cooked;
  3790. }
  3791. function __importStar(mod) {
  3792. if (mod && mod.__esModule) return mod;
  3793. var result = {};
  3794. if (mod != null) for (var k in mod) {
  3795. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  3796. }
  3797. result.default = mod;
  3798. return result;
  3799. }
  3800. function __importDefault(mod) {
  3801. return mod && mod.__esModule ? mod : {
  3802. default: mod
  3803. };
  3804. }
  3805. var tslib_1 = Object.freeze({
  3806. __extends: __extends,
  3807. get __assign () { return _assign; },
  3808. __rest: __rest,
  3809. __decorate: __decorate,
  3810. __param: __param,
  3811. __metadata: __metadata,
  3812. __awaiter: __awaiter,
  3813. __generator: __generator,
  3814. __exportStar: __exportStar,
  3815. __values: __values,
  3816. __read: __read,
  3817. __spread: __spread,
  3818. __await: __await,
  3819. __asyncGenerator: __asyncGenerator,
  3820. __asyncDelegator: __asyncDelegator,
  3821. __asyncValues: __asyncValues,
  3822. __makeTemplateObject: __makeTemplateObject,
  3823. __importStar: __importStar,
  3824. __importDefault: __importDefault
  3825. });
  3826. var api = createCommonjsModule(function (module, exports) {
  3827. "use strict";
  3828. Object.defineProperty(exports, "__esModule", {
  3829. value: true
  3830. });
  3831. exports.apiDescriptor = {
  3832. key: function key(_key) {
  3833. return /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(_key) ? _key : JSON.stringify(_key);
  3834. },
  3835. value(value) {
  3836. if (value === null || typeof value !== 'object') {
  3837. return JSON.stringify(value);
  3838. }
  3839. if (Array.isArray(value)) {
  3840. return `[${value.map(function (subValue) {
  3841. return exports.apiDescriptor.value(subValue);
  3842. }).join(', ')}]`;
  3843. }
  3844. var keys = Object.keys(value);
  3845. return keys.length === 0 ? '{}' : `{ ${keys.map(function (key) {
  3846. return `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`;
  3847. }).join(', ')} }`;
  3848. },
  3849. pair: function pair(_ref) {
  3850. var key = _ref.key,
  3851. value = _ref.value;
  3852. return exports.apiDescriptor.value({
  3853. [key]: value
  3854. });
  3855. }
  3856. };
  3857. });
  3858. unwrapExports(api);
  3859. var descriptors = createCommonjsModule(function (module, exports) {
  3860. "use strict";
  3861. Object.defineProperty(exports, "__esModule", {
  3862. value: true
  3863. });
  3864. tslib_1.__exportStar(api, exports);
  3865. });
  3866. unwrapExports(descriptors);
  3867. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  3868. var escapeStringRegexp = function escapeStringRegexp(str) {
  3869. if (typeof str !== 'string') {
  3870. throw new TypeError('Expected a string');
  3871. }
  3872. return str.replace(matchOperatorsRe, '\\$&');
  3873. };
  3874. var colorName = {
  3875. "aliceblue": [240, 248, 255],
  3876. "antiquewhite": [250, 235, 215],
  3877. "aqua": [0, 255, 255],
  3878. "aquamarine": [127, 255, 212],
  3879. "azure": [240, 255, 255],
  3880. "beige": [245, 245, 220],
  3881. "bisque": [255, 228, 196],
  3882. "black": [0, 0, 0],
  3883. "blanchedalmond": [255, 235, 205],
  3884. "blue": [0, 0, 255],
  3885. "blueviolet": [138, 43, 226],
  3886. "brown": [165, 42, 42],
  3887. "burlywood": [222, 184, 135],
  3888. "cadetblue": [95, 158, 160],
  3889. "chartreuse": [127, 255, 0],
  3890. "chocolate": [210, 105, 30],
  3891. "coral": [255, 127, 80],
  3892. "cornflowerblue": [100, 149, 237],
  3893. "cornsilk": [255, 248, 220],
  3894. "crimson": [220, 20, 60],
  3895. "cyan": [0, 255, 255],
  3896. "darkblue": [0, 0, 139],
  3897. "darkcyan": [0, 139, 139],
  3898. "darkgoldenrod": [184, 134, 11],
  3899. "darkgray": [169, 169, 169],
  3900. "darkgreen": [0, 100, 0],
  3901. "darkgrey": [169, 169, 169],
  3902. "darkkhaki": [189, 183, 107],
  3903. "darkmagenta": [139, 0, 139],
  3904. "darkolivegreen": [85, 107, 47],
  3905. "darkorange": [255, 140, 0],
  3906. "darkorchid": [153, 50, 204],
  3907. "darkred": [139, 0, 0],
  3908. "darksalmon": [233, 150, 122],
  3909. "darkseagreen": [143, 188, 143],
  3910. "darkslateblue": [72, 61, 139],
  3911. "darkslategray": [47, 79, 79],
  3912. "darkslategrey": [47, 79, 79],
  3913. "darkturquoise": [0, 206, 209],
  3914. "darkviolet": [148, 0, 211],
  3915. "deeppink": [255, 20, 147],
  3916. "deepskyblue": [0, 191, 255],
  3917. "dimgray": [105, 105, 105],
  3918. "dimgrey": [105, 105, 105],
  3919. "dodgerblue": [30, 144, 255],
  3920. "firebrick": [178, 34, 34],
  3921. "floralwhite": [255, 250, 240],
  3922. "forestgreen": [34, 139, 34],
  3923. "fuchsia": [255, 0, 255],
  3924. "gainsboro": [220, 220, 220],
  3925. "ghostwhite": [248, 248, 255],
  3926. "gold": [255, 215, 0],
  3927. "goldenrod": [218, 165, 32],
  3928. "gray": [128, 128, 128],
  3929. "green": [0, 128, 0],
  3930. "greenyellow": [173, 255, 47],
  3931. "grey": [128, 128, 128],
  3932. "honeydew": [240, 255, 240],
  3933. "hotpink": [255, 105, 180],
  3934. "indianred": [205, 92, 92],
  3935. "indigo": [75, 0, 130],
  3936. "ivory": [255, 255, 240],
  3937. "khaki": [240, 230, 140],
  3938. "lavender": [230, 230, 250],
  3939. "lavenderblush": [255, 240, 245],
  3940. "lawngreen": [124, 252, 0],
  3941. "lemonchiffon": [255, 250, 205],
  3942. "lightblue": [173, 216, 230],
  3943. "lightcoral": [240, 128, 128],
  3944. "lightcyan": [224, 255, 255],
  3945. "lightgoldenrodyellow": [250, 250, 210],
  3946. "lightgray": [211, 211, 211],
  3947. "lightgreen": [144, 238, 144],
  3948. "lightgrey": [211, 211, 211],
  3949. "lightpink": [255, 182, 193],
  3950. "lightsalmon": [255, 160, 122],
  3951. "lightseagreen": [32, 178, 170],
  3952. "lightskyblue": [135, 206, 250],
  3953. "lightslategray": [119, 136, 153],
  3954. "lightslategrey": [119, 136, 153],
  3955. "lightsteelblue": [176, 196, 222],
  3956. "lightyellow": [255, 255, 224],
  3957. "lime": [0, 255, 0],
  3958. "limegreen": [50, 205, 50],
  3959. "linen": [250, 240, 230],
  3960. "magenta": [255, 0, 255],
  3961. "maroon": [128, 0, 0],
  3962. "mediumaquamarine": [102, 205, 170],
  3963. "mediumblue": [0, 0, 205],
  3964. "mediumorchid": [186, 85, 211],
  3965. "mediumpurple": [147, 112, 219],
  3966. "mediumseagreen": [60, 179, 113],
  3967. "mediumslateblue": [123, 104, 238],
  3968. "mediumspringgreen": [0, 250, 154],
  3969. "mediumturquoise": [72, 209, 204],
  3970. "mediumvioletred": [199, 21, 133],
  3971. "midnightblue": [25, 25, 112],
  3972. "mintcream": [245, 255, 250],
  3973. "mistyrose": [255, 228, 225],
  3974. "moccasin": [255, 228, 181],
  3975. "navajowhite": [255, 222, 173],
  3976. "navy": [0, 0, 128],
  3977. "oldlace": [253, 245, 230],
  3978. "olive": [128, 128, 0],
  3979. "olivedrab": [107, 142, 35],
  3980. "orange": [255, 165, 0],
  3981. "orangered": [255, 69, 0],
  3982. "orchid": [218, 112, 214],
  3983. "palegoldenrod": [238, 232, 170],
  3984. "palegreen": [152, 251, 152],
  3985. "paleturquoise": [175, 238, 238],
  3986. "palevioletred": [219, 112, 147],
  3987. "papayawhip": [255, 239, 213],
  3988. "peachpuff": [255, 218, 185],
  3989. "peru": [205, 133, 63],
  3990. "pink": [255, 192, 203],
  3991. "plum": [221, 160, 221],
  3992. "powderblue": [176, 224, 230],
  3993. "purple": [128, 0, 128],
  3994. "rebeccapurple": [102, 51, 153],
  3995. "red": [255, 0, 0],
  3996. "rosybrown": [188, 143, 143],
  3997. "royalblue": [65, 105, 225],
  3998. "saddlebrown": [139, 69, 19],
  3999. "salmon": [250, 128, 114],
  4000. "sandybrown": [244, 164, 96],
  4001. "seagreen": [46, 139, 87],
  4002. "seashell": [255, 245, 238],
  4003. "sienna": [160, 82, 45],
  4004. "silver": [192, 192, 192],
  4005. "skyblue": [135, 206, 235],
  4006. "slateblue": [106, 90, 205],
  4007. "slategray": [112, 128, 144],
  4008. "slategrey": [112, 128, 144],
  4009. "snow": [255, 250, 250],
  4010. "springgreen": [0, 255, 127],
  4011. "steelblue": [70, 130, 180],
  4012. "tan": [210, 180, 140],
  4013. "teal": [0, 128, 128],
  4014. "thistle": [216, 191, 216],
  4015. "tomato": [255, 99, 71],
  4016. "turquoise": [64, 224, 208],
  4017. "violet": [238, 130, 238],
  4018. "wheat": [245, 222, 179],
  4019. "white": [255, 255, 255],
  4020. "whitesmoke": [245, 245, 245],
  4021. "yellow": [255, 255, 0],
  4022. "yellowgreen": [154, 205, 50]
  4023. };
  4024. var conversions = createCommonjsModule(function (module) {
  4025. /* MIT license */
  4026. // NOTE: conversions should only return primitive values (i.e. arrays, or
  4027. // values that give correct `typeof` results).
  4028. // do not use box values types (i.e. Number(), String(), etc.)
  4029. var reverseKeywords = {};
  4030. for (var key in colorName) {
  4031. if (colorName.hasOwnProperty(key)) {
  4032. reverseKeywords[colorName[key]] = key;
  4033. }
  4034. }
  4035. var convert = module.exports = {
  4036. rgb: {
  4037. channels: 3,
  4038. labels: 'rgb'
  4039. },
  4040. hsl: {
  4041. channels: 3,
  4042. labels: 'hsl'
  4043. },
  4044. hsv: {
  4045. channels: 3,
  4046. labels: 'hsv'
  4047. },
  4048. hwb: {
  4049. channels: 3,
  4050. labels: 'hwb'
  4051. },
  4052. cmyk: {
  4053. channels: 4,
  4054. labels: 'cmyk'
  4055. },
  4056. xyz: {
  4057. channels: 3,
  4058. labels: 'xyz'
  4059. },
  4060. lab: {
  4061. channels: 3,
  4062. labels: 'lab'
  4063. },
  4064. lch: {
  4065. channels: 3,
  4066. labels: 'lch'
  4067. },
  4068. hex: {
  4069. channels: 1,
  4070. labels: ['hex']
  4071. },
  4072. keyword: {
  4073. channels: 1,
  4074. labels: ['keyword']
  4075. },
  4076. ansi16: {
  4077. channels: 1,
  4078. labels: ['ansi16']
  4079. },
  4080. ansi256: {
  4081. channels: 1,
  4082. labels: ['ansi256']
  4083. },
  4084. hcg: {
  4085. channels: 3,
  4086. labels: ['h', 'c', 'g']
  4087. },
  4088. apple: {
  4089. channels: 3,
  4090. labels: ['r16', 'g16', 'b16']
  4091. },
  4092. gray: {
  4093. channels: 1,
  4094. labels: ['gray']
  4095. }
  4096. }; // hide .channels and .labels properties
  4097. for (var model in convert) {
  4098. if (convert.hasOwnProperty(model)) {
  4099. if (!('channels' in convert[model])) {
  4100. throw new Error('missing channels property: ' + model);
  4101. }
  4102. if (!('labels' in convert[model])) {
  4103. throw new Error('missing channel labels property: ' + model);
  4104. }
  4105. if (convert[model].labels.length !== convert[model].channels) {
  4106. throw new Error('channel and label counts mismatch: ' + model);
  4107. }
  4108. var channels = convert[model].channels;
  4109. var labels = convert[model].labels;
  4110. delete convert[model].channels;
  4111. delete convert[model].labels;
  4112. Object.defineProperty(convert[model], 'channels', {
  4113. value: channels
  4114. });
  4115. Object.defineProperty(convert[model], 'labels', {
  4116. value: labels
  4117. });
  4118. }
  4119. }
  4120. convert.rgb.hsl = function (rgb) {
  4121. var r = rgb[0] / 255;
  4122. var g = rgb[1] / 255;
  4123. var b = rgb[2] / 255;
  4124. var min = Math.min(r, g, b);
  4125. var max = Math.max(r, g, b);
  4126. var delta = max - min;
  4127. var h;
  4128. var s;
  4129. var l;
  4130. if (max === min) {
  4131. h = 0;
  4132. } else if (r === max) {
  4133. h = (g - b) / delta;
  4134. } else if (g === max) {
  4135. h = 2 + (b - r) / delta;
  4136. } else if (b === max) {
  4137. h = 4 + (r - g) / delta;
  4138. }
  4139. h = Math.min(h * 60, 360);
  4140. if (h < 0) {
  4141. h += 360;
  4142. }
  4143. l = (min + max) / 2;
  4144. if (max === min) {
  4145. s = 0;
  4146. } else if (l <= 0.5) {
  4147. s = delta / (max + min);
  4148. } else {
  4149. s = delta / (2 - max - min);
  4150. }
  4151. return [h, s * 100, l * 100];
  4152. };
  4153. convert.rgb.hsv = function (rgb) {
  4154. var r = rgb[0];
  4155. var g = rgb[1];
  4156. var b = rgb[2];
  4157. var min = Math.min(r, g, b);
  4158. var max = Math.max(r, g, b);
  4159. var delta = max - min;
  4160. var h;
  4161. var s;
  4162. var v;
  4163. if (max === 0) {
  4164. s = 0;
  4165. } else {
  4166. s = delta / max * 1000 / 10;
  4167. }
  4168. if (max === min) {
  4169. h = 0;
  4170. } else if (r === max) {
  4171. h = (g - b) / delta;
  4172. } else if (g === max) {
  4173. h = 2 + (b - r) / delta;
  4174. } else if (b === max) {
  4175. h = 4 + (r - g) / delta;
  4176. }
  4177. h = Math.min(h * 60, 360);
  4178. if (h < 0) {
  4179. h += 360;
  4180. }
  4181. v = max / 255 * 1000 / 10;
  4182. return [h, s, v];
  4183. };
  4184. convert.rgb.hwb = function (rgb) {
  4185. var r = rgb[0];
  4186. var g = rgb[1];
  4187. var b = rgb[2];
  4188. var h = convert.rgb.hsl(rgb)[0];
  4189. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  4190. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  4191. return [h, w * 100, b * 100];
  4192. };
  4193. convert.rgb.cmyk = function (rgb) {
  4194. var r = rgb[0] / 255;
  4195. var g = rgb[1] / 255;
  4196. var b = rgb[2] / 255;
  4197. var c;
  4198. var m;
  4199. var y;
  4200. var k;
  4201. k = Math.min(1 - r, 1 - g, 1 - b);
  4202. c = (1 - r - k) / (1 - k) || 0;
  4203. m = (1 - g - k) / (1 - k) || 0;
  4204. y = (1 - b - k) / (1 - k) || 0;
  4205. return [c * 100, m * 100, y * 100, k * 100];
  4206. };
  4207. /**
  4208. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  4209. * */
  4210. function comparativeDistance(x, y) {
  4211. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  4212. }
  4213. convert.rgb.keyword = function (rgb) {
  4214. var reversed = reverseKeywords[rgb];
  4215. if (reversed) {
  4216. return reversed;
  4217. }
  4218. var currentClosestDistance = Infinity;
  4219. var currentClosestKeyword;
  4220. for (var keyword in colorName) {
  4221. if (colorName.hasOwnProperty(keyword)) {
  4222. var value = colorName[keyword]; // Compute comparative distance
  4223. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  4224. if (distance < currentClosestDistance) {
  4225. currentClosestDistance = distance;
  4226. currentClosestKeyword = keyword;
  4227. }
  4228. }
  4229. }
  4230. return currentClosestKeyword;
  4231. };
  4232. convert.keyword.rgb = function (keyword) {
  4233. return colorName[keyword];
  4234. };
  4235. convert.rgb.xyz = function (rgb) {
  4236. var r = rgb[0] / 255;
  4237. var g = rgb[1] / 255;
  4238. var b = rgb[2] / 255; // assume sRGB
  4239. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  4240. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  4241. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  4242. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  4243. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  4244. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  4245. return [x * 100, y * 100, z * 100];
  4246. };
  4247. convert.rgb.lab = function (rgb) {
  4248. var xyz = convert.rgb.xyz(rgb);
  4249. var x = xyz[0];
  4250. var y = xyz[1];
  4251. var z = xyz[2];
  4252. var l;
  4253. var a;
  4254. var b;
  4255. x /= 95.047;
  4256. y /= 100;
  4257. z /= 108.883;
  4258. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4259. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4260. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4261. l = 116 * y - 16;
  4262. a = 500 * (x - y);
  4263. b = 200 * (y - z);
  4264. return [l, a, b];
  4265. };
  4266. convert.hsl.rgb = function (hsl) {
  4267. var h = hsl[0] / 360;
  4268. var s = hsl[1] / 100;
  4269. var l = hsl[2] / 100;
  4270. var t1;
  4271. var t2;
  4272. var t3;
  4273. var rgb;
  4274. var val;
  4275. if (s === 0) {
  4276. val = l * 255;
  4277. return [val, val, val];
  4278. }
  4279. if (l < 0.5) {
  4280. t2 = l * (1 + s);
  4281. } else {
  4282. t2 = l + s - l * s;
  4283. }
  4284. t1 = 2 * l - t2;
  4285. rgb = [0, 0, 0];
  4286. for (var i = 0; i < 3; i++) {
  4287. t3 = h + 1 / 3 * -(i - 1);
  4288. if (t3 < 0) {
  4289. t3++;
  4290. }
  4291. if (t3 > 1) {
  4292. t3--;
  4293. }
  4294. if (6 * t3 < 1) {
  4295. val = t1 + (t2 - t1) * 6 * t3;
  4296. } else if (2 * t3 < 1) {
  4297. val = t2;
  4298. } else if (3 * t3 < 2) {
  4299. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  4300. } else {
  4301. val = t1;
  4302. }
  4303. rgb[i] = val * 255;
  4304. }
  4305. return rgb;
  4306. };
  4307. convert.hsl.hsv = function (hsl) {
  4308. var h = hsl[0];
  4309. var s = hsl[1] / 100;
  4310. var l = hsl[2] / 100;
  4311. var smin = s;
  4312. var lmin = Math.max(l, 0.01);
  4313. var sv;
  4314. var v;
  4315. l *= 2;
  4316. s *= l <= 1 ? l : 2 - l;
  4317. smin *= lmin <= 1 ? lmin : 2 - lmin;
  4318. v = (l + s) / 2;
  4319. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  4320. return [h, sv * 100, v * 100];
  4321. };
  4322. convert.hsv.rgb = function (hsv) {
  4323. var h = hsv[0] / 60;
  4324. var s = hsv[1] / 100;
  4325. var v = hsv[2] / 100;
  4326. var hi = Math.floor(h) % 6;
  4327. var f = h - Math.floor(h);
  4328. var p = 255 * v * (1 - s);
  4329. var q = 255 * v * (1 - s * f);
  4330. var t = 255 * v * (1 - s * (1 - f));
  4331. v *= 255;
  4332. switch (hi) {
  4333. case 0:
  4334. return [v, t, p];
  4335. case 1:
  4336. return [q, v, p];
  4337. case 2:
  4338. return [p, v, t];
  4339. case 3:
  4340. return [p, q, v];
  4341. case 4:
  4342. return [t, p, v];
  4343. case 5:
  4344. return [v, p, q];
  4345. }
  4346. };
  4347. convert.hsv.hsl = function (hsv) {
  4348. var h = hsv[0];
  4349. var s = hsv[1] / 100;
  4350. var v = hsv[2] / 100;
  4351. var vmin = Math.max(v, 0.01);
  4352. var lmin;
  4353. var sl;
  4354. var l;
  4355. l = (2 - s) * v;
  4356. lmin = (2 - s) * vmin;
  4357. sl = s * vmin;
  4358. sl /= lmin <= 1 ? lmin : 2 - lmin;
  4359. sl = sl || 0;
  4360. l /= 2;
  4361. return [h, sl * 100, l * 100];
  4362. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  4363. convert.hwb.rgb = function (hwb) {
  4364. var h = hwb[0] / 360;
  4365. var wh = hwb[1] / 100;
  4366. var bl = hwb[2] / 100;
  4367. var ratio = wh + bl;
  4368. var i;
  4369. var v;
  4370. var f;
  4371. var n; // wh + bl cant be > 1
  4372. if (ratio > 1) {
  4373. wh /= ratio;
  4374. bl /= ratio;
  4375. }
  4376. i = Math.floor(6 * h);
  4377. v = 1 - bl;
  4378. f = 6 * h - i;
  4379. if ((i & 0x01) !== 0) {
  4380. f = 1 - f;
  4381. }
  4382. n = wh + f * (v - wh); // linear interpolation
  4383. var r;
  4384. var g;
  4385. var b;
  4386. switch (i) {
  4387. default:
  4388. case 6:
  4389. case 0:
  4390. r = v;
  4391. g = n;
  4392. b = wh;
  4393. break;
  4394. case 1:
  4395. r = n;
  4396. g = v;
  4397. b = wh;
  4398. break;
  4399. case 2:
  4400. r = wh;
  4401. g = v;
  4402. b = n;
  4403. break;
  4404. case 3:
  4405. r = wh;
  4406. g = n;
  4407. b = v;
  4408. break;
  4409. case 4:
  4410. r = n;
  4411. g = wh;
  4412. b = v;
  4413. break;
  4414. case 5:
  4415. r = v;
  4416. g = wh;
  4417. b = n;
  4418. break;
  4419. }
  4420. return [r * 255, g * 255, b * 255];
  4421. };
  4422. convert.cmyk.rgb = function (cmyk) {
  4423. var c = cmyk[0] / 100;
  4424. var m = cmyk[1] / 100;
  4425. var y = cmyk[2] / 100;
  4426. var k = cmyk[3] / 100;
  4427. var r;
  4428. var g;
  4429. var b;
  4430. r = 1 - Math.min(1, c * (1 - k) + k);
  4431. g = 1 - Math.min(1, m * (1 - k) + k);
  4432. b = 1 - Math.min(1, y * (1 - k) + k);
  4433. return [r * 255, g * 255, b * 255];
  4434. };
  4435. convert.xyz.rgb = function (xyz) {
  4436. var x = xyz[0] / 100;
  4437. var y = xyz[1] / 100;
  4438. var z = xyz[2] / 100;
  4439. var r;
  4440. var g;
  4441. var b;
  4442. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  4443. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  4444. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  4445. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  4446. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  4447. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  4448. r = Math.min(Math.max(0, r), 1);
  4449. g = Math.min(Math.max(0, g), 1);
  4450. b = Math.min(Math.max(0, b), 1);
  4451. return [r * 255, g * 255, b * 255];
  4452. };
  4453. convert.xyz.lab = function (xyz) {
  4454. var x = xyz[0];
  4455. var y = xyz[1];
  4456. var z = xyz[2];
  4457. var l;
  4458. var a;
  4459. var b;
  4460. x /= 95.047;
  4461. y /= 100;
  4462. z /= 108.883;
  4463. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4464. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4465. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4466. l = 116 * y - 16;
  4467. a = 500 * (x - y);
  4468. b = 200 * (y - z);
  4469. return [l, a, b];
  4470. };
  4471. convert.lab.xyz = function (lab) {
  4472. var l = lab[0];
  4473. var a = lab[1];
  4474. var b = lab[2];
  4475. var x;
  4476. var y;
  4477. var z;
  4478. y = (l + 16) / 116;
  4479. x = a / 500 + y;
  4480. z = y - b / 200;
  4481. var y2 = Math.pow(y, 3);
  4482. var x2 = Math.pow(x, 3);
  4483. var z2 = Math.pow(z, 3);
  4484. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  4485. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  4486. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  4487. x *= 95.047;
  4488. y *= 100;
  4489. z *= 108.883;
  4490. return [x, y, z];
  4491. };
  4492. convert.lab.lch = function (lab) {
  4493. var l = lab[0];
  4494. var a = lab[1];
  4495. var b = lab[2];
  4496. var hr;
  4497. var h;
  4498. var c;
  4499. hr = Math.atan2(b, a);
  4500. h = hr * 360 / 2 / Math.PI;
  4501. if (h < 0) {
  4502. h += 360;
  4503. }
  4504. c = Math.sqrt(a * a + b * b);
  4505. return [l, c, h];
  4506. };
  4507. convert.lch.lab = function (lch) {
  4508. var l = lch[0];
  4509. var c = lch[1];
  4510. var h = lch[2];
  4511. var a;
  4512. var b;
  4513. var hr;
  4514. hr = h / 360 * 2 * Math.PI;
  4515. a = c * Math.cos(hr);
  4516. b = c * Math.sin(hr);
  4517. return [l, a, b];
  4518. };
  4519. convert.rgb.ansi16 = function (args) {
  4520. var r = args[0];
  4521. var g = args[1];
  4522. var b = args[2];
  4523. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  4524. value = Math.round(value / 50);
  4525. if (value === 0) {
  4526. return 30;
  4527. }
  4528. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  4529. if (value === 2) {
  4530. ansi += 60;
  4531. }
  4532. return ansi;
  4533. };
  4534. convert.hsv.ansi16 = function (args) {
  4535. // optimization here; we already know the value and don't need to get
  4536. // it converted for us.
  4537. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  4538. };
  4539. convert.rgb.ansi256 = function (args) {
  4540. var r = args[0];
  4541. var g = args[1];
  4542. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  4543. // black and white. normal palette only has 4 greyscale shades.
  4544. if (r === g && g === b) {
  4545. if (r < 8) {
  4546. return 16;
  4547. }
  4548. if (r > 248) {
  4549. return 231;
  4550. }
  4551. return Math.round((r - 8) / 247 * 24) + 232;
  4552. }
  4553. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  4554. return ansi;
  4555. };
  4556. convert.ansi16.rgb = function (args) {
  4557. var color = args % 10; // handle greyscale
  4558. if (color === 0 || color === 7) {
  4559. if (args > 50) {
  4560. color += 3.5;
  4561. }
  4562. color = color / 10.5 * 255;
  4563. return [color, color, color];
  4564. }
  4565. var mult = (~~(args > 50) + 1) * 0.5;
  4566. var r = (color & 1) * mult * 255;
  4567. var g = (color >> 1 & 1) * mult * 255;
  4568. var b = (color >> 2 & 1) * mult * 255;
  4569. return [r, g, b];
  4570. };
  4571. convert.ansi256.rgb = function (args) {
  4572. // handle greyscale
  4573. if (args >= 232) {
  4574. var c = (args - 232) * 10 + 8;
  4575. return [c, c, c];
  4576. }
  4577. args -= 16;
  4578. var rem;
  4579. var r = Math.floor(args / 36) / 5 * 255;
  4580. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  4581. var b = rem % 6 / 5 * 255;
  4582. return [r, g, b];
  4583. };
  4584. convert.rgb.hex = function (args) {
  4585. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  4586. var string = integer.toString(16).toUpperCase();
  4587. return '000000'.substring(string.length) + string;
  4588. };
  4589. convert.hex.rgb = function (args) {
  4590. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  4591. if (!match) {
  4592. return [0, 0, 0];
  4593. }
  4594. var colorString = match[0];
  4595. if (match[0].length === 3) {
  4596. colorString = colorString.split('').map(function (char) {
  4597. return char + char;
  4598. }).join('');
  4599. }
  4600. var integer = parseInt(colorString, 16);
  4601. var r = integer >> 16 & 0xFF;
  4602. var g = integer >> 8 & 0xFF;
  4603. var b = integer & 0xFF;
  4604. return [r, g, b];
  4605. };
  4606. convert.rgb.hcg = function (rgb) {
  4607. var r = rgb[0] / 255;
  4608. var g = rgb[1] / 255;
  4609. var b = rgb[2] / 255;
  4610. var max = Math.max(Math.max(r, g), b);
  4611. var min = Math.min(Math.min(r, g), b);
  4612. var chroma = max - min;
  4613. var grayscale;
  4614. var hue;
  4615. if (chroma < 1) {
  4616. grayscale = min / (1 - chroma);
  4617. } else {
  4618. grayscale = 0;
  4619. }
  4620. if (chroma <= 0) {
  4621. hue = 0;
  4622. } else if (max === r) {
  4623. hue = (g - b) / chroma % 6;
  4624. } else if (max === g) {
  4625. hue = 2 + (b - r) / chroma;
  4626. } else {
  4627. hue = 4 + (r - g) / chroma + 4;
  4628. }
  4629. hue /= 6;
  4630. hue %= 1;
  4631. return [hue * 360, chroma * 100, grayscale * 100];
  4632. };
  4633. convert.hsl.hcg = function (hsl) {
  4634. var s = hsl[1] / 100;
  4635. var l = hsl[2] / 100;
  4636. var c = 1;
  4637. var f = 0;
  4638. if (l < 0.5) {
  4639. c = 2.0 * s * l;
  4640. } else {
  4641. c = 2.0 * s * (1.0 - l);
  4642. }
  4643. if (c < 1.0) {
  4644. f = (l - 0.5 * c) / (1.0 - c);
  4645. }
  4646. return [hsl[0], c * 100, f * 100];
  4647. };
  4648. convert.hsv.hcg = function (hsv) {
  4649. var s = hsv[1] / 100;
  4650. var v = hsv[2] / 100;
  4651. var c = s * v;
  4652. var f = 0;
  4653. if (c < 1.0) {
  4654. f = (v - c) / (1 - c);
  4655. }
  4656. return [hsv[0], c * 100, f * 100];
  4657. };
  4658. convert.hcg.rgb = function (hcg) {
  4659. var h = hcg[0] / 360;
  4660. var c = hcg[1] / 100;
  4661. var g = hcg[2] / 100;
  4662. if (c === 0.0) {
  4663. return [g * 255, g * 255, g * 255];
  4664. }
  4665. var pure = [0, 0, 0];
  4666. var hi = h % 1 * 6;
  4667. var v = hi % 1;
  4668. var w = 1 - v;
  4669. var mg = 0;
  4670. switch (Math.floor(hi)) {
  4671. case 0:
  4672. pure[0] = 1;
  4673. pure[1] = v;
  4674. pure[2] = 0;
  4675. break;
  4676. case 1:
  4677. pure[0] = w;
  4678. pure[1] = 1;
  4679. pure[2] = 0;
  4680. break;
  4681. case 2:
  4682. pure[0] = 0;
  4683. pure[1] = 1;
  4684. pure[2] = v;
  4685. break;
  4686. case 3:
  4687. pure[0] = 0;
  4688. pure[1] = w;
  4689. pure[2] = 1;
  4690. break;
  4691. case 4:
  4692. pure[0] = v;
  4693. pure[1] = 0;
  4694. pure[2] = 1;
  4695. break;
  4696. default:
  4697. pure[0] = 1;
  4698. pure[1] = 0;
  4699. pure[2] = w;
  4700. }
  4701. mg = (1.0 - c) * g;
  4702. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  4703. };
  4704. convert.hcg.hsv = function (hcg) {
  4705. var c = hcg[1] / 100;
  4706. var g = hcg[2] / 100;
  4707. var v = c + g * (1.0 - c);
  4708. var f = 0;
  4709. if (v > 0.0) {
  4710. f = c / v;
  4711. }
  4712. return [hcg[0], f * 100, v * 100];
  4713. };
  4714. convert.hcg.hsl = function (hcg) {
  4715. var c = hcg[1] / 100;
  4716. var g = hcg[2] / 100;
  4717. var l = g * (1.0 - c) + 0.5 * c;
  4718. var s = 0;
  4719. if (l > 0.0 && l < 0.5) {
  4720. s = c / (2 * l);
  4721. } else if (l >= 0.5 && l < 1.0) {
  4722. s = c / (2 * (1 - l));
  4723. }
  4724. return [hcg[0], s * 100, l * 100];
  4725. };
  4726. convert.hcg.hwb = function (hcg) {
  4727. var c = hcg[1] / 100;
  4728. var g = hcg[2] / 100;
  4729. var v = c + g * (1.0 - c);
  4730. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  4731. };
  4732. convert.hwb.hcg = function (hwb) {
  4733. var w = hwb[1] / 100;
  4734. var b = hwb[2] / 100;
  4735. var v = 1 - b;
  4736. var c = v - w;
  4737. var g = 0;
  4738. if (c < 1) {
  4739. g = (v - c) / (1 - c);
  4740. }
  4741. return [hwb[0], c * 100, g * 100];
  4742. };
  4743. convert.apple.rgb = function (apple) {
  4744. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  4745. };
  4746. convert.rgb.apple = function (rgb) {
  4747. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  4748. };
  4749. convert.gray.rgb = function (args) {
  4750. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  4751. };
  4752. convert.gray.hsl = convert.gray.hsv = function (args) {
  4753. return [0, 0, args[0]];
  4754. };
  4755. convert.gray.hwb = function (gray) {
  4756. return [0, 100, gray[0]];
  4757. };
  4758. convert.gray.cmyk = function (gray) {
  4759. return [0, 0, 0, gray[0]];
  4760. };
  4761. convert.gray.lab = function (gray) {
  4762. return [gray[0], 0, 0];
  4763. };
  4764. convert.gray.hex = function (gray) {
  4765. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  4766. var integer = (val << 16) + (val << 8) + val;
  4767. var string = integer.toString(16).toUpperCase();
  4768. return '000000'.substring(string.length) + string;
  4769. };
  4770. convert.rgb.gray = function (rgb) {
  4771. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  4772. return [val / 255 * 100];
  4773. };
  4774. });
  4775. /*
  4776. this function routes a model to all other models.
  4777. all functions that are routed have a property `.conversion` attached
  4778. to the returned synthetic function. This property is an array
  4779. of strings, each with the steps in between the 'from' and 'to'
  4780. color models (inclusive).
  4781. conversions that are not possible simply are not included.
  4782. */
  4783. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  4784. var models$1 = Object.keys(conversions);
  4785. function buildGraph() {
  4786. var graph = {};
  4787. for (var len = models$1.length, i = 0; i < len; i++) {
  4788. graph[models$1[i]] = {
  4789. // http://jsperf.com/1-vs-infinity
  4790. // micro-opt, but this is simple.
  4791. distance: -1,
  4792. parent: null
  4793. };
  4794. }
  4795. return graph;
  4796. } // https://en.wikipedia.org/wiki/Breadth-first_search
  4797. function deriveBFS(fromModel) {
  4798. var graph = buildGraph();
  4799. var queue = [fromModel]; // unshift -> queue -> pop
  4800. graph[fromModel].distance = 0;
  4801. while (queue.length) {
  4802. var current = queue.pop();
  4803. var adjacents = Object.keys(conversions[current]);
  4804. for (var len = adjacents.length, i = 0; i < len; i++) {
  4805. var adjacent = adjacents[i];
  4806. var node = graph[adjacent];
  4807. if (node.distance === -1) {
  4808. node.distance = graph[current].distance + 1;
  4809. node.parent = current;
  4810. queue.unshift(adjacent);
  4811. }
  4812. }
  4813. }
  4814. return graph;
  4815. }
  4816. function link(from, to) {
  4817. return function (args) {
  4818. return to(from(args));
  4819. };
  4820. }
  4821. function wrapConversion(toModel, graph) {
  4822. var path$$1 = [graph[toModel].parent, toModel];
  4823. var fn = conversions[graph[toModel].parent][toModel];
  4824. var cur = graph[toModel].parent;
  4825. while (graph[cur].parent) {
  4826. path$$1.unshift(graph[cur].parent);
  4827. fn = link(conversions[graph[cur].parent][cur], fn);
  4828. cur = graph[cur].parent;
  4829. }
  4830. fn.conversion = path$$1;
  4831. return fn;
  4832. }
  4833. var route = function route(fromModel) {
  4834. var graph = deriveBFS(fromModel);
  4835. var conversion = {};
  4836. var models = Object.keys(graph);
  4837. for (var len = models.length, i = 0; i < len; i++) {
  4838. var toModel = models[i];
  4839. var node = graph[toModel];
  4840. if (node.parent === null) {
  4841. // no possible conversion, or this node is the source model.
  4842. continue;
  4843. }
  4844. conversion[toModel] = wrapConversion(toModel, graph);
  4845. }
  4846. return conversion;
  4847. };
  4848. var convert = {};
  4849. var models = Object.keys(conversions);
  4850. function wrapRaw(fn) {
  4851. var wrappedFn = function wrappedFn(args) {
  4852. if (args === undefined || args === null) {
  4853. return args;
  4854. }
  4855. if (arguments.length > 1) {
  4856. args = Array.prototype.slice.call(arguments);
  4857. }
  4858. return fn(args);
  4859. }; // preserve .conversion property if there is one
  4860. if ('conversion' in fn) {
  4861. wrappedFn.conversion = fn.conversion;
  4862. }
  4863. return wrappedFn;
  4864. }
  4865. function wrapRounded(fn) {
  4866. var wrappedFn = function wrappedFn(args) {
  4867. if (args === undefined || args === null) {
  4868. return args;
  4869. }
  4870. if (arguments.length > 1) {
  4871. args = Array.prototype.slice.call(arguments);
  4872. }
  4873. var result = fn(args); // we're assuming the result is an array here.
  4874. // see notice in conversions.js; don't use box types
  4875. // in conversion functions.
  4876. if (typeof result === 'object') {
  4877. for (var len = result.length, i = 0; i < len; i++) {
  4878. result[i] = Math.round(result[i]);
  4879. }
  4880. }
  4881. return result;
  4882. }; // preserve .conversion property if there is one
  4883. if ('conversion' in fn) {
  4884. wrappedFn.conversion = fn.conversion;
  4885. }
  4886. return wrappedFn;
  4887. }
  4888. models.forEach(function (fromModel) {
  4889. convert[fromModel] = {};
  4890. Object.defineProperty(convert[fromModel], 'channels', {
  4891. value: conversions[fromModel].channels
  4892. });
  4893. Object.defineProperty(convert[fromModel], 'labels', {
  4894. value: conversions[fromModel].labels
  4895. });
  4896. var routes = route(fromModel);
  4897. var routeModels = Object.keys(routes);
  4898. routeModels.forEach(function (toModel) {
  4899. var fn = routes[toModel];
  4900. convert[fromModel][toModel] = wrapRounded(fn);
  4901. convert[fromModel][toModel].raw = wrapRaw(fn);
  4902. });
  4903. });
  4904. var colorConvert = convert;
  4905. var ansiStyles = createCommonjsModule(function (module) {
  4906. 'use strict';
  4907. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  4908. return function () {
  4909. var code = fn.apply(colorConvert, arguments);
  4910. return `\u001B[${code + offset}m`;
  4911. };
  4912. };
  4913. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  4914. return function () {
  4915. var code = fn.apply(colorConvert, arguments);
  4916. return `\u001B[${38 + offset};5;${code}m`;
  4917. };
  4918. };
  4919. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  4920. return function () {
  4921. var rgb = fn.apply(colorConvert, arguments);
  4922. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  4923. };
  4924. };
  4925. function assembleStyles() {
  4926. var codes = new Map();
  4927. var styles = {
  4928. modifier: {
  4929. reset: [0, 0],
  4930. // 21 isn't widely supported and 22 does the same thing
  4931. bold: [1, 22],
  4932. dim: [2, 22],
  4933. italic: [3, 23],
  4934. underline: [4, 24],
  4935. inverse: [7, 27],
  4936. hidden: [8, 28],
  4937. strikethrough: [9, 29]
  4938. },
  4939. color: {
  4940. black: [30, 39],
  4941. red: [31, 39],
  4942. green: [32, 39],
  4943. yellow: [33, 39],
  4944. blue: [34, 39],
  4945. magenta: [35, 39],
  4946. cyan: [36, 39],
  4947. white: [37, 39],
  4948. gray: [90, 39],
  4949. // Bright color
  4950. redBright: [91, 39],
  4951. greenBright: [92, 39],
  4952. yellowBright: [93, 39],
  4953. blueBright: [94, 39],
  4954. magentaBright: [95, 39],
  4955. cyanBright: [96, 39],
  4956. whiteBright: [97, 39]
  4957. },
  4958. bgColor: {
  4959. bgBlack: [40, 49],
  4960. bgRed: [41, 49],
  4961. bgGreen: [42, 49],
  4962. bgYellow: [43, 49],
  4963. bgBlue: [44, 49],
  4964. bgMagenta: [45, 49],
  4965. bgCyan: [46, 49],
  4966. bgWhite: [47, 49],
  4967. // Bright color
  4968. bgBlackBright: [100, 49],
  4969. bgRedBright: [101, 49],
  4970. bgGreenBright: [102, 49],
  4971. bgYellowBright: [103, 49],
  4972. bgBlueBright: [104, 49],
  4973. bgMagentaBright: [105, 49],
  4974. bgCyanBright: [106, 49],
  4975. bgWhiteBright: [107, 49]
  4976. }
  4977. }; // Fix humans
  4978. styles.color.grey = styles.color.gray;
  4979. var _arr = Object.keys(styles);
  4980. for (var _i = 0; _i < _arr.length; _i++) {
  4981. var groupName = _arr[_i];
  4982. var group = styles[groupName];
  4983. var _arr3 = Object.keys(group);
  4984. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  4985. var styleName = _arr3[_i3];
  4986. var style = group[styleName];
  4987. styles[styleName] = {
  4988. open: `\u001B[${style[0]}m`,
  4989. close: `\u001B[${style[1]}m`
  4990. };
  4991. group[styleName] = styles[styleName];
  4992. codes.set(style[0], style[1]);
  4993. }
  4994. Object.defineProperty(styles, groupName, {
  4995. value: group,
  4996. enumerable: false
  4997. });
  4998. Object.defineProperty(styles, 'codes', {
  4999. value: codes,
  5000. enumerable: false
  5001. });
  5002. }
  5003. var ansi2ansi = function ansi2ansi(n) {
  5004. return n;
  5005. };
  5006. var rgb2rgb = function rgb2rgb(r, g, b) {
  5007. return [r, g, b];
  5008. };
  5009. styles.color.close = '\u001B[39m';
  5010. styles.bgColor.close = '\u001B[49m';
  5011. styles.color.ansi = {
  5012. ansi: wrapAnsi16(ansi2ansi, 0)
  5013. };
  5014. styles.color.ansi256 = {
  5015. ansi256: wrapAnsi256(ansi2ansi, 0)
  5016. };
  5017. styles.color.ansi16m = {
  5018. rgb: wrapAnsi16m(rgb2rgb, 0)
  5019. };
  5020. styles.bgColor.ansi = {
  5021. ansi: wrapAnsi16(ansi2ansi, 10)
  5022. };
  5023. styles.bgColor.ansi256 = {
  5024. ansi256: wrapAnsi256(ansi2ansi, 10)
  5025. };
  5026. styles.bgColor.ansi16m = {
  5027. rgb: wrapAnsi16m(rgb2rgb, 10)
  5028. };
  5029. var _arr2 = Object.keys(colorConvert);
  5030. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5031. var key = _arr2[_i2];
  5032. if (typeof colorConvert[key] !== 'object') {
  5033. continue;
  5034. }
  5035. var suite = colorConvert[key];
  5036. if (key === 'ansi16') {
  5037. key = 'ansi';
  5038. }
  5039. if ('ansi16' in suite) {
  5040. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  5041. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  5042. }
  5043. if ('ansi256' in suite) {
  5044. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  5045. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  5046. }
  5047. if ('rgb' in suite) {
  5048. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  5049. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  5050. }
  5051. }
  5052. return styles;
  5053. } // Make the export immutable
  5054. Object.defineProperty(module, 'exports', {
  5055. enumerable: true,
  5056. get: assembleStyles
  5057. });
  5058. });
  5059. var hasFlag = createCommonjsModule(function (module) {
  5060. 'use strict';
  5061. module.exports = function (flag, argv) {
  5062. argv = argv || process.argv;
  5063. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  5064. var pos = argv.indexOf(prefix + flag);
  5065. var terminatorPos = argv.indexOf('--');
  5066. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  5067. };
  5068. });
  5069. var env = process.env;
  5070. var forceColor;
  5071. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  5072. forceColor = false;
  5073. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  5074. forceColor = true;
  5075. }
  5076. if ('FORCE_COLOR' in env) {
  5077. forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
  5078. }
  5079. function translateLevel(level) {
  5080. if (level === 0) {
  5081. return false;
  5082. }
  5083. return {
  5084. level,
  5085. hasBasic: true,
  5086. has256: level >= 2,
  5087. has16m: level >= 3
  5088. };
  5089. }
  5090. function supportsColor(stream) {
  5091. if (forceColor === false) {
  5092. return 0;
  5093. }
  5094. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  5095. return 3;
  5096. }
  5097. if (hasFlag('color=256')) {
  5098. return 2;
  5099. }
  5100. if (stream && !stream.isTTY && forceColor !== true) {
  5101. return 0;
  5102. }
  5103. var min = forceColor ? 1 : 0;
  5104. if (process.platform === 'win32') {
  5105. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  5106. // libuv that enables 256 color output on Windows. Anything earlier and it
  5107. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  5108. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  5109. // release that supports 256 colors. Windows 10 build 14931 is the first release
  5110. // that supports 16m/TrueColor.
  5111. var osRelease = os.release().split('.');
  5112. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  5113. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  5114. }
  5115. return 1;
  5116. }
  5117. if ('CI' in env) {
  5118. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  5119. return sign in env;
  5120. }) || env.CI_NAME === 'codeship') {
  5121. return 1;
  5122. }
  5123. return min;
  5124. }
  5125. if ('TEAMCITY_VERSION' in env) {
  5126. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  5127. }
  5128. if (env.COLORTERM === 'truecolor') {
  5129. return 3;
  5130. }
  5131. if ('TERM_PROGRAM' in env) {
  5132. var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  5133. switch (env.TERM_PROGRAM) {
  5134. case 'iTerm.app':
  5135. return version >= 3 ? 3 : 2;
  5136. case 'Apple_Terminal':
  5137. return 2;
  5138. // No default
  5139. }
  5140. }
  5141. if (/-256(color)?$/i.test(env.TERM)) {
  5142. return 2;
  5143. }
  5144. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  5145. return 1;
  5146. }
  5147. if ('COLORTERM' in env) {
  5148. return 1;
  5149. }
  5150. if (env.TERM === 'dumb') {
  5151. return min;
  5152. }
  5153. return min;
  5154. }
  5155. function getSupportLevel(stream) {
  5156. var level = supportsColor(stream);
  5157. return translateLevel(level);
  5158. }
  5159. var supportsColor_1 = {
  5160. supportsColor: getSupportLevel,
  5161. stdout: getSupportLevel(process.stdout),
  5162. stderr: getSupportLevel(process.stderr)
  5163. };
  5164. var templates = createCommonjsModule(function (module) {
  5165. 'use strict';
  5166. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  5167. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  5168. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  5169. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  5170. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  5171. function unescape(c) {
  5172. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  5173. return String.fromCharCode(parseInt(c.slice(1), 16));
  5174. }
  5175. return ESCAPES.get(c) || c;
  5176. }
  5177. function parseArguments(name, args) {
  5178. var results = [];
  5179. var chunks = args.trim().split(/\s*,\s*/g);
  5180. var matches;
  5181. var _iteratorNormalCompletion = true;
  5182. var _didIteratorError = false;
  5183. var _iteratorError = undefined;
  5184. try {
  5185. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5186. var chunk = _step.value;
  5187. if (!isNaN(chunk)) {
  5188. results.push(Number(chunk));
  5189. } else if (matches = chunk.match(STRING_REGEX)) {
  5190. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  5191. return escape ? unescape(escape) : chr;
  5192. }));
  5193. } else {
  5194. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  5195. }
  5196. }
  5197. } catch (err) {
  5198. _didIteratorError = true;
  5199. _iteratorError = err;
  5200. } finally {
  5201. try {
  5202. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5203. _iterator.return();
  5204. }
  5205. } finally {
  5206. if (_didIteratorError) {
  5207. throw _iteratorError;
  5208. }
  5209. }
  5210. }
  5211. return results;
  5212. }
  5213. function parseStyle(style) {
  5214. STYLE_REGEX.lastIndex = 0;
  5215. var results = [];
  5216. var matches;
  5217. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  5218. var name = matches[1];
  5219. if (matches[2]) {
  5220. var args = parseArguments(name, matches[2]);
  5221. results.push([name].concat(args));
  5222. } else {
  5223. results.push([name]);
  5224. }
  5225. }
  5226. return results;
  5227. }
  5228. function buildStyle(chalk, styles) {
  5229. var enabled = {};
  5230. var _iteratorNormalCompletion2 = true;
  5231. var _didIteratorError2 = false;
  5232. var _iteratorError2 = undefined;
  5233. try {
  5234. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5235. var layer = _step2.value;
  5236. var _iteratorNormalCompletion3 = true;
  5237. var _didIteratorError3 = false;
  5238. var _iteratorError3 = undefined;
  5239. try {
  5240. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5241. var style = _step3.value;
  5242. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  5243. }
  5244. } catch (err) {
  5245. _didIteratorError3 = true;
  5246. _iteratorError3 = err;
  5247. } finally {
  5248. try {
  5249. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  5250. _iterator3.return();
  5251. }
  5252. } finally {
  5253. if (_didIteratorError3) {
  5254. throw _iteratorError3;
  5255. }
  5256. }
  5257. }
  5258. }
  5259. } catch (err) {
  5260. _didIteratorError2 = true;
  5261. _iteratorError2 = err;
  5262. } finally {
  5263. try {
  5264. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5265. _iterator2.return();
  5266. }
  5267. } finally {
  5268. if (_didIteratorError2) {
  5269. throw _iteratorError2;
  5270. }
  5271. }
  5272. }
  5273. var current = chalk;
  5274. var _arr = Object.keys(enabled);
  5275. for (var _i = 0; _i < _arr.length; _i++) {
  5276. var styleName = _arr[_i];
  5277. if (Array.isArray(enabled[styleName])) {
  5278. if (!(styleName in current)) {
  5279. throw new Error(`Unknown Chalk style: ${styleName}`);
  5280. }
  5281. if (enabled[styleName].length > 0) {
  5282. current = current[styleName].apply(current, enabled[styleName]);
  5283. } else {
  5284. current = current[styleName];
  5285. }
  5286. }
  5287. }
  5288. return current;
  5289. }
  5290. module.exports = function (chalk, tmp) {
  5291. var styles = [];
  5292. var chunks = [];
  5293. var chunk = []; // eslint-disable-next-line max-params
  5294. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  5295. if (escapeChar) {
  5296. chunk.push(unescape(escapeChar));
  5297. } else if (style) {
  5298. var str = chunk.join('');
  5299. chunk = [];
  5300. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  5301. styles.push({
  5302. inverse,
  5303. styles: parseStyle(style)
  5304. });
  5305. } else if (close) {
  5306. if (styles.length === 0) {
  5307. throw new Error('Found extraneous } in Chalk template literal');
  5308. }
  5309. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  5310. chunk = [];
  5311. styles.pop();
  5312. } else {
  5313. chunk.push(chr);
  5314. }
  5315. });
  5316. chunks.push(chunk.join(''));
  5317. if (styles.length > 0) {
  5318. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  5319. throw new Error(errMsg);
  5320. }
  5321. return chunks.join('');
  5322. };
  5323. });
  5324. var chalk = createCommonjsModule(function (module) {
  5325. 'use strict';
  5326. var stdoutColor = supportsColor_1.stdout;
  5327. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  5328. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  5329. var skipModels = new Set(['gray']);
  5330. var styles = Object.create(null);
  5331. function applyOptions(obj, options) {
  5332. options = options || {}; // Detect level if not set manually
  5333. var scLevel = stdoutColor ? stdoutColor.level : 0;
  5334. obj.level = options.level === undefined ? scLevel : options.level;
  5335. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  5336. }
  5337. function Chalk(options) {
  5338. // We check for this.template here since calling `chalk.constructor()`
  5339. // by itself will have a `this` of a previously constructed chalk object
  5340. if (!this || !(this instanceof Chalk) || this.template) {
  5341. var _chalk = {};
  5342. applyOptions(_chalk, options);
  5343. _chalk.template = function () {
  5344. var args = [].slice.call(arguments);
  5345. return chalkTag.apply(null, [_chalk.template].concat(args));
  5346. };
  5347. Object.setPrototypeOf(_chalk, Chalk.prototype);
  5348. Object.setPrototypeOf(_chalk.template, _chalk);
  5349. _chalk.template.constructor = Chalk;
  5350. return _chalk.template;
  5351. }
  5352. applyOptions(this, options);
  5353. } // Use bright blue on Windows as the normal blue color is illegible
  5354. if (isSimpleWindowsTerm) {
  5355. ansiStyles.blue.open = '\u001B[94m';
  5356. }
  5357. var _arr = Object.keys(ansiStyles);
  5358. var _loop = function _loop() {
  5359. var key = _arr[_i];
  5360. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  5361. styles[key] = {
  5362. get() {
  5363. var codes = ansiStyles[key];
  5364. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  5365. }
  5366. };
  5367. };
  5368. for (var _i = 0; _i < _arr.length; _i++) {
  5369. _loop();
  5370. }
  5371. styles.visible = {
  5372. get() {
  5373. return build.call(this, this._styles || [], true, 'visible');
  5374. }
  5375. };
  5376. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  5377. var _arr2 = Object.keys(ansiStyles.color.ansi);
  5378. var _loop2 = function _loop2() {
  5379. var model = _arr2[_i2];
  5380. if (skipModels.has(model)) {
  5381. return "continue";
  5382. }
  5383. styles[model] = {
  5384. get() {
  5385. var level = this.level;
  5386. return function () {
  5387. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  5388. var codes = {
  5389. open,
  5390. close: ansiStyles.color.close,
  5391. closeRe: ansiStyles.color.closeRe
  5392. };
  5393. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5394. };
  5395. }
  5396. };
  5397. };
  5398. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5399. var _ret = _loop2();
  5400. if (_ret === "continue") continue;
  5401. }
  5402. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  5403. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  5404. var _loop3 = function _loop3() {
  5405. var model = _arr3[_i3];
  5406. if (skipModels.has(model)) {
  5407. return "continue";
  5408. }
  5409. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  5410. styles[bgModel] = {
  5411. get() {
  5412. var level = this.level;
  5413. return function () {
  5414. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  5415. var codes = {
  5416. open,
  5417. close: ansiStyles.bgColor.close,
  5418. closeRe: ansiStyles.bgColor.closeRe
  5419. };
  5420. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5421. };
  5422. }
  5423. };
  5424. };
  5425. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  5426. var _ret2 = _loop3();
  5427. if (_ret2 === "continue") continue;
  5428. }
  5429. var proto = Object.defineProperties(function () {}, styles);
  5430. function build(_styles, _empty, key) {
  5431. var builder = function builder() {
  5432. return applyStyle.apply(builder, arguments);
  5433. };
  5434. builder._styles = _styles;
  5435. builder._empty = _empty;
  5436. var self = this;
  5437. Object.defineProperty(builder, 'level', {
  5438. enumerable: true,
  5439. get() {
  5440. return self.level;
  5441. },
  5442. set(level) {
  5443. self.level = level;
  5444. }
  5445. });
  5446. Object.defineProperty(builder, 'enabled', {
  5447. enumerable: true,
  5448. get() {
  5449. return self.enabled;
  5450. },
  5451. set(enabled) {
  5452. self.enabled = enabled;
  5453. }
  5454. }); // See below for fix regarding invisible grey/dim combination on Windows
  5455. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  5456. // no way to create a function with a different prototype
  5457. builder.__proto__ = proto; // eslint-disable-line no-proto
  5458. return builder;
  5459. }
  5460. function applyStyle() {
  5461. // Support varags, but simply cast to string in case there's only one arg
  5462. var args = arguments;
  5463. var argsLen = args.length;
  5464. var str = String(arguments[0]);
  5465. if (argsLen === 0) {
  5466. return '';
  5467. }
  5468. if (argsLen > 1) {
  5469. // Don't slice `arguments`, it prevents V8 optimizations
  5470. for (var a = 1; a < argsLen; a++) {
  5471. str += ' ' + args[a];
  5472. }
  5473. }
  5474. if (!this.enabled || this.level <= 0 || !str) {
  5475. return this._empty ? '' : str;
  5476. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  5477. // see https://github.com/chalk/chalk/issues/58
  5478. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  5479. var originalDim = ansiStyles.dim.open;
  5480. if (isSimpleWindowsTerm && this.hasGrey) {
  5481. ansiStyles.dim.open = '';
  5482. }
  5483. var _iteratorNormalCompletion = true;
  5484. var _didIteratorError = false;
  5485. var _iteratorError = undefined;
  5486. try {
  5487. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5488. var code = _step.value;
  5489. // Replace any instances already present with a re-opening code
  5490. // otherwise only the part of the string until said closing code
  5491. // will be colored, and the rest will simply be 'plain'.
  5492. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  5493. // after next line to fix a bleed issue on macOS
  5494. // https://github.com/chalk/chalk/pull/92
  5495. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  5496. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  5497. } catch (err) {
  5498. _didIteratorError = true;
  5499. _iteratorError = err;
  5500. } finally {
  5501. try {
  5502. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5503. _iterator.return();
  5504. }
  5505. } finally {
  5506. if (_didIteratorError) {
  5507. throw _iteratorError;
  5508. }
  5509. }
  5510. }
  5511. ansiStyles.dim.open = originalDim;
  5512. return str;
  5513. }
  5514. function chalkTag(chalk, strings) {
  5515. if (!Array.isArray(strings)) {
  5516. // If chalk() was called by itself or with a string,
  5517. // return the string itself as a string.
  5518. return [].slice.call(arguments, 1).join(' ');
  5519. }
  5520. var args = [].slice.call(arguments, 2);
  5521. var parts = [strings.raw[0]];
  5522. for (var i = 1; i < strings.length; i++) {
  5523. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  5524. parts.push(String(strings.raw[i]));
  5525. }
  5526. return templates(chalk, parts.join(''));
  5527. }
  5528. Object.defineProperties(Chalk.prototype, styles);
  5529. module.exports = Chalk(); // eslint-disable-line new-cap
  5530. module.exports.supportsColor = stdoutColor;
  5531. module.exports.default = module.exports; // For TypeScript
  5532. });
  5533. var common = createCommonjsModule(function (module, exports) {
  5534. "use strict";
  5535. Object.defineProperty(exports, "__esModule", {
  5536. value: true
  5537. });
  5538. exports.commonDeprecatedHandler = function (keyOrPair, redirectTo, _ref) {
  5539. var descriptor = _ref.descriptor;
  5540. var messages = [`${chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
  5541. if (redirectTo) {
  5542. messages.push(`we now treat it as ${chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
  5543. }
  5544. return messages.join('; ') + '.';
  5545. };
  5546. });
  5547. unwrapExports(common);
  5548. var deprecated = createCommonjsModule(function (module, exports) {
  5549. "use strict";
  5550. Object.defineProperty(exports, "__esModule", {
  5551. value: true
  5552. });
  5553. tslib_1.__exportStar(common, exports);
  5554. });
  5555. unwrapExports(deprecated);
  5556. var common$2 = createCommonjsModule(function (module, exports) {
  5557. "use strict";
  5558. Object.defineProperty(exports, "__esModule", {
  5559. value: true
  5560. });
  5561. exports.commonInvalidHandler = function (key, value, utils) {
  5562. return [`Invalid ${chalk.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk.default.red(utils.descriptor.value(value))}.`].join(' ');
  5563. };
  5564. });
  5565. unwrapExports(common$2);
  5566. var invalid = createCommonjsModule(function (module, exports) {
  5567. "use strict";
  5568. Object.defineProperty(exports, "__esModule", {
  5569. value: true
  5570. });
  5571. tslib_1.__exportStar(common$2, exports);
  5572. });
  5573. unwrapExports(invalid);
  5574. /* eslint-disable no-nested-ternary */
  5575. var arr = [];
  5576. var charCodeCache = [];
  5577. var leven$1 = function leven(a, b) {
  5578. if (a === b) {
  5579. return 0;
  5580. }
  5581. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  5582. // shortest & which one is the longest
  5583. if (a.length > b.length) {
  5584. a = b;
  5585. b = swap;
  5586. }
  5587. var aLen = a.length;
  5588. var bLen = b.length;
  5589. if (aLen === 0) {
  5590. return bLen;
  5591. }
  5592. if (bLen === 0) {
  5593. return aLen;
  5594. } // Performing suffix trimming:
  5595. // We can linearly drop suffix common to both strings since they
  5596. // don't increase distance at all
  5597. // Note: `~-` is the bitwise way to perform a `- 1` operation
  5598. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  5599. aLen--;
  5600. bLen--;
  5601. }
  5602. if (aLen === 0) {
  5603. return bLen;
  5604. } // Performing prefix trimming
  5605. // We can linearly drop prefix common to both strings since they
  5606. // don't increase distance at all
  5607. var start = 0;
  5608. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  5609. start++;
  5610. }
  5611. aLen -= start;
  5612. bLen -= start;
  5613. if (aLen === 0) {
  5614. return bLen;
  5615. }
  5616. var bCharCode;
  5617. var ret;
  5618. var tmp;
  5619. var tmp2;
  5620. var i = 0;
  5621. var j = 0;
  5622. while (i < aLen) {
  5623. charCodeCache[start + i] = a.charCodeAt(start + i);
  5624. arr[i] = ++i;
  5625. }
  5626. while (j < bLen) {
  5627. bCharCode = b.charCodeAt(start + j);
  5628. tmp = j++;
  5629. ret = j;
  5630. for (i = 0; i < aLen; i++) {
  5631. tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
  5632. tmp = arr[i];
  5633. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  5634. }
  5635. }
  5636. return ret;
  5637. };
  5638. var leven_1 = createCommonjsModule(function (module, exports) {
  5639. "use strict";
  5640. Object.defineProperty(exports, "__esModule", {
  5641. value: true
  5642. });
  5643. exports.levenUnknownHandler = function (key, value, _ref) {
  5644. var descriptor = _ref.descriptor,
  5645. logger = _ref.logger,
  5646. schemas = _ref.schemas;
  5647. var messages = [`Ignored unknown option ${chalk.default.yellow(descriptor.pair({
  5648. key,
  5649. value
  5650. }))}.`];
  5651. var suggestion = Object.keys(schemas).sort().find(function (knownKey) {
  5652. return leven$1(key, knownKey) < 3;
  5653. });
  5654. if (suggestion) {
  5655. messages.push(`Did you mean ${chalk.default.blue(descriptor.key(suggestion))}?`);
  5656. }
  5657. logger.warn(messages.join(' '));
  5658. };
  5659. });
  5660. unwrapExports(leven_1);
  5661. var unknown = createCommonjsModule(function (module, exports) {
  5662. "use strict";
  5663. Object.defineProperty(exports, "__esModule", {
  5664. value: true
  5665. });
  5666. tslib_1.__exportStar(leven_1, exports);
  5667. });
  5668. unwrapExports(unknown);
  5669. var handlers = createCommonjsModule(function (module, exports) {
  5670. "use strict";
  5671. Object.defineProperty(exports, "__esModule", {
  5672. value: true
  5673. });
  5674. tslib_1.__exportStar(deprecated, exports);
  5675. tslib_1.__exportStar(invalid, exports);
  5676. tslib_1.__exportStar(unknown, exports);
  5677. });
  5678. unwrapExports(handlers);
  5679. var schema = createCommonjsModule(function (module, exports) {
  5680. "use strict";
  5681. Object.defineProperty(exports, "__esModule", {
  5682. value: true
  5683. });
  5684. var HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  5685. function createSchema(SchemaConstructor, parameters) {
  5686. var schema = new SchemaConstructor(parameters);
  5687. var subSchema = Object.create(schema);
  5688. for (var _i = 0; _i < HANDLER_KEYS.length; _i++) {
  5689. var handlerKey = HANDLER_KEYS[_i];
  5690. if (handlerKey in parameters) {
  5691. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  5692. }
  5693. }
  5694. return subSchema;
  5695. }
  5696. exports.createSchema = createSchema;
  5697. var Schema =
  5698. /*#__PURE__*/
  5699. function () {
  5700. function Schema(parameters) {
  5701. _classCallCheck(this, Schema);
  5702. this.name = parameters.name;
  5703. }
  5704. _createClass(Schema, [{
  5705. key: "default",
  5706. value: function _default(_utils) {
  5707. return undefined;
  5708. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  5709. }, {
  5710. key: "expected",
  5711. value: function expected(_utils) {
  5712. return 'nothing';
  5713. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  5714. }, {
  5715. key: "validate",
  5716. value: function validate(_value, _utils) {
  5717. return false;
  5718. }
  5719. }, {
  5720. key: "deprecated",
  5721. value: function deprecated(_value, _utils) {
  5722. return false;
  5723. }
  5724. }, {
  5725. key: "forward",
  5726. value: function forward(_value, _utils) {
  5727. return undefined;
  5728. }
  5729. }, {
  5730. key: "redirect",
  5731. value: function redirect(_value, _utils) {
  5732. return undefined;
  5733. }
  5734. }, {
  5735. key: "overlap",
  5736. value: function overlap(currentValue, _newValue, _utils) {
  5737. return currentValue;
  5738. }
  5739. }, {
  5740. key: "preprocess",
  5741. value: function preprocess(value, _utils) {
  5742. return value;
  5743. }
  5744. }, {
  5745. key: "postprocess",
  5746. value: function postprocess(value, _utils) {
  5747. return value;
  5748. }
  5749. }], [{
  5750. key: "create",
  5751. value: function create(parameters) {
  5752. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  5753. return createSchema(this, parameters);
  5754. }
  5755. }]);
  5756. return Schema;
  5757. }();
  5758. exports.Schema = Schema;
  5759. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  5760. return typeof handler === 'function' ? function () {
  5761. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5762. args[_key] = arguments[_key];
  5763. }
  5764. return handler.apply(void 0, _toConsumableArray(args.slice(0, handlerArgumentsLength - 1)).concat([superSchema], _toConsumableArray(args.slice(handlerArgumentsLength - 1))));
  5765. } : function () {
  5766. return handler;
  5767. };
  5768. }
  5769. });
  5770. unwrapExports(schema);
  5771. var alias = createCommonjsModule(function (module, exports) {
  5772. "use strict";
  5773. Object.defineProperty(exports, "__esModule", {
  5774. value: true
  5775. });
  5776. var AliasSchema =
  5777. /*#__PURE__*/
  5778. function (_schema_1$Schema) {
  5779. _inherits(AliasSchema, _schema_1$Schema);
  5780. function AliasSchema(parameters) {
  5781. var _this;
  5782. _classCallCheck(this, AliasSchema);
  5783. _this = _possibleConstructorReturn(this, _getPrototypeOf(AliasSchema).call(this, parameters));
  5784. _this._sourceName = parameters.sourceName;
  5785. return _this;
  5786. }
  5787. _createClass(AliasSchema, [{
  5788. key: "expected",
  5789. value: function expected(utils) {
  5790. return utils.schemas[this._sourceName].expected(utils);
  5791. }
  5792. }, {
  5793. key: "validate",
  5794. value: function validate(value, utils) {
  5795. return utils.schemas[this._sourceName].validate(value, utils);
  5796. }
  5797. }, {
  5798. key: "redirect",
  5799. value: function redirect(_value, _utils) {
  5800. return this._sourceName;
  5801. }
  5802. }]);
  5803. return AliasSchema;
  5804. }(schema.Schema);
  5805. exports.AliasSchema = AliasSchema;
  5806. });
  5807. unwrapExports(alias);
  5808. var any = createCommonjsModule(function (module, exports) {
  5809. "use strict";
  5810. Object.defineProperty(exports, "__esModule", {
  5811. value: true
  5812. });
  5813. var AnySchema =
  5814. /*#__PURE__*/
  5815. function (_schema_1$Schema) {
  5816. _inherits(AnySchema, _schema_1$Schema);
  5817. function AnySchema() {
  5818. _classCallCheck(this, AnySchema);
  5819. return _possibleConstructorReturn(this, _getPrototypeOf(AnySchema).apply(this, arguments));
  5820. }
  5821. _createClass(AnySchema, [{
  5822. key: "expected",
  5823. value: function expected() {
  5824. return 'anything';
  5825. }
  5826. }, {
  5827. key: "validate",
  5828. value: function validate() {
  5829. return true;
  5830. }
  5831. }]);
  5832. return AnySchema;
  5833. }(schema.Schema);
  5834. exports.AnySchema = AnySchema;
  5835. });
  5836. unwrapExports(any);
  5837. var array$2 = createCommonjsModule(function (module, exports) {
  5838. "use strict";
  5839. Object.defineProperty(exports, "__esModule", {
  5840. value: true
  5841. });
  5842. var ArraySchema =
  5843. /*#__PURE__*/
  5844. function (_schema_1$Schema) {
  5845. _inherits(ArraySchema, _schema_1$Schema);
  5846. function ArraySchema(_a) {
  5847. var _this;
  5848. _classCallCheck(this, ArraySchema);
  5849. var valueSchema = _a.valueSchema,
  5850. _a$name = _a.name,
  5851. name = _a$name === void 0 ? valueSchema.name : _a$name,
  5852. handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
  5853. _this = _possibleConstructorReturn(this, _getPrototypeOf(ArraySchema).call(this, Object.assign({}, handlers, {
  5854. name
  5855. })));
  5856. _this._valueSchema = valueSchema;
  5857. return _this;
  5858. }
  5859. _createClass(ArraySchema, [{
  5860. key: "expected",
  5861. value: function expected(utils) {
  5862. return `an array of ${this._valueSchema.expected(utils)}`;
  5863. }
  5864. }, {
  5865. key: "validate",
  5866. value: function validate(value, utils) {
  5867. if (!Array.isArray(value)) {
  5868. return false;
  5869. }
  5870. var invalidValues = [];
  5871. var _iteratorNormalCompletion = true;
  5872. var _didIteratorError = false;
  5873. var _iteratorError = undefined;
  5874. try {
  5875. for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5876. var subValue = _step.value;
  5877. var subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  5878. if (subValidateResult !== true) {
  5879. invalidValues.push(subValidateResult.value);
  5880. }
  5881. }
  5882. } catch (err) {
  5883. _didIteratorError = true;
  5884. _iteratorError = err;
  5885. } finally {
  5886. try {
  5887. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5888. _iterator.return();
  5889. }
  5890. } finally {
  5891. if (_didIteratorError) {
  5892. throw _iteratorError;
  5893. }
  5894. }
  5895. }
  5896. return invalidValues.length === 0 ? true : {
  5897. value: invalidValues
  5898. };
  5899. }
  5900. }, {
  5901. key: "deprecated",
  5902. value: function deprecated(value, utils) {
  5903. var deprecatedResult = [];
  5904. var _iteratorNormalCompletion2 = true;
  5905. var _didIteratorError2 = false;
  5906. var _iteratorError2 = undefined;
  5907. try {
  5908. for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5909. var subValue = _step2.value;
  5910. var subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  5911. if (subDeprecatedResult !== false) {
  5912. deprecatedResult.push.apply(deprecatedResult, _toConsumableArray(subDeprecatedResult.map(function (_ref) {
  5913. var deprecatedValue = _ref.value;
  5914. return {
  5915. value: [deprecatedValue]
  5916. };
  5917. })));
  5918. }
  5919. }
  5920. } catch (err) {
  5921. _didIteratorError2 = true;
  5922. _iteratorError2 = err;
  5923. } finally {
  5924. try {
  5925. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5926. _iterator2.return();
  5927. }
  5928. } finally {
  5929. if (_didIteratorError2) {
  5930. throw _iteratorError2;
  5931. }
  5932. }
  5933. }
  5934. return deprecatedResult;
  5935. }
  5936. }, {
  5937. key: "forward",
  5938. value: function forward(value, utils) {
  5939. var forwardResult = [];
  5940. var _iteratorNormalCompletion3 = true;
  5941. var _didIteratorError3 = false;
  5942. var _iteratorError3 = undefined;
  5943. try {
  5944. for (var _iterator3 = value[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5945. var subValue = _step3.value;
  5946. var subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  5947. forwardResult.push.apply(forwardResult, _toConsumableArray(subForwardResult.map(wrapTransferResult)));
  5948. }
  5949. } catch (err) {
  5950. _didIteratorError3 = true;
  5951. _iteratorError3 = err;
  5952. } finally {
  5953. try {
  5954. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  5955. _iterator3.return();
  5956. }
  5957. } finally {
  5958. if (_didIteratorError3) {
  5959. throw _iteratorError3;
  5960. }
  5961. }
  5962. }
  5963. return forwardResult;
  5964. }
  5965. }, {
  5966. key: "redirect",
  5967. value: function redirect(value, utils) {
  5968. var remain = [];
  5969. var redirect = [];
  5970. var _iteratorNormalCompletion4 = true;
  5971. var _didIteratorError4 = false;
  5972. var _iteratorError4 = undefined;
  5973. try {
  5974. for (var _iterator4 = value[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  5975. var subValue = _step4.value;
  5976. var subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  5977. if ('remain' in subRedirectResult) {
  5978. remain.push(subRedirectResult.remain);
  5979. }
  5980. redirect.push.apply(redirect, _toConsumableArray(subRedirectResult.redirect.map(wrapTransferResult)));
  5981. }
  5982. } catch (err) {
  5983. _didIteratorError4 = true;
  5984. _iteratorError4 = err;
  5985. } finally {
  5986. try {
  5987. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  5988. _iterator4.return();
  5989. }
  5990. } finally {
  5991. if (_didIteratorError4) {
  5992. throw _iteratorError4;
  5993. }
  5994. }
  5995. }
  5996. return remain.length === 0 ? {
  5997. redirect
  5998. } : {
  5999. redirect,
  6000. remain
  6001. };
  6002. }
  6003. }, {
  6004. key: "overlap",
  6005. value: function overlap(currentValue, newValue) {
  6006. return currentValue.concat(newValue);
  6007. }
  6008. }]);
  6009. return ArraySchema;
  6010. }(schema.Schema);
  6011. exports.ArraySchema = ArraySchema;
  6012. function wrapTransferResult(_ref2) {
  6013. var from = _ref2.from,
  6014. to = _ref2.to;
  6015. return {
  6016. from: [from],
  6017. to
  6018. };
  6019. }
  6020. });
  6021. unwrapExports(array$2);
  6022. var boolean_1 = createCommonjsModule(function (module, exports) {
  6023. "use strict";
  6024. Object.defineProperty(exports, "__esModule", {
  6025. value: true
  6026. });
  6027. var BooleanSchema =
  6028. /*#__PURE__*/
  6029. function (_schema_1$Schema) {
  6030. _inherits(BooleanSchema, _schema_1$Schema);
  6031. function BooleanSchema() {
  6032. _classCallCheck(this, BooleanSchema);
  6033. return _possibleConstructorReturn(this, _getPrototypeOf(BooleanSchema).apply(this, arguments));
  6034. }
  6035. _createClass(BooleanSchema, [{
  6036. key: "expected",
  6037. value: function expected() {
  6038. return 'true or false';
  6039. }
  6040. }, {
  6041. key: "validate",
  6042. value: function validate(value) {
  6043. return typeof value === 'boolean';
  6044. }
  6045. }]);
  6046. return BooleanSchema;
  6047. }(schema.Schema);
  6048. exports.BooleanSchema = BooleanSchema;
  6049. });
  6050. unwrapExports(boolean_1);
  6051. var utils = createCommonjsModule(function (module, exports) {
  6052. "use strict";
  6053. Object.defineProperty(exports, "__esModule", {
  6054. value: true
  6055. });
  6056. function recordFromArray(array, mainKey) {
  6057. var record = Object.create(null);
  6058. var _iteratorNormalCompletion = true;
  6059. var _didIteratorError = false;
  6060. var _iteratorError = undefined;
  6061. try {
  6062. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6063. var value = _step.value;
  6064. var key = value[mainKey]; // istanbul ignore next
  6065. if (record[key]) {
  6066. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  6067. } // @ts-ignore
  6068. record[key] = value;
  6069. }
  6070. } catch (err) {
  6071. _didIteratorError = true;
  6072. _iteratorError = err;
  6073. } finally {
  6074. try {
  6075. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6076. _iterator.return();
  6077. }
  6078. } finally {
  6079. if (_didIteratorError) {
  6080. throw _iteratorError;
  6081. }
  6082. }
  6083. }
  6084. return record;
  6085. }
  6086. exports.recordFromArray = recordFromArray;
  6087. function mapFromArray(array, mainKey) {
  6088. var map = new Map();
  6089. var _iteratorNormalCompletion2 = true;
  6090. var _didIteratorError2 = false;
  6091. var _iteratorError2 = undefined;
  6092. try {
  6093. for (var _iterator2 = array[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6094. var value = _step2.value;
  6095. var key = value[mainKey]; // istanbul ignore next
  6096. if (map.has(key)) {
  6097. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  6098. }
  6099. map.set(key, value);
  6100. }
  6101. } catch (err) {
  6102. _didIteratorError2 = true;
  6103. _iteratorError2 = err;
  6104. } finally {
  6105. try {
  6106. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6107. _iterator2.return();
  6108. }
  6109. } finally {
  6110. if (_didIteratorError2) {
  6111. throw _iteratorError2;
  6112. }
  6113. }
  6114. }
  6115. return map;
  6116. }
  6117. exports.mapFromArray = mapFromArray;
  6118. function createAutoChecklist() {
  6119. var map = Object.create(null);
  6120. return function (id) {
  6121. var idString = JSON.stringify(id);
  6122. if (map[idString]) {
  6123. return true;
  6124. }
  6125. map[idString] = true;
  6126. return false;
  6127. };
  6128. }
  6129. exports.createAutoChecklist = createAutoChecklist;
  6130. function partition(array, predicate) {
  6131. var trueArray = [];
  6132. var falseArray = [];
  6133. var _iteratorNormalCompletion3 = true;
  6134. var _didIteratorError3 = false;
  6135. var _iteratorError3 = undefined;
  6136. try {
  6137. for (var _iterator3 = array[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6138. var value = _step3.value;
  6139. if (predicate(value)) {
  6140. trueArray.push(value);
  6141. } else {
  6142. falseArray.push(value);
  6143. }
  6144. }
  6145. } catch (err) {
  6146. _didIteratorError3 = true;
  6147. _iteratorError3 = err;
  6148. } finally {
  6149. try {
  6150. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6151. _iterator3.return();
  6152. }
  6153. } finally {
  6154. if (_didIteratorError3) {
  6155. throw _iteratorError3;
  6156. }
  6157. }
  6158. }
  6159. return [trueArray, falseArray];
  6160. }
  6161. exports.partition = partition;
  6162. function isInt(value) {
  6163. return value === Math.floor(value);
  6164. }
  6165. exports.isInt = isInt;
  6166. function comparePrimitive(a, b) {
  6167. if (a === b) {
  6168. return 0;
  6169. }
  6170. var typeofA = typeof a;
  6171. var typeofB = typeof b;
  6172. var orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  6173. if (typeofA !== typeofB) {
  6174. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  6175. }
  6176. if (typeofA !== 'string') {
  6177. return Number(a) - Number(b);
  6178. }
  6179. return a.localeCompare(b);
  6180. }
  6181. exports.comparePrimitive = comparePrimitive;
  6182. function normalizeDefaultResult(result) {
  6183. return result === undefined ? {} : result;
  6184. }
  6185. exports.normalizeDefaultResult = normalizeDefaultResult;
  6186. function normalizeValidateResult(result, value) {
  6187. return result === true ? true : result === false ? {
  6188. value
  6189. } : result;
  6190. }
  6191. exports.normalizeValidateResult = normalizeValidateResult;
  6192. function normalizeDeprecatedResult(result, value) {
  6193. var doNotNormalizeTrue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6194. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  6195. value
  6196. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  6197. }
  6198. exports.normalizeDeprecatedResult = normalizeDeprecatedResult;
  6199. function normalizeTransferResult(result, value) {
  6200. return typeof result === 'string' || 'key' in result ? {
  6201. from: value,
  6202. to: result
  6203. } : 'from' in result ? {
  6204. from: result.from,
  6205. to: result.to
  6206. } : {
  6207. from: value,
  6208. to: result.to
  6209. };
  6210. }
  6211. exports.normalizeTransferResult = normalizeTransferResult;
  6212. function normalizeForwardResult(result, value) {
  6213. return result === undefined ? [] : Array.isArray(result) ? result.map(function (transferResult) {
  6214. return normalizeTransferResult(transferResult, value);
  6215. }) : [normalizeTransferResult(result, value)];
  6216. }
  6217. exports.normalizeForwardResult = normalizeForwardResult;
  6218. function normalizeRedirectResult(result, value) {
  6219. var redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
  6220. return redirect.length === 0 ? {
  6221. remain: value,
  6222. redirect
  6223. } : typeof result === 'object' && 'remain' in result ? {
  6224. remain: result.remain,
  6225. redirect
  6226. } : {
  6227. redirect
  6228. };
  6229. }
  6230. exports.normalizeRedirectResult = normalizeRedirectResult;
  6231. });
  6232. unwrapExports(utils);
  6233. var choice = createCommonjsModule(function (module, exports) {
  6234. "use strict";
  6235. Object.defineProperty(exports, "__esModule", {
  6236. value: true
  6237. });
  6238. var ChoiceSchema =
  6239. /*#__PURE__*/
  6240. function (_schema_1$Schema) {
  6241. _inherits(ChoiceSchema, _schema_1$Schema);
  6242. function ChoiceSchema(parameters) {
  6243. var _this;
  6244. _classCallCheck(this, ChoiceSchema);
  6245. _this = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceSchema).call(this, parameters));
  6246. _this._choices = utils.mapFromArray(parameters.choices.map(function (choice) {
  6247. return choice && typeof choice === 'object' ? choice : {
  6248. value: choice
  6249. };
  6250. }), 'value');
  6251. return _this;
  6252. }
  6253. _createClass(ChoiceSchema, [{
  6254. key: "expected",
  6255. value: function expected(_ref) {
  6256. var _this2 = this;
  6257. var descriptor = _ref.descriptor;
  6258. var choiceValues = Array.from(this._choices.keys()).map(function (value) {
  6259. return _this2._choices.get(value);
  6260. }).filter(function (choiceInfo) {
  6261. return !choiceInfo.deprecated;
  6262. }).map(function (choiceInfo) {
  6263. return choiceInfo.value;
  6264. }).sort(utils.comparePrimitive).map(descriptor.value);
  6265. var head = choiceValues.slice(0, -2);
  6266. var tail = choiceValues.slice(-2);
  6267. return head.concat(tail.join(' or ')).join(', ');
  6268. }
  6269. }, {
  6270. key: "validate",
  6271. value: function validate(value) {
  6272. return this._choices.has(value);
  6273. }
  6274. }, {
  6275. key: "deprecated",
  6276. value: function deprecated(value) {
  6277. var choiceInfo = this._choices.get(value);
  6278. return choiceInfo && choiceInfo.deprecated ? {
  6279. value
  6280. } : false;
  6281. }
  6282. }, {
  6283. key: "forward",
  6284. value: function forward(value) {
  6285. var choiceInfo = this._choices.get(value);
  6286. return choiceInfo ? choiceInfo.forward : undefined;
  6287. }
  6288. }, {
  6289. key: "redirect",
  6290. value: function redirect(value) {
  6291. var choiceInfo = this._choices.get(value);
  6292. return choiceInfo ? choiceInfo.redirect : undefined;
  6293. }
  6294. }]);
  6295. return ChoiceSchema;
  6296. }(schema.Schema);
  6297. exports.ChoiceSchema = ChoiceSchema;
  6298. });
  6299. unwrapExports(choice);
  6300. var number = createCommonjsModule(function (module, exports) {
  6301. "use strict";
  6302. Object.defineProperty(exports, "__esModule", {
  6303. value: true
  6304. });
  6305. var NumberSchema =
  6306. /*#__PURE__*/
  6307. function (_schema_1$Schema) {
  6308. _inherits(NumberSchema, _schema_1$Schema);
  6309. function NumberSchema() {
  6310. _classCallCheck(this, NumberSchema);
  6311. return _possibleConstructorReturn(this, _getPrototypeOf(NumberSchema).apply(this, arguments));
  6312. }
  6313. _createClass(NumberSchema, [{
  6314. key: "expected",
  6315. value: function expected() {
  6316. return 'a number';
  6317. }
  6318. }, {
  6319. key: "validate",
  6320. value: function validate(value, _utils) {
  6321. return typeof value === 'number';
  6322. }
  6323. }]);
  6324. return NumberSchema;
  6325. }(schema.Schema);
  6326. exports.NumberSchema = NumberSchema;
  6327. });
  6328. unwrapExports(number);
  6329. var integer = createCommonjsModule(function (module, exports) {
  6330. "use strict";
  6331. Object.defineProperty(exports, "__esModule", {
  6332. value: true
  6333. });
  6334. var IntegerSchema =
  6335. /*#__PURE__*/
  6336. function (_number_1$NumberSchem) {
  6337. _inherits(IntegerSchema, _number_1$NumberSchem);
  6338. function IntegerSchema() {
  6339. _classCallCheck(this, IntegerSchema);
  6340. return _possibleConstructorReturn(this, _getPrototypeOf(IntegerSchema).apply(this, arguments));
  6341. }
  6342. _createClass(IntegerSchema, [{
  6343. key: "expected",
  6344. value: function expected() {
  6345. return 'an integer';
  6346. }
  6347. }, {
  6348. key: "validate",
  6349. value: function validate(value, utils$$2) {
  6350. return utils$$2.normalizeValidateResult(_get(_getPrototypeOf(IntegerSchema.prototype), "validate", this).call(this, value, utils$$2), value) === true && utils.isInt(value);
  6351. }
  6352. }]);
  6353. return IntegerSchema;
  6354. }(number.NumberSchema);
  6355. exports.IntegerSchema = IntegerSchema;
  6356. });
  6357. unwrapExports(integer);
  6358. var string = createCommonjsModule(function (module, exports) {
  6359. "use strict";
  6360. Object.defineProperty(exports, "__esModule", {
  6361. value: true
  6362. });
  6363. var StringSchema =
  6364. /*#__PURE__*/
  6365. function (_schema_1$Schema) {
  6366. _inherits(StringSchema, _schema_1$Schema);
  6367. function StringSchema() {
  6368. _classCallCheck(this, StringSchema);
  6369. return _possibleConstructorReturn(this, _getPrototypeOf(StringSchema).apply(this, arguments));
  6370. }
  6371. _createClass(StringSchema, [{
  6372. key: "expected",
  6373. value: function expected() {
  6374. return 'a string';
  6375. }
  6376. }, {
  6377. key: "validate",
  6378. value: function validate(value) {
  6379. return typeof value === 'string';
  6380. }
  6381. }]);
  6382. return StringSchema;
  6383. }(schema.Schema);
  6384. exports.StringSchema = StringSchema;
  6385. });
  6386. unwrapExports(string);
  6387. var schemas = createCommonjsModule(function (module, exports) {
  6388. "use strict";
  6389. Object.defineProperty(exports, "__esModule", {
  6390. value: true
  6391. });
  6392. tslib_1.__exportStar(alias, exports);
  6393. tslib_1.__exportStar(any, exports);
  6394. tslib_1.__exportStar(array$2, exports);
  6395. tslib_1.__exportStar(boolean_1, exports);
  6396. tslib_1.__exportStar(choice, exports);
  6397. tslib_1.__exportStar(integer, exports);
  6398. tslib_1.__exportStar(number, exports);
  6399. tslib_1.__exportStar(string, exports);
  6400. });
  6401. unwrapExports(schemas);
  6402. var defaults = createCommonjsModule(function (module, exports) {
  6403. "use strict";
  6404. Object.defineProperty(exports, "__esModule", {
  6405. value: true
  6406. });
  6407. exports.defaultDescriptor = api.apiDescriptor;
  6408. exports.defaultUnknownHandler = leven_1.levenUnknownHandler;
  6409. exports.defaultInvalidHandler = invalid.commonInvalidHandler;
  6410. exports.defaultDeprecatedHandler = common.commonDeprecatedHandler;
  6411. });
  6412. unwrapExports(defaults);
  6413. var normalize$1 = createCommonjsModule(function (module, exports) {
  6414. "use strict";
  6415. Object.defineProperty(exports, "__esModule", {
  6416. value: true
  6417. });
  6418. exports.normalize = function (options, schemas, opts) {
  6419. return new Normalizer(schemas, opts).normalize(options);
  6420. };
  6421. var Normalizer =
  6422. /*#__PURE__*/
  6423. function () {
  6424. function Normalizer(schemas, opts) {
  6425. _classCallCheck(this, Normalizer);
  6426. // istanbul ignore next
  6427. var _ref = opts || {},
  6428. _ref$logger = _ref.logger,
  6429. logger = _ref$logger === void 0 ? console : _ref$logger,
  6430. _ref$descriptor = _ref.descriptor,
  6431. descriptor = _ref$descriptor === void 0 ? defaults.defaultDescriptor : _ref$descriptor,
  6432. _ref$unknown = _ref.unknown,
  6433. unknown = _ref$unknown === void 0 ? defaults.defaultUnknownHandler : _ref$unknown,
  6434. _ref$invalid = _ref.invalid,
  6435. invalid = _ref$invalid === void 0 ? defaults.defaultInvalidHandler : _ref$invalid,
  6436. _ref$deprecated = _ref.deprecated,
  6437. deprecated = _ref$deprecated === void 0 ? defaults.defaultDeprecatedHandler : _ref$deprecated;
  6438. this._utils = {
  6439. descriptor,
  6440. logger:
  6441. /* istanbul ignore next */
  6442. logger || {
  6443. warn: function warn() {}
  6444. },
  6445. schemas: utils.recordFromArray(schemas, 'name'),
  6446. normalizeDefaultResult: utils.normalizeDefaultResult,
  6447. normalizeDeprecatedResult: utils.normalizeDeprecatedResult,
  6448. normalizeForwardResult: utils.normalizeForwardResult,
  6449. normalizeRedirectResult: utils.normalizeRedirectResult,
  6450. normalizeValidateResult: utils.normalizeValidateResult
  6451. };
  6452. this._unknownHandler = unknown;
  6453. this._invalidHandler = invalid;
  6454. this._deprecatedHandler = deprecated;
  6455. this.cleanHistory();
  6456. }
  6457. _createClass(Normalizer, [{
  6458. key: "cleanHistory",
  6459. value: function cleanHistory() {
  6460. this._hasDeprecationWarned = utils.createAutoChecklist();
  6461. }
  6462. }, {
  6463. key: "normalize",
  6464. value: function normalize(options) {
  6465. var _this = this;
  6466. var normalized = {};
  6467. var restOptionsArray = [options];
  6468. var applyNormalization = function applyNormalization() {
  6469. while (restOptionsArray.length !== 0) {
  6470. var currentOptions = restOptionsArray.shift();
  6471. var transferredOptionsArray = _this._applyNormalization(currentOptions, normalized);
  6472. restOptionsArray.push.apply(restOptionsArray, _toConsumableArray(transferredOptionsArray));
  6473. }
  6474. };
  6475. applyNormalization();
  6476. var _arr = Object.keys(this._utils.schemas);
  6477. for (var _i = 0; _i < _arr.length; _i++) {
  6478. var key = _arr[_i];
  6479. var schema = this._utils.schemas[key];
  6480. if (!(key in normalized)) {
  6481. var defaultResult = utils.normalizeDefaultResult(schema.default(this._utils));
  6482. if ('value' in defaultResult) {
  6483. restOptionsArray.push({
  6484. [key]: defaultResult.value
  6485. });
  6486. }
  6487. }
  6488. }
  6489. applyNormalization();
  6490. var _arr2 = Object.keys(this._utils.schemas);
  6491. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  6492. var _key = _arr2[_i2];
  6493. var _schema = this._utils.schemas[_key];
  6494. if (_key in normalized) {
  6495. normalized[_key] = _schema.postprocess(normalized[_key], this._utils);
  6496. }
  6497. }
  6498. return normalized;
  6499. }
  6500. }, {
  6501. key: "_applyNormalization",
  6502. value: function _applyNormalization(options, normalized) {
  6503. var _this2 = this;
  6504. var transferredOptionsArray = [];
  6505. var _utils_1$partition = utils.partition(Object.keys(options), function (key) {
  6506. return key in _this2._utils.schemas;
  6507. }),
  6508. _utils_1$partition2 = _slicedToArray(_utils_1$partition, 2),
  6509. knownOptionNames = _utils_1$partition2[0],
  6510. unknownOptionNames = _utils_1$partition2[1];
  6511. var _iteratorNormalCompletion = true;
  6512. var _didIteratorError = false;
  6513. var _iteratorError = undefined;
  6514. try {
  6515. var _loop = function _loop() {
  6516. var key = _step.value;
  6517. var schema = _this2._utils.schemas[key];
  6518. var value = schema.preprocess(options[key], _this2._utils);
  6519. var validateResult = utils.normalizeValidateResult(schema.validate(value, _this2._utils), value);
  6520. if (validateResult !== true) {
  6521. var invalidValue = validateResult.value;
  6522. var errorMessageOrError = _this2._invalidHandler(key, invalidValue, _this2._utils);
  6523. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  6524. /* istanbul ignore next*/
  6525. errorMessageOrError;
  6526. }
  6527. var appendTransferredOptions = function appendTransferredOptions(_ref2) {
  6528. var from = _ref2.from,
  6529. to = _ref2.to;
  6530. transferredOptionsArray.push(typeof to === 'string' ? {
  6531. [to]: from
  6532. } : {
  6533. [to.key]: to.value
  6534. });
  6535. };
  6536. var warnDeprecated = function warnDeprecated(_ref3) {
  6537. var currentValue = _ref3.value,
  6538. redirectTo = _ref3.redirectTo;
  6539. var deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, _this2._utils), value,
  6540. /* doNotNormalizeTrue */
  6541. true);
  6542. if (deprecatedResult === false) {
  6543. return;
  6544. }
  6545. if (deprecatedResult === true) {
  6546. if (!_this2._hasDeprecationWarned(key)) {
  6547. _this2._utils.logger.warn(_this2._deprecatedHandler(key, redirectTo, _this2._utils));
  6548. }
  6549. } else {
  6550. var _iteratorNormalCompletion3 = true;
  6551. var _didIteratorError3 = false;
  6552. var _iteratorError3 = undefined;
  6553. try {
  6554. for (var _iterator3 = deprecatedResult[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6555. var deprecatedValue = _step3.value.value;
  6556. var pair = {
  6557. key,
  6558. value: deprecatedValue
  6559. };
  6560. if (!_this2._hasDeprecationWarned(pair)) {
  6561. var redirectToPair = typeof redirectTo === 'string' ? {
  6562. key: redirectTo,
  6563. value: deprecatedValue
  6564. } : redirectTo;
  6565. _this2._utils.logger.warn(_this2._deprecatedHandler(pair, redirectToPair, _this2._utils));
  6566. }
  6567. }
  6568. } catch (err) {
  6569. _didIteratorError3 = true;
  6570. _iteratorError3 = err;
  6571. } finally {
  6572. try {
  6573. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6574. _iterator3.return();
  6575. }
  6576. } finally {
  6577. if (_didIteratorError3) {
  6578. throw _iteratorError3;
  6579. }
  6580. }
  6581. }
  6582. }
  6583. };
  6584. var forwardResult = utils.normalizeForwardResult(schema.forward(value, _this2._utils), value);
  6585. forwardResult.forEach(appendTransferredOptions);
  6586. var redirectResult = utils.normalizeRedirectResult(schema.redirect(value, _this2._utils), value);
  6587. redirectResult.redirect.forEach(appendTransferredOptions);
  6588. if ('remain' in redirectResult) {
  6589. var remainingValue = redirectResult.remain;
  6590. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, _this2._utils) : remainingValue;
  6591. warnDeprecated({
  6592. value: remainingValue
  6593. });
  6594. }
  6595. var _iteratorNormalCompletion4 = true;
  6596. var _didIteratorError4 = false;
  6597. var _iteratorError4 = undefined;
  6598. try {
  6599. for (var _iterator4 = redirectResult.redirect[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  6600. var _step4$value = _step4.value,
  6601. from = _step4$value.from,
  6602. to = _step4$value.to;
  6603. warnDeprecated({
  6604. value: from,
  6605. redirectTo: to
  6606. });
  6607. }
  6608. } catch (err) {
  6609. _didIteratorError4 = true;
  6610. _iteratorError4 = err;
  6611. } finally {
  6612. try {
  6613. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  6614. _iterator4.return();
  6615. }
  6616. } finally {
  6617. if (_didIteratorError4) {
  6618. throw _iteratorError4;
  6619. }
  6620. }
  6621. }
  6622. };
  6623. for (var _iterator = knownOptionNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6624. _loop();
  6625. }
  6626. } catch (err) {
  6627. _didIteratorError = true;
  6628. _iteratorError = err;
  6629. } finally {
  6630. try {
  6631. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6632. _iterator.return();
  6633. }
  6634. } finally {
  6635. if (_didIteratorError) {
  6636. throw _iteratorError;
  6637. }
  6638. }
  6639. }
  6640. var _iteratorNormalCompletion2 = true;
  6641. var _didIteratorError2 = false;
  6642. var _iteratorError2 = undefined;
  6643. try {
  6644. for (var _iterator2 = unknownOptionNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6645. var key = _step2.value;
  6646. var value = options[key];
  6647. var unknownResult = this._unknownHandler(key, value, this._utils);
  6648. if (unknownResult) {
  6649. var _arr3 = Object.keys(unknownResult);
  6650. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  6651. var unknownKey = _arr3[_i3];
  6652. var unknownOption = {
  6653. [unknownKey]: unknownResult[unknownKey]
  6654. };
  6655. if (unknownKey in this._utils.schemas) {
  6656. transferredOptionsArray.push(unknownOption);
  6657. } else {
  6658. Object.assign(normalized, unknownOption);
  6659. }
  6660. }
  6661. }
  6662. }
  6663. } catch (err) {
  6664. _didIteratorError2 = true;
  6665. _iteratorError2 = err;
  6666. } finally {
  6667. try {
  6668. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6669. _iterator2.return();
  6670. }
  6671. } finally {
  6672. if (_didIteratorError2) {
  6673. throw _iteratorError2;
  6674. }
  6675. }
  6676. }
  6677. return transferredOptionsArray;
  6678. }
  6679. }]);
  6680. return Normalizer;
  6681. }();
  6682. exports.Normalizer = Normalizer;
  6683. });
  6684. unwrapExports(normalize$1);
  6685. var lib$1 = createCommonjsModule(function (module, exports) {
  6686. "use strict";
  6687. Object.defineProperty(exports, "__esModule", {
  6688. value: true
  6689. });
  6690. tslib_1.__exportStar(descriptors, exports);
  6691. tslib_1.__exportStar(handlers, exports);
  6692. tslib_1.__exportStar(schemas, exports);
  6693. tslib_1.__exportStar(normalize$1, exports);
  6694. tslib_1.__exportStar(schema, exports);
  6695. });
  6696. unwrapExports(lib$1);
  6697. var hasFlag$3 = function hasFlag(flag, argv) {
  6698. argv = argv || process.argv;
  6699. var terminatorPos = argv.indexOf('--');
  6700. var prefix = /^-{1,2}/.test(flag) ? '' : '--';
  6701. var pos = argv.indexOf(prefix + flag);
  6702. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6703. };
  6704. var supportsColor$1 = createCommonjsModule(function (module) {
  6705. 'use strict';
  6706. var env = process.env;
  6707. var support = function support(level) {
  6708. if (level === 0) {
  6709. return false;
  6710. }
  6711. return {
  6712. level,
  6713. hasBasic: true,
  6714. has256: level >= 2,
  6715. has16m: level >= 3
  6716. };
  6717. };
  6718. var supportLevel = function () {
  6719. if (hasFlag$3('no-color') || hasFlag$3('no-colors') || hasFlag$3('color=false')) {
  6720. return 0;
  6721. }
  6722. if (hasFlag$3('color=16m') || hasFlag$3('color=full') || hasFlag$3('color=truecolor')) {
  6723. return 3;
  6724. }
  6725. if (hasFlag$3('color=256')) {
  6726. return 2;
  6727. }
  6728. if (hasFlag$3('color') || hasFlag$3('colors') || hasFlag$3('color=true') || hasFlag$3('color=always')) {
  6729. return 1;
  6730. }
  6731. if (process.stdout && !process.stdout.isTTY) {
  6732. return 0;
  6733. }
  6734. if (process.platform === 'win32') {
  6735. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6736. // libuv that enables 256 color output on Windows. Anything earlier and it
  6737. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6738. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6739. // release that supports 256 colors.
  6740. var osRelease = os.release().split('.');
  6741. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6742. return 2;
  6743. }
  6744. return 1;
  6745. }
  6746. if ('CI' in env) {
  6747. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  6748. return sign in env;
  6749. }) || env.CI_NAME === 'codeship') {
  6750. return 1;
  6751. }
  6752. return 0;
  6753. }
  6754. if ('TEAMCITY_VERSION' in env) {
  6755. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  6756. }
  6757. if ('TERM_PROGRAM' in env) {
  6758. var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6759. switch (env.TERM_PROGRAM) {
  6760. case 'iTerm.app':
  6761. return version >= 3 ? 3 : 2;
  6762. case 'Hyper':
  6763. return 3;
  6764. case 'Apple_Terminal':
  6765. return 2;
  6766. // No default
  6767. }
  6768. }
  6769. if (/-256(color)?$/i.test(env.TERM)) {
  6770. return 2;
  6771. }
  6772. if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  6773. return 1;
  6774. }
  6775. if ('COLORTERM' in env) {
  6776. return 1;
  6777. }
  6778. if (env.TERM === 'dumb') {
  6779. return 0;
  6780. }
  6781. return 0;
  6782. }();
  6783. if ('FORCE_COLOR' in env) {
  6784. supportLevel = parseInt(env.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
  6785. }
  6786. module.exports = process && support(supportLevel);
  6787. });
  6788. var templates$2 = createCommonjsModule(function (module) {
  6789. 'use strict';
  6790. var TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  6791. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  6792. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  6793. var ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi;
  6794. var ESCAPES = {
  6795. n: '\n',
  6796. r: '\r',
  6797. t: '\t',
  6798. b: '\b',
  6799. f: '\f',
  6800. v: '\v',
  6801. 0: '\0',
  6802. '\\': '\\',
  6803. e: '\u001b',
  6804. a: '\u0007'
  6805. };
  6806. function unescape(c) {
  6807. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  6808. return String.fromCharCode(parseInt(c.slice(1), 16));
  6809. }
  6810. return ESCAPES[c] || c;
  6811. }
  6812. function parseArguments(name, args) {
  6813. var results = [];
  6814. var chunks = args.trim().split(/\s*,\s*/g);
  6815. var matches;
  6816. var _iteratorNormalCompletion = true;
  6817. var _didIteratorError = false;
  6818. var _iteratorError = undefined;
  6819. try {
  6820. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6821. var chunk = _step.value;
  6822. if (!isNaN(chunk)) {
  6823. results.push(Number(chunk));
  6824. } else if (matches = chunk.match(STRING_REGEX)) {
  6825. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  6826. return escape ? unescape(escape) : chr;
  6827. }));
  6828. } else {
  6829. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  6830. }
  6831. }
  6832. } catch (err) {
  6833. _didIteratorError = true;
  6834. _iteratorError = err;
  6835. } finally {
  6836. try {
  6837. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6838. _iterator.return();
  6839. }
  6840. } finally {
  6841. if (_didIteratorError) {
  6842. throw _iteratorError;
  6843. }
  6844. }
  6845. }
  6846. return results;
  6847. }
  6848. function parseStyle(style) {
  6849. STYLE_REGEX.lastIndex = 0;
  6850. var results = [];
  6851. var matches;
  6852. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  6853. var name = matches[1];
  6854. if (matches[2]) {
  6855. var args = parseArguments(name, matches[2]);
  6856. results.push([name].concat(args));
  6857. } else {
  6858. results.push([name]);
  6859. }
  6860. }
  6861. return results;
  6862. }
  6863. function buildStyle(chalk, styles) {
  6864. var enabled = {};
  6865. var _iteratorNormalCompletion2 = true;
  6866. var _didIteratorError2 = false;
  6867. var _iteratorError2 = undefined;
  6868. try {
  6869. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6870. var layer = _step2.value;
  6871. var _iteratorNormalCompletion3 = true;
  6872. var _didIteratorError3 = false;
  6873. var _iteratorError3 = undefined;
  6874. try {
  6875. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6876. var style = _step3.value;
  6877. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  6878. }
  6879. } catch (err) {
  6880. _didIteratorError3 = true;
  6881. _iteratorError3 = err;
  6882. } finally {
  6883. try {
  6884. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6885. _iterator3.return();
  6886. }
  6887. } finally {
  6888. if (_didIteratorError3) {
  6889. throw _iteratorError3;
  6890. }
  6891. }
  6892. }
  6893. }
  6894. } catch (err) {
  6895. _didIteratorError2 = true;
  6896. _iteratorError2 = err;
  6897. } finally {
  6898. try {
  6899. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6900. _iterator2.return();
  6901. }
  6902. } finally {
  6903. if (_didIteratorError2) {
  6904. throw _iteratorError2;
  6905. }
  6906. }
  6907. }
  6908. var current = chalk;
  6909. var _arr = Object.keys(enabled);
  6910. for (var _i = 0; _i < _arr.length; _i++) {
  6911. var styleName = _arr[_i];
  6912. if (Array.isArray(enabled[styleName])) {
  6913. if (!(styleName in current)) {
  6914. throw new Error(`Unknown Chalk style: ${styleName}`);
  6915. }
  6916. if (enabled[styleName].length > 0) {
  6917. current = current[styleName].apply(current, enabled[styleName]);
  6918. } else {
  6919. current = current[styleName];
  6920. }
  6921. }
  6922. }
  6923. return current;
  6924. }
  6925. module.exports = function (chalk, tmp) {
  6926. var styles = [];
  6927. var chunks = [];
  6928. var chunk = []; // eslint-disable-next-line max-params
  6929. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  6930. if (escapeChar) {
  6931. chunk.push(unescape(escapeChar));
  6932. } else if (style) {
  6933. var str = chunk.join('');
  6934. chunk = [];
  6935. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  6936. styles.push({
  6937. inverse,
  6938. styles: parseStyle(style)
  6939. });
  6940. } else if (close) {
  6941. if (styles.length === 0) {
  6942. throw new Error('Found extraneous } in Chalk template literal');
  6943. }
  6944. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  6945. chunk = [];
  6946. styles.pop();
  6947. } else {
  6948. chunk.push(chr);
  6949. }
  6950. });
  6951. chunks.push(chunk.join(''));
  6952. if (styles.length > 0) {
  6953. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  6954. throw new Error(errMsg);
  6955. }
  6956. return chunks.join('');
  6957. };
  6958. });
  6959. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  6960. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  6961. var skipModels = new Set(['gray']);
  6962. var styles = Object.create(null);
  6963. function applyOptions(obj, options) {
  6964. options = options || {}; // Detect level if not set manually
  6965. var scLevel = supportsColor$1 ? supportsColor$1.level : 0;
  6966. obj.level = options.level === undefined ? scLevel : options.level;
  6967. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  6968. }
  6969. function Chalk(options) {
  6970. // We check for this.template here since calling `chalk.constructor()`
  6971. // by itself will have a `this` of a previously constructed chalk object
  6972. if (!this || !(this instanceof Chalk) || this.template) {
  6973. var _chalk = {};
  6974. applyOptions(_chalk, options);
  6975. _chalk.template = function () {
  6976. var args = [].slice.call(arguments);
  6977. return chalkTag.apply(null, [_chalk.template].concat(args));
  6978. };
  6979. Object.setPrototypeOf(_chalk, Chalk.prototype);
  6980. Object.setPrototypeOf(_chalk.template, _chalk);
  6981. _chalk.template.constructor = Chalk;
  6982. return _chalk.template;
  6983. }
  6984. applyOptions(this, options);
  6985. } // Use bright blue on Windows as the normal blue color is illegible
  6986. if (isSimpleWindowsTerm) {
  6987. ansiStyles.blue.open = '\u001B[94m';
  6988. }
  6989. var _arr = Object.keys(ansiStyles);
  6990. var _loop = function _loop() {
  6991. var key = _arr[_i];
  6992. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  6993. styles[key] = {
  6994. get() {
  6995. var codes = ansiStyles[key];
  6996. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
  6997. }
  6998. };
  6999. };
  7000. for (var _i = 0; _i < _arr.length; _i++) {
  7001. _loop();
  7002. }
  7003. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  7004. var _arr2 = Object.keys(ansiStyles.color.ansi);
  7005. var _loop2 = function _loop2() {
  7006. var model = _arr2[_i2];
  7007. if (skipModels.has(model)) {
  7008. return "continue";
  7009. }
  7010. styles[model] = {
  7011. get() {
  7012. var level = this.level;
  7013. return function () {
  7014. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7015. var codes = {
  7016. open,
  7017. close: ansiStyles.color.close,
  7018. closeRe: ansiStyles.color.closeRe
  7019. };
  7020. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  7021. };
  7022. }
  7023. };
  7024. };
  7025. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  7026. var _ret = _loop2();
  7027. if (_ret === "continue") continue;
  7028. }
  7029. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7030. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  7031. var _loop3 = function _loop3() {
  7032. var model = _arr3[_i3];
  7033. if (skipModels.has(model)) {
  7034. return "continue";
  7035. }
  7036. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7037. styles[bgModel] = {
  7038. get() {
  7039. var level = this.level;
  7040. return function () {
  7041. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7042. var codes = {
  7043. open,
  7044. close: ansiStyles.bgColor.close,
  7045. closeRe: ansiStyles.bgColor.closeRe
  7046. };
  7047. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  7048. };
  7049. }
  7050. };
  7051. };
  7052. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  7053. var _ret2 = _loop3();
  7054. if (_ret2 === "continue") continue;
  7055. }
  7056. var proto = Object.defineProperties(function () {}, styles);
  7057. function build(_styles, key) {
  7058. var builder = function builder() {
  7059. return applyStyle.apply(builder, arguments);
  7060. };
  7061. builder._styles = _styles;
  7062. var self = this;
  7063. Object.defineProperty(builder, 'level', {
  7064. enumerable: true,
  7065. get() {
  7066. return self.level;
  7067. },
  7068. set(level) {
  7069. self.level = level;
  7070. }
  7071. });
  7072. Object.defineProperty(builder, 'enabled', {
  7073. enumerable: true,
  7074. get() {
  7075. return self.enabled;
  7076. },
  7077. set(enabled) {
  7078. self.enabled = enabled;
  7079. }
  7080. }); // See below for fix regarding invisible grey/dim combination on Windows
  7081. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  7082. // no way to create a function with a different prototype
  7083. builder.__proto__ = proto; // eslint-disable-line no-proto
  7084. return builder;
  7085. }
  7086. function applyStyle() {
  7087. // Support varags, but simply cast to string in case there's only one arg
  7088. var args = arguments;
  7089. var argsLen = args.length;
  7090. var str = String(arguments[0]);
  7091. if (argsLen === 0) {
  7092. return '';
  7093. }
  7094. if (argsLen > 1) {
  7095. // Don't slice `arguments`, it prevents V8 optimizations
  7096. for (var a = 1; a < argsLen; a++) {
  7097. str += ' ' + args[a];
  7098. }
  7099. }
  7100. if (!this.enabled || this.level <= 0 || !str) {
  7101. return str;
  7102. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  7103. // see https://github.com/chalk/chalk/issues/58
  7104. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  7105. var originalDim = ansiStyles.dim.open;
  7106. if (isSimpleWindowsTerm && this.hasGrey) {
  7107. ansiStyles.dim.open = '';
  7108. }
  7109. var _iteratorNormalCompletion = true;
  7110. var _didIteratorError = false;
  7111. var _iteratorError = undefined;
  7112. try {
  7113. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7114. var code = _step.value;
  7115. // Replace any instances already present with a re-opening code
  7116. // otherwise only the part of the string until said closing code
  7117. // will be colored, and the rest will simply be 'plain'.
  7118. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  7119. // after next line to fix a bleed issue on macOS
  7120. // https://github.com/chalk/chalk/pull/92
  7121. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  7122. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  7123. } catch (err) {
  7124. _didIteratorError = true;
  7125. _iteratorError = err;
  7126. } finally {
  7127. try {
  7128. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7129. _iterator.return();
  7130. }
  7131. } finally {
  7132. if (_didIteratorError) {
  7133. throw _iteratorError;
  7134. }
  7135. }
  7136. }
  7137. ansiStyles.dim.open = originalDim;
  7138. return str;
  7139. }
  7140. function chalkTag(chalk, strings) {
  7141. if (!Array.isArray(strings)) {
  7142. // If chalk() was called by itself or with a string,
  7143. // return the string itself as a string.
  7144. return [].slice.call(arguments, 1).join(' ');
  7145. }
  7146. var args = [].slice.call(arguments, 2);
  7147. var parts = [strings.raw[0]];
  7148. for (var i = 1; i < strings.length; i++) {
  7149. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7150. parts.push(String(strings.raw[i]));
  7151. }
  7152. return templates$2(chalk, parts.join(''));
  7153. }
  7154. Object.defineProperties(Chalk.prototype, styles);
  7155. var chalk$2 = Chalk(); // eslint-disable-line new-cap
  7156. var supportsColor_1$2 = supportsColor$1;
  7157. chalk$2.supportsColor = supportsColor_1$2;
  7158. var cliDescriptor = {
  7159. key: function key(_key) {
  7160. return _key.length === 1 ? `-${_key}` : `--${_key}`;
  7161. },
  7162. value: function value(_value) {
  7163. return lib$1.apiDescriptor.value(_value);
  7164. },
  7165. pair: function pair(_ref) {
  7166. var key = _ref.key,
  7167. value = _ref.value;
  7168. return value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`;
  7169. }
  7170. };
  7171. var FlagSchema =
  7172. /*#__PURE__*/
  7173. function (_vnopts$ChoiceSchema) {
  7174. _inherits(FlagSchema, _vnopts$ChoiceSchema);
  7175. function FlagSchema(_ref2) {
  7176. var _this;
  7177. var name = _ref2.name,
  7178. flags = _ref2.flags;
  7179. _classCallCheck(this, FlagSchema);
  7180. _this = _possibleConstructorReturn(this, _getPrototypeOf(FlagSchema).call(this, {
  7181. name,
  7182. choices: flags
  7183. }));
  7184. _this._flags = flags.slice().sort();
  7185. return _this;
  7186. }
  7187. _createClass(FlagSchema, [{
  7188. key: "preprocess",
  7189. value: function preprocess(value, utils) {
  7190. if (typeof value === "string" && value.length !== 0 && this._flags.indexOf(value) === -1) {
  7191. var suggestion = this._flags.find(function (flag) {
  7192. return leven$1(flag, value) < 3;
  7193. });
  7194. if (suggestion) {
  7195. utils.logger.warn([`Unknown flag ${chalk$2.yellow(utils.descriptor.value(value))},`, `did you mean ${chalk$2.blue(utils.descriptor.value(suggestion))}?`].join(" "));
  7196. return suggestion;
  7197. }
  7198. }
  7199. return value;
  7200. }
  7201. }, {
  7202. key: "expected",
  7203. value: function expected() {
  7204. return "a flag";
  7205. }
  7206. }]);
  7207. return FlagSchema;
  7208. }(lib$1.ChoiceSchema);
  7209. var hasDeprecationWarned;
  7210. function normalizeOptions$1(options, optionInfos) {
  7211. var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  7212. logger = _ref3.logger,
  7213. _ref3$isCLI = _ref3.isCLI,
  7214. isCLI = _ref3$isCLI === void 0 ? false : _ref3$isCLI,
  7215. _ref3$passThrough = _ref3.passThrough,
  7216. passThrough = _ref3$passThrough === void 0 ? false : _ref3$passThrough;
  7217. var unknown = !passThrough ? lib$1.levenUnknownHandler : Array.isArray(passThrough) ? function (key, value) {
  7218. return passThrough.indexOf(key) === -1 ? undefined : {
  7219. [key]: value
  7220. };
  7221. } : function (key, value) {
  7222. return {
  7223. [key]: value
  7224. };
  7225. };
  7226. var descriptor = isCLI ? cliDescriptor : lib$1.apiDescriptor;
  7227. var schemas = optionInfosToSchemas(optionInfos, {
  7228. isCLI
  7229. });
  7230. var normalizer = new lib$1.Normalizer(schemas, {
  7231. logger,
  7232. unknown,
  7233. descriptor
  7234. });
  7235. var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  7236. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  7237. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  7238. }
  7239. var normalized = normalizer.normalize(options);
  7240. if (shouldSuppressDuplicateDeprecationWarnings) {
  7241. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  7242. }
  7243. return normalized;
  7244. }
  7245. function optionInfosToSchemas(optionInfos, _ref4) {
  7246. var isCLI = _ref4.isCLI;
  7247. var schemas = [];
  7248. if (isCLI) {
  7249. schemas.push(lib$1.AnySchema.create({
  7250. name: "_"
  7251. }));
  7252. }
  7253. var _iteratorNormalCompletion = true;
  7254. var _didIteratorError = false;
  7255. var _iteratorError = undefined;
  7256. try {
  7257. for (var _iterator = optionInfos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7258. var optionInfo = _step.value;
  7259. schemas.push(optionInfoToSchema(optionInfo, {
  7260. isCLI,
  7261. optionInfos
  7262. }));
  7263. if (optionInfo.alias && isCLI) {
  7264. schemas.push(lib$1.AliasSchema.create({
  7265. name: optionInfo.alias,
  7266. sourceName: optionInfo.name
  7267. }));
  7268. }
  7269. }
  7270. } catch (err) {
  7271. _didIteratorError = true;
  7272. _iteratorError = err;
  7273. } finally {
  7274. try {
  7275. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7276. _iterator.return();
  7277. }
  7278. } finally {
  7279. if (_didIteratorError) {
  7280. throw _iteratorError;
  7281. }
  7282. }
  7283. }
  7284. return schemas;
  7285. }
  7286. function optionInfoToSchema(optionInfo, _ref5) {
  7287. var isCLI = _ref5.isCLI,
  7288. optionInfos = _ref5.optionInfos;
  7289. var SchemaConstructor;
  7290. var parameters = {
  7291. name: optionInfo.name
  7292. };
  7293. var handlers = {};
  7294. switch (optionInfo.type) {
  7295. case "int":
  7296. SchemaConstructor = lib$1.IntegerSchema;
  7297. if (isCLI) {
  7298. parameters.preprocess = function (value) {
  7299. return Number(value);
  7300. };
  7301. }
  7302. break;
  7303. case "choice":
  7304. SchemaConstructor = lib$1.ChoiceSchema;
  7305. parameters.choices = optionInfo.choices.map(function (choiceInfo) {
  7306. return typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, {
  7307. redirect: {
  7308. to: {
  7309. key: optionInfo.name,
  7310. value: choiceInfo.redirect
  7311. }
  7312. }
  7313. }) : choiceInfo;
  7314. });
  7315. break;
  7316. case "boolean":
  7317. SchemaConstructor = lib$1.BooleanSchema;
  7318. break;
  7319. case "flag":
  7320. SchemaConstructor = FlagSchema;
  7321. parameters.flags = optionInfos.map(function (optionInfo) {
  7322. return [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? `no-${optionInfo.name}` : []);
  7323. }).reduce(function (a, b) {
  7324. return a.concat(b);
  7325. }, []);
  7326. break;
  7327. case "path":
  7328. SchemaConstructor = lib$1.StringSchema;
  7329. break;
  7330. default:
  7331. throw new Error(`Unexpected type ${optionInfo.type}`);
  7332. }
  7333. if (optionInfo.exception) {
  7334. parameters.validate = function (value, schema, utils) {
  7335. return optionInfo.exception(value) || schema.validate(value, utils);
  7336. };
  7337. } else {
  7338. parameters.validate = function (value, schema, utils) {
  7339. return value === undefined || schema.validate(value, utils);
  7340. };
  7341. }
  7342. if (optionInfo.redirect) {
  7343. handlers.redirect = function (value) {
  7344. return !value ? undefined : {
  7345. to: {
  7346. key: optionInfo.redirect.option,
  7347. value: optionInfo.redirect.value
  7348. }
  7349. };
  7350. };
  7351. }
  7352. if (optionInfo.deprecated) {
  7353. handlers.deprecated = true;
  7354. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  7355. if (isCLI && !optionInfo.array) {
  7356. var originalPreprocess = parameters.preprocess || function (x) {
  7357. return x;
  7358. };
  7359. parameters.preprocess = function (value, schema, utils) {
  7360. return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
  7361. };
  7362. }
  7363. return optionInfo.array ? lib$1.ArraySchema.create(Object.assign(isCLI ? {
  7364. preprocess: function preprocess(v) {
  7365. return [].concat(v);
  7366. }
  7367. } : {}, handlers, {
  7368. valueSchema: SchemaConstructor.create(parameters)
  7369. })) : SchemaConstructor.create(Object.assign({}, parameters, handlers));
  7370. }
  7371. function normalizeApiOptions(options, optionInfos, opts) {
  7372. return normalizeOptions$1(options, optionInfos, opts);
  7373. }
  7374. function normalizeCliOptions(options, optionInfos, opts) {
  7375. return normalizeOptions$1(options, optionInfos, Object.assign({
  7376. isCLI: true
  7377. }, opts));
  7378. }
  7379. var optionsNormalizer = {
  7380. normalizeApiOptions,
  7381. normalizeCliOptions
  7382. };
  7383. var getLast = function getLast(arr) {
  7384. return arr.length > 0 ? arr[arr.length - 1] : null;
  7385. };
  7386. function locStart$1(node, opts) {
  7387. opts = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  7388. if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
  7389. return locStart$1(node.declaration.decorators[0]);
  7390. }
  7391. if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) {
  7392. return locStart$1(node.decorators[0]);
  7393. }
  7394. if (node.__location) {
  7395. return node.__location.startOffset;
  7396. }
  7397. if (node.range) {
  7398. return node.range[0];
  7399. }
  7400. if (typeof node.start === "number") {
  7401. return node.start;
  7402. }
  7403. if (node.loc) {
  7404. return node.loc.start;
  7405. }
  7406. return null;
  7407. }
  7408. function locEnd$1(node) {
  7409. var endNode = node.nodes && getLast(node.nodes);
  7410. if (endNode && node.source && !node.source.end) {
  7411. node = endNode;
  7412. }
  7413. if (node.__location) {
  7414. return node.__location.endOffset;
  7415. }
  7416. var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
  7417. if (node.typeAnnotation) {
  7418. return Math.max(loc, locEnd$1(node.typeAnnotation));
  7419. }
  7420. if (node.loc && !loc) {
  7421. return node.loc.end;
  7422. }
  7423. return loc;
  7424. }
  7425. var loc = {
  7426. locStart: locStart$1,
  7427. locEnd: locEnd$1
  7428. };
  7429. var jsTokens = createCommonjsModule(function (module, exports) {
  7430. // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
  7431. // License: MIT. (See LICENSE.)
  7432. Object.defineProperty(exports, "__esModule", {
  7433. value: true
  7434. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  7435. // (run `npm run build`).
  7436. exports.default = /((['"])(?:(?!\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;
  7437. exports.matchToToken = function (match) {
  7438. var token = {
  7439. type: "invalid",
  7440. value: match[0],
  7441. closed: undefined
  7442. };
  7443. 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";
  7444. return token;
  7445. };
  7446. });
  7447. unwrapExports(jsTokens);
  7448. var ast = createCommonjsModule(function (module) {
  7449. /*
  7450. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7451. Redistribution and use in source and binary forms, with or without
  7452. modification, are permitted provided that the following conditions are met:
  7453. * Redistributions of source code must retain the above copyright
  7454. notice, this list of conditions and the following disclaimer.
  7455. * Redistributions in binary form must reproduce the above copyright
  7456. notice, this list of conditions and the following disclaimer in the
  7457. documentation and/or other materials provided with the distribution.
  7458. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  7459. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7460. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7461. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7462. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7463. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7464. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7465. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7466. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7467. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7468. */
  7469. (function () {
  7470. 'use strict';
  7471. function isExpression(node) {
  7472. if (node == null) {
  7473. return false;
  7474. }
  7475. switch (node.type) {
  7476. case 'ArrayExpression':
  7477. case 'AssignmentExpression':
  7478. case 'BinaryExpression':
  7479. case 'CallExpression':
  7480. case 'ConditionalExpression':
  7481. case 'FunctionExpression':
  7482. case 'Identifier':
  7483. case 'Literal':
  7484. case 'LogicalExpression':
  7485. case 'MemberExpression':
  7486. case 'NewExpression':
  7487. case 'ObjectExpression':
  7488. case 'SequenceExpression':
  7489. case 'ThisExpression':
  7490. case 'UnaryExpression':
  7491. case 'UpdateExpression':
  7492. return true;
  7493. }
  7494. return false;
  7495. }
  7496. function isIterationStatement(node) {
  7497. if (node == null) {
  7498. return false;
  7499. }
  7500. switch (node.type) {
  7501. case 'DoWhileStatement':
  7502. case 'ForInStatement':
  7503. case 'ForStatement':
  7504. case 'WhileStatement':
  7505. return true;
  7506. }
  7507. return false;
  7508. }
  7509. function isStatement(node) {
  7510. if (node == null) {
  7511. return false;
  7512. }
  7513. switch (node.type) {
  7514. case 'BlockStatement':
  7515. case 'BreakStatement':
  7516. case 'ContinueStatement':
  7517. case 'DebuggerStatement':
  7518. case 'DoWhileStatement':
  7519. case 'EmptyStatement':
  7520. case 'ExpressionStatement':
  7521. case 'ForInStatement':
  7522. case 'ForStatement':
  7523. case 'IfStatement':
  7524. case 'LabeledStatement':
  7525. case 'ReturnStatement':
  7526. case 'SwitchStatement':
  7527. case 'ThrowStatement':
  7528. case 'TryStatement':
  7529. case 'VariableDeclaration':
  7530. case 'WhileStatement':
  7531. case 'WithStatement':
  7532. return true;
  7533. }
  7534. return false;
  7535. }
  7536. function isSourceElement(node) {
  7537. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  7538. }
  7539. function trailingStatement(node) {
  7540. switch (node.type) {
  7541. case 'IfStatement':
  7542. if (node.alternate != null) {
  7543. return node.alternate;
  7544. }
  7545. return node.consequent;
  7546. case 'LabeledStatement':
  7547. case 'ForStatement':
  7548. case 'ForInStatement':
  7549. case 'WhileStatement':
  7550. case 'WithStatement':
  7551. return node.body;
  7552. }
  7553. return null;
  7554. }
  7555. function isProblematicIfStatement(node) {
  7556. var current;
  7557. if (node.type !== 'IfStatement') {
  7558. return false;
  7559. }
  7560. if (node.alternate == null) {
  7561. return false;
  7562. }
  7563. current = node.consequent;
  7564. do {
  7565. if (current.type === 'IfStatement') {
  7566. if (current.alternate == null) {
  7567. return true;
  7568. }
  7569. }
  7570. current = trailingStatement(current);
  7571. } while (current);
  7572. return false;
  7573. }
  7574. module.exports = {
  7575. isExpression: isExpression,
  7576. isStatement: isStatement,
  7577. isIterationStatement: isIterationStatement,
  7578. isSourceElement: isSourceElement,
  7579. isProblematicIfStatement: isProblematicIfStatement,
  7580. trailingStatement: trailingStatement
  7581. };
  7582. })();
  7583. /* vim: set sw=4 ts=4 et tw=80 : */
  7584. });
  7585. var code = createCommonjsModule(function (module) {
  7586. /*
  7587. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  7588. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  7589. Redistribution and use in source and binary forms, with or without
  7590. modification, are permitted provided that the following conditions are met:
  7591. * Redistributions of source code must retain the above copyright
  7592. notice, this list of conditions and the following disclaimer.
  7593. * Redistributions in binary form must reproduce the above copyright
  7594. notice, this list of conditions and the following disclaimer in the
  7595. documentation and/or other materials provided with the distribution.
  7596. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7597. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7598. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7599. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7600. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7601. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7602. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7603. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7604. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7605. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7606. */
  7607. (function () {
  7608. 'use strict';
  7609. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  7610. ES5Regex = {
  7611. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  7612. 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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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]/,
  7613. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  7614. 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-\u08B2\u08E4-\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\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\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\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\u0D57\u0D60-\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-\u13F4\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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-\uFE2D\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]/
  7615. };
  7616. ES6Regex = {
  7617. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  7618. 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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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\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\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]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\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]|\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]|\uD87E[\uDC00-\uDE1D]/,
  7619. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  7620. 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-\u08B2\u08E4-\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\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\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\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\u0D57\u0D60-\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-\u13F4\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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-\uFE2D\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\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\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]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\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]|\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]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\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]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  7621. };
  7622. function isDecimalDigit(ch) {
  7623. return 0x30 <= ch && ch <= 0x39; // 0..9
  7624. }
  7625. function isHexDigit(ch) {
  7626. return 0x30 <= ch && ch <= 0x39 || // 0..9
  7627. 0x61 <= ch && ch <= 0x66 || // a..f
  7628. 0x41 <= ch && ch <= 0x46; // A..F
  7629. }
  7630. function isOctalDigit(ch) {
  7631. return ch >= 0x30 && ch <= 0x37; // 0..7
  7632. } // 7.2 White Space
  7633. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  7634. function isWhiteSpace(ch) {
  7635. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  7636. } // 7.3 Line Terminators
  7637. function isLineTerminator(ch) {
  7638. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  7639. } // 7.6 Identifier Names and Identifiers
  7640. function fromCodePoint(cp) {
  7641. if (cp <= 0xFFFF) {
  7642. return String.fromCharCode(cp);
  7643. }
  7644. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  7645. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  7646. return cu1 + cu2;
  7647. }
  7648. IDENTIFIER_START = new Array(0x80);
  7649. for (ch = 0; ch < 0x80; ++ch) {
  7650. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  7651. ch >= 0x41 && ch <= 0x5A || // A..Z
  7652. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  7653. }
  7654. IDENTIFIER_PART = new Array(0x80);
  7655. for (ch = 0; ch < 0x80; ++ch) {
  7656. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  7657. ch >= 0x41 && ch <= 0x5A || // A..Z
  7658. ch >= 0x30 && ch <= 0x39 || // 0..9
  7659. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  7660. }
  7661. function isIdentifierStartES5(ch) {
  7662. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  7663. }
  7664. function isIdentifierPartES5(ch) {
  7665. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  7666. }
  7667. function isIdentifierStartES6(ch) {
  7668. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  7669. }
  7670. function isIdentifierPartES6(ch) {
  7671. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  7672. }
  7673. module.exports = {
  7674. isDecimalDigit: isDecimalDigit,
  7675. isHexDigit: isHexDigit,
  7676. isOctalDigit: isOctalDigit,
  7677. isWhiteSpace: isWhiteSpace,
  7678. isLineTerminator: isLineTerminator,
  7679. isIdentifierStartES5: isIdentifierStartES5,
  7680. isIdentifierPartES5: isIdentifierPartES5,
  7681. isIdentifierStartES6: isIdentifierStartES6,
  7682. isIdentifierPartES6: isIdentifierPartES6
  7683. };
  7684. })();
  7685. /* vim: set sw=4 ts=4 et tw=80 : */
  7686. });
  7687. var keyword = createCommonjsModule(function (module) {
  7688. /*
  7689. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7690. Redistribution and use in source and binary forms, with or without
  7691. modification, are permitted provided that the following conditions are met:
  7692. * Redistributions of source code must retain the above copyright
  7693. notice, this list of conditions and the following disclaimer.
  7694. * Redistributions in binary form must reproduce the above copyright
  7695. notice, this list of conditions and the following disclaimer in the
  7696. documentation and/or other materials provided with the distribution.
  7697. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7698. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7699. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7700. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7701. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7702. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7703. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7704. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7705. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7706. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7707. */
  7708. (function () {
  7709. 'use strict';
  7710. var code$$1 = code;
  7711. function isStrictModeReservedWordES6(id) {
  7712. switch (id) {
  7713. case 'implements':
  7714. case 'interface':
  7715. case 'package':
  7716. case 'private':
  7717. case 'protected':
  7718. case 'public':
  7719. case 'static':
  7720. case 'let':
  7721. return true;
  7722. default:
  7723. return false;
  7724. }
  7725. }
  7726. function isKeywordES5(id, strict) {
  7727. // yield should not be treated as keyword under non-strict mode.
  7728. if (!strict && id === 'yield') {
  7729. return false;
  7730. }
  7731. return isKeywordES6(id, strict);
  7732. }
  7733. function isKeywordES6(id, strict) {
  7734. if (strict && isStrictModeReservedWordES6(id)) {
  7735. return true;
  7736. }
  7737. switch (id.length) {
  7738. case 2:
  7739. return id === 'if' || id === 'in' || id === 'do';
  7740. case 3:
  7741. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  7742. case 4:
  7743. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  7744. case 5:
  7745. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  7746. case 6:
  7747. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  7748. case 7:
  7749. return id === 'default' || id === 'finally' || id === 'extends';
  7750. case 8:
  7751. return id === 'function' || id === 'continue' || id === 'debugger';
  7752. case 10:
  7753. return id === 'instanceof';
  7754. default:
  7755. return false;
  7756. }
  7757. }
  7758. function isReservedWordES5(id, strict) {
  7759. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  7760. }
  7761. function isReservedWordES6(id, strict) {
  7762. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  7763. }
  7764. function isRestrictedWord(id) {
  7765. return id === 'eval' || id === 'arguments';
  7766. }
  7767. function isIdentifierNameES5(id) {
  7768. var i, iz, ch;
  7769. if (id.length === 0) {
  7770. return false;
  7771. }
  7772. ch = id.charCodeAt(0);
  7773. if (!code$$1.isIdentifierStartES5(ch)) {
  7774. return false;
  7775. }
  7776. for (i = 1, iz = id.length; i < iz; ++i) {
  7777. ch = id.charCodeAt(i);
  7778. if (!code$$1.isIdentifierPartES5(ch)) {
  7779. return false;
  7780. }
  7781. }
  7782. return true;
  7783. }
  7784. function decodeUtf16(lead, trail) {
  7785. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  7786. }
  7787. function isIdentifierNameES6(id) {
  7788. var i, iz, ch, lowCh, check;
  7789. if (id.length === 0) {
  7790. return false;
  7791. }
  7792. check = code$$1.isIdentifierStartES6;
  7793. for (i = 0, iz = id.length; i < iz; ++i) {
  7794. ch = id.charCodeAt(i);
  7795. if (0xD800 <= ch && ch <= 0xDBFF) {
  7796. ++i;
  7797. if (i >= iz) {
  7798. return false;
  7799. }
  7800. lowCh = id.charCodeAt(i);
  7801. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  7802. return false;
  7803. }
  7804. ch = decodeUtf16(ch, lowCh);
  7805. }
  7806. if (!check(ch)) {
  7807. return false;
  7808. }
  7809. check = code$$1.isIdentifierPartES6;
  7810. }
  7811. return true;
  7812. }
  7813. function isIdentifierES5(id, strict) {
  7814. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  7815. }
  7816. function isIdentifierES6(id, strict) {
  7817. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  7818. }
  7819. module.exports = {
  7820. isKeywordES5: isKeywordES5,
  7821. isKeywordES6: isKeywordES6,
  7822. isReservedWordES5: isReservedWordES5,
  7823. isReservedWordES6: isReservedWordES6,
  7824. isRestrictedWord: isRestrictedWord,
  7825. isIdentifierNameES5: isIdentifierNameES5,
  7826. isIdentifierNameES6: isIdentifierNameES6,
  7827. isIdentifierES5: isIdentifierES5,
  7828. isIdentifierES6: isIdentifierES6
  7829. };
  7830. })();
  7831. /* vim: set sw=4 ts=4 et tw=80 : */
  7832. });
  7833. var utils$2 = createCommonjsModule(function (module, exports) {
  7834. /*
  7835. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7836. Redistribution and use in source and binary forms, with or without
  7837. modification, are permitted provided that the following conditions are met:
  7838. * Redistributions of source code must retain the above copyright
  7839. notice, this list of conditions and the following disclaimer.
  7840. * Redistributions in binary form must reproduce the above copyright
  7841. notice, this list of conditions and the following disclaimer in the
  7842. documentation and/or other materials provided with the distribution.
  7843. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7844. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7845. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7846. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7847. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7848. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7849. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7850. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7851. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7852. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7853. */
  7854. (function () {
  7855. 'use strict';
  7856. exports.ast = ast;
  7857. exports.code = code;
  7858. exports.keyword = keyword;
  7859. })();
  7860. /* vim: set sw=4 ts=4 et tw=80 : */
  7861. });
  7862. var hasFlag$6 = createCommonjsModule(function (module) {
  7863. 'use strict';
  7864. module.exports = function (flag, argv) {
  7865. argv = argv || process.argv;
  7866. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  7867. var pos = argv.indexOf(prefix + flag);
  7868. var terminatorPos = argv.indexOf('--');
  7869. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  7870. };
  7871. });
  7872. var env$1 = process.env;
  7873. var forceColor$1;
  7874. if (hasFlag$6('no-color') || hasFlag$6('no-colors') || hasFlag$6('color=false')) {
  7875. forceColor$1 = false;
  7876. } else if (hasFlag$6('color') || hasFlag$6('colors') || hasFlag$6('color=true') || hasFlag$6('color=always')) {
  7877. forceColor$1 = true;
  7878. }
  7879. if ('FORCE_COLOR' in env$1) {
  7880. forceColor$1 = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0;
  7881. }
  7882. function translateLevel$1(level) {
  7883. if (level === 0) {
  7884. return false;
  7885. }
  7886. return {
  7887. level,
  7888. hasBasic: true,
  7889. has256: level >= 2,
  7890. has16m: level >= 3
  7891. };
  7892. }
  7893. function supportsColor$4(stream) {
  7894. if (forceColor$1 === false) {
  7895. return 0;
  7896. }
  7897. if (hasFlag$6('color=16m') || hasFlag$6('color=full') || hasFlag$6('color=truecolor')) {
  7898. return 3;
  7899. }
  7900. if (hasFlag$6('color=256')) {
  7901. return 2;
  7902. }
  7903. if (stream && !stream.isTTY && forceColor$1 !== true) {
  7904. return 0;
  7905. }
  7906. var min = forceColor$1 ? 1 : 0;
  7907. if (process.platform === 'win32') {
  7908. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  7909. // libuv that enables 256 color output on Windows. Anything earlier and it
  7910. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  7911. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  7912. // release that supports 256 colors. Windows 10 build 14931 is the first release
  7913. // that supports 16m/TrueColor.
  7914. var osRelease = os.release().split('.');
  7915. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  7916. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  7917. }
  7918. return 1;
  7919. }
  7920. if ('CI' in env$1) {
  7921. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  7922. return sign in env$1;
  7923. }) || env$1.CI_NAME === 'codeship') {
  7924. return 1;
  7925. }
  7926. return min;
  7927. }
  7928. if ('TEAMCITY_VERSION' in env$1) {
  7929. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  7930. }
  7931. if (env$1.COLORTERM === 'truecolor') {
  7932. return 3;
  7933. }
  7934. if ('TERM_PROGRAM' in env$1) {
  7935. var version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  7936. switch (env$1.TERM_PROGRAM) {
  7937. case 'iTerm.app':
  7938. return version >= 3 ? 3 : 2;
  7939. case 'Apple_Terminal':
  7940. return 2;
  7941. // No default
  7942. }
  7943. }
  7944. if (/-256(color)?$/i.test(env$1.TERM)) {
  7945. return 2;
  7946. }
  7947. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  7948. return 1;
  7949. }
  7950. if ('COLORTERM' in env$1) {
  7951. return 1;
  7952. }
  7953. if (env$1.TERM === 'dumb') {
  7954. return min;
  7955. }
  7956. return min;
  7957. }
  7958. function getSupportLevel$1(stream) {
  7959. var level = supportsColor$4(stream);
  7960. return translateLevel$1(level);
  7961. }
  7962. var supportsColor_1$3 = {
  7963. supportsColor: getSupportLevel$1,
  7964. stdout: getSupportLevel$1(process.stdout),
  7965. stderr: getSupportLevel$1(process.stderr)
  7966. };
  7967. var templates$4 = createCommonjsModule(function (module) {
  7968. 'use strict';
  7969. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7970. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7971. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7972. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7973. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  7974. function unescape(c) {
  7975. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  7976. return String.fromCharCode(parseInt(c.slice(1), 16));
  7977. }
  7978. return ESCAPES.get(c) || c;
  7979. }
  7980. function parseArguments(name, args) {
  7981. var results = [];
  7982. var chunks = args.trim().split(/\s*,\s*/g);
  7983. var matches;
  7984. var _iteratorNormalCompletion = true;
  7985. var _didIteratorError = false;
  7986. var _iteratorError = undefined;
  7987. try {
  7988. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7989. var chunk = _step.value;
  7990. if (!isNaN(chunk)) {
  7991. results.push(Number(chunk));
  7992. } else if (matches = chunk.match(STRING_REGEX)) {
  7993. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  7994. return escape ? unescape(escape) : chr;
  7995. }));
  7996. } else {
  7997. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  7998. }
  7999. }
  8000. } catch (err) {
  8001. _didIteratorError = true;
  8002. _iteratorError = err;
  8003. } finally {
  8004. try {
  8005. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8006. _iterator.return();
  8007. }
  8008. } finally {
  8009. if (_didIteratorError) {
  8010. throw _iteratorError;
  8011. }
  8012. }
  8013. }
  8014. return results;
  8015. }
  8016. function parseStyle(style) {
  8017. STYLE_REGEX.lastIndex = 0;
  8018. var results = [];
  8019. var matches;
  8020. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  8021. var name = matches[1];
  8022. if (matches[2]) {
  8023. var args = parseArguments(name, matches[2]);
  8024. results.push([name].concat(args));
  8025. } else {
  8026. results.push([name]);
  8027. }
  8028. }
  8029. return results;
  8030. }
  8031. function buildStyle(chalk, styles) {
  8032. var enabled = {};
  8033. var _iteratorNormalCompletion2 = true;
  8034. var _didIteratorError2 = false;
  8035. var _iteratorError2 = undefined;
  8036. try {
  8037. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8038. var layer = _step2.value;
  8039. var _iteratorNormalCompletion3 = true;
  8040. var _didIteratorError3 = false;
  8041. var _iteratorError3 = undefined;
  8042. try {
  8043. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8044. var style = _step3.value;
  8045. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  8046. }
  8047. } catch (err) {
  8048. _didIteratorError3 = true;
  8049. _iteratorError3 = err;
  8050. } finally {
  8051. try {
  8052. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8053. _iterator3.return();
  8054. }
  8055. } finally {
  8056. if (_didIteratorError3) {
  8057. throw _iteratorError3;
  8058. }
  8059. }
  8060. }
  8061. }
  8062. } catch (err) {
  8063. _didIteratorError2 = true;
  8064. _iteratorError2 = err;
  8065. } finally {
  8066. try {
  8067. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8068. _iterator2.return();
  8069. }
  8070. } finally {
  8071. if (_didIteratorError2) {
  8072. throw _iteratorError2;
  8073. }
  8074. }
  8075. }
  8076. var current = chalk;
  8077. var _arr = Object.keys(enabled);
  8078. for (var _i = 0; _i < _arr.length; _i++) {
  8079. var styleName = _arr[_i];
  8080. if (Array.isArray(enabled[styleName])) {
  8081. if (!(styleName in current)) {
  8082. throw new Error(`Unknown Chalk style: ${styleName}`);
  8083. }
  8084. if (enabled[styleName].length > 0) {
  8085. current = current[styleName].apply(current, enabled[styleName]);
  8086. } else {
  8087. current = current[styleName];
  8088. }
  8089. }
  8090. }
  8091. return current;
  8092. }
  8093. module.exports = function (chalk, tmp) {
  8094. var styles = [];
  8095. var chunks = [];
  8096. var chunk = []; // eslint-disable-next-line max-params
  8097. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  8098. if (escapeChar) {
  8099. chunk.push(unescape(escapeChar));
  8100. } else if (style) {
  8101. var str = chunk.join('');
  8102. chunk = [];
  8103. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  8104. styles.push({
  8105. inverse,
  8106. styles: parseStyle(style)
  8107. });
  8108. } else if (close) {
  8109. if (styles.length === 0) {
  8110. throw new Error('Found extraneous } in Chalk template literal');
  8111. }
  8112. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  8113. chunk = [];
  8114. styles.pop();
  8115. } else {
  8116. chunk.push(chr);
  8117. }
  8118. });
  8119. chunks.push(chunk.join(''));
  8120. if (styles.length > 0) {
  8121. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  8122. throw new Error(errMsg);
  8123. }
  8124. return chunks.join('');
  8125. };
  8126. });
  8127. var chalk$5 = createCommonjsModule(function (module) {
  8128. 'use strict';
  8129. var stdoutColor = supportsColor_1$3.stdout;
  8130. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  8131. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  8132. var skipModels = new Set(['gray']);
  8133. var styles = Object.create(null);
  8134. function applyOptions(obj, options) {
  8135. options = options || {}; // Detect level if not set manually
  8136. var scLevel = stdoutColor ? stdoutColor.level : 0;
  8137. obj.level = options.level === undefined ? scLevel : options.level;
  8138. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  8139. }
  8140. function Chalk(options) {
  8141. // We check for this.template here since calling `chalk.constructor()`
  8142. // by itself will have a `this` of a previously constructed chalk object
  8143. if (!this || !(this instanceof Chalk) || this.template) {
  8144. var _chalk = {};
  8145. applyOptions(_chalk, options);
  8146. _chalk.template = function () {
  8147. var args = [].slice.call(arguments);
  8148. return chalkTag.apply(null, [_chalk.template].concat(args));
  8149. };
  8150. Object.setPrototypeOf(_chalk, Chalk.prototype);
  8151. Object.setPrototypeOf(_chalk.template, _chalk);
  8152. _chalk.template.constructor = Chalk;
  8153. return _chalk.template;
  8154. }
  8155. applyOptions(this, options);
  8156. } // Use bright blue on Windows as the normal blue color is illegible
  8157. if (isSimpleWindowsTerm) {
  8158. ansiStyles.blue.open = '\u001B[94m';
  8159. }
  8160. var _arr = Object.keys(ansiStyles);
  8161. var _loop = function _loop() {
  8162. var key = _arr[_i];
  8163. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  8164. styles[key] = {
  8165. get() {
  8166. var codes = ansiStyles[key];
  8167. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  8168. }
  8169. };
  8170. };
  8171. for (var _i = 0; _i < _arr.length; _i++) {
  8172. _loop();
  8173. }
  8174. styles.visible = {
  8175. get() {
  8176. return build.call(this, this._styles || [], true, 'visible');
  8177. }
  8178. };
  8179. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  8180. var _arr2 = Object.keys(ansiStyles.color.ansi);
  8181. var _loop2 = function _loop2() {
  8182. var model = _arr2[_i2];
  8183. if (skipModels.has(model)) {
  8184. return "continue";
  8185. }
  8186. styles[model] = {
  8187. get() {
  8188. var level = this.level;
  8189. return function () {
  8190. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  8191. var codes = {
  8192. open,
  8193. close: ansiStyles.color.close,
  8194. closeRe: ansiStyles.color.closeRe
  8195. };
  8196. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8197. };
  8198. }
  8199. };
  8200. };
  8201. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8202. var _ret = _loop2();
  8203. if (_ret === "continue") continue;
  8204. }
  8205. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  8206. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  8207. var _loop3 = function _loop3() {
  8208. var model = _arr3[_i3];
  8209. if (skipModels.has(model)) {
  8210. return "continue";
  8211. }
  8212. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8213. styles[bgModel] = {
  8214. get() {
  8215. var level = this.level;
  8216. return function () {
  8217. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  8218. var codes = {
  8219. open,
  8220. close: ansiStyles.bgColor.close,
  8221. closeRe: ansiStyles.bgColor.closeRe
  8222. };
  8223. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8224. };
  8225. }
  8226. };
  8227. };
  8228. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8229. var _ret2 = _loop3();
  8230. if (_ret2 === "continue") continue;
  8231. }
  8232. var proto = Object.defineProperties(function () {}, styles);
  8233. function build(_styles, _empty, key) {
  8234. var builder = function builder() {
  8235. return applyStyle.apply(builder, arguments);
  8236. };
  8237. builder._styles = _styles;
  8238. builder._empty = _empty;
  8239. var self = this;
  8240. Object.defineProperty(builder, 'level', {
  8241. enumerable: true,
  8242. get() {
  8243. return self.level;
  8244. },
  8245. set(level) {
  8246. self.level = level;
  8247. }
  8248. });
  8249. Object.defineProperty(builder, 'enabled', {
  8250. enumerable: true,
  8251. get() {
  8252. return self.enabled;
  8253. },
  8254. set(enabled) {
  8255. self.enabled = enabled;
  8256. }
  8257. }); // See below for fix regarding invisible grey/dim combination on Windows
  8258. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  8259. // no way to create a function with a different prototype
  8260. builder.__proto__ = proto; // eslint-disable-line no-proto
  8261. return builder;
  8262. }
  8263. function applyStyle() {
  8264. // Support varags, but simply cast to string in case there's only one arg
  8265. var args = arguments;
  8266. var argsLen = args.length;
  8267. var str = String(arguments[0]);
  8268. if (argsLen === 0) {
  8269. return '';
  8270. }
  8271. if (argsLen > 1) {
  8272. // Don't slice `arguments`, it prevents V8 optimizations
  8273. for (var a = 1; a < argsLen; a++) {
  8274. str += ' ' + args[a];
  8275. }
  8276. }
  8277. if (!this.enabled || this.level <= 0 || !str) {
  8278. return this._empty ? '' : str;
  8279. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  8280. // see https://github.com/chalk/chalk/issues/58
  8281. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  8282. var originalDim = ansiStyles.dim.open;
  8283. if (isSimpleWindowsTerm && this.hasGrey) {
  8284. ansiStyles.dim.open = '';
  8285. }
  8286. var _iteratorNormalCompletion = true;
  8287. var _didIteratorError = false;
  8288. var _iteratorError = undefined;
  8289. try {
  8290. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8291. var code = _step.value;
  8292. // Replace any instances already present with a re-opening code
  8293. // otherwise only the part of the string until said closing code
  8294. // will be colored, and the rest will simply be 'plain'.
  8295. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  8296. // after next line to fix a bleed issue on macOS
  8297. // https://github.com/chalk/chalk/pull/92
  8298. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  8299. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  8300. } catch (err) {
  8301. _didIteratorError = true;
  8302. _iteratorError = err;
  8303. } finally {
  8304. try {
  8305. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8306. _iterator.return();
  8307. }
  8308. } finally {
  8309. if (_didIteratorError) {
  8310. throw _iteratorError;
  8311. }
  8312. }
  8313. }
  8314. ansiStyles.dim.open = originalDim;
  8315. return str;
  8316. }
  8317. function chalkTag(chalk, strings) {
  8318. if (!Array.isArray(strings)) {
  8319. // If chalk() was called by itself or with a string,
  8320. // return the string itself as a string.
  8321. return [].slice.call(arguments, 1).join(' ');
  8322. }
  8323. var args = [].slice.call(arguments, 2);
  8324. var parts = [strings.raw[0]];
  8325. for (var i = 1; i < strings.length; i++) {
  8326. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  8327. parts.push(String(strings.raw[i]));
  8328. }
  8329. return templates$4(chalk, parts.join(''));
  8330. }
  8331. Object.defineProperties(Chalk.prototype, styles);
  8332. module.exports = Chalk(); // eslint-disable-line new-cap
  8333. module.exports.supportsColor = stdoutColor;
  8334. module.exports.default = module.exports; // For TypeScript
  8335. });
  8336. var lib$3 = createCommonjsModule(function (module, exports) {
  8337. "use strict";
  8338. Object.defineProperty(exports, "__esModule", {
  8339. value: true
  8340. });
  8341. exports.shouldHighlight = shouldHighlight;
  8342. exports.getChalk = getChalk;
  8343. exports.default = highlight;
  8344. function _jsTokens() {
  8345. var data = _interopRequireWildcard$$1(jsTokens);
  8346. _jsTokens = function _jsTokens() {
  8347. return data;
  8348. };
  8349. return data;
  8350. }
  8351. function _esutils() {
  8352. var data = _interopRequireDefault$$1(utils$2);
  8353. _esutils = function _esutils() {
  8354. return data;
  8355. };
  8356. return data;
  8357. }
  8358. function _chalk() {
  8359. var data = _interopRequireDefault$$1(chalk$5);
  8360. _chalk = function _chalk() {
  8361. return data;
  8362. };
  8363. return data;
  8364. }
  8365. function _interopRequireDefault$$1(obj) {
  8366. return obj && obj.__esModule ? obj : {
  8367. default: obj
  8368. };
  8369. }
  8370. function _interopRequireWildcard$$1(obj) {
  8371. if (obj && obj.__esModule) {
  8372. return obj;
  8373. } else {
  8374. var newObj = {};
  8375. if (obj != null) {
  8376. for (var key in obj) {
  8377. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  8378. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  8379. if (desc.get || desc.set) {
  8380. Object.defineProperty(newObj, key, desc);
  8381. } else {
  8382. newObj[key] = obj[key];
  8383. }
  8384. }
  8385. }
  8386. }
  8387. newObj.default = obj;
  8388. return newObj;
  8389. }
  8390. }
  8391. function getDefs(chalk) {
  8392. return {
  8393. keyword: chalk.cyan,
  8394. capitalized: chalk.yellow,
  8395. jsx_tag: chalk.yellow,
  8396. punctuator: chalk.yellow,
  8397. number: chalk.magenta,
  8398. string: chalk.green,
  8399. regex: chalk.magenta,
  8400. comment: chalk.grey,
  8401. invalid: chalk.white.bgRed.bold
  8402. };
  8403. }
  8404. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  8405. var JSX_TAG = /^[a-z][\w-]*$/i;
  8406. var BRACKET = /^[()[\]{}]$/;
  8407. function getTokenType(match) {
  8408. var _match$slice = match.slice(-2),
  8409. _match$slice2 = _slicedToArray(_match$slice, 2),
  8410. offset = _match$slice2[0],
  8411. text = _match$slice2[1];
  8412. var token = (0, _jsTokens().matchToToken)(match);
  8413. if (token.type === "name") {
  8414. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  8415. return "keyword";
  8416. }
  8417. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  8418. return "jsx_tag";
  8419. }
  8420. if (token.value[0] !== token.value[0].toLowerCase()) {
  8421. return "capitalized";
  8422. }
  8423. }
  8424. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  8425. return "bracket";
  8426. }
  8427. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  8428. return "punctuator";
  8429. }
  8430. return token.type;
  8431. }
  8432. function highlightTokens(defs, text) {
  8433. return text.replace(_jsTokens().default, function () {
  8434. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  8435. args[_key] = arguments[_key];
  8436. }
  8437. var type = getTokenType(args);
  8438. var colorize = defs[type];
  8439. if (colorize) {
  8440. return args[0].split(NEWLINE).map(function (str) {
  8441. return colorize(str);
  8442. }).join("\n");
  8443. } else {
  8444. return args[0];
  8445. }
  8446. });
  8447. }
  8448. function shouldHighlight(options) {
  8449. return _chalk().default.supportsColor || options.forceColor;
  8450. }
  8451. function getChalk(options) {
  8452. var chalk = _chalk().default;
  8453. if (options.forceColor) {
  8454. chalk = new (_chalk().default.constructor)({
  8455. enabled: true,
  8456. level: 1
  8457. });
  8458. }
  8459. return chalk;
  8460. }
  8461. function highlight(code) {
  8462. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8463. if (shouldHighlight(options)) {
  8464. var chalk = getChalk(options);
  8465. var defs = getDefs(chalk);
  8466. return highlightTokens(defs, code);
  8467. } else {
  8468. return code;
  8469. }
  8470. }
  8471. });
  8472. unwrapExports(lib$3);
  8473. var lib$2 = createCommonjsModule(function (module, exports) {
  8474. "use strict";
  8475. Object.defineProperty(exports, "__esModule", {
  8476. value: true
  8477. });
  8478. exports.codeFrameColumns = codeFrameColumns;
  8479. exports.default = _default;
  8480. function _highlight() {
  8481. var data = _interopRequireWildcard(lib$3);
  8482. _highlight = function _highlight() {
  8483. return data;
  8484. };
  8485. return data;
  8486. }
  8487. function _interopRequireWildcard(obj) {
  8488. if (obj && obj.__esModule) {
  8489. return obj;
  8490. } else {
  8491. var newObj = {};
  8492. if (obj != null) {
  8493. for (var key in obj) {
  8494. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  8495. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  8496. if (desc.get || desc.set) {
  8497. Object.defineProperty(newObj, key, desc);
  8498. } else {
  8499. newObj[key] = obj[key];
  8500. }
  8501. }
  8502. }
  8503. }
  8504. newObj.default = obj;
  8505. return newObj;
  8506. }
  8507. }
  8508. var deprecationWarningShown = false;
  8509. function getDefs(chalk) {
  8510. return {
  8511. gutter: chalk.grey,
  8512. marker: chalk.red.bold,
  8513. message: chalk.red.bold
  8514. };
  8515. }
  8516. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  8517. function getMarkerLines(loc, source, opts) {
  8518. var startLoc = Object.assign({
  8519. column: 0,
  8520. line: -1
  8521. }, loc.start);
  8522. var endLoc = Object.assign({}, startLoc, loc.end);
  8523. var _ref = opts || {},
  8524. _ref$linesAbove = _ref.linesAbove,
  8525. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  8526. _ref$linesBelow = _ref.linesBelow,
  8527. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  8528. var startLine = startLoc.line;
  8529. var startColumn = startLoc.column;
  8530. var endLine = endLoc.line;
  8531. var endColumn = endLoc.column;
  8532. var start = Math.max(startLine - (linesAbove + 1), 0);
  8533. var end = Math.min(source.length, endLine + linesBelow);
  8534. if (startLine === -1) {
  8535. start = 0;
  8536. }
  8537. if (endLine === -1) {
  8538. end = source.length;
  8539. }
  8540. var lineDiff = endLine - startLine;
  8541. var markerLines = {};
  8542. if (lineDiff) {
  8543. for (var i = 0; i <= lineDiff; i++) {
  8544. var lineNumber = i + startLine;
  8545. if (!startColumn) {
  8546. markerLines[lineNumber] = true;
  8547. } else if (i === 0) {
  8548. var sourceLength = source[lineNumber - 1].length;
  8549. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  8550. } else if (i === lineDiff) {
  8551. markerLines[lineNumber] = [0, endColumn];
  8552. } else {
  8553. var _sourceLength = source[lineNumber - i].length;
  8554. markerLines[lineNumber] = [0, _sourceLength];
  8555. }
  8556. }
  8557. } else {
  8558. if (startColumn === endColumn) {
  8559. if (startColumn) {
  8560. markerLines[startLine] = [startColumn, 0];
  8561. } else {
  8562. markerLines[startLine] = true;
  8563. }
  8564. } else {
  8565. markerLines[startLine] = [startColumn, endColumn - startColumn];
  8566. }
  8567. }
  8568. return {
  8569. start,
  8570. end,
  8571. markerLines
  8572. };
  8573. }
  8574. function codeFrameColumns(rawLines, loc) {
  8575. var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  8576. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  8577. var chalk = (0, _highlight().getChalk)(opts);
  8578. var defs = getDefs(chalk);
  8579. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  8580. return highlighted ? chalkFn(string) : string;
  8581. };
  8582. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  8583. var lines = rawLines.split(NEWLINE);
  8584. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  8585. start = _getMarkerLines.start,
  8586. end = _getMarkerLines.end,
  8587. markerLines = _getMarkerLines.markerLines;
  8588. var hasColumns = loc.start && typeof loc.start.column === "number";
  8589. var numberMaxWidth = String(end).length;
  8590. var frame = lines.slice(start, end).map(function (line, index) {
  8591. var number = start + 1 + index;
  8592. var paddedNumber = ` ${number}`.slice(-numberMaxWidth);
  8593. var gutter = ` ${paddedNumber} | `;
  8594. var hasMarker = markerLines[number];
  8595. var lastMarkerLine = !markerLines[number + 1];
  8596. if (hasMarker) {
  8597. var markerLine = "";
  8598. if (Array.isArray(hasMarker)) {
  8599. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  8600. var numberOfMarkers = hasMarker[1] || 1;
  8601. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  8602. if (lastMarkerLine && opts.message) {
  8603. markerLine += " " + maybeHighlight(defs.message, opts.message);
  8604. }
  8605. }
  8606. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  8607. } else {
  8608. return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
  8609. }
  8610. }).join("\n");
  8611. if (opts.message && !hasColumns) {
  8612. frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
  8613. }
  8614. if (highlighted) {
  8615. return chalk.reset(frame);
  8616. } else {
  8617. return frame;
  8618. }
  8619. }
  8620. function _default(rawLines, lineNumber, colNumber) {
  8621. var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  8622. if (!deprecationWarningShown) {
  8623. deprecationWarningShown = true;
  8624. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  8625. if (process.emitWarning) {
  8626. process.emitWarning(message, "DeprecationWarning");
  8627. } else {
  8628. var deprecationError = new Error(message);
  8629. deprecationError.name = "DeprecationWarning";
  8630. console.warn(new Error(message));
  8631. }
  8632. }
  8633. colNumber = Math.max(colNumber, 0);
  8634. var location = {
  8635. start: {
  8636. column: colNumber,
  8637. line: lineNumber
  8638. }
  8639. };
  8640. return codeFrameColumns(rawLines, location, opts);
  8641. }
  8642. });
  8643. unwrapExports(lib$2);
  8644. var ConfigError$1 = errors.ConfigError;
  8645. var locStart = loc.locStart;
  8646. var locEnd = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  8647. // triggering the parsers getters.
  8648. var ownNames = Object.getOwnPropertyNames;
  8649. var ownDescriptor = Object.getOwnPropertyDescriptor;
  8650. function getParsers(options) {
  8651. var parsers = {};
  8652. var _iteratorNormalCompletion = true;
  8653. var _didIteratorError = false;
  8654. var _iteratorError = undefined;
  8655. try {
  8656. for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8657. var plugin = _step.value;
  8658. if (!plugin.parsers) {
  8659. continue;
  8660. }
  8661. var _iteratorNormalCompletion2 = true;
  8662. var _didIteratorError2 = false;
  8663. var _iteratorError2 = undefined;
  8664. try {
  8665. for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8666. var name = _step2.value;
  8667. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  8668. }
  8669. } catch (err) {
  8670. _didIteratorError2 = true;
  8671. _iteratorError2 = err;
  8672. } finally {
  8673. try {
  8674. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8675. _iterator2.return();
  8676. }
  8677. } finally {
  8678. if (_didIteratorError2) {
  8679. throw _iteratorError2;
  8680. }
  8681. }
  8682. }
  8683. }
  8684. } catch (err) {
  8685. _didIteratorError = true;
  8686. _iteratorError = err;
  8687. } finally {
  8688. try {
  8689. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8690. _iterator.return();
  8691. }
  8692. } finally {
  8693. if (_didIteratorError) {
  8694. throw _iteratorError;
  8695. }
  8696. }
  8697. }
  8698. return parsers;
  8699. }
  8700. function resolveParser$1(opts, parsers) {
  8701. parsers = parsers || getParsers(opts);
  8702. if (typeof opts.parser === "function") {
  8703. // Custom parser API always works with JavaScript.
  8704. return {
  8705. parse: opts.parser,
  8706. astFormat: "estree",
  8707. locStart,
  8708. locEnd
  8709. };
  8710. }
  8711. if (typeof opts.parser === "string") {
  8712. if (parsers.hasOwnProperty(opts.parser)) {
  8713. return parsers[opts.parser];
  8714. }
  8715. /* istanbul ignore next */
  8716. {
  8717. try {
  8718. return {
  8719. parse: require(path.resolve(process.cwd(), opts.parser)),
  8720. astFormat: "estree",
  8721. locStart,
  8722. locEnd
  8723. };
  8724. } catch (err) {
  8725. /* istanbul ignore next */
  8726. throw new ConfigError$1(`Couldn't resolve parser "${opts.parser}"`);
  8727. }
  8728. }
  8729. }
  8730. }
  8731. function parse$2(text, opts) {
  8732. var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  8733. // the parsers getters when actually calling the parser `parse` function.
  8734. var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) {
  8735. return Object.defineProperty(object, parserName, {
  8736. enumerable: true,
  8737. get() {
  8738. return parsers[parserName].parse;
  8739. }
  8740. });
  8741. }, {});
  8742. var parser = resolveParser$1(opts, parsers);
  8743. try {
  8744. if (parser.preprocess) {
  8745. text = parser.preprocess(text, opts);
  8746. }
  8747. return {
  8748. text,
  8749. ast: parser.parse(text, parsersForCustomParserApi, opts)
  8750. };
  8751. } catch (error) {
  8752. var loc$$1 = error.loc;
  8753. if (loc$$1) {
  8754. var codeFrame = lib$2;
  8755. error.codeFrame = codeFrame.codeFrameColumns(text, loc$$1, {
  8756. highlightCode: true
  8757. });
  8758. error.message += "\n" + error.codeFrame;
  8759. throw error;
  8760. }
  8761. /* istanbul ignore next */
  8762. throw error.stack;
  8763. }
  8764. }
  8765. var parser = {
  8766. parse: parse$2,
  8767. resolveParser: resolveParser$1
  8768. };
  8769. var UndefinedParserError = errors.UndefinedParserError;
  8770. var getSupportInfo$1 = support.getSupportInfo;
  8771. var resolveParser = parser.resolveParser;
  8772. var hiddenDefaults = {
  8773. astFormat: "estree",
  8774. printer: {},
  8775. originalText: undefined,
  8776. locStart: null,
  8777. locEnd: null
  8778. }; // Copy options and fill in default values.
  8779. function normalize(options, opts) {
  8780. opts = opts || {};
  8781. var rawOptions = Object.assign({}, options);
  8782. var supportOptions = getSupportInfo$1(null, {
  8783. plugins: options.plugins,
  8784. showUnreleased: true,
  8785. showDeprecated: true
  8786. }).options;
  8787. var defaults = supportOptions.reduce(function (reduced, optionInfo) {
  8788. return optionInfo.default !== undefined ? Object.assign(reduced, {
  8789. [optionInfo.name]: optionInfo.default
  8790. }) : reduced;
  8791. }, Object.assign({}, hiddenDefaults));
  8792. if (!rawOptions.parser) {
  8793. if (!rawOptions.filepath) {
  8794. var logger = opts.logger || console;
  8795. 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.");
  8796. rawOptions.parser = "babel";
  8797. } else {
  8798. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  8799. if (!rawOptions.parser) {
  8800. throw new UndefinedParserError(`No parser could be inferred for file: ${rawOptions.filepath}`);
  8801. }
  8802. }
  8803. }
  8804. var parser$$1 = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) {
  8805. return x.name === "parser";
  8806. })], {
  8807. passThrough: true,
  8808. logger: false
  8809. }));
  8810. rawOptions.astFormat = parser$$1.astFormat;
  8811. rawOptions.locEnd = parser$$1.locEnd;
  8812. rawOptions.locStart = parser$$1.locStart;
  8813. var plugin = getPlugin(rawOptions);
  8814. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  8815. var pluginDefaults = supportOptions.filter(function (optionInfo) {
  8816. return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name];
  8817. }).reduce(function (reduced, optionInfo) {
  8818. return Object.assign(reduced, {
  8819. [optionInfo.name]: optionInfo.pluginDefaults[plugin.name]
  8820. });
  8821. }, {});
  8822. var mixedDefaults = Object.assign({}, defaults, pluginDefaults);
  8823. Object.keys(mixedDefaults).forEach(function (k) {
  8824. if (rawOptions[k] == null) {
  8825. rawOptions[k] = mixedDefaults[k];
  8826. }
  8827. });
  8828. if (rawOptions.parser === "json") {
  8829. rawOptions.trailingComma = "none";
  8830. }
  8831. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  8832. passThrough: Object.keys(hiddenDefaults)
  8833. }, opts));
  8834. }
  8835. function getPlugin(options) {
  8836. var astFormat = options.astFormat;
  8837. if (!astFormat) {
  8838. throw new Error("getPlugin() requires astFormat to be set");
  8839. }
  8840. var printerPlugin = options.plugins.find(function (plugin) {
  8841. return plugin.printers && plugin.printers[astFormat];
  8842. });
  8843. if (!printerPlugin) {
  8844. throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
  8845. }
  8846. return printerPlugin;
  8847. }
  8848. function getInterpreter(filepath) {
  8849. if (typeof filepath !== "string") {
  8850. return "";
  8851. }
  8852. var fd;
  8853. try {
  8854. fd = fs.openSync(filepath, "r");
  8855. } catch (err) {
  8856. return "";
  8857. }
  8858. try {
  8859. var liner = new readlines(fd);
  8860. var firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  8861. var m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  8862. if (m1) {
  8863. return m1[1];
  8864. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  8865. var m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  8866. if (m2) {
  8867. return m2[1];
  8868. }
  8869. return "";
  8870. } catch (err) {
  8871. // There are some weird cases where paths are missing, causing Jest
  8872. // failures. It's unclear what these correspond to in the real world.
  8873. return "";
  8874. } finally {
  8875. try {
  8876. // There are some weird cases where paths are missing, causing Jest
  8877. // failures. It's unclear what these correspond to in the real world.
  8878. fs.closeSync(fd);
  8879. } catch (err) {// nop
  8880. }
  8881. }
  8882. }
  8883. function inferParser(filepath, plugins) {
  8884. var filepathParts = normalizePath(filepath).split("/");
  8885. var filename = filepathParts[filepathParts.length - 1].toLowerCase(); // If the file has no extension, we can try to infer the language from the
  8886. // interpreter in the shebang line, if any; but since this requires FS access,
  8887. // do it last.
  8888. var language = getSupportInfo$1(null, {
  8889. plugins
  8890. }).languages.find(function (language) {
  8891. return language.since !== null && (language.extensions && language.extensions.some(function (extension) {
  8892. return filename.endsWith(extension);
  8893. }) || language.filenames && language.filenames.find(function (name) {
  8894. return name.toLowerCase() === filename;
  8895. }) || filename.indexOf(".") === -1 && language.interpreters && language.interpreters.indexOf(getInterpreter(filepath)) !== -1);
  8896. });
  8897. return language && language.parsers[0];
  8898. }
  8899. var options = {
  8900. normalize,
  8901. hiddenDefaults,
  8902. inferParser
  8903. };
  8904. function massageAST(ast, options, parent) {
  8905. if (Array.isArray(ast)) {
  8906. return ast.map(function (e) {
  8907. return massageAST(e, options, parent);
  8908. }).filter(function (e) {
  8909. return e;
  8910. });
  8911. }
  8912. if (!ast || typeof ast !== "object") {
  8913. return ast;
  8914. }
  8915. var newObj = {};
  8916. var _arr = Object.keys(ast);
  8917. for (var _i = 0; _i < _arr.length; _i++) {
  8918. var key = _arr[_i];
  8919. if (typeof ast[key] !== "function") {
  8920. newObj[key] = massageAST(ast[key], options, ast);
  8921. }
  8922. }
  8923. if (options.printer.massageAstNode) {
  8924. var result = options.printer.massageAstNode(ast, newObj, parent);
  8925. if (result === null) {
  8926. return undefined;
  8927. }
  8928. if (result) {
  8929. return result;
  8930. }
  8931. }
  8932. return newObj;
  8933. }
  8934. var massageAst = massageAST;
  8935. function concat$1(parts) {
  8936. return {
  8937. type: "concat",
  8938. parts
  8939. };
  8940. }
  8941. function indent$1(contents) {
  8942. return {
  8943. type: "indent",
  8944. contents
  8945. };
  8946. }
  8947. function align(n, contents) {
  8948. return {
  8949. type: "align",
  8950. contents,
  8951. n
  8952. };
  8953. }
  8954. function group(contents, opts) {
  8955. opts = opts || {};
  8956. return {
  8957. type: "group",
  8958. id: opts.id,
  8959. contents: contents,
  8960. break: !!opts.shouldBreak,
  8961. expandedStates: opts.expandedStates
  8962. };
  8963. }
  8964. function dedentToRoot(contents) {
  8965. return align(-Infinity, contents);
  8966. }
  8967. function markAsRoot(contents) {
  8968. return align({
  8969. type: "root"
  8970. }, contents);
  8971. }
  8972. function dedent$1(contents) {
  8973. return align(-1, contents);
  8974. }
  8975. function conditionalGroup(states, opts) {
  8976. return group(states[0], Object.assign(opts || {}, {
  8977. expandedStates: states
  8978. }));
  8979. }
  8980. function fill(parts) {
  8981. return {
  8982. type: "fill",
  8983. parts
  8984. };
  8985. }
  8986. function ifBreak(breakContents, flatContents, opts) {
  8987. opts = opts || {};
  8988. return {
  8989. type: "if-break",
  8990. breakContents,
  8991. flatContents,
  8992. groupId: opts.groupId
  8993. };
  8994. }
  8995. function lineSuffix$1(contents) {
  8996. return {
  8997. type: "line-suffix",
  8998. contents
  8999. };
  9000. }
  9001. var lineSuffixBoundary = {
  9002. type: "line-suffix-boundary"
  9003. };
  9004. var breakParent$1 = {
  9005. type: "break-parent"
  9006. };
  9007. var trim = {
  9008. type: "trim"
  9009. };
  9010. var line$2 = {
  9011. type: "line"
  9012. };
  9013. var softline = {
  9014. type: "line",
  9015. soft: true
  9016. };
  9017. var hardline$1 = concat$1([{
  9018. type: "line",
  9019. hard: true
  9020. }, breakParent$1]);
  9021. var literalline = concat$1([{
  9022. type: "line",
  9023. hard: true,
  9024. literal: true
  9025. }, breakParent$1]);
  9026. var cursor$1 = {
  9027. type: "cursor",
  9028. placeholder: Symbol("cursor")
  9029. };
  9030. function join$1(sep, arr) {
  9031. var res = [];
  9032. for (var i = 0; i < arr.length; i++) {
  9033. if (i !== 0) {
  9034. res.push(sep);
  9035. }
  9036. res.push(arr[i]);
  9037. }
  9038. return concat$1(res);
  9039. }
  9040. function addAlignmentToDoc(doc, size, tabWidth) {
  9041. var aligned = doc;
  9042. if (size > 0) {
  9043. // Use indent to add tabs for all the levels of tabs we need
  9044. for (var i = 0; i < Math.floor(size / tabWidth); ++i) {
  9045. aligned = indent$1(aligned);
  9046. } // Use align for all the spaces that are needed
  9047. aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
  9048. // indentation, so we use -Infinity to reset the indentation to 0
  9049. aligned = align(-Infinity, aligned);
  9050. }
  9051. return aligned;
  9052. }
  9053. var docBuilders = {
  9054. concat: concat$1,
  9055. join: join$1,
  9056. line: line$2,
  9057. softline,
  9058. hardline: hardline$1,
  9059. literalline,
  9060. group,
  9061. conditionalGroup,
  9062. fill,
  9063. lineSuffix: lineSuffix$1,
  9064. lineSuffixBoundary,
  9065. cursor: cursor$1,
  9066. breakParent: breakParent$1,
  9067. ifBreak,
  9068. trim,
  9069. indent: indent$1,
  9070. align,
  9071. addAlignmentToDoc,
  9072. markAsRoot,
  9073. dedentToRoot,
  9074. dedent: dedent$1
  9075. };
  9076. var ansiRegex = createCommonjsModule(function (module) {
  9077. 'use strict';
  9078. module.exports = function (options) {
  9079. options = Object.assign({
  9080. onlyFirst: false
  9081. }, options);
  9082. var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  9083. return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
  9084. };
  9085. });
  9086. var stripAnsi = function stripAnsi(input) {
  9087. return typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
  9088. };
  9089. var isFullwidthCodePoint = createCommonjsModule(function (module) {
  9090. 'use strict';
  9091. /* eslint-disable yoda */
  9092. module.exports = function (x) {
  9093. if (Number.isNaN(x)) {
  9094. return false;
  9095. } // code points are derived from:
  9096. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  9097. if (x >= 0x1100 && (x <= 0x115f || // Hangul Jamo
  9098. x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  9099. x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
  9100. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  9101. 0x2e80 <= x && x <= 0x3247 && x !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  9102. 0x3250 <= x && x <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals
  9103. 0x4e00 <= x && x <= 0xa4c6 || // Hangul Jamo Extended-A
  9104. 0xa960 <= x && x <= 0xa97c || // Hangul Syllables
  9105. 0xac00 <= x && x <= 0xd7a3 || // CJK Compatibility Ideographs
  9106. 0xf900 <= x && x <= 0xfaff || // Vertical Forms
  9107. 0xfe10 <= x && x <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants
  9108. 0xfe30 <= x && x <= 0xfe6b || // Halfwidth and Fullwidth Forms
  9109. 0xff01 <= x && x <= 0xff60 || 0xffe0 <= x && x <= 0xffe6 || // Kana Supplement
  9110. 0x1b000 <= x && x <= 0x1b001 || // Enclosed Ideographic Supplement
  9111. 0x1f200 <= x && x <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  9112. 0x20000 <= x && x <= 0x3fffd)) {
  9113. return true;
  9114. }
  9115. return false;
  9116. };
  9117. });
  9118. var emojiRegex = function emojiRegex() {
  9119. // https://mths.be/emoji
  9120. return /\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\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])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\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[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\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\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|(?:\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\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\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\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\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*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\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g;
  9121. };
  9122. var stringWidth = createCommonjsModule(function (module) {
  9123. 'use strict';
  9124. var emojiRegex$$1 = emojiRegex();
  9125. module.exports = function (input) {
  9126. input = input.replace(emojiRegex$$1, ' ');
  9127. if (typeof input !== 'string' || input.length === 0) {
  9128. return 0;
  9129. }
  9130. input = stripAnsi(input);
  9131. var width = 0;
  9132. for (var i = 0; i < input.length; i++) {
  9133. var code = input.codePointAt(i); // Ignore control characters
  9134. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  9135. continue;
  9136. } // Ignore combining characters
  9137. if (code >= 0x300 && code <= 0x36F) {
  9138. continue;
  9139. } // Surrogates
  9140. if (code > 0xFFFF) {
  9141. i++;
  9142. }
  9143. width += isFullwidthCodePoint(code) ? 2 : 1;
  9144. }
  9145. return width;
  9146. };
  9147. });
  9148. var notAsciiRegex = /[^\x20-\x7F]/;
  9149. function isExportDeclaration(node) {
  9150. if (node) {
  9151. switch (node.type) {
  9152. case "ExportDefaultDeclaration":
  9153. case "ExportDefaultSpecifier":
  9154. case "DeclareExportDeclaration":
  9155. case "ExportNamedDeclaration":
  9156. case "ExportAllDeclaration":
  9157. return true;
  9158. }
  9159. }
  9160. return false;
  9161. }
  9162. function getParentExportDeclaration(path$$1) {
  9163. var parentNode = path$$1.getParentNode();
  9164. if (path$$1.getName() === "declaration" && isExportDeclaration(parentNode)) {
  9165. return parentNode;
  9166. }
  9167. return null;
  9168. }
  9169. function getPenultimate(arr) {
  9170. if (arr.length > 1) {
  9171. return arr[arr.length - 2];
  9172. }
  9173. return null;
  9174. }
  9175. function skip(chars) {
  9176. return function (text, index, opts) {
  9177. var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  9178. // to check for failures (did someone say monads?).
  9179. if (index === false) {
  9180. return false;
  9181. }
  9182. var length = text.length;
  9183. var cursor = index;
  9184. while (cursor >= 0 && cursor < length) {
  9185. var c = text.charAt(cursor);
  9186. if (chars instanceof RegExp) {
  9187. if (!chars.test(c)) {
  9188. return cursor;
  9189. }
  9190. } else if (chars.indexOf(c) === -1) {
  9191. return cursor;
  9192. }
  9193. backwards ? cursor-- : cursor++;
  9194. }
  9195. if (cursor === -1 || cursor === length) {
  9196. // If we reached the beginning or end of the file, return the
  9197. // out-of-bounds cursor. It's up to the caller to handle this
  9198. // correctly. We don't want to indicate `false` though if it
  9199. // actually skipped valid characters.
  9200. return cursor;
  9201. }
  9202. return false;
  9203. };
  9204. }
  9205. var skipWhitespace = skip(/\s/);
  9206. var skipSpaces = skip(" \t");
  9207. var skipToLineEnd = skip(",; \t");
  9208. var skipEverythingButNewLine = skip(/[^\r\n]/);
  9209. function skipInlineComment(text, index) {
  9210. if (index === false) {
  9211. return false;
  9212. }
  9213. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  9214. for (var i = index + 2; i < text.length; ++i) {
  9215. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  9216. return i + 2;
  9217. }
  9218. }
  9219. }
  9220. return index;
  9221. }
  9222. function skipTrailingComment(text, index) {
  9223. if (index === false) {
  9224. return false;
  9225. }
  9226. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  9227. return skipEverythingButNewLine(text, index);
  9228. }
  9229. return index;
  9230. } // This one doesn't use the above helper function because it wants to
  9231. // test \r\n in order and `skip` doesn't support ordering and we only
  9232. // want to skip one newline. It's simple to implement.
  9233. function skipNewline$1(text, index, opts) {
  9234. var backwards = opts && opts.backwards;
  9235. if (index === false) {
  9236. return false;
  9237. }
  9238. var atIndex = text.charAt(index);
  9239. if (backwards) {
  9240. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  9241. return index - 2;
  9242. }
  9243. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  9244. return index - 1;
  9245. }
  9246. } else {
  9247. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  9248. return index + 2;
  9249. }
  9250. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  9251. return index + 1;
  9252. }
  9253. }
  9254. return index;
  9255. }
  9256. function hasNewline$1(text, index, opts) {
  9257. opts = opts || {};
  9258. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  9259. var idx2 = skipNewline$1(text, idx, opts);
  9260. return idx !== idx2;
  9261. }
  9262. function hasNewlineInRange(text, start, end) {
  9263. for (var i = start; i < end; ++i) {
  9264. if (text.charAt(i) === "\n") {
  9265. return true;
  9266. }
  9267. }
  9268. return false;
  9269. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  9270. function isPreviousLineEmpty$1(text, node, locStart) {
  9271. var idx = locStart(node) - 1;
  9272. idx = skipSpaces(text, idx, {
  9273. backwards: true
  9274. });
  9275. idx = skipNewline$1(text, idx, {
  9276. backwards: true
  9277. });
  9278. idx = skipSpaces(text, idx, {
  9279. backwards: true
  9280. });
  9281. var idx2 = skipNewline$1(text, idx, {
  9282. backwards: true
  9283. });
  9284. return idx !== idx2;
  9285. }
  9286. function isNextLineEmptyAfterIndex(text, index) {
  9287. var oldIdx = null;
  9288. var idx = index;
  9289. while (idx !== oldIdx) {
  9290. // We need to skip all the potential trailing inline comments
  9291. oldIdx = idx;
  9292. idx = skipToLineEnd(text, idx);
  9293. idx = skipInlineComment(text, idx);
  9294. idx = skipSpaces(text, idx);
  9295. }
  9296. idx = skipTrailingComment(text, idx);
  9297. idx = skipNewline$1(text, idx);
  9298. return hasNewline$1(text, idx);
  9299. }
  9300. function isNextLineEmpty(text, node, locEnd) {
  9301. return isNextLineEmptyAfterIndex(text, locEnd(node));
  9302. }
  9303. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
  9304. var oldIdx = null;
  9305. while (idx !== oldIdx) {
  9306. oldIdx = idx;
  9307. idx = skipSpaces(text, idx);
  9308. idx = skipInlineComment(text, idx);
  9309. idx = skipTrailingComment(text, idx);
  9310. idx = skipNewline$1(text, idx);
  9311. }
  9312. return idx;
  9313. }
  9314. function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
  9315. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
  9316. }
  9317. function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
  9318. return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
  9319. }
  9320. function hasSpaces(text, index, opts) {
  9321. opts = opts || {};
  9322. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  9323. return idx !== index;
  9324. }
  9325. function setLocStart(node, index) {
  9326. if (node.range) {
  9327. node.range[0] = index;
  9328. } else {
  9329. node.start = index;
  9330. }
  9331. }
  9332. function setLocEnd(node, index) {
  9333. if (node.range) {
  9334. node.range[1] = index;
  9335. } else {
  9336. node.end = index;
  9337. }
  9338. }
  9339. var PRECEDENCE = {};
  9340. [["|>"], ["||", "??"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) {
  9341. tier.forEach(function (op) {
  9342. PRECEDENCE[op] = i;
  9343. });
  9344. });
  9345. function getPrecedence(op) {
  9346. return PRECEDENCE[op];
  9347. }
  9348. var equalityOperators = {
  9349. "==": true,
  9350. "!=": true,
  9351. "===": true,
  9352. "!==": true
  9353. };
  9354. var multiplicativeOperators = {
  9355. "*": true,
  9356. "/": true,
  9357. "%": true
  9358. };
  9359. var bitshiftOperators = {
  9360. ">>": true,
  9361. ">>>": true,
  9362. "<<": true
  9363. };
  9364. function shouldFlatten(parentOp, nodeOp) {
  9365. if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
  9366. return false;
  9367. } // ** is right-associative
  9368. // x ** y ** z --> x ** (y ** z)
  9369. if (parentOp === "**") {
  9370. return false;
  9371. } // x == y == z --> (x == y) == z
  9372. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  9373. return false;
  9374. } // x * y % z --> (x * y) % z
  9375. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  9376. return false;
  9377. } // x * y / z --> (x * y) / z
  9378. // x / y * z --> (x / y) * z
  9379. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  9380. return false;
  9381. } // x << y << z --> (x << y) << z
  9382. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  9383. return false;
  9384. }
  9385. return true;
  9386. }
  9387. function isBitwiseOperator(operator) {
  9388. return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
  9389. } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  9390. // holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  9391. // already necessary grouping parentheses.
  9392. function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
  9393. node = getLeftMost(node);
  9394. switch (node.type) {
  9395. case "FunctionExpression":
  9396. case "ClassExpression":
  9397. case "DoExpression":
  9398. return forbidFunctionClassAndDoExpr;
  9399. case "ObjectExpression":
  9400. return true;
  9401. case "MemberExpression":
  9402. return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  9403. case "TaggedTemplateExpression":
  9404. if (node.tag.type === "FunctionExpression") {
  9405. // IIFEs are always already parenthesized
  9406. return false;
  9407. }
  9408. return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
  9409. case "CallExpression":
  9410. if (node.callee.type === "FunctionExpression") {
  9411. // IIFEs are always already parenthesized
  9412. return false;
  9413. }
  9414. return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
  9415. case "ConditionalExpression":
  9416. return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
  9417. case "UpdateExpression":
  9418. return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
  9419. case "BindExpression":
  9420. return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  9421. case "SequenceExpression":
  9422. return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
  9423. case "TSAsExpression":
  9424. return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
  9425. default:
  9426. return false;
  9427. }
  9428. }
  9429. function getLeftMost(node) {
  9430. if (node.left) {
  9431. return getLeftMost(node.left);
  9432. }
  9433. return node;
  9434. }
  9435. function getAlignmentSize(value, tabWidth, startIndex) {
  9436. startIndex = startIndex || 0;
  9437. var size = 0;
  9438. for (var i = startIndex; i < value.length; ++i) {
  9439. if (value[i] === "\t") {
  9440. // Tabs behave in a way that they are aligned to the nearest
  9441. // multiple of tabWidth:
  9442. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  9443. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  9444. size = size + tabWidth - size % tabWidth;
  9445. } else {
  9446. size++;
  9447. }
  9448. }
  9449. return size;
  9450. }
  9451. function getIndentSize(value, tabWidth) {
  9452. var lastNewlineIndex = value.lastIndexOf("\n");
  9453. if (lastNewlineIndex === -1) {
  9454. return 0;
  9455. }
  9456. return getAlignmentSize( // All the leading whitespaces
  9457. value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
  9458. }
  9459. function getPreferredQuote(raw, preferredQuote) {
  9460. // `rawContent` is the string exactly like it appeared in the input source
  9461. // code, without its enclosing quotes.
  9462. var rawContent = raw.slice(1, -1);
  9463. var double = {
  9464. quote: '"',
  9465. regex: /"/g
  9466. };
  9467. var single = {
  9468. quote: "'",
  9469. regex: /'/g
  9470. };
  9471. var preferred = preferredQuote === "'" ? single : double;
  9472. var alternate = preferred === single ? double : single;
  9473. var result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
  9474. // the string, we might want to enclose with the alternate quote instead, to
  9475. // minimize the number of escaped quotes.
  9476. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  9477. var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  9478. var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  9479. result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
  9480. }
  9481. return result;
  9482. }
  9483. function printString(raw, options, isDirectiveLiteral) {
  9484. // `rawContent` is the string exactly like it appeared in the input source
  9485. // code, without its enclosing quotes.
  9486. var rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  9487. // the quotes on a DirectiveLiteral.
  9488. var canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
  9489. var enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
  9490. // change the escape sequences they use.
  9491. // See https://github.com/prettier/prettier/issues/1555
  9492. // and https://tc39.github.io/ecma262/#directive-prologue
  9493. if (isDirectiveLiteral) {
  9494. if (canChangeDirectiveQuotes) {
  9495. return enclosingQuote + rawContent + enclosingQuote;
  9496. }
  9497. return raw;
  9498. } // It might sound unnecessary to use `makeString` even if the string already
  9499. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  9500. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  9501. // sure that we consistently output the minimum amount of escaped quotes.
  9502. return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
  9503. }
  9504. function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  9505. var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  9506. var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to
  9507. // enclose `rawContent` with `enclosingQuote`.
  9508. var newContent = rawContent.replace(regex, function (match, escaped, quote) {
  9509. // If we matched an escape, and the escaped character is a quote of the
  9510. // other type than we intend to enclose the string with, there's no need for
  9511. // it to be escaped, so return it _without_ the backslash.
  9512. if (escaped === otherQuote) {
  9513. return escaped;
  9514. } // If we matched an unescaped quote and it is of the _same_ type as we
  9515. // intend to enclose the string with, it must be escaped, so return it with
  9516. // a backslash.
  9517. if (quote === enclosingQuote) {
  9518. return "\\" + quote;
  9519. }
  9520. if (quote) {
  9521. return quote;
  9522. } // Unescape any unnecessarily escaped character.
  9523. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  9524. return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
  9525. });
  9526. return enclosingQuote + newContent + enclosingQuote;
  9527. }
  9528. function printNumber(rawNumber) {
  9529. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  9530. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  9531. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  9532. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  9533. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  9534. .replace(/\.(?=e|$)/, "");
  9535. }
  9536. function getMaxContinuousCount(str, target) {
  9537. var results = str.match(new RegExp(`(${escapeStringRegexp(target)})+`, "g"));
  9538. if (results === null) {
  9539. return 0;
  9540. }
  9541. return results.reduce(function (maxCount, result) {
  9542. return Math.max(maxCount, result.length / target.length);
  9543. }, 0);
  9544. }
  9545. function getMinNotPresentContinuousCount(str, target) {
  9546. var matches = str.match(new RegExp(`(${escapeStringRegexp(target)})+`, "g"));
  9547. if (matches === null) {
  9548. return 0;
  9549. }
  9550. var countPresent = new Map();
  9551. var max = 0;
  9552. var _iteratorNormalCompletion = true;
  9553. var _didIteratorError = false;
  9554. var _iteratorError = undefined;
  9555. try {
  9556. for (var _iterator = matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9557. var match = _step.value;
  9558. var count = match.length / target.length;
  9559. countPresent.set(count, true);
  9560. if (count > max) {
  9561. max = count;
  9562. }
  9563. }
  9564. } catch (err) {
  9565. _didIteratorError = true;
  9566. _iteratorError = err;
  9567. } finally {
  9568. try {
  9569. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9570. _iterator.return();
  9571. }
  9572. } finally {
  9573. if (_didIteratorError) {
  9574. throw _iteratorError;
  9575. }
  9576. }
  9577. }
  9578. for (var i = 1; i < max; i++) {
  9579. if (!countPresent.get(i)) {
  9580. return i;
  9581. }
  9582. }
  9583. return max + 1;
  9584. }
  9585. function getStringWidth$1(text) {
  9586. if (!text) {
  9587. return 0;
  9588. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  9589. if (!notAsciiRegex.test(text)) {
  9590. return text.length;
  9591. }
  9592. return stringWidth(text);
  9593. }
  9594. function hasIgnoreComment(path$$1) {
  9595. var node = path$$1.getValue();
  9596. return hasNodeIgnoreComment(node);
  9597. }
  9598. function hasNodeIgnoreComment(node) {
  9599. return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) {
  9600. return comment.value.trim() === "prettier-ignore";
  9601. });
  9602. }
  9603. function matchAncestorTypes(path$$1, types, index) {
  9604. index = index || 0;
  9605. types = types.slice();
  9606. while (types.length) {
  9607. var parent = path$$1.getParentNode(index);
  9608. var type = types.shift();
  9609. if (!parent || parent.type !== type) {
  9610. return false;
  9611. }
  9612. index++;
  9613. }
  9614. return true;
  9615. }
  9616. function addCommentHelper(node, comment) {
  9617. var comments = node.comments || (node.comments = []);
  9618. comments.push(comment);
  9619. comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
  9620. // We already "print" it via the raw text, we don't need to re-print it as a
  9621. // comment
  9622. if (node.type === "JSXText") {
  9623. comment.printed = true;
  9624. }
  9625. }
  9626. function addLeadingComment$1(node, comment) {
  9627. comment.leading = true;
  9628. comment.trailing = false;
  9629. addCommentHelper(node, comment);
  9630. }
  9631. function addDanglingComment$1(node, comment) {
  9632. comment.leading = false;
  9633. comment.trailing = false;
  9634. addCommentHelper(node, comment);
  9635. }
  9636. function addTrailingComment$1(node, comment) {
  9637. comment.leading = false;
  9638. comment.trailing = true;
  9639. addCommentHelper(node, comment);
  9640. }
  9641. function isWithinParentArrayProperty(path$$1, propertyName) {
  9642. var node = path$$1.getValue();
  9643. var parent = path$$1.getParentNode();
  9644. if (parent == null) {
  9645. return false;
  9646. }
  9647. if (!Array.isArray(parent[propertyName])) {
  9648. return false;
  9649. }
  9650. var key = path$$1.getName();
  9651. return parent[propertyName][key] === node;
  9652. }
  9653. function replaceEndOfLineWith(text, replacement) {
  9654. var parts = [];
  9655. var _iteratorNormalCompletion2 = true;
  9656. var _didIteratorError2 = false;
  9657. var _iteratorError2 = undefined;
  9658. try {
  9659. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  9660. var part = _step2.value;
  9661. if (parts.length !== 0) {
  9662. parts.push(replacement);
  9663. }
  9664. parts.push(part);
  9665. }
  9666. } catch (err) {
  9667. _didIteratorError2 = true;
  9668. _iteratorError2 = err;
  9669. } finally {
  9670. try {
  9671. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  9672. _iterator2.return();
  9673. }
  9674. } finally {
  9675. if (_didIteratorError2) {
  9676. throw _iteratorError2;
  9677. }
  9678. }
  9679. }
  9680. return parts;
  9681. }
  9682. var util$1 = {
  9683. replaceEndOfLineWith,
  9684. getStringWidth: getStringWidth$1,
  9685. getMaxContinuousCount,
  9686. getMinNotPresentContinuousCount,
  9687. getPrecedence,
  9688. shouldFlatten,
  9689. isBitwiseOperator,
  9690. isExportDeclaration,
  9691. getParentExportDeclaration,
  9692. getPenultimate,
  9693. getLast,
  9694. getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  9695. getNextNonSpaceNonCommentCharacterIndex,
  9696. getNextNonSpaceNonCommentCharacter,
  9697. skip,
  9698. skipWhitespace,
  9699. skipSpaces,
  9700. skipToLineEnd,
  9701. skipEverythingButNewLine,
  9702. skipInlineComment,
  9703. skipTrailingComment,
  9704. skipNewline: skipNewline$1,
  9705. isNextLineEmptyAfterIndex,
  9706. isNextLineEmpty,
  9707. isPreviousLineEmpty: isPreviousLineEmpty$1,
  9708. hasNewline: hasNewline$1,
  9709. hasNewlineInRange,
  9710. hasSpaces,
  9711. setLocStart,
  9712. setLocEnd,
  9713. startsWithNoLookaheadToken,
  9714. getAlignmentSize,
  9715. getIndentSize,
  9716. getPreferredQuote,
  9717. printString,
  9718. printNumber,
  9719. hasIgnoreComment,
  9720. hasNodeIgnoreComment,
  9721. makeString,
  9722. matchAncestorTypes,
  9723. addLeadingComment: addLeadingComment$1,
  9724. addDanglingComment: addDanglingComment$1,
  9725. addTrailingComment: addTrailingComment$1,
  9726. isWithinParentArrayProperty
  9727. };
  9728. function guessEndOfLine$1(text) {
  9729. var index = text.indexOf("\r");
  9730. if (index >= 0) {
  9731. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  9732. }
  9733. return "lf";
  9734. }
  9735. function convertEndOfLineToChars$2(value) {
  9736. switch (value) {
  9737. case "cr":
  9738. return "\r";
  9739. case "crlf":
  9740. return "\r\n";
  9741. default:
  9742. return "\n";
  9743. }
  9744. }
  9745. var endOfLine = {
  9746. guessEndOfLine: guessEndOfLine$1,
  9747. convertEndOfLineToChars: convertEndOfLineToChars$2
  9748. };
  9749. var getStringWidth = util$1.getStringWidth;
  9750. var convertEndOfLineToChars$1 = endOfLine.convertEndOfLineToChars;
  9751. var concat$2 = docBuilders.concat;
  9752. var fill$1 = docBuilders.fill;
  9753. var cursor$2 = docBuilders.cursor;
  9754. /** @type {{[groupId: PropertyKey]: MODE}} */
  9755. var groupModeMap;
  9756. var MODE_BREAK = 1;
  9757. var MODE_FLAT = 2;
  9758. function rootIndent() {
  9759. return {
  9760. value: "",
  9761. length: 0,
  9762. queue: []
  9763. };
  9764. }
  9765. function makeIndent(ind, options) {
  9766. return generateInd(ind, {
  9767. type: "indent"
  9768. }, options);
  9769. }
  9770. function makeAlign(ind, n, options) {
  9771. return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
  9772. type: "dedent"
  9773. }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
  9774. root: ind
  9775. }) : typeof n === "string" ? generateInd(ind, {
  9776. type: "stringAlign",
  9777. n
  9778. }, options) : generateInd(ind, {
  9779. type: "numberAlign",
  9780. n
  9781. }, options);
  9782. }
  9783. function generateInd(ind, newPart, options) {
  9784. var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
  9785. var value = "";
  9786. var length = 0;
  9787. var lastTabs = 0;
  9788. var lastSpaces = 0;
  9789. var _iteratorNormalCompletion = true;
  9790. var _didIteratorError = false;
  9791. var _iteratorError = undefined;
  9792. try {
  9793. for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9794. var part = _step.value;
  9795. switch (part.type) {
  9796. case "indent":
  9797. flush();
  9798. if (options.useTabs) {
  9799. addTabs(1);
  9800. } else {
  9801. addSpaces(options.tabWidth);
  9802. }
  9803. break;
  9804. case "stringAlign":
  9805. flush();
  9806. value += part.n;
  9807. length += part.n.length;
  9808. break;
  9809. case "numberAlign":
  9810. lastTabs += 1;
  9811. lastSpaces += part.n;
  9812. break;
  9813. /* istanbul ignore next */
  9814. default:
  9815. throw new Error(`Unexpected type '${part.type}'`);
  9816. }
  9817. }
  9818. } catch (err) {
  9819. _didIteratorError = true;
  9820. _iteratorError = err;
  9821. } finally {
  9822. try {
  9823. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9824. _iterator.return();
  9825. }
  9826. } finally {
  9827. if (_didIteratorError) {
  9828. throw _iteratorError;
  9829. }
  9830. }
  9831. }
  9832. flushSpaces();
  9833. return Object.assign({}, ind, {
  9834. value,
  9835. length,
  9836. queue
  9837. });
  9838. function addTabs(count) {
  9839. value += "\t".repeat(count);
  9840. length += options.tabWidth * count;
  9841. }
  9842. function addSpaces(count) {
  9843. value += " ".repeat(count);
  9844. length += count;
  9845. }
  9846. function flush() {
  9847. if (options.useTabs) {
  9848. flushTabs();
  9849. } else {
  9850. flushSpaces();
  9851. }
  9852. }
  9853. function flushTabs() {
  9854. if (lastTabs > 0) {
  9855. addTabs(lastTabs);
  9856. }
  9857. resetLast();
  9858. }
  9859. function flushSpaces() {
  9860. if (lastSpaces > 0) {
  9861. addSpaces(lastSpaces);
  9862. }
  9863. resetLast();
  9864. }
  9865. function resetLast() {
  9866. lastTabs = 0;
  9867. lastSpaces = 0;
  9868. }
  9869. }
  9870. function trim$1(out) {
  9871. if (out.length === 0) {
  9872. return 0;
  9873. }
  9874. var trimCount = 0; // Trim whitespace at the end of line
  9875. while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) {
  9876. trimCount += out.pop().length;
  9877. }
  9878. if (out.length && typeof out[out.length - 1] === "string") {
  9879. var trimmed = out[out.length - 1].replace(/[ \t]*$/, "");
  9880. trimCount += out[out.length - 1].length - trimmed.length;
  9881. out[out.length - 1] = trimmed;
  9882. }
  9883. return trimCount;
  9884. }
  9885. function fits(next, restCommands, width, options, mustBeFlat) {
  9886. var restIdx = restCommands.length;
  9887. var cmds = [next]; // `out` is only used for width counting because `trim` requires to look
  9888. // backwards for space characters.
  9889. var out = [];
  9890. while (width >= 0) {
  9891. if (cmds.length === 0) {
  9892. if (restIdx === 0) {
  9893. return true;
  9894. }
  9895. cmds.push(restCommands[restIdx - 1]);
  9896. restIdx--;
  9897. continue;
  9898. }
  9899. var x = cmds.pop();
  9900. var ind = x[0];
  9901. var mode = x[1];
  9902. var doc = x[2];
  9903. if (typeof doc === "string") {
  9904. out.push(doc);
  9905. width -= getStringWidth(doc);
  9906. } else {
  9907. switch (doc.type) {
  9908. case "concat":
  9909. for (var i = doc.parts.length - 1; i >= 0; i--) {
  9910. cmds.push([ind, mode, doc.parts[i]]);
  9911. }
  9912. break;
  9913. case "indent":
  9914. cmds.push([makeIndent(ind, options), mode, doc.contents]);
  9915. break;
  9916. case "align":
  9917. cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
  9918. break;
  9919. case "trim":
  9920. width += trim$1(out);
  9921. break;
  9922. case "group":
  9923. if (mustBeFlat && doc.break) {
  9924. return false;
  9925. }
  9926. cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
  9927. if (doc.id) {
  9928. groupModeMap[doc.id] = cmds[cmds.length - 1][1];
  9929. }
  9930. break;
  9931. case "fill":
  9932. for (var _i = doc.parts.length - 1; _i >= 0; _i--) {
  9933. cmds.push([ind, mode, doc.parts[_i]]);
  9934. }
  9935. break;
  9936. case "if-break":
  9937. {
  9938. var groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
  9939. if (groupMode === MODE_BREAK) {
  9940. if (doc.breakContents) {
  9941. cmds.push([ind, mode, doc.breakContents]);
  9942. }
  9943. }
  9944. if (groupMode === MODE_FLAT) {
  9945. if (doc.flatContents) {
  9946. cmds.push([ind, mode, doc.flatContents]);
  9947. }
  9948. }
  9949. break;
  9950. }
  9951. case "line":
  9952. switch (mode) {
  9953. // fallthrough
  9954. case MODE_FLAT:
  9955. if (!doc.hard) {
  9956. if (!doc.soft) {
  9957. out.push(" ");
  9958. width -= 1;
  9959. }
  9960. break;
  9961. }
  9962. return true;
  9963. case MODE_BREAK:
  9964. return true;
  9965. }
  9966. break;
  9967. }
  9968. }
  9969. }
  9970. return false;
  9971. }
  9972. function printDocToString$1(doc, options) {
  9973. groupModeMap = {};
  9974. var width = options.printWidth;
  9975. var newLine = convertEndOfLineToChars$1(options.endOfLine);
  9976. var pos = 0; // cmds is basically a stack. We've turned a recursive call into a
  9977. // while loop which is much faster. The while loop below adds new
  9978. // cmds to the array instead of recursively calling `print`.
  9979. var cmds = [[rootIndent(), MODE_BREAK, doc]];
  9980. var out = [];
  9981. var shouldRemeasure = false;
  9982. var lineSuffix = [];
  9983. while (cmds.length !== 0) {
  9984. var x = cmds.pop();
  9985. var ind = x[0];
  9986. var mode = x[1];
  9987. var _doc = x[2];
  9988. if (typeof _doc === "string") {
  9989. out.push(_doc);
  9990. pos += getStringWidth(_doc);
  9991. } else {
  9992. switch (_doc.type) {
  9993. case "cursor":
  9994. out.push(cursor$2.placeholder);
  9995. break;
  9996. case "concat":
  9997. for (var i = _doc.parts.length - 1; i >= 0; i--) {
  9998. cmds.push([ind, mode, _doc.parts[i]]);
  9999. }
  10000. break;
  10001. case "indent":
  10002. cmds.push([makeIndent(ind, options), mode, _doc.contents]);
  10003. break;
  10004. case "align":
  10005. cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]);
  10006. break;
  10007. case "trim":
  10008. pos -= trim$1(out);
  10009. break;
  10010. case "group":
  10011. switch (mode) {
  10012. case MODE_FLAT:
  10013. if (!shouldRemeasure) {
  10014. cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]);
  10015. break;
  10016. }
  10017. // fallthrough
  10018. case MODE_BREAK:
  10019. {
  10020. shouldRemeasure = false;
  10021. var next = [ind, MODE_FLAT, _doc.contents];
  10022. var rem = width - pos;
  10023. if (!_doc.break && fits(next, cmds, rem, options)) {
  10024. cmds.push(next);
  10025. } else {
  10026. // Expanded states are a rare case where a document
  10027. // can manually provide multiple representations of
  10028. // itself. It provides an array of documents
  10029. // going from the least expanded (most flattened)
  10030. // representation first to the most expanded. If a
  10031. // group has these, we need to manually go through
  10032. // these states and find the first one that fits.
  10033. if (_doc.expandedStates) {
  10034. var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1];
  10035. if (_doc.break) {
  10036. cmds.push([ind, MODE_BREAK, mostExpanded]);
  10037. break;
  10038. } else {
  10039. for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) {
  10040. if (_i2 >= _doc.expandedStates.length) {
  10041. cmds.push([ind, MODE_BREAK, mostExpanded]);
  10042. break;
  10043. } else {
  10044. var state = _doc.expandedStates[_i2];
  10045. var cmd = [ind, MODE_FLAT, state];
  10046. if (fits(cmd, cmds, rem, options)) {
  10047. cmds.push(cmd);
  10048. break;
  10049. }
  10050. }
  10051. }
  10052. }
  10053. } else {
  10054. cmds.push([ind, MODE_BREAK, _doc.contents]);
  10055. }
  10056. }
  10057. break;
  10058. }
  10059. }
  10060. if (_doc.id) {
  10061. groupModeMap[_doc.id] = cmds[cmds.length - 1][1];
  10062. }
  10063. break;
  10064. // Fills each line with as much code as possible before moving to a new
  10065. // line with the same indentation.
  10066. //
  10067. // Expects doc.parts to be an array of alternating content and
  10068. // whitespace. The whitespace contains the linebreaks.
  10069. //
  10070. // For example:
  10071. // ["I", line, "love", line, "monkeys"]
  10072. // or
  10073. // [{ type: group, ... }, softline, { type: group, ... }]
  10074. //
  10075. // It uses this parts structure to handle three main layout cases:
  10076. // * The first two content items fit on the same line without
  10077. // breaking
  10078. // -> output the first content item and the whitespace "flat".
  10079. // * Only the first content item fits on the line without breaking
  10080. // -> output the first content item "flat" and the whitespace with
  10081. // "break".
  10082. // * Neither content item fits on the line without breaking
  10083. // -> output the first content item and the whitespace with "break".
  10084. case "fill":
  10085. {
  10086. var _rem = width - pos;
  10087. var parts = _doc.parts;
  10088. if (parts.length === 0) {
  10089. break;
  10090. }
  10091. var content = parts[0];
  10092. var contentFlatCmd = [ind, MODE_FLAT, content];
  10093. var contentBreakCmd = [ind, MODE_BREAK, content];
  10094. var contentFits = fits(contentFlatCmd, [], _rem, options, true);
  10095. if (parts.length === 1) {
  10096. if (contentFits) {
  10097. cmds.push(contentFlatCmd);
  10098. } else {
  10099. cmds.push(contentBreakCmd);
  10100. }
  10101. break;
  10102. }
  10103. var whitespace = parts[1];
  10104. var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
  10105. var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
  10106. if (parts.length === 2) {
  10107. if (contentFits) {
  10108. cmds.push(whitespaceFlatCmd);
  10109. cmds.push(contentFlatCmd);
  10110. } else {
  10111. cmds.push(whitespaceBreakCmd);
  10112. cmds.push(contentBreakCmd);
  10113. }
  10114. break;
  10115. } // At this point we've handled the first pair (context, separator)
  10116. // and will create a new fill doc for the rest of the content.
  10117. // Ideally we wouldn't mutate the array here but coping all the
  10118. // elements to a new array would make this algorithm quadratic,
  10119. // which is unusable for large arrays (e.g. large texts in JSX).
  10120. parts.splice(0, 2);
  10121. var remainingCmd = [ind, mode, fill$1(parts)];
  10122. var secondContent = parts[0];
  10123. var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$2([content, whitespace, secondContent])];
  10124. var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true);
  10125. if (firstAndSecondContentFits) {
  10126. cmds.push(remainingCmd);
  10127. cmds.push(whitespaceFlatCmd);
  10128. cmds.push(contentFlatCmd);
  10129. } else if (contentFits) {
  10130. cmds.push(remainingCmd);
  10131. cmds.push(whitespaceBreakCmd);
  10132. cmds.push(contentFlatCmd);
  10133. } else {
  10134. cmds.push(remainingCmd);
  10135. cmds.push(whitespaceBreakCmd);
  10136. cmds.push(contentBreakCmd);
  10137. }
  10138. break;
  10139. }
  10140. case "if-break":
  10141. {
  10142. var groupMode = _doc.groupId ? groupModeMap[_doc.groupId] : mode;
  10143. if (groupMode === MODE_BREAK) {
  10144. if (_doc.breakContents) {
  10145. cmds.push([ind, mode, _doc.breakContents]);
  10146. }
  10147. }
  10148. if (groupMode === MODE_FLAT) {
  10149. if (_doc.flatContents) {
  10150. cmds.push([ind, mode, _doc.flatContents]);
  10151. }
  10152. }
  10153. break;
  10154. }
  10155. case "line-suffix":
  10156. lineSuffix.push([ind, mode, _doc.contents]);
  10157. break;
  10158. case "line-suffix-boundary":
  10159. if (lineSuffix.length > 0) {
  10160. cmds.push([ind, mode, {
  10161. type: "line",
  10162. hard: true
  10163. }]);
  10164. }
  10165. break;
  10166. case "line":
  10167. switch (mode) {
  10168. case MODE_FLAT:
  10169. if (!_doc.hard) {
  10170. if (!_doc.soft) {
  10171. out.push(" ");
  10172. pos += 1;
  10173. }
  10174. break;
  10175. } else {
  10176. // This line was forced into the output even if we
  10177. // were in flattened mode, so we need to tell the next
  10178. // group that no matter what, it needs to remeasure
  10179. // because the previous measurement didn't accurately
  10180. // capture the entire expression (this is necessary
  10181. // for nested groups)
  10182. shouldRemeasure = true;
  10183. }
  10184. // fallthrough
  10185. case MODE_BREAK:
  10186. if (lineSuffix.length) {
  10187. cmds.push([ind, mode, _doc]);
  10188. [].push.apply(cmds, lineSuffix.reverse());
  10189. lineSuffix = [];
  10190. break;
  10191. }
  10192. if (_doc.literal) {
  10193. if (ind.root) {
  10194. out.push(newLine, ind.root.value);
  10195. pos = ind.root.length;
  10196. } else {
  10197. out.push(newLine);
  10198. pos = 0;
  10199. }
  10200. } else {
  10201. pos -= trim$1(out);
  10202. out.push(newLine + ind.value);
  10203. pos = ind.length;
  10204. }
  10205. break;
  10206. }
  10207. break;
  10208. default:
  10209. }
  10210. }
  10211. }
  10212. var cursorPlaceholderIndex = out.indexOf(cursor$2.placeholder);
  10213. if (cursorPlaceholderIndex !== -1) {
  10214. var otherCursorPlaceholderIndex = out.indexOf(cursor$2.placeholder, cursorPlaceholderIndex + 1);
  10215. var beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  10216. var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  10217. var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  10218. return {
  10219. formatted: beforeCursor + aroundCursor + afterCursor,
  10220. cursorNodeStart: beforeCursor.length,
  10221. cursorNodeText: aroundCursor
  10222. };
  10223. }
  10224. return {
  10225. formatted: out.join("")
  10226. };
  10227. }
  10228. var docPrinter = {
  10229. printDocToString: printDocToString$1
  10230. };
  10231. var traverseDocOnExitStackMarker = {};
  10232. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  10233. var docsStack = [doc];
  10234. while (docsStack.length !== 0) {
  10235. var _doc = docsStack.pop();
  10236. if (_doc === traverseDocOnExitStackMarker) {
  10237. onExit(docsStack.pop());
  10238. continue;
  10239. }
  10240. var shouldRecurse = true;
  10241. if (onEnter) {
  10242. if (onEnter(_doc) === false) {
  10243. shouldRecurse = false;
  10244. }
  10245. }
  10246. if (onExit) {
  10247. docsStack.push(_doc);
  10248. docsStack.push(traverseDocOnExitStackMarker);
  10249. }
  10250. if (shouldRecurse) {
  10251. // When there are multiple parts to process,
  10252. // the parts need to be pushed onto the stack in reverse order,
  10253. // so that they are processed in the original order
  10254. // when the stack is popped.
  10255. if (_doc.type === "concat" || _doc.type === "fill") {
  10256. for (var ic = _doc.parts.length, i = ic - 1; i >= 0; --i) {
  10257. docsStack.push(_doc.parts[i]);
  10258. }
  10259. } else if (_doc.type === "if-break") {
  10260. if (_doc.flatContents) {
  10261. docsStack.push(_doc.flatContents);
  10262. }
  10263. if (_doc.breakContents) {
  10264. docsStack.push(_doc.breakContents);
  10265. }
  10266. } else if (_doc.type === "group" && _doc.expandedStates) {
  10267. if (shouldTraverseConditionalGroups) {
  10268. for (var _ic = _doc.expandedStates.length, _i = _ic - 1; _i >= 0; --_i) {
  10269. docsStack.push(_doc.expandedStates[_i]);
  10270. }
  10271. } else {
  10272. docsStack.push(_doc.contents);
  10273. }
  10274. } else if (_doc.contents) {
  10275. docsStack.push(_doc.contents);
  10276. }
  10277. }
  10278. }
  10279. }
  10280. function mapDoc$1(doc, cb) {
  10281. if (doc.type === "concat" || doc.type === "fill") {
  10282. var parts = doc.parts.map(function (part) {
  10283. return mapDoc$1(part, cb);
  10284. });
  10285. return cb(Object.assign({}, doc, {
  10286. parts
  10287. }));
  10288. } else if (doc.type === "if-break") {
  10289. var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
  10290. var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
  10291. return cb(Object.assign({}, doc, {
  10292. breakContents,
  10293. flatContents
  10294. }));
  10295. } else if (doc.contents) {
  10296. var contents = mapDoc$1(doc.contents, cb);
  10297. return cb(Object.assign({}, doc, {
  10298. contents
  10299. }));
  10300. }
  10301. return cb(doc);
  10302. }
  10303. function findInDoc(doc, fn, defaultValue) {
  10304. var result = defaultValue;
  10305. var hasStopped = false;
  10306. function findInDocOnEnterFn(doc) {
  10307. var maybeResult = fn(doc);
  10308. if (maybeResult !== undefined) {
  10309. hasStopped = true;
  10310. result = maybeResult;
  10311. }
  10312. if (hasStopped) {
  10313. return false;
  10314. }
  10315. }
  10316. traverseDoc(doc, findInDocOnEnterFn);
  10317. return result;
  10318. }
  10319. function isEmpty(n) {
  10320. return typeof n === "string" && n.length === 0;
  10321. }
  10322. function isLineNextFn(doc) {
  10323. if (typeof doc === "string") {
  10324. return false;
  10325. }
  10326. if (doc.type === "line") {
  10327. return true;
  10328. }
  10329. }
  10330. function isLineNext(doc) {
  10331. return findInDoc(doc, isLineNextFn, false);
  10332. }
  10333. function willBreakFn(doc) {
  10334. if (doc.type === "group" && doc.break) {
  10335. return true;
  10336. }
  10337. if (doc.type === "line" && doc.hard) {
  10338. return true;
  10339. }
  10340. if (doc.type === "break-parent") {
  10341. return true;
  10342. }
  10343. }
  10344. function willBreak(doc) {
  10345. return findInDoc(doc, willBreakFn, false);
  10346. }
  10347. function breakParentGroup(groupStack) {
  10348. if (groupStack.length > 0) {
  10349. var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
  10350. // the user is expected to manually handle what breaks.
  10351. if (!parentGroup.expandedStates) {
  10352. parentGroup.break = true;
  10353. }
  10354. }
  10355. return null;
  10356. }
  10357. function propagateBreaks(doc) {
  10358. var alreadyVisitedSet = new Set();
  10359. var groupStack = [];
  10360. function propagateBreaksOnEnterFn(doc) {
  10361. if (doc.type === "break-parent") {
  10362. breakParentGroup(groupStack);
  10363. }
  10364. if (doc.type === "group") {
  10365. groupStack.push(doc);
  10366. if (alreadyVisitedSet.has(doc)) {
  10367. return false;
  10368. }
  10369. alreadyVisitedSet.add(doc);
  10370. }
  10371. }
  10372. function propagateBreaksOnExitFn(doc) {
  10373. if (doc.type === "group") {
  10374. var group = groupStack.pop();
  10375. if (group.break) {
  10376. breakParentGroup(groupStack);
  10377. }
  10378. }
  10379. }
  10380. traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
  10381. /* shouldTraverseConditionalGroups */
  10382. true);
  10383. }
  10384. function removeLinesFn(doc) {
  10385. // Force this doc into flat mode by statically converting all
  10386. // lines into spaces (or soft lines into nothing). Hard lines
  10387. // should still output because there's too great of a chance
  10388. // of breaking existing assumptions otherwise.
  10389. if (doc.type === "line" && !doc.hard) {
  10390. return doc.soft ? "" : " ";
  10391. } else if (doc.type === "if-break") {
  10392. return doc.flatContents || "";
  10393. }
  10394. return doc;
  10395. }
  10396. function removeLines(doc) {
  10397. return mapDoc$1(doc, removeLinesFn);
  10398. }
  10399. function stripTrailingHardline(doc) {
  10400. // HACK remove ending hardline, original PR: #1984
  10401. if (doc.type === "concat" && doc.parts.length !== 0) {
  10402. var lastPart = doc.parts[doc.parts.length - 1];
  10403. if (lastPart.type === "concat") {
  10404. if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
  10405. return {
  10406. type: "concat",
  10407. parts: doc.parts.slice(0, -1)
  10408. };
  10409. }
  10410. return {
  10411. type: "concat",
  10412. parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
  10413. };
  10414. }
  10415. }
  10416. return doc;
  10417. }
  10418. var docUtils = {
  10419. isEmpty,
  10420. willBreak,
  10421. isLineNext,
  10422. traverseDoc,
  10423. findInDoc,
  10424. mapDoc: mapDoc$1,
  10425. propagateBreaks,
  10426. removeLines,
  10427. stripTrailingHardline
  10428. };
  10429. function flattenDoc(doc) {
  10430. if (doc.type === "concat") {
  10431. var res = [];
  10432. for (var i = 0; i < doc.parts.length; ++i) {
  10433. var doc2 = doc.parts[i];
  10434. if (typeof doc2 !== "string" && doc2.type === "concat") {
  10435. [].push.apply(res, flattenDoc(doc2).parts);
  10436. } else {
  10437. var flattened = flattenDoc(doc2);
  10438. if (flattened !== "") {
  10439. res.push(flattened);
  10440. }
  10441. }
  10442. }
  10443. return Object.assign({}, doc, {
  10444. parts: res
  10445. });
  10446. } else if (doc.type === "if-break") {
  10447. return Object.assign({}, doc, {
  10448. breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
  10449. flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
  10450. });
  10451. } else if (doc.type === "group") {
  10452. return Object.assign({}, doc, {
  10453. contents: flattenDoc(doc.contents),
  10454. expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
  10455. });
  10456. } else if (doc.contents) {
  10457. return Object.assign({}, doc, {
  10458. contents: flattenDoc(doc.contents)
  10459. });
  10460. }
  10461. return doc;
  10462. }
  10463. function printDoc(doc) {
  10464. if (typeof doc === "string") {
  10465. return JSON.stringify(doc);
  10466. }
  10467. if (doc.type === "line") {
  10468. if (doc.literal) {
  10469. return "literalline";
  10470. }
  10471. if (doc.hard) {
  10472. return "hardline";
  10473. }
  10474. if (doc.soft) {
  10475. return "softline";
  10476. }
  10477. return "line";
  10478. }
  10479. if (doc.type === "break-parent") {
  10480. return "breakParent";
  10481. }
  10482. if (doc.type === "trim") {
  10483. return "trim";
  10484. }
  10485. if (doc.type === "concat") {
  10486. return "[" + doc.parts.map(printDoc).join(", ") + "]";
  10487. }
  10488. if (doc.type === "indent") {
  10489. return "indent(" + printDoc(doc.contents) + ")";
  10490. }
  10491. if (doc.type === "align") {
  10492. return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
  10493. }
  10494. if (doc.type === "if-break") {
  10495. return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
  10496. }
  10497. if (doc.type === "group") {
  10498. if (doc.expandedStates) {
  10499. return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
  10500. }
  10501. return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
  10502. }
  10503. if (doc.type === "fill") {
  10504. return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
  10505. }
  10506. if (doc.type === "line-suffix") {
  10507. return "lineSuffix(" + printDoc(doc.contents) + ")";
  10508. }
  10509. if (doc.type === "line-suffix-boundary") {
  10510. return "lineSuffixBoundary";
  10511. }
  10512. throw new Error("Unknown doc type " + doc.type);
  10513. }
  10514. var docDebug = {
  10515. printDocToDebug: function printDocToDebug(doc) {
  10516. return printDoc(flattenDoc(doc));
  10517. }
  10518. };
  10519. var doc = {
  10520. builders: docBuilders,
  10521. printer: docPrinter,
  10522. utils: docUtils,
  10523. debug: docDebug
  10524. };
  10525. var mapDoc$2 = doc.utils.mapDoc;
  10526. function isNextLineEmpty$1(text, node, options) {
  10527. return util$1.isNextLineEmpty(text, node, options.locEnd);
  10528. }
  10529. function isPreviousLineEmpty$2(text, node, options) {
  10530. return util$1.isPreviousLineEmpty(text, node, options.locStart);
  10531. }
  10532. function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) {
  10533. return util$1.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd);
  10534. }
  10535. var utilShared = {
  10536. getMaxContinuousCount: util$1.getMaxContinuousCount,
  10537. getStringWidth: util$1.getStringWidth,
  10538. getAlignmentSize: util$1.getAlignmentSize,
  10539. getIndentSize: util$1.getIndentSize,
  10540. skip: util$1.skip,
  10541. skipWhitespace: util$1.skipWhitespace,
  10542. skipSpaces: util$1.skipSpaces,
  10543. skipNewline: util$1.skipNewline,
  10544. skipToLineEnd: util$1.skipToLineEnd,
  10545. skipEverythingButNewLine: util$1.skipEverythingButNewLine,
  10546. skipInlineComment: util$1.skipInlineComment,
  10547. skipTrailingComment: util$1.skipTrailingComment,
  10548. hasNewline: util$1.hasNewline,
  10549. hasNewlineInRange: util$1.hasNewlineInRange,
  10550. hasSpaces: util$1.hasSpaces,
  10551. isNextLineEmpty: isNextLineEmpty$1,
  10552. isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
  10553. isPreviousLineEmpty: isPreviousLineEmpty$2,
  10554. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
  10555. mapDoc: mapDoc$2,
  10556. // TODO: remove in 2.0, we already exposed it in docUtils
  10557. makeString: util$1.makeString,
  10558. addLeadingComment: util$1.addLeadingComment,
  10559. addDanglingComment: util$1.addDanglingComment,
  10560. addTrailingComment: util$1.addTrailingComment
  10561. };
  10562. var _require$$0$builders = doc.builders;
  10563. var concat = _require$$0$builders.concat;
  10564. var hardline = _require$$0$builders.hardline;
  10565. var breakParent = _require$$0$builders.breakParent;
  10566. var indent = _require$$0$builders.indent;
  10567. var lineSuffix = _require$$0$builders.lineSuffix;
  10568. var join = _require$$0$builders.join;
  10569. var cursor = _require$$0$builders.cursor;
  10570. var hasNewline = util$1.hasNewline;
  10571. var skipNewline = util$1.skipNewline;
  10572. var isPreviousLineEmpty = util$1.isPreviousLineEmpty;
  10573. var addLeadingComment = utilShared.addLeadingComment;
  10574. var addDanglingComment = utilShared.addDanglingComment;
  10575. var addTrailingComment = utilShared.addTrailingComment;
  10576. var childNodesCacheKey = Symbol("child-nodes");
  10577. function getSortedChildNodes(node, options, resultArray) {
  10578. if (!node) {
  10579. return;
  10580. }
  10581. var printer = options.printer,
  10582. locStart = options.locStart,
  10583. locEnd = options.locEnd;
  10584. if (resultArray) {
  10585. if (node && printer.canAttachComment && printer.canAttachComment(node)) {
  10586. // This reverse insertion sort almost always takes constant
  10587. // time because we almost always (maybe always?) append the
  10588. // nodes in order anyway.
  10589. var i;
  10590. for (i = resultArray.length - 1; i >= 0; --i) {
  10591. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  10592. break;
  10593. }
  10594. }
  10595. resultArray.splice(i + 1, 0, node);
  10596. return;
  10597. }
  10598. } else if (node[childNodesCacheKey]) {
  10599. return node[childNodesCacheKey];
  10600. }
  10601. var childNodes;
  10602. if (printer.getCommentChildNodes) {
  10603. childNodes = printer.getCommentChildNodes(node);
  10604. } else if (node && typeof node === "object") {
  10605. childNodes = Object.keys(node).filter(function (n) {
  10606. return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode";
  10607. }).map(function (n) {
  10608. return node[n];
  10609. });
  10610. }
  10611. if (!childNodes) {
  10612. return;
  10613. }
  10614. if (!resultArray) {
  10615. Object.defineProperty(node, childNodesCacheKey, {
  10616. value: resultArray = [],
  10617. enumerable: false
  10618. });
  10619. }
  10620. childNodes.forEach(function (childNode) {
  10621. getSortedChildNodes(childNode, options, resultArray);
  10622. });
  10623. return resultArray;
  10624. } // As efficiently as possible, decorate the comment object with
  10625. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  10626. // least one of which is guaranteed to be defined.
  10627. function decorateComment(node, comment, options) {
  10628. var locStart = options.locStart,
  10629. locEnd = options.locEnd;
  10630. var childNodes = getSortedChildNodes(node, options);
  10631. var precedingNode;
  10632. var followingNode; // Time to dust off the old binary search robes and wizard hat.
  10633. var left = 0;
  10634. var right = childNodes.length;
  10635. while (left < right) {
  10636. var middle = left + right >> 1;
  10637. var child = childNodes[middle];
  10638. if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
  10639. // The comment is completely contained by this child node.
  10640. comment.enclosingNode = child;
  10641. decorateComment(child, comment, options);
  10642. return; // Abandon the binary search at this level.
  10643. }
  10644. if (locEnd(child) - locStart(comment) <= 0) {
  10645. // This child node falls completely before the comment.
  10646. // Because we will never consider this node or any nodes
  10647. // before it again, this node must be the closest preceding
  10648. // node we have encountered so far.
  10649. precedingNode = child;
  10650. left = middle + 1;
  10651. continue;
  10652. }
  10653. if (locEnd(comment) - locStart(child) <= 0) {
  10654. // This child node falls completely after the comment.
  10655. // Because we will never consider this node or any nodes after
  10656. // it again, this node must be the closest following node we
  10657. // have encountered so far.
  10658. followingNode = child;
  10659. right = middle;
  10660. continue;
  10661. }
  10662. /* istanbul ignore next */
  10663. throw new Error("Comment location overlaps with node location");
  10664. } // We don't want comments inside of different expressions inside of the same
  10665. // template literal to move to another expression.
  10666. if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
  10667. var quasis = comment.enclosingNode.quasis;
  10668. var commentIndex = findExpressionIndexForComment(quasis, comment, options);
  10669. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  10670. precedingNode = null;
  10671. }
  10672. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  10673. followingNode = null;
  10674. }
  10675. }
  10676. if (precedingNode) {
  10677. comment.precedingNode = precedingNode;
  10678. }
  10679. if (followingNode) {
  10680. comment.followingNode = followingNode;
  10681. }
  10682. }
  10683. function attach(comments, ast, text, options) {
  10684. if (!Array.isArray(comments)) {
  10685. return;
  10686. }
  10687. var tiesToBreak = [];
  10688. var locStart = options.locStart,
  10689. locEnd = options.locEnd;
  10690. comments.forEach(function (comment, i) {
  10691. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  10692. if (locStart(comment) - locStart(ast) <= 0) {
  10693. addLeadingComment(ast, comment);
  10694. return;
  10695. }
  10696. if (locEnd(comment) - locEnd(ast) >= 0) {
  10697. addTrailingComment(ast, comment);
  10698. return;
  10699. }
  10700. }
  10701. decorateComment(ast, comment, options);
  10702. var precedingNode = comment.precedingNode,
  10703. enclosingNode = comment.enclosingNode,
  10704. followingNode = comment.followingNode;
  10705. var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () {
  10706. return false;
  10707. };
  10708. var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () {
  10709. return false;
  10710. };
  10711. var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () {
  10712. return false;
  10713. };
  10714. var isLastComment = comments.length - 1 === i;
  10715. if (hasNewline(text, locStart(comment), {
  10716. backwards: true
  10717. })) {
  10718. // If a comment exists on its own line, prefer a leading comment.
  10719. // We also need to check if it's the first line of the file.
  10720. if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) {// We're good
  10721. } else if (followingNode) {
  10722. // Always a leading comment.
  10723. addLeadingComment(followingNode, comment);
  10724. } else if (precedingNode) {
  10725. addTrailingComment(precedingNode, comment);
  10726. } else if (enclosingNode) {
  10727. addDanglingComment(enclosingNode, comment);
  10728. } else {
  10729. // There are no nodes, let's attach it to the root of the ast
  10730. /* istanbul ignore next */
  10731. addDanglingComment(ast, comment);
  10732. }
  10733. } else if (hasNewline(text, locEnd(comment))) {
  10734. if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) {// We're good
  10735. } else if (precedingNode) {
  10736. // There is content before this comment on the same line, but
  10737. // none after it, so prefer a trailing comment of the previous node.
  10738. addTrailingComment(precedingNode, comment);
  10739. } else if (followingNode) {
  10740. addLeadingComment(followingNode, comment);
  10741. } else if (enclosingNode) {
  10742. addDanglingComment(enclosingNode, comment);
  10743. } else {
  10744. // There are no nodes, let's attach it to the root of the ast
  10745. /* istanbul ignore next */
  10746. addDanglingComment(ast, comment);
  10747. }
  10748. } else {
  10749. if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) {// We're good
  10750. } else if (precedingNode && followingNode) {
  10751. // Otherwise, text exists both before and after the comment on
  10752. // the same line. If there is both a preceding and following
  10753. // node, use a tie-breaking algorithm to determine if it should
  10754. // be attached to the next or previous node. In the last case,
  10755. // simply attach the right node;
  10756. var tieCount = tiesToBreak.length;
  10757. if (tieCount > 0) {
  10758. var lastTie = tiesToBreak[tieCount - 1];
  10759. if (lastTie.followingNode !== comment.followingNode) {
  10760. breakTies(tiesToBreak, text, options);
  10761. }
  10762. }
  10763. tiesToBreak.push(comment);
  10764. } else if (precedingNode) {
  10765. addTrailingComment(precedingNode, comment);
  10766. } else if (followingNode) {
  10767. addLeadingComment(followingNode, comment);
  10768. } else if (enclosingNode) {
  10769. addDanglingComment(enclosingNode, comment);
  10770. } else {
  10771. // There are no nodes, let's attach it to the root of the ast
  10772. /* istanbul ignore next */
  10773. addDanglingComment(ast, comment);
  10774. }
  10775. }
  10776. });
  10777. breakTies(tiesToBreak, text, options);
  10778. comments.forEach(function (comment) {
  10779. // These node references were useful for breaking ties, but we
  10780. // don't need them anymore, and they create cycles in the AST that
  10781. // may lead to infinite recursion if we don't delete them here.
  10782. delete comment.precedingNode;
  10783. delete comment.enclosingNode;
  10784. delete comment.followingNode;
  10785. });
  10786. }
  10787. function breakTies(tiesToBreak, text, options) {
  10788. var tieCount = tiesToBreak.length;
  10789. if (tieCount === 0) {
  10790. return;
  10791. }
  10792. var _tiesToBreak$ = tiesToBreak[0],
  10793. precedingNode = _tiesToBreak$.precedingNode,
  10794. followingNode = _tiesToBreak$.followingNode;
  10795. var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  10796. // between the tied comments. In order to qualify as leading, a
  10797. // comment must be separated from followingNode by an unbroken series of
  10798. // gaps (or other comments). Gaps should only contain whitespace or open
  10799. // parentheses.
  10800. var indexOfFirstLeadingComment;
  10801. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  10802. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  10803. assert.strictEqual(comment.precedingNode, precedingNode);
  10804. assert.strictEqual(comment.followingNode, followingNode);
  10805. var gap = text.slice(options.locEnd(comment), gapEndPos).trim();
  10806. if (gap === "" || /^\(+$/.test(gap)) {
  10807. gapEndPos = options.locStart(comment);
  10808. } else {
  10809. // The gap string contained something other than whitespace or open
  10810. // parentheses.
  10811. break;
  10812. }
  10813. }
  10814. tiesToBreak.forEach(function (comment, i) {
  10815. if (i < indexOfFirstLeadingComment) {
  10816. addTrailingComment(precedingNode, comment);
  10817. } else {
  10818. addLeadingComment(followingNode, comment);
  10819. }
  10820. });
  10821. tiesToBreak.length = 0;
  10822. }
  10823. function printComment(commentPath, options) {
  10824. var comment = commentPath.getValue();
  10825. comment.printed = true;
  10826. return options.printer.printComment(commentPath, options);
  10827. }
  10828. function findExpressionIndexForComment(quasis, comment, options) {
  10829. var startPos = options.locStart(comment) - 1;
  10830. for (var i = 1; i < quasis.length; ++i) {
  10831. if (startPos < getQuasiRange(quasis[i]).start) {
  10832. return i - 1;
  10833. }
  10834. } // We haven't found it, it probably means that some of the locations are off.
  10835. // Let's just return the first one.
  10836. /* istanbul ignore next */
  10837. return 0;
  10838. }
  10839. function getQuasiRange(expr) {
  10840. if (expr.start !== undefined) {
  10841. // Babel
  10842. return {
  10843. start: expr.start,
  10844. end: expr.end
  10845. };
  10846. } // Flow
  10847. return {
  10848. start: expr.range[0],
  10849. end: expr.range[1]
  10850. };
  10851. }
  10852. function printLeadingComment(commentPath, print, options) {
  10853. var comment = commentPath.getValue();
  10854. var contents = printComment(commentPath, options);
  10855. if (!contents) {
  10856. return "";
  10857. }
  10858. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  10859. // same line or not.
  10860. if (isBlock) {
  10861. return concat([contents, hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "]);
  10862. }
  10863. return concat([contents, hardline]);
  10864. }
  10865. function printTrailingComment(commentPath, print, options) {
  10866. var comment = commentPath.getValue();
  10867. var contents = printComment(commentPath, options);
  10868. if (!contents) {
  10869. return "";
  10870. }
  10871. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break
  10872. // when the parentParentNode is a ClassDeclaration/-Expression
  10873. // And the parentNode is in the superClass property
  10874. var parentNode = commentPath.getNode(1);
  10875. var parentParentNode = commentPath.getNode(2);
  10876. var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
  10877. if (hasNewline(options.originalText, options.locStart(comment), {
  10878. backwards: true
  10879. })) {
  10880. // This allows comments at the end of nested structures:
  10881. // {
  10882. // x: 1,
  10883. // y: 2
  10884. // // A comment
  10885. // }
  10886. // Those kinds of comments are almost always leading comments, but
  10887. // here it doesn't go "outside" the block and turns it into a
  10888. // trailing comment for `2`. We can simulate the above by checking
  10889. // if this a comment on its own line; normal trailing comments are
  10890. // always at the end of another expression.
  10891. var isLineBeforeEmpty = isPreviousLineEmpty(options.originalText, comment, options.locStart);
  10892. return lineSuffix(concat([hardline, isLineBeforeEmpty ? hardline : "", contents]));
  10893. } else if (isBlock || isParentSuperClass) {
  10894. // Trailing block comments never need a newline
  10895. return concat([" ", contents]);
  10896. }
  10897. return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
  10898. }
  10899. function printDanglingComments(path$$1, options, sameIndent, filter) {
  10900. var parts = [];
  10901. var node = path$$1.getValue();
  10902. if (!node || !node.comments) {
  10903. return "";
  10904. }
  10905. path$$1.each(function (commentPath) {
  10906. var comment = commentPath.getValue();
  10907. if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
  10908. parts.push(printComment(commentPath, options));
  10909. }
  10910. }, "comments");
  10911. if (parts.length === 0) {
  10912. return "";
  10913. }
  10914. if (sameIndent) {
  10915. return join(hardline, parts);
  10916. }
  10917. return indent(concat([hardline, join(hardline, parts)]));
  10918. }
  10919. function prependCursorPlaceholder(path$$1, options, printed) {
  10920. if (path$$1.getNode() === options.cursorNode && path$$1.getValue()) {
  10921. return concat([cursor, printed, cursor]);
  10922. }
  10923. return printed;
  10924. }
  10925. function printComments(path$$1, print, options, needsSemi) {
  10926. var value = path$$1.getValue();
  10927. var printed = print(path$$1);
  10928. var comments = value && value.comments;
  10929. if (!comments || comments.length === 0) {
  10930. return prependCursorPlaceholder(path$$1, options, printed);
  10931. }
  10932. var leadingParts = [];
  10933. var trailingParts = [needsSemi ? ";" : "", printed];
  10934. path$$1.each(function (commentPath) {
  10935. var comment = commentPath.getValue();
  10936. var leading = comment.leading,
  10937. trailing = comment.trailing;
  10938. if (leading) {
  10939. var contents = printLeadingComment(commentPath, print, options);
  10940. if (!contents) {
  10941. return;
  10942. }
  10943. leadingParts.push(contents);
  10944. var text = options.originalText;
  10945. if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
  10946. leadingParts.push(hardline);
  10947. }
  10948. } else if (trailing) {
  10949. trailingParts.push(printTrailingComment(commentPath, print, options));
  10950. }
  10951. }, "comments");
  10952. return prependCursorPlaceholder(path$$1, options, concat(leadingParts.concat(trailingParts)));
  10953. }
  10954. var comments = {
  10955. attach,
  10956. printComments,
  10957. printDanglingComments,
  10958. getSortedChildNodes
  10959. };
  10960. function FastPath(value) {
  10961. assert.ok(this instanceof FastPath);
  10962. this.stack = [value];
  10963. } // The name of the current property is always the penultimate element of
  10964. // this.stack, and always a String.
  10965. FastPath.prototype.getName = function getName() {
  10966. var s = this.stack;
  10967. var len = s.length;
  10968. if (len > 1) {
  10969. return s[len - 2];
  10970. } // Since the name is always a string, null is a safe sentinel value to
  10971. // return if we do not know the name of the (root) value.
  10972. /* istanbul ignore next */
  10973. return null;
  10974. }; // The value of the current property is always the final element of
  10975. // this.stack.
  10976. FastPath.prototype.getValue = function getValue() {
  10977. var s = this.stack;
  10978. return s[s.length - 1];
  10979. };
  10980. function getNodeHelper(path$$1, count) {
  10981. var stackIndex = getNodeStackIndexHelper(path$$1.stack, count);
  10982. return stackIndex === -1 ? null : path$$1.stack[stackIndex];
  10983. }
  10984. function getNodeStackIndexHelper(stack, count) {
  10985. for (var i = stack.length - 1; i >= 0; i -= 2) {
  10986. var value = stack[i];
  10987. if (value && !Array.isArray(value) && --count < 0) {
  10988. return i;
  10989. }
  10990. }
  10991. return -1;
  10992. }
  10993. FastPath.prototype.getNode = function getNode(count) {
  10994. return getNodeHelper(this, ~~count);
  10995. };
  10996. FastPath.prototype.getParentNode = function getParentNode(count) {
  10997. return getNodeHelper(this, ~~count + 1);
  10998. }; // Temporarily push properties named by string arguments given after the
  10999. // callback function onto this.stack, then call the callback with a
  11000. // reference to this (modified) FastPath object. Note that the stack will
  11001. // be restored to its original state after the callback is finished, so it
  11002. // is probably a mistake to retain a reference to the path.
  11003. FastPath.prototype.call = function call(callback
  11004. /*, name1, name2, ... */
  11005. ) {
  11006. var s = this.stack;
  11007. var origLen = s.length;
  11008. var value = s[origLen - 1];
  11009. var argc = arguments.length;
  11010. for (var i = 1; i < argc; ++i) {
  11011. var name = arguments[i];
  11012. value = value[name];
  11013. s.push(name, value);
  11014. }
  11015. var result = callback(this);
  11016. s.length = origLen;
  11017. return result;
  11018. };
  11019. FastPath.prototype.callParent = function callParent(callback, count) {
  11020. var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
  11021. var parentValues = this.stack.splice(stackIndex + 1);
  11022. var result = callback(this);
  11023. Array.prototype.push.apply(this.stack, parentValues);
  11024. return result;
  11025. }; // Similar to FastPath.prototype.call, except that the value obtained by
  11026. // accessing this.getValue()[name1][name2]... should be array-like. The
  11027. // callback will be called with a reference to this path object for each
  11028. // element of the array.
  11029. FastPath.prototype.each = function each(callback
  11030. /*, name1, name2, ... */
  11031. ) {
  11032. var s = this.stack;
  11033. var origLen = s.length;
  11034. var value = s[origLen - 1];
  11035. var argc = arguments.length;
  11036. for (var i = 1; i < argc; ++i) {
  11037. var name = arguments[i];
  11038. value = value[name];
  11039. s.push(name, value);
  11040. }
  11041. for (var _i = 0; _i < value.length; ++_i) {
  11042. if (_i in value) {
  11043. s.push(_i, value[_i]); // If the callback needs to know the value of i, call
  11044. // path.getName(), assuming path is the parameter name.
  11045. callback(this);
  11046. s.length -= 2;
  11047. }
  11048. }
  11049. s.length = origLen;
  11050. }; // Similar to FastPath.prototype.each, except that the results of the
  11051. // callback function invocations are stored in an array and returned at
  11052. // the end of the iteration.
  11053. FastPath.prototype.map = function map(callback
  11054. /*, name1, name2, ... */
  11055. ) {
  11056. var s = this.stack;
  11057. var origLen = s.length;
  11058. var value = s[origLen - 1];
  11059. var argc = arguments.length;
  11060. for (var i = 1; i < argc; ++i) {
  11061. var name = arguments[i];
  11062. value = value[name];
  11063. s.push(name, value);
  11064. }
  11065. var result = new Array(value.length);
  11066. for (var _i2 = 0; _i2 < value.length; ++_i2) {
  11067. if (_i2 in value) {
  11068. s.push(_i2, value[_i2]);
  11069. result[_i2] = callback(this, _i2);
  11070. s.length -= 2;
  11071. }
  11072. }
  11073. s.length = origLen;
  11074. return result;
  11075. };
  11076. var fastPath = FastPath;
  11077. var normalize$3 = options.normalize;
  11078. function printSubtree(path$$1, print, options$$1, printAstToDoc) {
  11079. if (options$$1.printer.embed) {
  11080. return options$$1.printer.embed(path$$1, print, function (text, partialNextOptions) {
  11081. return textToDoc(text, partialNextOptions, options$$1, printAstToDoc);
  11082. }, options$$1);
  11083. }
  11084. }
  11085. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
  11086. var nextOptions = normalize$3(Object.assign({}, parentOptions, partialNextOptions, {
  11087. parentParser: parentOptions.parser,
  11088. embeddedInHtml: !!(parentOptions.embeddedInHtml || parentOptions.parser === "html" || parentOptions.parser === "vue" || parentOptions.parser === "angular" || parentOptions.parser === "lwc"),
  11089. originalText: text
  11090. }), {
  11091. passThrough: true
  11092. });
  11093. var result = parser.parse(text, nextOptions);
  11094. var ast = result.ast;
  11095. text = result.text;
  11096. var astComments = ast.comments;
  11097. delete ast.comments;
  11098. comments.attach(astComments, ast, text, nextOptions);
  11099. return printAstToDoc(ast, nextOptions);
  11100. }
  11101. var multiparser = {
  11102. printSubtree
  11103. };
  11104. var doc$2 = doc;
  11105. var docBuilders$2 = doc$2.builders;
  11106. var concat$3 = docBuilders$2.concat;
  11107. var hardline$2 = docBuilders$2.hardline;
  11108. var addAlignmentToDoc$1 = docBuilders$2.addAlignmentToDoc;
  11109. var docUtils$2 = doc$2.utils;
  11110. /**
  11111. * Takes an abstract syntax tree (AST) and recursively converts it to a
  11112. * document (series of printing primitives).
  11113. *
  11114. * This is done by descending down the AST recursively. The recursion
  11115. * involves two functions that call each other:
  11116. *
  11117. * 1. printGenerically(), which is defined as an inner function here.
  11118. * It basically takes care of node caching.
  11119. * 2. callPluginPrintFunction(), which checks for some options, and
  11120. * ultimately calls the print() function provided by the plugin.
  11121. *
  11122. * The plugin function will call printGenerically() again for child nodes
  11123. * of the current node, which will do its housekeeping, then call the
  11124. * plugin function again, and so on.
  11125. *
  11126. * All the while, these functions pass a "path" variable around, which
  11127. * is a stack-like data structure (FastPath) that maintains the current
  11128. * state of the recursion. It is called "path", because it represents
  11129. * the path to the current node through the Abstract Syntax Tree.
  11130. */
  11131. function printAstToDoc(ast, options) {
  11132. var alignmentSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11133. var printer = options.printer;
  11134. if (printer.preprocess) {
  11135. ast = printer.preprocess(ast, options);
  11136. }
  11137. var cache = new Map();
  11138. function printGenerically(path$$1, args) {
  11139. var node = path$$1.getValue();
  11140. var shouldCache = node && typeof node === "object" && args === undefined;
  11141. if (shouldCache && cache.has(node)) {
  11142. return cache.get(node);
  11143. } // We let JSXElement print its comments itself because it adds () around
  11144. // UnionTypeAnnotation has to align the child without the comments
  11145. var res;
  11146. if (printer.willPrintOwnComments && printer.willPrintOwnComments(path$$1, options)) {
  11147. res = callPluginPrintFunction(path$$1, options, printGenerically, args);
  11148. } else {
  11149. // printComments will call the plugin print function and check for
  11150. // comments to print
  11151. res = comments.printComments(path$$1, function (p) {
  11152. return callPluginPrintFunction(p, options, printGenerically, args);
  11153. }, options, args && args.needsSemi);
  11154. }
  11155. if (shouldCache) {
  11156. cache.set(node, res);
  11157. }
  11158. return res;
  11159. }
  11160. var doc$$2 = printGenerically(new fastPath(ast));
  11161. if (alignmentSize > 0) {
  11162. // Add a hardline to make the indents take effect
  11163. // It should be removed in index.js format()
  11164. doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
  11165. }
  11166. docUtils$2.propagateBreaks(doc$$2);
  11167. return doc$$2;
  11168. }
  11169. function callPluginPrintFunction(path$$1, options, printPath, args) {
  11170. assert.ok(path$$1 instanceof fastPath);
  11171. var node = path$$1.getValue();
  11172. var printer = options.printer; // Escape hatch
  11173. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path$$1)) {
  11174. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  11175. }
  11176. if (node) {
  11177. try {
  11178. // Potentially switch to a different parser
  11179. var sub = multiparser.printSubtree(path$$1, printPath, options, printAstToDoc);
  11180. if (sub) {
  11181. return sub;
  11182. }
  11183. } catch (error) {
  11184. /* istanbul ignore if */
  11185. if (process.env.PRETTIER_DEBUG) {
  11186. throw error;
  11187. } // Continue with current parser
  11188. }
  11189. }
  11190. return printer.print(path$$1, options, printPath, args);
  11191. }
  11192. var astToDoc = printAstToDoc;
  11193. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
  11194. var resultStartNode = startNodeAndParents.node;
  11195. var resultEndNode = endNodeAndParents.node;
  11196. if (resultStartNode === resultEndNode) {
  11197. return {
  11198. startNode: resultStartNode,
  11199. endNode: resultEndNode
  11200. };
  11201. }
  11202. var _iteratorNormalCompletion = true;
  11203. var _didIteratorError = false;
  11204. var _iteratorError = undefined;
  11205. try {
  11206. for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11207. var endParent = _step.value;
  11208. if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
  11209. resultEndNode = endParent;
  11210. } else {
  11211. break;
  11212. }
  11213. }
  11214. } catch (err) {
  11215. _didIteratorError = true;
  11216. _iteratorError = err;
  11217. } finally {
  11218. try {
  11219. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11220. _iterator.return();
  11221. }
  11222. } finally {
  11223. if (_didIteratorError) {
  11224. throw _iteratorError;
  11225. }
  11226. }
  11227. }
  11228. var _iteratorNormalCompletion2 = true;
  11229. var _didIteratorError2 = false;
  11230. var _iteratorError2 = undefined;
  11231. try {
  11232. for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  11233. var startParent = _step2.value;
  11234. if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
  11235. resultStartNode = startParent;
  11236. } else {
  11237. break;
  11238. }
  11239. }
  11240. } catch (err) {
  11241. _didIteratorError2 = true;
  11242. _iteratorError2 = err;
  11243. } finally {
  11244. try {
  11245. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  11246. _iterator2.return();
  11247. }
  11248. } finally {
  11249. if (_didIteratorError2) {
  11250. throw _iteratorError2;
  11251. }
  11252. }
  11253. }
  11254. return {
  11255. startNode: resultStartNode,
  11256. endNode: resultEndNode
  11257. };
  11258. }
  11259. function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
  11260. predicate = predicate || function () {
  11261. return true;
  11262. };
  11263. parentNodes = parentNodes || [];
  11264. var start = options.locStart(node, options.locStart);
  11265. var end = options.locEnd(node, options.locEnd);
  11266. if (start <= offset && offset <= end) {
  11267. var _iteratorNormalCompletion3 = true;
  11268. var _didIteratorError3 = false;
  11269. var _iteratorError3 = undefined;
  11270. try {
  11271. for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  11272. var childNode = _step3.value;
  11273. var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
  11274. if (childResult) {
  11275. return childResult;
  11276. }
  11277. }
  11278. } catch (err) {
  11279. _didIteratorError3 = true;
  11280. _iteratorError3 = err;
  11281. } finally {
  11282. try {
  11283. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  11284. _iterator3.return();
  11285. }
  11286. } finally {
  11287. if (_didIteratorError3) {
  11288. throw _iteratorError3;
  11289. }
  11290. }
  11291. }
  11292. if (predicate(node)) {
  11293. return {
  11294. node: node,
  11295. parentNodes: parentNodes
  11296. };
  11297. }
  11298. }
  11299. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  11300. function isSourceElement(opts, node) {
  11301. if (node == null) {
  11302. return false;
  11303. } // JS and JS like to avoid repetitions
  11304. var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015
  11305. "ImportDeclaration", // Module
  11306. "ExportDefaultDeclaration", // Module
  11307. "ExportNamedDeclaration", // Module
  11308. "ExportAllDeclaration", // Module
  11309. "TypeAlias", // Flow
  11310. "InterfaceDeclaration", // Flow, TypeScript
  11311. "TypeAliasDeclaration", // TypeScript
  11312. "ExportAssignment", // TypeScript
  11313. "ExportDeclaration" // TypeScript
  11314. ];
  11315. var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
  11316. var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
  11317. switch (opts.parser) {
  11318. case "flow":
  11319. case "babel":
  11320. case "typescript":
  11321. return jsSourceElements.indexOf(node.type) > -1;
  11322. case "json":
  11323. return jsonSourceElements.indexOf(node.type) > -1;
  11324. case "graphql":
  11325. return graphqlSourceElements.indexOf(node.kind) > -1;
  11326. case "vue":
  11327. return node.tag !== "root";
  11328. }
  11329. return false;
  11330. }
  11331. function calculateRange(text, opts, ast) {
  11332. // Contract the range so that it has non-whitespace characters at its endpoints.
  11333. // This ensures we can format a range that doesn't end on a node.
  11334. var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
  11335. var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
  11336. var endNonWhitespace;
  11337. for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
  11338. if (text[endNonWhitespace - 1].match(/\S/)) {
  11339. break;
  11340. }
  11341. }
  11342. var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) {
  11343. return isSourceElement(opts, node);
  11344. });
  11345. var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) {
  11346. return isSourceElement(opts, node);
  11347. });
  11348. if (!startNodeAndParents || !endNodeAndParents) {
  11349. return {
  11350. rangeStart: 0,
  11351. rangeEnd: 0
  11352. };
  11353. }
  11354. var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
  11355. var startNode = siblingAncestors.startNode,
  11356. endNode = siblingAncestors.endNode;
  11357. var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
  11358. var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
  11359. return {
  11360. rangeStart: rangeStart,
  11361. rangeEnd: rangeEnd
  11362. };
  11363. }
  11364. var rangeUtil = {
  11365. calculateRange,
  11366. findNodeAtOffset
  11367. };
  11368. var normalizeOptions = options.normalize;
  11369. var guessEndOfLine = endOfLine.guessEndOfLine;
  11370. var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
  11371. var mapDoc = doc.utils.mapDoc;
  11372. var printDocToString = doc.printer.printDocToString;
  11373. var printDocToDebug = doc.debug.printDocToDebug;
  11374. var UTF8BOM = 0xfeff;
  11375. var CURSOR = Symbol("cursor");
  11376. var PLACEHOLDERS = {
  11377. cursorOffset: "<<<PRETTIER_CURSOR>>>",
  11378. rangeStart: "<<<PRETTIER_RANGE_START>>>",
  11379. rangeEnd: "<<<PRETTIER_RANGE_END>>>"
  11380. };
  11381. function ensureAllCommentsPrinted(astComments) {
  11382. if (!astComments) {
  11383. return;
  11384. }
  11385. for (var i = 0; i < astComments.length; ++i) {
  11386. if (astComments[i].value.trim() === "prettier-ignore") {
  11387. // If there's a prettier-ignore, we're not printing that sub-tree so we
  11388. // don't know if the comments was printed or not.
  11389. return;
  11390. }
  11391. }
  11392. astComments.forEach(function (comment) {
  11393. if (!comment.printed) {
  11394. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  11395. }
  11396. delete comment.printed;
  11397. });
  11398. }
  11399. function attachComments(text, ast, opts) {
  11400. var astComments = ast.comments;
  11401. if (astComments) {
  11402. delete ast.comments;
  11403. comments.attach(astComments, ast, text, opts);
  11404. }
  11405. ast.tokens = [];
  11406. opts.originalText = opts.parser === "yaml" ? text : text.trimRight();
  11407. return astComments;
  11408. }
  11409. function coreFormat(text, opts, addAlignmentSize) {
  11410. if (!text || !text.trim().length) {
  11411. return {
  11412. formatted: "",
  11413. cursorOffset: 0
  11414. };
  11415. }
  11416. addAlignmentSize = addAlignmentSize || 0;
  11417. var parsed = parser.parse(text, opts);
  11418. var ast = parsed.ast;
  11419. text = parsed.text;
  11420. if (opts.cursorOffset >= 0) {
  11421. var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  11422. if (nodeResult && nodeResult.node) {
  11423. opts.cursorNode = nodeResult.node;
  11424. }
  11425. }
  11426. var astComments = attachComments(text, ast, opts);
  11427. var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
  11428. var eol = convertEndOfLineToChars(opts.endOfLine);
  11429. var result = printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
  11430. return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
  11431. }), opts);
  11432. ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  11433. if (addAlignmentSize > 0) {
  11434. var trimmed = result.formatted.trim();
  11435. if (result.cursorNodeStart !== undefined) {
  11436. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  11437. }
  11438. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  11439. }
  11440. if (opts.cursorOffset >= 0) {
  11441. var oldCursorNodeStart;
  11442. var oldCursorNodeText;
  11443. var cursorOffsetRelativeToOldCursorNode;
  11444. var newCursorNodeStart;
  11445. var newCursorNodeText;
  11446. if (opts.cursorNode && result.cursorNodeText) {
  11447. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  11448. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  11449. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  11450. newCursorNodeStart = result.cursorNodeStart;
  11451. newCursorNodeText = result.cursorNodeText;
  11452. } else {
  11453. oldCursorNodeStart = 0;
  11454. oldCursorNodeText = text;
  11455. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  11456. newCursorNodeStart = 0;
  11457. newCursorNodeText = result.formatted;
  11458. }
  11459. if (oldCursorNodeText === newCursorNodeText) {
  11460. return {
  11461. formatted: result.formatted,
  11462. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
  11463. };
  11464. } // diff old and new cursor node texts, with a special cursor
  11465. // symbol inserted to find out where it moves to
  11466. var oldCursorNodeCharArray = oldCursorNodeText.split("");
  11467. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  11468. var newCursorNodeCharArray = newCursorNodeText.split("");
  11469. var cursorNodeDiff = lib.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  11470. var cursorOffset = newCursorNodeStart;
  11471. var _iteratorNormalCompletion = true;
  11472. var _didIteratorError = false;
  11473. var _iteratorError = undefined;
  11474. try {
  11475. for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11476. var entry = _step.value;
  11477. if (entry.removed) {
  11478. if (entry.value.indexOf(CURSOR) > -1) {
  11479. break;
  11480. }
  11481. } else {
  11482. cursorOffset += entry.count;
  11483. }
  11484. }
  11485. } catch (err) {
  11486. _didIteratorError = true;
  11487. _iteratorError = err;
  11488. } finally {
  11489. try {
  11490. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11491. _iterator.return();
  11492. }
  11493. } finally {
  11494. if (_didIteratorError) {
  11495. throw _iteratorError;
  11496. }
  11497. }
  11498. }
  11499. return {
  11500. formatted: result.formatted,
  11501. cursorOffset
  11502. };
  11503. }
  11504. return {
  11505. formatted: result.formatted
  11506. };
  11507. }
  11508. function formatRange(text, opts) {
  11509. var parsed = parser.parse(text, opts);
  11510. var ast = parsed.ast;
  11511. text = parsed.text;
  11512. var range = rangeUtil.calculateRange(text, opts, ast);
  11513. var rangeStart = range.rangeStart;
  11514. var rangeEnd = range.rangeEnd;
  11515. var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  11516. // This is so we can detect indentation correctly and restore it.
  11517. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  11518. var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  11519. var indentString = text.slice(rangeStart2, rangeStart);
  11520. var alignmentSize = util$1.getAlignmentSize(indentString, opts.tabWidth);
  11521. var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
  11522. rangeStart: 0,
  11523. rangeEnd: Infinity,
  11524. // track the cursor offset only if it's within our range
  11525. cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
  11526. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  11527. // we need to remove the newline that was inserted by the `format` call.
  11528. var rangeTrimmed = rangeResult.formatted.trimRight();
  11529. var rangeLeft = text.slice(0, rangeStart);
  11530. var rangeRight = text.slice(rangeEnd);
  11531. var cursorOffset = opts.cursorOffset;
  11532. if (opts.cursorOffset >= rangeEnd) {
  11533. // handle the case where the cursor was past the end of the range
  11534. cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
  11535. } else if (rangeResult.cursorOffset !== undefined) {
  11536. // handle the case where the cursor was in the range
  11537. cursorOffset = rangeResult.cursorOffset + rangeStart;
  11538. } // keep the cursor as it was if it was before the start of the range
  11539. var formatted;
  11540. if (opts.endOfLine === "lf") {
  11541. formatted = rangeLeft + rangeTrimmed + rangeRight;
  11542. } else {
  11543. var eol = convertEndOfLineToChars(opts.endOfLine);
  11544. if (cursorOffset >= 0) {
  11545. var parts = [rangeLeft, rangeTrimmed, rangeRight];
  11546. var partIndex = 0;
  11547. var partOffset = cursorOffset;
  11548. while (partIndex < parts.length) {
  11549. var part = parts[partIndex];
  11550. if (partOffset < part.length) {
  11551. parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
  11552. break;
  11553. }
  11554. partIndex++;
  11555. partOffset -= part.length;
  11556. }
  11557. var newRangeLeft = parts[0],
  11558. newRangeTrimmed = parts[1],
  11559. newRangeRight = parts[2];
  11560. formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
  11561. cursorOffset = index;
  11562. return "";
  11563. });
  11564. } else {
  11565. formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
  11566. }
  11567. }
  11568. return {
  11569. formatted,
  11570. cursorOffset
  11571. };
  11572. }
  11573. function format(text, opts) {
  11574. var selectedParser = parser.resolveParser(opts);
  11575. var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
  11576. if (opts.requirePragma && !hasPragma) {
  11577. return {
  11578. formatted: text
  11579. };
  11580. }
  11581. if (opts.endOfLine === "auto") {
  11582. opts.endOfLine = guessEndOfLine(text);
  11583. }
  11584. var hasCursor = opts.cursorOffset >= 0;
  11585. var hasRangeStart = opts.rangeStart > 0;
  11586. var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
  11587. if (text.indexOf("\r") !== -1) {
  11588. var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
  11589. return opts[aKey] - opts[bKey];
  11590. });
  11591. for (var i = offsetKeys.length - 1; i >= 0; i--) {
  11592. var key = offsetKeys[i];
  11593. text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
  11594. }
  11595. text = text.replace(/\r\n?/g, "\n");
  11596. var _loop = function _loop(_i) {
  11597. var key = offsetKeys[_i];
  11598. text = text.replace(PLACEHOLDERS[key], function (_, index) {
  11599. opts[key] = index;
  11600. return "";
  11601. });
  11602. };
  11603. for (var _i = 0; _i < offsetKeys.length; _i++) {
  11604. _loop(_i);
  11605. }
  11606. }
  11607. var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
  11608. if (hasUnicodeBOM) {
  11609. text = text.substring(1);
  11610. if (hasCursor) {
  11611. opts.cursorOffset++;
  11612. }
  11613. if (hasRangeStart) {
  11614. opts.rangeStart++;
  11615. }
  11616. if (hasRangeEnd) {
  11617. opts.rangeEnd++;
  11618. }
  11619. }
  11620. if (!hasCursor) {
  11621. opts.cursorOffset = -1;
  11622. }
  11623. if (opts.rangeStart < 0) {
  11624. opts.rangeStart = 0;
  11625. }
  11626. if (opts.rangeEnd > text.length) {
  11627. opts.rangeEnd = text.length;
  11628. }
  11629. var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
  11630. if (hasUnicodeBOM) {
  11631. result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
  11632. if (hasCursor) {
  11633. result.cursorOffset++;
  11634. }
  11635. }
  11636. return result;
  11637. }
  11638. var core = {
  11639. formatWithCursor(text, opts) {
  11640. opts = normalizeOptions(opts);
  11641. return format(text, opts);
  11642. },
  11643. parse(text, opts, massage) {
  11644. opts = normalizeOptions(opts);
  11645. if (text.indexOf("\r") !== -1) {
  11646. text = text.replace(/\r\n?/g, "\n");
  11647. }
  11648. var parsed = parser.parse(text, opts);
  11649. if (massage) {
  11650. parsed.ast = massageAst(parsed.ast, opts);
  11651. }
  11652. return parsed;
  11653. },
  11654. formatAST(ast, opts) {
  11655. opts = normalizeOptions(opts);
  11656. var doc$$1 = astToDoc(ast, opts);
  11657. return printDocToString(doc$$1, opts);
  11658. },
  11659. // Doesn't handle shebang for now
  11660. formatDoc(doc$$1, opts) {
  11661. var debug = printDocToDebug(doc$$1);
  11662. opts = normalizeOptions(Object.assign({}, opts, {
  11663. parser: "babel"
  11664. }));
  11665. return format(debug, opts).formatted;
  11666. },
  11667. printToDoc(text, opts) {
  11668. opts = normalizeOptions(opts);
  11669. var parsed = parser.parse(text, opts);
  11670. var ast = parsed.ast;
  11671. text = parsed.text;
  11672. attachComments(text, ast, opts);
  11673. return astToDoc(ast, opts);
  11674. },
  11675. printDocToString(doc$$1, opts) {
  11676. return printDocToString(doc$$1, normalizeOptions(opts));
  11677. }
  11678. };
  11679. var ignore = createCommonjsModule(function (module) {
  11680. // A simple implementation of make-array
  11681. function make_array(subject) {
  11682. return Array.isArray(subject) ? subject : [subject];
  11683. }
  11684. var REGEX_BLANK_LINE = /^\s+$/;
  11685. var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  11686. var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
  11687. var SLASH = '/';
  11688. var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  11689. /* istanbul ignore next */
  11690. : 'node-ignore';
  11691. var define = function define(object, key, value) {
  11692. return Object.defineProperty(object, key, {
  11693. value
  11694. });
  11695. };
  11696. var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
  11697. // The cases are complicated, see test cases for details
  11698. var sanitizeRange = function sanitizeRange(range) {
  11699. return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
  11700. return from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
  11701. // fatal for JavaScript regular expression, so eliminate it.
  11702. : '';
  11703. });
  11704. }; // > If the pattern ends with a slash,
  11705. // > it is removed for the purpose of the following description,
  11706. // > but it would only find a match with a directory.
  11707. // > In other words, foo/ will match a directory foo and paths underneath it,
  11708. // > but will not match a regular file or a symbolic link foo
  11709. // > (this is consistent with the way how pathspec works in general in Git).
  11710. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  11711. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  11712. // you could use option `mark: true` with `glob`
  11713. // '`foo/`' should not continue with the '`..`'
  11714. var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  11715. [// (a\ ) -> (a )
  11716. // (a ) -> (a)
  11717. // (a \ ) -> (a )
  11718. /\\?\s+$/, function (match) {
  11719. return match.indexOf('\\') === 0 ? ' ' : '';
  11720. }], // replace (\ ) with ' '
  11721. [/\\\s/g, function () {
  11722. return ' ';
  11723. }], // Escape metacharacters
  11724. // which is written down by users but means special for regular expressions.
  11725. // > There are 12 characters with special meanings:
  11726. // > - the backslash \,
  11727. // > - the caret ^,
  11728. // > - the dollar sign $,
  11729. // > - the period or dot .,
  11730. // > - the vertical bar or pipe symbol |,
  11731. // > - the question mark ?,
  11732. // > - the asterisk or star *,
  11733. // > - the plus sign +,
  11734. // > - the opening parenthesis (,
  11735. // > - the closing parenthesis ),
  11736. // > - and the opening square bracket [,
  11737. // > - the opening curly brace {,
  11738. // > These special characters are often called "metacharacters".
  11739. [/[\\^$.|*+(){]/g, function (match) {
  11740. return `\\${match}`;
  11741. }], [// > [abc] matches any character inside the brackets
  11742. // > (in this case a, b, or c);
  11743. /\[([^\]/]*)($|\])/g, function (match, p1, p2) {
  11744. return p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`;
  11745. }], [// > a question mark (?) matches a single character
  11746. /(?!\\)\?/g, function () {
  11747. return '[^/]';
  11748. }], // leading slash
  11749. [// > A leading slash matches the beginning of the pathname.
  11750. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  11751. // A leading slash matches the beginning of the pathname
  11752. /^\//, function () {
  11753. return '^';
  11754. }], // replace special metacharacter slash after the leading slash
  11755. [/\//g, function () {
  11756. return '\\/';
  11757. }], [// > A leading "**" followed by a slash means match in all directories.
  11758. // > For example, "**/foo" matches file or directory "foo" anywhere,
  11759. // > the same as pattern "foo".
  11760. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  11761. // > under directory "foo".
  11762. // Notice that the '*'s have been replaced as '\\*'
  11763. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  11764. function () {
  11765. return '^(?:.*\\/)?';
  11766. }]];
  11767. var DEFAULT_REPLACER_SUFFIX = [// starting
  11768. [// there will be no leading '/'
  11769. // (which has been replaced by section "leading slash")
  11770. // If starts with '**', adding a '^' to the regular expression also works
  11771. /^(?=[^^])/, function startingReplacer() {
  11772. return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
  11773. // > Git treats it as a shell glob pattern
  11774. // Actually, if there is only a trailing slash,
  11775. // git also treats it as a shell glob pattern
  11776. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
  11777. // > consumption by fnmatch(3)
  11778. : '^';
  11779. }], // two globstars
  11780. [// Use lookahead assertions so that we could match more than one `'/**'`
  11781. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  11782. // should not use '*', or it will be replaced by the next replacer
  11783. // Check if it is not the last `'/**'`
  11784. function (match, index, str) {
  11785. return index + 6 < str.length // case: /**/
  11786. // > A slash followed by two consecutive asterisks then a slash matches
  11787. // > zero or more directories.
  11788. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  11789. // '/**/'
  11790. ? '(?:\\/[^\\/]+)*' // case: /**
  11791. // > A trailing `"/**"` matches everything inside.
  11792. // #21: everything inside but it should not include the current folder
  11793. : '\\/.+';
  11794. }], // intermediate wildcards
  11795. [// Never replace escaped '*'
  11796. // ignore rule '\*' will match the path '*'
  11797. // 'abc.*/' -> go
  11798. // 'abc.*' -> skip this rule
  11799. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  11800. // '*.js' doesn't match 'abc'
  11801. function (match, p1) {
  11802. return `${p1}[^\\/]*`;
  11803. }], // trailing wildcard
  11804. [/(\^|\\\/)?\\\*$/, function (match, p1) {
  11805. var prefix = p1 // '\^':
  11806. // '/*' does not match ''
  11807. // '/*' does not match everything
  11808. // '\\\/':
  11809. // 'abc/*' does not match 'abc/'
  11810. ? `${p1}[^/]+` // 'a*' matches 'a'
  11811. // 'a*' matches 'aa'
  11812. : '[^/]*';
  11813. return `${prefix}(?=$|\\/$)`;
  11814. }], [// unescape
  11815. /\\\\\\/g, function () {
  11816. return '\\';
  11817. }]];
  11818. var POSITIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// 'f'
  11819. // matches
  11820. // - /f(end)
  11821. // - /f/
  11822. // - (start)f(end)
  11823. // - (start)f/
  11824. // doesn't match
  11825. // - oof
  11826. // - foo
  11827. // pseudo:
  11828. // -> (^|/)f(/|$)
  11829. // ending
  11830. [// 'js' will not match 'js.'
  11831. // 'ab' will not match 'abc'
  11832. /(?:[^*/])$/, // 'js*' will not match 'a.js'
  11833. // 'js/' will not match 'a.js'
  11834. // 'js' will match 'a.js' and 'a.js/'
  11835. function (match) {
  11836. return `${match}(?=$|\\/)`;
  11837. }]], DEFAULT_REPLACER_SUFFIX);
  11838. var NEGATIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// #24, #38
  11839. // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
  11840. // A negative pattern without a trailing wildcard should not
  11841. // re-include the things inside that directory.
  11842. // eg:
  11843. // ['node_modules/*', '!node_modules']
  11844. // should ignore `node_modules/a.js`
  11845. [/(?:[^*])$/, function (match) {
  11846. return `${match}(?=$|\\/$)`;
  11847. }]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
  11848. var cache = Object.create(null); // @param {pattern}
  11849. var make_regex = function make_regex(pattern, negative, ignorecase) {
  11850. var r = cache[pattern];
  11851. if (r) {
  11852. return r;
  11853. }
  11854. var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
  11855. var source = replacers.reduce(function (prev, current) {
  11856. return prev.replace(current[0], current[1].bind(pattern));
  11857. }, pattern);
  11858. return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  11859. }; // > A blank line matches no files, so it can serve as a separator for readability.
  11860. var checkPattern = function checkPattern(pattern) {
  11861. return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  11862. && pattern.indexOf('#') !== 0;
  11863. };
  11864. var createRule = function createRule(pattern, ignorecase) {
  11865. var origin = pattern;
  11866. var negative = false; // > An optional prefix "!" which negates the pattern;
  11867. if (pattern.indexOf('!') === 0) {
  11868. negative = true;
  11869. pattern = pattern.substr(1);
  11870. }
  11871. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
  11872. // > begin with a literal "!", for example, `"\!important!.txt"`.
  11873. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
  11874. // > begin with a hash.
  11875. .replace(REGEX_LEADING_EXCAPED_HASH, '#');
  11876. var regex = make_regex(pattern, negative, ignorecase);
  11877. return {
  11878. origin,
  11879. pattern,
  11880. negative,
  11881. regex
  11882. };
  11883. };
  11884. var IgnoreBase =
  11885. /*#__PURE__*/
  11886. function () {
  11887. function IgnoreBase() {
  11888. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11889. _ref$ignorecase = _ref.ignorecase,
  11890. ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase;
  11891. _classCallCheck(this, IgnoreBase);
  11892. this._rules = [];
  11893. this._ignorecase = ignorecase;
  11894. define(this, KEY_IGNORE, true);
  11895. this._initCache();
  11896. }
  11897. _createClass(IgnoreBase, [{
  11898. key: "_initCache",
  11899. value: function _initCache() {
  11900. this._cache = Object.create(null);
  11901. } // @param {Array.<string>|string|Ignore} pattern
  11902. }, {
  11903. key: "add",
  11904. value: function add(pattern) {
  11905. this._added = false;
  11906. if (typeof pattern === 'string') {
  11907. pattern = pattern.split(/\r?\n/g);
  11908. }
  11909. make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  11910. // making the behavior changed.
  11911. if (this._added) {
  11912. this._initCache();
  11913. }
  11914. return this;
  11915. } // legacy
  11916. }, {
  11917. key: "addPattern",
  11918. value: function addPattern(pattern) {
  11919. return this.add(pattern);
  11920. }
  11921. }, {
  11922. key: "_addPattern",
  11923. value: function _addPattern(pattern) {
  11924. // #32
  11925. if (pattern && pattern[KEY_IGNORE]) {
  11926. this._rules = this._rules.concat(pattern._rules);
  11927. this._added = true;
  11928. return;
  11929. }
  11930. if (checkPattern(pattern)) {
  11931. var rule = createRule(pattern, this._ignorecase);
  11932. this._added = true;
  11933. this._rules.push(rule);
  11934. }
  11935. }
  11936. }, {
  11937. key: "filter",
  11938. value: function filter(paths) {
  11939. var _this = this;
  11940. return make_array(paths).filter(function (path$$1) {
  11941. return _this._filter(path$$1);
  11942. });
  11943. }
  11944. }, {
  11945. key: "createFilter",
  11946. value: function createFilter() {
  11947. var _this2 = this;
  11948. return function (path$$1) {
  11949. return _this2._filter(path$$1);
  11950. };
  11951. }
  11952. }, {
  11953. key: "ignores",
  11954. value: function ignores(path$$1) {
  11955. return !this._filter(path$$1);
  11956. } // @returns `Boolean` true if the `path` is NOT ignored
  11957. }, {
  11958. key: "_filter",
  11959. value: function _filter(path$$1, slices) {
  11960. if (!path$$1) {
  11961. return false;
  11962. }
  11963. if (path$$1 in this._cache) {
  11964. return this._cache[path$$1];
  11965. }
  11966. if (!slices) {
  11967. // path/to/a.js
  11968. // ['path', 'to', 'a.js']
  11969. slices = path$$1.split(SLASH);
  11970. }
  11971. slices.pop();
  11972. return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of
  11973. // > that file is excluded.
  11974. // If the path contains a parent directory, check the parent first
  11975. ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
  11976. : this._test(path$$1);
  11977. } // @returns {Boolean} true if a file is NOT ignored
  11978. }, {
  11979. key: "_test",
  11980. value: function _test(path$$1) {
  11981. // Explicitly define variable type by setting matched to `0`
  11982. var matched = 0;
  11983. this._rules.forEach(function (rule) {
  11984. // if matched = true, then we only test negative rules
  11985. // if matched = false, then we test non-negative rules
  11986. if (!(matched ^ rule.negative)) {
  11987. matched = rule.negative ^ rule.regex.test(path$$1);
  11988. }
  11989. });
  11990. return !matched;
  11991. }
  11992. }]);
  11993. return IgnoreBase;
  11994. }(); // Windows
  11995. // --------------------------------------------------------------
  11996. /* istanbul ignore if */
  11997. if ( // Detect `process` so that it can run in browsers.
  11998. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  11999. var filter = IgnoreBase.prototype._filter;
  12000. /* eslint no-control-regex: "off" */
  12001. var make_posix = function make_posix(str) {
  12002. return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
  12003. };
  12004. IgnoreBase.prototype._filter = function filterWin32(path$$1, slices) {
  12005. path$$1 = make_posix(path$$1);
  12006. return filter.call(this, path$$1, slices);
  12007. };
  12008. }
  12009. module.exports = function (options) {
  12010. return new IgnoreBase(options);
  12011. };
  12012. });
  12013. /**
  12014. * @param {string} filename
  12015. * @returns {Promise<null | string>}
  12016. */
  12017. function getFileContentOrNull(filename) {
  12018. return new Promise(function (resolve, reject) {
  12019. fs.readFile(filename, "utf8", function (error, data) {
  12020. if (error && error.code !== "ENOENT") {
  12021. reject(createError(filename, error));
  12022. } else {
  12023. resolve(error ? null : data);
  12024. }
  12025. });
  12026. });
  12027. }
  12028. /**
  12029. * @param {string} filename
  12030. * @returns {null | string}
  12031. */
  12032. getFileContentOrNull.sync = function (filename) {
  12033. try {
  12034. return fs.readFileSync(filename, "utf8");
  12035. } catch (error) {
  12036. if (error && error.code === "ENOENT") {
  12037. return null;
  12038. }
  12039. throw createError(filename, error);
  12040. }
  12041. };
  12042. function createError(filename, error) {
  12043. return new Error(`Unable to read ${filename}: ${error.message}`);
  12044. }
  12045. var getFileContentOrNull_1 = getFileContentOrNull;
  12046. /**
  12047. * @param {undefined | string} ignorePath
  12048. * @param {undefined | boolean} withNodeModules
  12049. */
  12050. function createIgnorer(ignorePath, withNodeModules) {
  12051. return (!ignorePath ? Promise.resolve(null) : getFileContentOrNull_1(path.resolve(ignorePath))).then(function (ignoreContent) {
  12052. return _createIgnorer(ignoreContent, withNodeModules);
  12053. });
  12054. }
  12055. /**
  12056. * @param {undefined | string} ignorePath
  12057. * @param {undefined | boolean} withNodeModules
  12058. */
  12059. createIgnorer.sync = function (ignorePath, withNodeModules) {
  12060. var ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path.resolve(ignorePath));
  12061. return _createIgnorer(ignoreContent, withNodeModules);
  12062. };
  12063. /**
  12064. * @param {null | string} ignoreContent
  12065. * @param {undefined | boolean} withNodeModules
  12066. */
  12067. function _createIgnorer(ignoreContent, withNodeModules) {
  12068. var ignorer = ignore().add(ignoreContent || "");
  12069. if (!withNodeModules) {
  12070. ignorer.add("node_modules");
  12071. }
  12072. return ignorer;
  12073. }
  12074. var createIgnorer_1 = createIgnorer;
  12075. /**
  12076. * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
  12077. * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
  12078. */
  12079. /**
  12080. * @param {string} filePath
  12081. * @param {FileInfoOptions} opts
  12082. * @returns {Promise<FileInfoResult>}
  12083. *
  12084. * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
  12085. * not an object. A transformation from this array to an object is automatically done
  12086. * internally by the method wrapper. See withPlugins() in index.js.
  12087. */
  12088. function getFileInfo(filePath, opts) {
  12089. return createIgnorer_1(opts.ignorePath, opts.withNodeModules).then(function (ignorer) {
  12090. return _getFileInfo(ignorer, normalizeFilePath(filePath, opts.ignorePath), opts.plugins);
  12091. });
  12092. }
  12093. /**
  12094. * @param {string} filePath
  12095. * @param {FileInfoOptions} opts
  12096. * @returns {FileInfoResult}
  12097. */
  12098. getFileInfo.sync = function (filePath, opts) {
  12099. var ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
  12100. return _getFileInfo(ignorer, normalizeFilePath(filePath, opts.ignorePath), opts.plugins);
  12101. };
  12102. function _getFileInfo(ignorer, filePath, plugins) {
  12103. var ignored = ignorer.ignores(filePath);
  12104. var inferredParser = options.inferParser(filePath, plugins) || null;
  12105. return {
  12106. ignored,
  12107. inferredParser
  12108. };
  12109. }
  12110. function normalizeFilePath(filePath, ignorePath) {
  12111. return ignorePath ? path.relative(path.dirname(ignorePath), filePath) : filePath;
  12112. }
  12113. var getFileInfo_1 = getFileInfo;
  12114. var lodash_uniqby = createCommonjsModule(function (module, exports) {
  12115. /**
  12116. * lodash (Custom Build) <https://lodash.com/>
  12117. * Build: `lodash modularize exports="npm" -o ./`
  12118. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  12119. * Released under MIT license <https://lodash.com/license>
  12120. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  12121. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  12122. */
  12123. /** Used as the size to enable large array optimizations. */
  12124. var LARGE_ARRAY_SIZE = 200;
  12125. /** Used as the `TypeError` message for "Functions" methods. */
  12126. var FUNC_ERROR_TEXT = 'Expected a function';
  12127. /** Used to stand-in for `undefined` hash values. */
  12128. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  12129. /** Used to compose bitmasks for comparison styles. */
  12130. var UNORDERED_COMPARE_FLAG = 1,
  12131. PARTIAL_COMPARE_FLAG = 2;
  12132. /** Used as references for various `Number` constants. */
  12133. var INFINITY = 1 / 0,
  12134. MAX_SAFE_INTEGER = 9007199254740991;
  12135. /** `Object#toString` result references. */
  12136. var argsTag = '[object Arguments]',
  12137. arrayTag = '[object Array]',
  12138. boolTag = '[object Boolean]',
  12139. dateTag = '[object Date]',
  12140. errorTag = '[object Error]',
  12141. funcTag = '[object Function]',
  12142. genTag = '[object GeneratorFunction]',
  12143. mapTag = '[object Map]',
  12144. numberTag = '[object Number]',
  12145. objectTag = '[object Object]',
  12146. promiseTag = '[object Promise]',
  12147. regexpTag = '[object RegExp]',
  12148. setTag = '[object Set]',
  12149. stringTag = '[object String]',
  12150. symbolTag = '[object Symbol]',
  12151. weakMapTag = '[object WeakMap]';
  12152. var arrayBufferTag = '[object ArrayBuffer]',
  12153. dataViewTag = '[object DataView]',
  12154. float32Tag = '[object Float32Array]',
  12155. float64Tag = '[object Float64Array]',
  12156. int8Tag = '[object Int8Array]',
  12157. int16Tag = '[object Int16Array]',
  12158. int32Tag = '[object Int32Array]',
  12159. uint8Tag = '[object Uint8Array]',
  12160. uint8ClampedTag = '[object Uint8ClampedArray]',
  12161. uint16Tag = '[object Uint16Array]',
  12162. uint32Tag = '[object Uint32Array]';
  12163. /** Used to match property names within property paths. */
  12164. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  12165. reIsPlainProp = /^\w*$/,
  12166. reLeadingDot = /^\./,
  12167. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  12168. /**
  12169. * Used to match `RegExp`
  12170. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  12171. */
  12172. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  12173. /** Used to match backslashes in property paths. */
  12174. var reEscapeChar = /\\(\\)?/g;
  12175. /** Used to detect host constructors (Safari). */
  12176. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  12177. /** Used to detect unsigned integer values. */
  12178. var reIsUint = /^(?:0|[1-9]\d*)$/;
  12179. /** Used to identify `toStringTag` values of typed arrays. */
  12180. var typedArrayTags = {};
  12181. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  12182. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  12183. /** Detect free variable `global` from Node.js. */
  12184. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  12185. /** Detect free variable `self`. */
  12186. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  12187. /** Used as a reference to the global object. */
  12188. var root = freeGlobal || freeSelf || Function('return this')();
  12189. /** Detect free variable `exports`. */
  12190. var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports;
  12191. /** Detect free variable `module`. */
  12192. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  12193. /** Detect the popular CommonJS extension `module.exports`. */
  12194. var moduleExports = freeModule && freeModule.exports === freeExports;
  12195. /** Detect free variable `process` from Node.js. */
  12196. var freeProcess = moduleExports && freeGlobal.process;
  12197. /** Used to access faster Node.js helpers. */
  12198. var nodeUtil = function () {
  12199. try {
  12200. return freeProcess && freeProcess.binding('util');
  12201. } catch (e) {}
  12202. }();
  12203. /* Node.js helper references. */
  12204. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  12205. /**
  12206. * A specialized version of `_.includes` for arrays without support for
  12207. * specifying an index to search from.
  12208. *
  12209. * @private
  12210. * @param {Array} [array] The array to inspect.
  12211. * @param {*} target The value to search for.
  12212. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  12213. */
  12214. function arrayIncludes(array, value) {
  12215. var length = array ? array.length : 0;
  12216. return !!length && baseIndexOf(array, value, 0) > -1;
  12217. }
  12218. /**
  12219. * This function is like `arrayIncludes` except that it accepts a comparator.
  12220. *
  12221. * @private
  12222. * @param {Array} [array] The array to inspect.
  12223. * @param {*} target The value to search for.
  12224. * @param {Function} comparator The comparator invoked per element.
  12225. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  12226. */
  12227. function arrayIncludesWith(array, value, comparator) {
  12228. var index = -1,
  12229. length = array ? array.length : 0;
  12230. while (++index < length) {
  12231. if (comparator(value, array[index])) {
  12232. return true;
  12233. }
  12234. }
  12235. return false;
  12236. }
  12237. /**
  12238. * A specialized version of `_.some` for arrays without support for iteratee
  12239. * shorthands.
  12240. *
  12241. * @private
  12242. * @param {Array} [array] The array to iterate over.
  12243. * @param {Function} predicate The function invoked per iteration.
  12244. * @returns {boolean} Returns `true` if any element passes the predicate check,
  12245. * else `false`.
  12246. */
  12247. function arraySome(array, predicate) {
  12248. var index = -1,
  12249. length = array ? array.length : 0;
  12250. while (++index < length) {
  12251. if (predicate(array[index], index, array)) {
  12252. return true;
  12253. }
  12254. }
  12255. return false;
  12256. }
  12257. /**
  12258. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  12259. * support for iteratee shorthands.
  12260. *
  12261. * @private
  12262. * @param {Array} array The array to inspect.
  12263. * @param {Function} predicate The function invoked per iteration.
  12264. * @param {number} fromIndex The index to search from.
  12265. * @param {boolean} [fromRight] Specify iterating from right to left.
  12266. * @returns {number} Returns the index of the matched value, else `-1`.
  12267. */
  12268. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  12269. var length = array.length,
  12270. index = fromIndex + (fromRight ? 1 : -1);
  12271. while (fromRight ? index-- : ++index < length) {
  12272. if (predicate(array[index], index, array)) {
  12273. return index;
  12274. }
  12275. }
  12276. return -1;
  12277. }
  12278. /**
  12279. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  12280. *
  12281. * @private
  12282. * @param {Array} array The array to inspect.
  12283. * @param {*} value The value to search for.
  12284. * @param {number} fromIndex The index to search from.
  12285. * @returns {number} Returns the index of the matched value, else `-1`.
  12286. */
  12287. function baseIndexOf(array, value, fromIndex) {
  12288. if (value !== value) {
  12289. return baseFindIndex(array, baseIsNaN, fromIndex);
  12290. }
  12291. var index = fromIndex - 1,
  12292. length = array.length;
  12293. while (++index < length) {
  12294. if (array[index] === value) {
  12295. return index;
  12296. }
  12297. }
  12298. return -1;
  12299. }
  12300. /**
  12301. * The base implementation of `_.isNaN` without support for number objects.
  12302. *
  12303. * @private
  12304. * @param {*} value The value to check.
  12305. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12306. */
  12307. function baseIsNaN(value) {
  12308. return value !== value;
  12309. }
  12310. /**
  12311. * The base implementation of `_.property` without support for deep paths.
  12312. *
  12313. * @private
  12314. * @param {string} key The key of the property to get.
  12315. * @returns {Function} Returns the new accessor function.
  12316. */
  12317. function baseProperty(key) {
  12318. return function (object) {
  12319. return object == null ? undefined : object[key];
  12320. };
  12321. }
  12322. /**
  12323. * The base implementation of `_.times` without support for iteratee shorthands
  12324. * or max array length checks.
  12325. *
  12326. * @private
  12327. * @param {number} n The number of times to invoke `iteratee`.
  12328. * @param {Function} iteratee The function invoked per iteration.
  12329. * @returns {Array} Returns the array of results.
  12330. */
  12331. function baseTimes(n, iteratee) {
  12332. var index = -1,
  12333. result = Array(n);
  12334. while (++index < n) {
  12335. result[index] = iteratee(index);
  12336. }
  12337. return result;
  12338. }
  12339. /**
  12340. * The base implementation of `_.unary` without support for storing metadata.
  12341. *
  12342. * @private
  12343. * @param {Function} func The function to cap arguments for.
  12344. * @returns {Function} Returns the new capped function.
  12345. */
  12346. function baseUnary(func) {
  12347. return function (value) {
  12348. return func(value);
  12349. };
  12350. }
  12351. /**
  12352. * Checks if a cache value for `key` exists.
  12353. *
  12354. * @private
  12355. * @param {Object} cache The cache to query.
  12356. * @param {string} key The key of the entry to check.
  12357. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12358. */
  12359. function cacheHas(cache, key) {
  12360. return cache.has(key);
  12361. }
  12362. /**
  12363. * Gets the value at `key` of `object`.
  12364. *
  12365. * @private
  12366. * @param {Object} [object] The object to query.
  12367. * @param {string} key The key of the property to get.
  12368. * @returns {*} Returns the property value.
  12369. */
  12370. function getValue(object, key) {
  12371. return object == null ? undefined : object[key];
  12372. }
  12373. /**
  12374. * Checks if `value` is a host object in IE < 9.
  12375. *
  12376. * @private
  12377. * @param {*} value The value to check.
  12378. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  12379. */
  12380. function isHostObject(value) {
  12381. // Many host objects are `Object` objects that can coerce to strings
  12382. // despite having improperly defined `toString` methods.
  12383. var result = false;
  12384. if (value != null && typeof value.toString != 'function') {
  12385. try {
  12386. result = !!(value + '');
  12387. } catch (e) {}
  12388. }
  12389. return result;
  12390. }
  12391. /**
  12392. * Converts `map` to its key-value pairs.
  12393. *
  12394. * @private
  12395. * @param {Object} map The map to convert.
  12396. * @returns {Array} Returns the key-value pairs.
  12397. */
  12398. function mapToArray(map) {
  12399. var index = -1,
  12400. result = Array(map.size);
  12401. map.forEach(function (value, key) {
  12402. result[++index] = [key, value];
  12403. });
  12404. return result;
  12405. }
  12406. /**
  12407. * Creates a unary function that invokes `func` with its argument transformed.
  12408. *
  12409. * @private
  12410. * @param {Function} func The function to wrap.
  12411. * @param {Function} transform The argument transform.
  12412. * @returns {Function} Returns the new function.
  12413. */
  12414. function overArg(func, transform) {
  12415. return function (arg) {
  12416. return func(transform(arg));
  12417. };
  12418. }
  12419. /**
  12420. * Converts `set` to an array of its values.
  12421. *
  12422. * @private
  12423. * @param {Object} set The set to convert.
  12424. * @returns {Array} Returns the values.
  12425. */
  12426. function setToArray(set) {
  12427. var index = -1,
  12428. result = Array(set.size);
  12429. set.forEach(function (value) {
  12430. result[++index] = value;
  12431. });
  12432. return result;
  12433. }
  12434. /** Used for built-in method references. */
  12435. var arrayProto = Array.prototype,
  12436. funcProto = Function.prototype,
  12437. objectProto = Object.prototype;
  12438. /** Used to detect overreaching core-js shims. */
  12439. var coreJsData = root['__core-js_shared__'];
  12440. /** Used to detect methods masquerading as native. */
  12441. var maskSrcKey = function () {
  12442. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  12443. return uid ? 'Symbol(src)_1.' + uid : '';
  12444. }();
  12445. /** Used to resolve the decompiled source of functions. */
  12446. var funcToString = funcProto.toString;
  12447. /** Used to check objects for own properties. */
  12448. var hasOwnProperty = objectProto.hasOwnProperty;
  12449. /**
  12450. * Used to resolve the
  12451. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  12452. * of values.
  12453. */
  12454. var objectToString = objectProto.toString;
  12455. /** Used to detect if a method is native. */
  12456. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  12457. /** Built-in value references. */
  12458. var Symbol = root.Symbol,
  12459. Uint8Array = root.Uint8Array,
  12460. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  12461. splice = arrayProto.splice;
  12462. /* Built-in method references for those with the same name as other `lodash` methods. */
  12463. var nativeKeys = overArg(Object.keys, Object);
  12464. /* Built-in method references that are verified to be native. */
  12465. var DataView = getNative(root, 'DataView'),
  12466. Map = getNative(root, 'Map'),
  12467. Promise = getNative(root, 'Promise'),
  12468. Set = getNative(root, 'Set'),
  12469. WeakMap = getNative(root, 'WeakMap'),
  12470. nativeCreate = getNative(Object, 'create');
  12471. /** Used to detect maps, sets, and weakmaps. */
  12472. var dataViewCtorString = toSource(DataView),
  12473. mapCtorString = toSource(Map),
  12474. promiseCtorString = toSource(Promise),
  12475. setCtorString = toSource(Set),
  12476. weakMapCtorString = toSource(WeakMap);
  12477. /** Used to convert symbols to primitives and strings. */
  12478. var symbolProto = Symbol ? Symbol.prototype : undefined,
  12479. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  12480. symbolToString = symbolProto ? symbolProto.toString : undefined;
  12481. /**
  12482. * Creates a hash object.
  12483. *
  12484. * @private
  12485. * @constructor
  12486. * @param {Array} [entries] The key-value pairs to cache.
  12487. */
  12488. function Hash(entries) {
  12489. var index = -1,
  12490. length = entries ? entries.length : 0;
  12491. this.clear();
  12492. while (++index < length) {
  12493. var entry = entries[index];
  12494. this.set(entry[0], entry[1]);
  12495. }
  12496. }
  12497. /**
  12498. * Removes all key-value entries from the hash.
  12499. *
  12500. * @private
  12501. * @name clear
  12502. * @memberOf Hash
  12503. */
  12504. function hashClear() {
  12505. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  12506. }
  12507. /**
  12508. * Removes `key` and its value from the hash.
  12509. *
  12510. * @private
  12511. * @name delete
  12512. * @memberOf Hash
  12513. * @param {Object} hash The hash to modify.
  12514. * @param {string} key The key of the value to remove.
  12515. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12516. */
  12517. function hashDelete(key) {
  12518. return this.has(key) && delete this.__data__[key];
  12519. }
  12520. /**
  12521. * Gets the hash value for `key`.
  12522. *
  12523. * @private
  12524. * @name get
  12525. * @memberOf Hash
  12526. * @param {string} key The key of the value to get.
  12527. * @returns {*} Returns the entry value.
  12528. */
  12529. function hashGet(key) {
  12530. var data = this.__data__;
  12531. if (nativeCreate) {
  12532. var result = data[key];
  12533. return result === HASH_UNDEFINED ? undefined : result;
  12534. }
  12535. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  12536. }
  12537. /**
  12538. * Checks if a hash value for `key` exists.
  12539. *
  12540. * @private
  12541. * @name has
  12542. * @memberOf Hash
  12543. * @param {string} key The key of the entry to check.
  12544. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12545. */
  12546. function hashHas(key) {
  12547. var data = this.__data__;
  12548. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  12549. }
  12550. /**
  12551. * Sets the hash `key` to `value`.
  12552. *
  12553. * @private
  12554. * @name set
  12555. * @memberOf Hash
  12556. * @param {string} key The key of the value to set.
  12557. * @param {*} value The value to set.
  12558. * @returns {Object} Returns the hash instance.
  12559. */
  12560. function hashSet(key, value) {
  12561. var data = this.__data__;
  12562. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  12563. return this;
  12564. } // Add methods to `Hash`.
  12565. Hash.prototype.clear = hashClear;
  12566. Hash.prototype['delete'] = hashDelete;
  12567. Hash.prototype.get = hashGet;
  12568. Hash.prototype.has = hashHas;
  12569. Hash.prototype.set = hashSet;
  12570. /**
  12571. * Creates an list cache object.
  12572. *
  12573. * @private
  12574. * @constructor
  12575. * @param {Array} [entries] The key-value pairs to cache.
  12576. */
  12577. function ListCache(entries) {
  12578. var index = -1,
  12579. length = entries ? entries.length : 0;
  12580. this.clear();
  12581. while (++index < length) {
  12582. var entry = entries[index];
  12583. this.set(entry[0], entry[1]);
  12584. }
  12585. }
  12586. /**
  12587. * Removes all key-value entries from the list cache.
  12588. *
  12589. * @private
  12590. * @name clear
  12591. * @memberOf ListCache
  12592. */
  12593. function listCacheClear() {
  12594. this.__data__ = [];
  12595. }
  12596. /**
  12597. * Removes `key` and its value from the list cache.
  12598. *
  12599. * @private
  12600. * @name delete
  12601. * @memberOf ListCache
  12602. * @param {string} key The key of the value to remove.
  12603. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12604. */
  12605. function listCacheDelete(key) {
  12606. var data = this.__data__,
  12607. index = assocIndexOf(data, key);
  12608. if (index < 0) {
  12609. return false;
  12610. }
  12611. var lastIndex = data.length - 1;
  12612. if (index == lastIndex) {
  12613. data.pop();
  12614. } else {
  12615. splice.call(data, index, 1);
  12616. }
  12617. return true;
  12618. }
  12619. /**
  12620. * Gets the list cache value for `key`.
  12621. *
  12622. * @private
  12623. * @name get
  12624. * @memberOf ListCache
  12625. * @param {string} key The key of the value to get.
  12626. * @returns {*} Returns the entry value.
  12627. */
  12628. function listCacheGet(key) {
  12629. var data = this.__data__,
  12630. index = assocIndexOf(data, key);
  12631. return index < 0 ? undefined : data[index][1];
  12632. }
  12633. /**
  12634. * Checks if a list cache value for `key` exists.
  12635. *
  12636. * @private
  12637. * @name has
  12638. * @memberOf ListCache
  12639. * @param {string} key The key of the entry to check.
  12640. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12641. */
  12642. function listCacheHas(key) {
  12643. return assocIndexOf(this.__data__, key) > -1;
  12644. }
  12645. /**
  12646. * Sets the list cache `key` to `value`.
  12647. *
  12648. * @private
  12649. * @name set
  12650. * @memberOf ListCache
  12651. * @param {string} key The key of the value to set.
  12652. * @param {*} value The value to set.
  12653. * @returns {Object} Returns the list cache instance.
  12654. */
  12655. function listCacheSet(key, value) {
  12656. var data = this.__data__,
  12657. index = assocIndexOf(data, key);
  12658. if (index < 0) {
  12659. data.push([key, value]);
  12660. } else {
  12661. data[index][1] = value;
  12662. }
  12663. return this;
  12664. } // Add methods to `ListCache`.
  12665. ListCache.prototype.clear = listCacheClear;
  12666. ListCache.prototype['delete'] = listCacheDelete;
  12667. ListCache.prototype.get = listCacheGet;
  12668. ListCache.prototype.has = listCacheHas;
  12669. ListCache.prototype.set = listCacheSet;
  12670. /**
  12671. * Creates a map cache object to store key-value pairs.
  12672. *
  12673. * @private
  12674. * @constructor
  12675. * @param {Array} [entries] The key-value pairs to cache.
  12676. */
  12677. function MapCache(entries) {
  12678. var index = -1,
  12679. length = entries ? entries.length : 0;
  12680. this.clear();
  12681. while (++index < length) {
  12682. var entry = entries[index];
  12683. this.set(entry[0], entry[1]);
  12684. }
  12685. }
  12686. /**
  12687. * Removes all key-value entries from the map.
  12688. *
  12689. * @private
  12690. * @name clear
  12691. * @memberOf MapCache
  12692. */
  12693. function mapCacheClear() {
  12694. this.__data__ = {
  12695. 'hash': new Hash(),
  12696. 'map': new (Map || ListCache)(),
  12697. 'string': new Hash()
  12698. };
  12699. }
  12700. /**
  12701. * Removes `key` and its value from the map.
  12702. *
  12703. * @private
  12704. * @name delete
  12705. * @memberOf MapCache
  12706. * @param {string} key The key of the value to remove.
  12707. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12708. */
  12709. function mapCacheDelete(key) {
  12710. return getMapData(this, key)['delete'](key);
  12711. }
  12712. /**
  12713. * Gets the map value for `key`.
  12714. *
  12715. * @private
  12716. * @name get
  12717. * @memberOf MapCache
  12718. * @param {string} key The key of the value to get.
  12719. * @returns {*} Returns the entry value.
  12720. */
  12721. function mapCacheGet(key) {
  12722. return getMapData(this, key).get(key);
  12723. }
  12724. /**
  12725. * Checks if a map value for `key` exists.
  12726. *
  12727. * @private
  12728. * @name has
  12729. * @memberOf MapCache
  12730. * @param {string} key The key of the entry to check.
  12731. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12732. */
  12733. function mapCacheHas(key) {
  12734. return getMapData(this, key).has(key);
  12735. }
  12736. /**
  12737. * Sets the map `key` to `value`.
  12738. *
  12739. * @private
  12740. * @name set
  12741. * @memberOf MapCache
  12742. * @param {string} key The key of the value to set.
  12743. * @param {*} value The value to set.
  12744. * @returns {Object} Returns the map cache instance.
  12745. */
  12746. function mapCacheSet(key, value) {
  12747. getMapData(this, key).set(key, value);
  12748. return this;
  12749. } // Add methods to `MapCache`.
  12750. MapCache.prototype.clear = mapCacheClear;
  12751. MapCache.prototype['delete'] = mapCacheDelete;
  12752. MapCache.prototype.get = mapCacheGet;
  12753. MapCache.prototype.has = mapCacheHas;
  12754. MapCache.prototype.set = mapCacheSet;
  12755. /**
  12756. *
  12757. * Creates an array cache object to store unique values.
  12758. *
  12759. * @private
  12760. * @constructor
  12761. * @param {Array} [values] The values to cache.
  12762. */
  12763. function SetCache(values) {
  12764. var index = -1,
  12765. length = values ? values.length : 0;
  12766. this.__data__ = new MapCache();
  12767. while (++index < length) {
  12768. this.add(values[index]);
  12769. }
  12770. }
  12771. /**
  12772. * Adds `value` to the array cache.
  12773. *
  12774. * @private
  12775. * @name add
  12776. * @memberOf SetCache
  12777. * @alias push
  12778. * @param {*} value The value to cache.
  12779. * @returns {Object} Returns the cache instance.
  12780. */
  12781. function setCacheAdd(value) {
  12782. this.__data__.set(value, HASH_UNDEFINED);
  12783. return this;
  12784. }
  12785. /**
  12786. * Checks if `value` is in the array cache.
  12787. *
  12788. * @private
  12789. * @name has
  12790. * @memberOf SetCache
  12791. * @param {*} value The value to search for.
  12792. * @returns {number} Returns `true` if `value` is found, else `false`.
  12793. */
  12794. function setCacheHas(value) {
  12795. return this.__data__.has(value);
  12796. } // Add methods to `SetCache`.
  12797. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  12798. SetCache.prototype.has = setCacheHas;
  12799. /**
  12800. * Creates a stack cache object to store key-value pairs.
  12801. *
  12802. * @private
  12803. * @constructor
  12804. * @param {Array} [entries] The key-value pairs to cache.
  12805. */
  12806. function Stack(entries) {
  12807. this.__data__ = new ListCache(entries);
  12808. }
  12809. /**
  12810. * Removes all key-value entries from the stack.
  12811. *
  12812. * @private
  12813. * @name clear
  12814. * @memberOf Stack
  12815. */
  12816. function stackClear() {
  12817. this.__data__ = new ListCache();
  12818. }
  12819. /**
  12820. * Removes `key` and its value from the stack.
  12821. *
  12822. * @private
  12823. * @name delete
  12824. * @memberOf Stack
  12825. * @param {string} key The key of the value to remove.
  12826. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12827. */
  12828. function stackDelete(key) {
  12829. return this.__data__['delete'](key);
  12830. }
  12831. /**
  12832. * Gets the stack value for `key`.
  12833. *
  12834. * @private
  12835. * @name get
  12836. * @memberOf Stack
  12837. * @param {string} key The key of the value to get.
  12838. * @returns {*} Returns the entry value.
  12839. */
  12840. function stackGet(key) {
  12841. return this.__data__.get(key);
  12842. }
  12843. /**
  12844. * Checks if a stack value for `key` exists.
  12845. *
  12846. * @private
  12847. * @name has
  12848. * @memberOf Stack
  12849. * @param {string} key The key of the entry to check.
  12850. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12851. */
  12852. function stackHas(key) {
  12853. return this.__data__.has(key);
  12854. }
  12855. /**
  12856. * Sets the stack `key` to `value`.
  12857. *
  12858. * @private
  12859. * @name set
  12860. * @memberOf Stack
  12861. * @param {string} key The key of the value to set.
  12862. * @param {*} value The value to set.
  12863. * @returns {Object} Returns the stack cache instance.
  12864. */
  12865. function stackSet(key, value) {
  12866. var cache = this.__data__;
  12867. if (cache instanceof ListCache) {
  12868. var pairs = cache.__data__;
  12869. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  12870. pairs.push([key, value]);
  12871. return this;
  12872. }
  12873. cache = this.__data__ = new MapCache(pairs);
  12874. }
  12875. cache.set(key, value);
  12876. return this;
  12877. } // Add methods to `Stack`.
  12878. Stack.prototype.clear = stackClear;
  12879. Stack.prototype['delete'] = stackDelete;
  12880. Stack.prototype.get = stackGet;
  12881. Stack.prototype.has = stackHas;
  12882. Stack.prototype.set = stackSet;
  12883. /**
  12884. * Creates an array of the enumerable property names of the array-like `value`.
  12885. *
  12886. * @private
  12887. * @param {*} value The value to query.
  12888. * @param {boolean} inherited Specify returning inherited property names.
  12889. * @returns {Array} Returns the array of property names.
  12890. */
  12891. function arrayLikeKeys(value, inherited) {
  12892. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  12893. // Safari 9 makes `arguments.length` enumerable in strict mode.
  12894. var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
  12895. var length = result.length,
  12896. skipIndexes = !!length;
  12897. for (var key in value) {
  12898. if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  12899. result.push(key);
  12900. }
  12901. }
  12902. return result;
  12903. }
  12904. /**
  12905. * Gets the index at which the `key` is found in `array` of key-value pairs.
  12906. *
  12907. * @private
  12908. * @param {Array} array The array to inspect.
  12909. * @param {*} key The key to search for.
  12910. * @returns {number} Returns the index of the matched value, else `-1`.
  12911. */
  12912. function assocIndexOf(array, key) {
  12913. var length = array.length;
  12914. while (length--) {
  12915. if (eq(array[length][0], key)) {
  12916. return length;
  12917. }
  12918. }
  12919. return -1;
  12920. }
  12921. /**
  12922. * The base implementation of `_.get` without support for default values.
  12923. *
  12924. * @private
  12925. * @param {Object} object The object to query.
  12926. * @param {Array|string} path The path of the property to get.
  12927. * @returns {*} Returns the resolved value.
  12928. */
  12929. function baseGet(object, path$$1) {
  12930. path$$1 = isKey(path$$1, object) ? [path$$1] : castPath(path$$1);
  12931. var index = 0,
  12932. length = path$$1.length;
  12933. while (object != null && index < length) {
  12934. object = object[toKey(path$$1[index++])];
  12935. }
  12936. return index && index == length ? object : undefined;
  12937. }
  12938. /**
  12939. * The base implementation of `getTag`.
  12940. *
  12941. * @private
  12942. * @param {*} value The value to query.
  12943. * @returns {string} Returns the `toStringTag`.
  12944. */
  12945. function baseGetTag(value) {
  12946. return objectToString.call(value);
  12947. }
  12948. /**
  12949. * The base implementation of `_.hasIn` without support for deep paths.
  12950. *
  12951. * @private
  12952. * @param {Object} [object] The object to query.
  12953. * @param {Array|string} key The key to check.
  12954. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  12955. */
  12956. function baseHasIn(object, key) {
  12957. return object != null && key in Object(object);
  12958. }
  12959. /**
  12960. * The base implementation of `_.isEqual` which supports partial comparisons
  12961. * and tracks traversed objects.
  12962. *
  12963. * @private
  12964. * @param {*} value The value to compare.
  12965. * @param {*} other The other value to compare.
  12966. * @param {Function} [customizer] The function to customize comparisons.
  12967. * @param {boolean} [bitmask] The bitmask of comparison flags.
  12968. * The bitmask may be composed of the following flags:
  12969. * 1 - Unordered comparison
  12970. * 2 - Partial comparison
  12971. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  12972. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12973. */
  12974. function baseIsEqual(value, other, customizer, bitmask, stack) {
  12975. if (value === other) {
  12976. return true;
  12977. }
  12978. if (value == null || other == null || !isObject(value) && !isObjectLike(other)) {
  12979. return value !== value && other !== other;
  12980. }
  12981. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  12982. }
  12983. /**
  12984. * A specialized version of `baseIsEqual` for arrays and objects which performs
  12985. * deep comparisons and tracks traversed objects enabling objects with circular
  12986. * references to be compared.
  12987. *
  12988. * @private
  12989. * @param {Object} object The object to compare.
  12990. * @param {Object} other The other object to compare.
  12991. * @param {Function} equalFunc The function to determine equivalents of values.
  12992. * @param {Function} [customizer] The function to customize comparisons.
  12993. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  12994. * for more details.
  12995. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  12996. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  12997. */
  12998. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  12999. var objIsArr = isArray(object),
  13000. othIsArr = isArray(other),
  13001. objTag = arrayTag,
  13002. othTag = arrayTag;
  13003. if (!objIsArr) {
  13004. objTag = getTag(object);
  13005. objTag = objTag == argsTag ? objectTag : objTag;
  13006. }
  13007. if (!othIsArr) {
  13008. othTag = getTag(other);
  13009. othTag = othTag == argsTag ? objectTag : othTag;
  13010. }
  13011. var objIsObj = objTag == objectTag && !isHostObject(object),
  13012. othIsObj = othTag == objectTag && !isHostObject(other),
  13013. isSameTag = objTag == othTag;
  13014. if (isSameTag && !objIsObj) {
  13015. stack || (stack = new Stack());
  13016. return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  13017. }
  13018. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  13019. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  13020. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  13021. if (objIsWrapped || othIsWrapped) {
  13022. var objUnwrapped = objIsWrapped ? object.value() : object,
  13023. othUnwrapped = othIsWrapped ? other.value() : other;
  13024. stack || (stack = new Stack());
  13025. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  13026. }
  13027. }
  13028. if (!isSameTag) {
  13029. return false;
  13030. }
  13031. stack || (stack = new Stack());
  13032. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  13033. }
  13034. /**
  13035. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  13036. *
  13037. * @private
  13038. * @param {Object} object The object to inspect.
  13039. * @param {Object} source The object of property values to match.
  13040. * @param {Array} matchData The property names, values, and compare flags to match.
  13041. * @param {Function} [customizer] The function to customize comparisons.
  13042. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  13043. */
  13044. function baseIsMatch(object, source, matchData, customizer) {
  13045. var index = matchData.length,
  13046. length = index,
  13047. noCustomizer = !customizer;
  13048. if (object == null) {
  13049. return !length;
  13050. }
  13051. object = Object(object);
  13052. while (index--) {
  13053. var data = matchData[index];
  13054. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  13055. return false;
  13056. }
  13057. }
  13058. while (++index < length) {
  13059. data = matchData[index];
  13060. var key = data[0],
  13061. objValue = object[key],
  13062. srcValue = data[1];
  13063. if (noCustomizer && data[2]) {
  13064. if (objValue === undefined && !(key in object)) {
  13065. return false;
  13066. }
  13067. } else {
  13068. var stack = new Stack();
  13069. if (customizer) {
  13070. var result = customizer(objValue, srcValue, key, object, source, stack);
  13071. }
  13072. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
  13073. return false;
  13074. }
  13075. }
  13076. }
  13077. return true;
  13078. }
  13079. /**
  13080. * The base implementation of `_.isNative` without bad shim checks.
  13081. *
  13082. * @private
  13083. * @param {*} value The value to check.
  13084. * @returns {boolean} Returns `true` if `value` is a native function,
  13085. * else `false`.
  13086. */
  13087. function baseIsNative(value) {
  13088. if (!isObject(value) || isMasked(value)) {
  13089. return false;
  13090. }
  13091. var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
  13092. return pattern.test(toSource(value));
  13093. }
  13094. /**
  13095. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  13096. *
  13097. * @private
  13098. * @param {*} value The value to check.
  13099. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  13100. */
  13101. function baseIsTypedArray(value) {
  13102. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  13103. }
  13104. /**
  13105. * The base implementation of `_.iteratee`.
  13106. *
  13107. * @private
  13108. * @param {*} [value=_.identity] The value to convert to an iteratee.
  13109. * @returns {Function} Returns the iteratee.
  13110. */
  13111. function baseIteratee(value) {
  13112. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  13113. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  13114. if (typeof value == 'function') {
  13115. return value;
  13116. }
  13117. if (value == null) {
  13118. return identity;
  13119. }
  13120. if (typeof value == 'object') {
  13121. return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  13122. }
  13123. return property(value);
  13124. }
  13125. /**
  13126. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  13127. *
  13128. * @private
  13129. * @param {Object} object The object to query.
  13130. * @returns {Array} Returns the array of property names.
  13131. */
  13132. function baseKeys(object) {
  13133. if (!isPrototype(object)) {
  13134. return nativeKeys(object);
  13135. }
  13136. var result = [];
  13137. for (var key in Object(object)) {
  13138. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  13139. result.push(key);
  13140. }
  13141. }
  13142. return result;
  13143. }
  13144. /**
  13145. * The base implementation of `_.matches` which doesn't clone `source`.
  13146. *
  13147. * @private
  13148. * @param {Object} source The object of property values to match.
  13149. * @returns {Function} Returns the new spec function.
  13150. */
  13151. function baseMatches(source) {
  13152. var matchData = getMatchData(source);
  13153. if (matchData.length == 1 && matchData[0][2]) {
  13154. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  13155. }
  13156. return function (object) {
  13157. return object === source || baseIsMatch(object, source, matchData);
  13158. };
  13159. }
  13160. /**
  13161. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  13162. *
  13163. * @private
  13164. * @param {string} path The path of the property to get.
  13165. * @param {*} srcValue The value to match.
  13166. * @returns {Function} Returns the new spec function.
  13167. */
  13168. function baseMatchesProperty(path$$1, srcValue) {
  13169. if (isKey(path$$1) && isStrictComparable(srcValue)) {
  13170. return matchesStrictComparable(toKey(path$$1), srcValue);
  13171. }
  13172. return function (object) {
  13173. var objValue = get(object, path$$1);
  13174. return objValue === undefined && objValue === srcValue ? hasIn(object, path$$1) : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  13175. };
  13176. }
  13177. /**
  13178. * A specialized version of `baseProperty` which supports deep paths.
  13179. *
  13180. * @private
  13181. * @param {Array|string} path The path of the property to get.
  13182. * @returns {Function} Returns the new accessor function.
  13183. */
  13184. function basePropertyDeep(path$$1) {
  13185. return function (object) {
  13186. return baseGet(object, path$$1);
  13187. };
  13188. }
  13189. /**
  13190. * The base implementation of `_.toString` which doesn't convert nullish
  13191. * values to empty strings.
  13192. *
  13193. * @private
  13194. * @param {*} value The value to process.
  13195. * @returns {string} Returns the string.
  13196. */
  13197. function baseToString(value) {
  13198. // Exit early for strings to avoid a performance hit in some environments.
  13199. if (typeof value == 'string') {
  13200. return value;
  13201. }
  13202. if (isSymbol(value)) {
  13203. return symbolToString ? symbolToString.call(value) : '';
  13204. }
  13205. var result = value + '';
  13206. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  13207. }
  13208. /**
  13209. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  13210. *
  13211. * @private
  13212. * @param {Array} array The array to inspect.
  13213. * @param {Function} [iteratee] The iteratee invoked per element.
  13214. * @param {Function} [comparator] The comparator invoked per element.
  13215. * @returns {Array} Returns the new duplicate free array.
  13216. */
  13217. function baseUniq(array, iteratee, comparator) {
  13218. var index = -1,
  13219. includes = arrayIncludes,
  13220. length = array.length,
  13221. isCommon = true,
  13222. result = [],
  13223. seen = result;
  13224. if (comparator) {
  13225. isCommon = false;
  13226. includes = arrayIncludesWith;
  13227. } else if (length >= LARGE_ARRAY_SIZE) {
  13228. var set = iteratee ? null : createSet(array);
  13229. if (set) {
  13230. return setToArray(set);
  13231. }
  13232. isCommon = false;
  13233. includes = cacheHas;
  13234. seen = new SetCache();
  13235. } else {
  13236. seen = iteratee ? [] : result;
  13237. }
  13238. outer: while (++index < length) {
  13239. var value = array[index],
  13240. computed = iteratee ? iteratee(value) : value;
  13241. value = comparator || value !== 0 ? value : 0;
  13242. if (isCommon && computed === computed) {
  13243. var seenIndex = seen.length;
  13244. while (seenIndex--) {
  13245. if (seen[seenIndex] === computed) {
  13246. continue outer;
  13247. }
  13248. }
  13249. if (iteratee) {
  13250. seen.push(computed);
  13251. }
  13252. result.push(value);
  13253. } else if (!includes(seen, computed, comparator)) {
  13254. if (seen !== result) {
  13255. seen.push(computed);
  13256. }
  13257. result.push(value);
  13258. }
  13259. }
  13260. return result;
  13261. }
  13262. /**
  13263. * Casts `value` to a path array if it's not one.
  13264. *
  13265. * @private
  13266. * @param {*} value The value to inspect.
  13267. * @returns {Array} Returns the cast property path array.
  13268. */
  13269. function castPath(value) {
  13270. return isArray(value) ? value : stringToPath(value);
  13271. }
  13272. /**
  13273. * Creates a set object of `values`.
  13274. *
  13275. * @private
  13276. * @param {Array} values The values to add to the set.
  13277. * @returns {Object} Returns the new set.
  13278. */
  13279. var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function (values) {
  13280. return new Set(values);
  13281. };
  13282. /**
  13283. * A specialized version of `baseIsEqualDeep` for arrays with support for
  13284. * partial deep comparisons.
  13285. *
  13286. * @private
  13287. * @param {Array} array The array to compare.
  13288. * @param {Array} other The other array to compare.
  13289. * @param {Function} equalFunc The function to determine equivalents of values.
  13290. * @param {Function} customizer The function to customize comparisons.
  13291. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13292. * for more details.
  13293. * @param {Object} stack Tracks traversed `array` and `other` objects.
  13294. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  13295. */
  13296. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  13297. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  13298. arrLength = array.length,
  13299. othLength = other.length;
  13300. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  13301. return false;
  13302. } // Assume cyclic values are equal.
  13303. var stacked = stack.get(array);
  13304. if (stacked && stack.get(other)) {
  13305. return stacked == other;
  13306. }
  13307. var index = -1,
  13308. result = true,
  13309. seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache() : undefined;
  13310. stack.set(array, other);
  13311. stack.set(other, array); // Ignore non-index properties.
  13312. while (++index < arrLength) {
  13313. var arrValue = array[index],
  13314. othValue = other[index];
  13315. if (customizer) {
  13316. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  13317. }
  13318. if (compared !== undefined) {
  13319. if (compared) {
  13320. continue;
  13321. }
  13322. result = false;
  13323. break;
  13324. } // Recursively compare arrays (susceptible to call stack limits).
  13325. if (seen) {
  13326. if (!arraySome(other, function (othValue, othIndex) {
  13327. if (!seen.has(othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  13328. return seen.add(othIndex);
  13329. }
  13330. })) {
  13331. result = false;
  13332. break;
  13333. }
  13334. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  13335. result = false;
  13336. break;
  13337. }
  13338. }
  13339. stack['delete'](array);
  13340. stack['delete'](other);
  13341. return result;
  13342. }
  13343. /**
  13344. * A specialized version of `baseIsEqualDeep` for comparing objects of
  13345. * the same `toStringTag`.
  13346. *
  13347. * **Note:** This function only supports comparing values with tags of
  13348. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  13349. *
  13350. * @private
  13351. * @param {Object} object The object to compare.
  13352. * @param {Object} other The other object to compare.
  13353. * @param {string} tag The `toStringTag` of the objects to compare.
  13354. * @param {Function} equalFunc The function to determine equivalents of values.
  13355. * @param {Function} customizer The function to customize comparisons.
  13356. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13357. * for more details.
  13358. * @param {Object} stack Tracks traversed `object` and `other` objects.
  13359. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  13360. */
  13361. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  13362. switch (tag) {
  13363. case dataViewTag:
  13364. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  13365. return false;
  13366. }
  13367. object = object.buffer;
  13368. other = other.buffer;
  13369. case arrayBufferTag:
  13370. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  13371. return false;
  13372. }
  13373. return true;
  13374. case boolTag:
  13375. case dateTag:
  13376. case numberTag:
  13377. // Coerce booleans to `1` or `0` and dates to milliseconds.
  13378. // Invalid dates are coerced to `NaN`.
  13379. return eq(+object, +other);
  13380. case errorTag:
  13381. return object.name == other.name && object.message == other.message;
  13382. case regexpTag:
  13383. case stringTag:
  13384. // Coerce regexes to strings and treat strings, primitives and objects,
  13385. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  13386. // for more details.
  13387. return object == other + '';
  13388. case mapTag:
  13389. var convert = mapToArray;
  13390. case setTag:
  13391. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  13392. convert || (convert = setToArray);
  13393. if (object.size != other.size && !isPartial) {
  13394. return false;
  13395. } // Assume cyclic values are equal.
  13396. var stacked = stack.get(object);
  13397. if (stacked) {
  13398. return stacked == other;
  13399. }
  13400. bitmask |= UNORDERED_COMPARE_FLAG; // Recursively compare objects (susceptible to call stack limits).
  13401. stack.set(object, other);
  13402. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  13403. stack['delete'](object);
  13404. return result;
  13405. case symbolTag:
  13406. if (symbolValueOf) {
  13407. return symbolValueOf.call(object) == symbolValueOf.call(other);
  13408. }
  13409. }
  13410. return false;
  13411. }
  13412. /**
  13413. * A specialized version of `baseIsEqualDeep` for objects with support for
  13414. * partial deep comparisons.
  13415. *
  13416. * @private
  13417. * @param {Object} object The object to compare.
  13418. * @param {Object} other The other object to compare.
  13419. * @param {Function} equalFunc The function to determine equivalents of values.
  13420. * @param {Function} customizer The function to customize comparisons.
  13421. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13422. * for more details.
  13423. * @param {Object} stack Tracks traversed `object` and `other` objects.
  13424. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  13425. */
  13426. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  13427. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  13428. objProps = keys(object),
  13429. objLength = objProps.length,
  13430. othProps = keys(other),
  13431. othLength = othProps.length;
  13432. if (objLength != othLength && !isPartial) {
  13433. return false;
  13434. }
  13435. var index = objLength;
  13436. while (index--) {
  13437. var key = objProps[index];
  13438. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  13439. return false;
  13440. }
  13441. } // Assume cyclic values are equal.
  13442. var stacked = stack.get(object);
  13443. if (stacked && stack.get(other)) {
  13444. return stacked == other;
  13445. }
  13446. var result = true;
  13447. stack.set(object, other);
  13448. stack.set(other, object);
  13449. var skipCtor = isPartial;
  13450. while (++index < objLength) {
  13451. key = objProps[index];
  13452. var objValue = object[key],
  13453. othValue = other[key];
  13454. if (customizer) {
  13455. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  13456. } // Recursively compare objects (susceptible to call stack limits).
  13457. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
  13458. result = false;
  13459. break;
  13460. }
  13461. skipCtor || (skipCtor = key == 'constructor');
  13462. }
  13463. if (result && !skipCtor) {
  13464. var objCtor = object.constructor,
  13465. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  13466. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  13467. result = false;
  13468. }
  13469. }
  13470. stack['delete'](object);
  13471. stack['delete'](other);
  13472. return result;
  13473. }
  13474. /**
  13475. * Gets the data for `map`.
  13476. *
  13477. * @private
  13478. * @param {Object} map The map to query.
  13479. * @param {string} key The reference key.
  13480. * @returns {*} Returns the map data.
  13481. */
  13482. function getMapData(map, key) {
  13483. var data = map.__data__;
  13484. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  13485. }
  13486. /**
  13487. * Gets the property names, values, and compare flags of `object`.
  13488. *
  13489. * @private
  13490. * @param {Object} object The object to query.
  13491. * @returns {Array} Returns the match data of `object`.
  13492. */
  13493. function getMatchData(object) {
  13494. var result = keys(object),
  13495. length = result.length;
  13496. while (length--) {
  13497. var key = result[length],
  13498. value = object[key];
  13499. result[length] = [key, value, isStrictComparable(value)];
  13500. }
  13501. return result;
  13502. }
  13503. /**
  13504. * Gets the native function at `key` of `object`.
  13505. *
  13506. * @private
  13507. * @param {Object} object The object to query.
  13508. * @param {string} key The key of the method to get.
  13509. * @returns {*} Returns the function if it's native, else `undefined`.
  13510. */
  13511. function getNative(object, key) {
  13512. var value = getValue(object, key);
  13513. return baseIsNative(value) ? value : undefined;
  13514. }
  13515. /**
  13516. * Gets the `toStringTag` of `value`.
  13517. *
  13518. * @private
  13519. * @param {*} value The value to query.
  13520. * @returns {string} Returns the `toStringTag`.
  13521. */
  13522. var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11,
  13523. // for data views in Edge < 14, and promises in Node.js.
  13524. 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) {
  13525. getTag = function getTag(value) {
  13526. var result = objectToString.call(value),
  13527. Ctor = result == objectTag ? value.constructor : undefined,
  13528. ctorString = Ctor ? toSource(Ctor) : undefined;
  13529. if (ctorString) {
  13530. switch (ctorString) {
  13531. case dataViewCtorString:
  13532. return dataViewTag;
  13533. case mapCtorString:
  13534. return mapTag;
  13535. case promiseCtorString:
  13536. return promiseTag;
  13537. case setCtorString:
  13538. return setTag;
  13539. case weakMapCtorString:
  13540. return weakMapTag;
  13541. }
  13542. }
  13543. return result;
  13544. };
  13545. }
  13546. /**
  13547. * Checks if `path` exists on `object`.
  13548. *
  13549. * @private
  13550. * @param {Object} object The object to query.
  13551. * @param {Array|string} path The path to check.
  13552. * @param {Function} hasFunc The function to check properties.
  13553. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13554. */
  13555. function hasPath(object, path$$1, hasFunc) {
  13556. path$$1 = isKey(path$$1, object) ? [path$$1] : castPath(path$$1);
  13557. var result,
  13558. index = -1,
  13559. length = path$$1.length;
  13560. while (++index < length) {
  13561. var key = toKey(path$$1[index]);
  13562. if (!(result = object != null && hasFunc(object, key))) {
  13563. break;
  13564. }
  13565. object = object[key];
  13566. }
  13567. if (result) {
  13568. return result;
  13569. }
  13570. var length = object ? object.length : 0;
  13571. return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
  13572. }
  13573. /**
  13574. * Checks if `value` is a valid array-like index.
  13575. *
  13576. * @private
  13577. * @param {*} value The value to check.
  13578. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  13579. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  13580. */
  13581. function isIndex(value, length) {
  13582. length = length == null ? MAX_SAFE_INTEGER : length;
  13583. return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  13584. }
  13585. /**
  13586. * Checks if `value` is a property name and not a property path.
  13587. *
  13588. * @private
  13589. * @param {*} value The value to check.
  13590. * @param {Object} [object] The object to query keys on.
  13591. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  13592. */
  13593. function isKey(value, object) {
  13594. if (isArray(value)) {
  13595. return false;
  13596. }
  13597. var type = typeof value;
  13598. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
  13599. return true;
  13600. }
  13601. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  13602. }
  13603. /**
  13604. * Checks if `value` is suitable for use as unique object key.
  13605. *
  13606. * @private
  13607. * @param {*} value The value to check.
  13608. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  13609. */
  13610. function isKeyable(value) {
  13611. var type = typeof value;
  13612. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  13613. }
  13614. /**
  13615. * Checks if `func` has its source masked.
  13616. *
  13617. * @private
  13618. * @param {Function} func The function to check.
  13619. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  13620. */
  13621. function isMasked(func) {
  13622. return !!maskSrcKey && maskSrcKey in func;
  13623. }
  13624. /**
  13625. * Checks if `value` is likely a prototype object.
  13626. *
  13627. * @private
  13628. * @param {*} value The value to check.
  13629. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  13630. */
  13631. function isPrototype(value) {
  13632. var Ctor = value && value.constructor,
  13633. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
  13634. return value === proto;
  13635. }
  13636. /**
  13637. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  13638. *
  13639. * @private
  13640. * @param {*} value The value to check.
  13641. * @returns {boolean} Returns `true` if `value` if suitable for strict
  13642. * equality comparisons, else `false`.
  13643. */
  13644. function isStrictComparable(value) {
  13645. return value === value && !isObject(value);
  13646. }
  13647. /**
  13648. * A specialized version of `matchesProperty` for source values suitable
  13649. * for strict equality comparisons, i.e. `===`.
  13650. *
  13651. * @private
  13652. * @param {string} key The key of the property to get.
  13653. * @param {*} srcValue The value to match.
  13654. * @returns {Function} Returns the new spec function.
  13655. */
  13656. function matchesStrictComparable(key, srcValue) {
  13657. return function (object) {
  13658. if (object == null) {
  13659. return false;
  13660. }
  13661. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  13662. };
  13663. }
  13664. /**
  13665. * Converts `string` to a property path array.
  13666. *
  13667. * @private
  13668. * @param {string} string The string to convert.
  13669. * @returns {Array} Returns the property path array.
  13670. */
  13671. var stringToPath = memoize(function (string) {
  13672. string = toString(string);
  13673. var result = [];
  13674. if (reLeadingDot.test(string)) {
  13675. result.push('');
  13676. }
  13677. string.replace(rePropName, function (match, number, quote, string) {
  13678. result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
  13679. });
  13680. return result;
  13681. });
  13682. /**
  13683. * Converts `value` to a string key if it's not a string or symbol.
  13684. *
  13685. * @private
  13686. * @param {*} value The value to inspect.
  13687. * @returns {string|symbol} Returns the key.
  13688. */
  13689. function toKey(value) {
  13690. if (typeof value == 'string' || isSymbol(value)) {
  13691. return value;
  13692. }
  13693. var result = value + '';
  13694. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  13695. }
  13696. /**
  13697. * Converts `func` to its source code.
  13698. *
  13699. * @private
  13700. * @param {Function} func The function to process.
  13701. * @returns {string} Returns the source code.
  13702. */
  13703. function toSource(func) {
  13704. if (func != null) {
  13705. try {
  13706. return funcToString.call(func);
  13707. } catch (e) {}
  13708. try {
  13709. return func + '';
  13710. } catch (e) {}
  13711. }
  13712. return '';
  13713. }
  13714. /**
  13715. * This method is like `_.uniq` except that it accepts `iteratee` which is
  13716. * invoked for each element in `array` to generate the criterion by which
  13717. * uniqueness is computed. The iteratee is invoked with one argument: (value).
  13718. *
  13719. * @static
  13720. * @memberOf _
  13721. * @since 4.0.0
  13722. * @category Array
  13723. * @param {Array} array The array to inspect.
  13724. * @param {Function} [iteratee=_.identity]
  13725. * The iteratee invoked per element.
  13726. * @returns {Array} Returns the new duplicate free array.
  13727. * @example
  13728. *
  13729. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  13730. * // => [2.1, 1.2]
  13731. *
  13732. * // The `_.property` iteratee shorthand.
  13733. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  13734. * // => [{ 'x': 1 }, { 'x': 2 }]
  13735. */
  13736. function uniqBy(array, iteratee) {
  13737. return array && array.length ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
  13738. }
  13739. /**
  13740. * Creates a function that memoizes the result of `func`. If `resolver` is
  13741. * provided, it determines the cache key for storing the result based on the
  13742. * arguments provided to the memoized function. By default, the first argument
  13743. * provided to the memoized function is used as the map cache key. The `func`
  13744. * is invoked with the `this` binding of the memoized function.
  13745. *
  13746. * **Note:** The cache is exposed as the `cache` property on the memoized
  13747. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  13748. * constructor with one whose instances implement the
  13749. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  13750. * method interface of `delete`, `get`, `has`, and `set`.
  13751. *
  13752. * @static
  13753. * @memberOf _
  13754. * @since 0.1.0
  13755. * @category Function
  13756. * @param {Function} func The function to have its output memoized.
  13757. * @param {Function} [resolver] The function to resolve the cache key.
  13758. * @returns {Function} Returns the new memoized function.
  13759. * @example
  13760. *
  13761. * var object = { 'a': 1, 'b': 2 };
  13762. * var other = { 'c': 3, 'd': 4 };
  13763. *
  13764. * var values = _.memoize(_.values);
  13765. * values(object);
  13766. * // => [1, 2]
  13767. *
  13768. * values(other);
  13769. * // => [3, 4]
  13770. *
  13771. * object.a = 2;
  13772. * values(object);
  13773. * // => [1, 2]
  13774. *
  13775. * // Modify the result cache.
  13776. * values.cache.set(object, ['a', 'b']);
  13777. * values(object);
  13778. * // => ['a', 'b']
  13779. *
  13780. * // Replace `_.memoize.Cache`.
  13781. * _.memoize.Cache = WeakMap;
  13782. */
  13783. function memoize(func, resolver) {
  13784. if (typeof func != 'function' || resolver && typeof resolver != 'function') {
  13785. throw new TypeError(FUNC_ERROR_TEXT);
  13786. }
  13787. var memoized = function memoized() {
  13788. var args = arguments,
  13789. key = resolver ? resolver.apply(this, args) : args[0],
  13790. cache = memoized.cache;
  13791. if (cache.has(key)) {
  13792. return cache.get(key);
  13793. }
  13794. var result = func.apply(this, args);
  13795. memoized.cache = cache.set(key, result);
  13796. return result;
  13797. };
  13798. memoized.cache = new (memoize.Cache || MapCache)();
  13799. return memoized;
  13800. } // Assign cache to `_.memoize`.
  13801. memoize.Cache = MapCache;
  13802. /**
  13803. * Performs a
  13804. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13805. * comparison between two values to determine if they are equivalent.
  13806. *
  13807. * @static
  13808. * @memberOf _
  13809. * @since 4.0.0
  13810. * @category Lang
  13811. * @param {*} value The value to compare.
  13812. * @param {*} other The other value to compare.
  13813. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  13814. * @example
  13815. *
  13816. * var object = { 'a': 1 };
  13817. * var other = { 'a': 1 };
  13818. *
  13819. * _.eq(object, object);
  13820. * // => true
  13821. *
  13822. * _.eq(object, other);
  13823. * // => false
  13824. *
  13825. * _.eq('a', 'a');
  13826. * // => true
  13827. *
  13828. * _.eq('a', Object('a'));
  13829. * // => false
  13830. *
  13831. * _.eq(NaN, NaN);
  13832. * // => true
  13833. */
  13834. function eq(value, other) {
  13835. return value === other || value !== value && other !== other;
  13836. }
  13837. /**
  13838. * Checks if `value` is likely an `arguments` object.
  13839. *
  13840. * @static
  13841. * @memberOf _
  13842. * @since 0.1.0
  13843. * @category Lang
  13844. * @param {*} value The value to check.
  13845. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  13846. * else `false`.
  13847. * @example
  13848. *
  13849. * _.isArguments(function() { return arguments; }());
  13850. * // => true
  13851. *
  13852. * _.isArguments([1, 2, 3]);
  13853. * // => false
  13854. */
  13855. function isArguments(value) {
  13856. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  13857. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  13858. }
  13859. /**
  13860. * Checks if `value` is classified as an `Array` object.
  13861. *
  13862. * @static
  13863. * @memberOf _
  13864. * @since 0.1.0
  13865. * @category Lang
  13866. * @param {*} value The value to check.
  13867. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  13868. * @example
  13869. *
  13870. * _.isArray([1, 2, 3]);
  13871. * // => true
  13872. *
  13873. * _.isArray(document.body.children);
  13874. * // => false
  13875. *
  13876. * _.isArray('abc');
  13877. * // => false
  13878. *
  13879. * _.isArray(_.noop);
  13880. * // => false
  13881. */
  13882. var isArray = Array.isArray;
  13883. /**
  13884. * Checks if `value` is array-like. A value is considered array-like if it's
  13885. * not a function and has a `value.length` that's an integer greater than or
  13886. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  13887. *
  13888. * @static
  13889. * @memberOf _
  13890. * @since 4.0.0
  13891. * @category Lang
  13892. * @param {*} value The value to check.
  13893. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  13894. * @example
  13895. *
  13896. * _.isArrayLike([1, 2, 3]);
  13897. * // => true
  13898. *
  13899. * _.isArrayLike(document.body.children);
  13900. * // => true
  13901. *
  13902. * _.isArrayLike('abc');
  13903. * // => true
  13904. *
  13905. * _.isArrayLike(_.noop);
  13906. * // => false
  13907. */
  13908. function isArrayLike(value) {
  13909. return value != null && isLength(value.length) && !isFunction(value);
  13910. }
  13911. /**
  13912. * This method is like `_.isArrayLike` except that it also checks if `value`
  13913. * is an object.
  13914. *
  13915. * @static
  13916. * @memberOf _
  13917. * @since 4.0.0
  13918. * @category Lang
  13919. * @param {*} value The value to check.
  13920. * @returns {boolean} Returns `true` if `value` is an array-like object,
  13921. * else `false`.
  13922. * @example
  13923. *
  13924. * _.isArrayLikeObject([1, 2, 3]);
  13925. * // => true
  13926. *
  13927. * _.isArrayLikeObject(document.body.children);
  13928. * // => true
  13929. *
  13930. * _.isArrayLikeObject('abc');
  13931. * // => false
  13932. *
  13933. * _.isArrayLikeObject(_.noop);
  13934. * // => false
  13935. */
  13936. function isArrayLikeObject(value) {
  13937. return isObjectLike(value) && isArrayLike(value);
  13938. }
  13939. /**
  13940. * Checks if `value` is classified as a `Function` object.
  13941. *
  13942. * @static
  13943. * @memberOf _
  13944. * @since 0.1.0
  13945. * @category Lang
  13946. * @param {*} value The value to check.
  13947. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  13948. * @example
  13949. *
  13950. * _.isFunction(_);
  13951. * // => true
  13952. *
  13953. * _.isFunction(/abc/);
  13954. * // => false
  13955. */
  13956. function isFunction(value) {
  13957. // The use of `Object#toString` avoids issues with the `typeof` operator
  13958. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  13959. var tag = isObject(value) ? objectToString.call(value) : '';
  13960. return tag == funcTag || tag == genTag;
  13961. }
  13962. /**
  13963. * Checks if `value` is a valid array-like length.
  13964. *
  13965. * **Note:** This method is loosely based on
  13966. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  13967. *
  13968. * @static
  13969. * @memberOf _
  13970. * @since 4.0.0
  13971. * @category Lang
  13972. * @param {*} value The value to check.
  13973. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  13974. * @example
  13975. *
  13976. * _.isLength(3);
  13977. * // => true
  13978. *
  13979. * _.isLength(Number.MIN_VALUE);
  13980. * // => false
  13981. *
  13982. * _.isLength(Infinity);
  13983. * // => false
  13984. *
  13985. * _.isLength('3');
  13986. * // => false
  13987. */
  13988. function isLength(value) {
  13989. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  13990. }
  13991. /**
  13992. * Checks if `value` is the
  13993. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  13994. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  13995. *
  13996. * @static
  13997. * @memberOf _
  13998. * @since 0.1.0
  13999. * @category Lang
  14000. * @param {*} value The value to check.
  14001. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  14002. * @example
  14003. *
  14004. * _.isObject({});
  14005. * // => true
  14006. *
  14007. * _.isObject([1, 2, 3]);
  14008. * // => true
  14009. *
  14010. * _.isObject(_.noop);
  14011. * // => true
  14012. *
  14013. * _.isObject(null);
  14014. * // => false
  14015. */
  14016. function isObject(value) {
  14017. var type = typeof value;
  14018. return !!value && (type == 'object' || type == 'function');
  14019. }
  14020. /**
  14021. * Checks if `value` is object-like. A value is object-like if it's not `null`
  14022. * and has a `typeof` result of "object".
  14023. *
  14024. * @static
  14025. * @memberOf _
  14026. * @since 4.0.0
  14027. * @category Lang
  14028. * @param {*} value The value to check.
  14029. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  14030. * @example
  14031. *
  14032. * _.isObjectLike({});
  14033. * // => true
  14034. *
  14035. * _.isObjectLike([1, 2, 3]);
  14036. * // => true
  14037. *
  14038. * _.isObjectLike(_.noop);
  14039. * // => false
  14040. *
  14041. * _.isObjectLike(null);
  14042. * // => false
  14043. */
  14044. function isObjectLike(value) {
  14045. return !!value && typeof value == 'object';
  14046. }
  14047. /**
  14048. * Checks if `value` is classified as a `Symbol` primitive or object.
  14049. *
  14050. * @static
  14051. * @memberOf _
  14052. * @since 4.0.0
  14053. * @category Lang
  14054. * @param {*} value The value to check.
  14055. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  14056. * @example
  14057. *
  14058. * _.isSymbol(Symbol.iterator);
  14059. * // => true
  14060. *
  14061. * _.isSymbol('abc');
  14062. * // => false
  14063. */
  14064. function isSymbol(value) {
  14065. return typeof value == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
  14066. }
  14067. /**
  14068. * Checks if `value` is classified as a typed array.
  14069. *
  14070. * @static
  14071. * @memberOf _
  14072. * @since 3.0.0
  14073. * @category Lang
  14074. * @param {*} value The value to check.
  14075. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  14076. * @example
  14077. *
  14078. * _.isTypedArray(new Uint8Array);
  14079. * // => true
  14080. *
  14081. * _.isTypedArray([]);
  14082. * // => false
  14083. */
  14084. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  14085. /**
  14086. * Converts `value` to a string. An empty string is returned for `null`
  14087. * and `undefined` values. The sign of `-0` is preserved.
  14088. *
  14089. * @static
  14090. * @memberOf _
  14091. * @since 4.0.0
  14092. * @category Lang
  14093. * @param {*} value The value to process.
  14094. * @returns {string} Returns the string.
  14095. * @example
  14096. *
  14097. * _.toString(null);
  14098. * // => ''
  14099. *
  14100. * _.toString(-0);
  14101. * // => '-0'
  14102. *
  14103. * _.toString([1, 2, 3]);
  14104. * // => '1,2,3'
  14105. */
  14106. function toString(value) {
  14107. return value == null ? '' : baseToString(value);
  14108. }
  14109. /**
  14110. * Gets the value at `path` of `object`. If the resolved value is
  14111. * `undefined`, the `defaultValue` is returned in its place.
  14112. *
  14113. * @static
  14114. * @memberOf _
  14115. * @since 3.7.0
  14116. * @category Object
  14117. * @param {Object} object The object to query.
  14118. * @param {Array|string} path The path of the property to get.
  14119. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14120. * @returns {*} Returns the resolved value.
  14121. * @example
  14122. *
  14123. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14124. *
  14125. * _.get(object, 'a[0].b.c');
  14126. * // => 3
  14127. *
  14128. * _.get(object, ['a', '0', 'b', 'c']);
  14129. * // => 3
  14130. *
  14131. * _.get(object, 'a.b.c', 'default');
  14132. * // => 'default'
  14133. */
  14134. function get(object, path$$1, defaultValue) {
  14135. var result = object == null ? undefined : baseGet(object, path$$1);
  14136. return result === undefined ? defaultValue : result;
  14137. }
  14138. /**
  14139. * Checks if `path` is a direct or inherited property of `object`.
  14140. *
  14141. * @static
  14142. * @memberOf _
  14143. * @since 4.0.0
  14144. * @category Object
  14145. * @param {Object} object The object to query.
  14146. * @param {Array|string} path The path to check.
  14147. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14148. * @example
  14149. *
  14150. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  14151. *
  14152. * _.hasIn(object, 'a');
  14153. * // => true
  14154. *
  14155. * _.hasIn(object, 'a.b');
  14156. * // => true
  14157. *
  14158. * _.hasIn(object, ['a', 'b']);
  14159. * // => true
  14160. *
  14161. * _.hasIn(object, 'b');
  14162. * // => false
  14163. */
  14164. function hasIn(object, path$$1) {
  14165. return object != null && hasPath(object, path$$1, baseHasIn);
  14166. }
  14167. /**
  14168. * Creates an array of the own enumerable property names of `object`.
  14169. *
  14170. * **Note:** Non-object values are coerced to objects. See the
  14171. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  14172. * for more details.
  14173. *
  14174. * @static
  14175. * @since 0.1.0
  14176. * @memberOf _
  14177. * @category Object
  14178. * @param {Object} object The object to query.
  14179. * @returns {Array} Returns the array of property names.
  14180. * @example
  14181. *
  14182. * function Foo() {
  14183. * this.a = 1;
  14184. * this.b = 2;
  14185. * }
  14186. *
  14187. * Foo.prototype.c = 3;
  14188. *
  14189. * _.keys(new Foo);
  14190. * // => ['a', 'b'] (iteration order is not guaranteed)
  14191. *
  14192. * _.keys('hi');
  14193. * // => ['0', '1']
  14194. */
  14195. function keys(object) {
  14196. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  14197. }
  14198. /**
  14199. * This method returns the first argument it receives.
  14200. *
  14201. * @static
  14202. * @since 0.1.0
  14203. * @memberOf _
  14204. * @category Util
  14205. * @param {*} value Any value.
  14206. * @returns {*} Returns `value`.
  14207. * @example
  14208. *
  14209. * var object = { 'a': 1 };
  14210. *
  14211. * console.log(_.identity(object) === object);
  14212. * // => true
  14213. */
  14214. function identity(value) {
  14215. return value;
  14216. }
  14217. /**
  14218. * This method returns `undefined`.
  14219. *
  14220. * @static
  14221. * @memberOf _
  14222. * @since 2.3.0
  14223. * @category Util
  14224. * @example
  14225. *
  14226. * _.times(2, _.noop);
  14227. * // => [undefined, undefined]
  14228. */
  14229. function noop() {} // No operation performed.
  14230. /**
  14231. * Creates a function that returns the value at `path` of a given object.
  14232. *
  14233. * @static
  14234. * @memberOf _
  14235. * @since 2.4.0
  14236. * @category Util
  14237. * @param {Array|string} path The path of the property to get.
  14238. * @returns {Function} Returns the new accessor function.
  14239. * @example
  14240. *
  14241. * var objects = [
  14242. * { 'a': { 'b': 2 } },
  14243. * { 'a': { 'b': 1 } }
  14244. * ];
  14245. *
  14246. * _.map(objects, _.property('a.b'));
  14247. * // => [2, 1]
  14248. *
  14249. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  14250. * // => [1, 2]
  14251. */
  14252. function property(path$$1) {
  14253. return isKey(path$$1) ? baseProperty(toKey(path$$1)) : basePropertyDeep(path$$1);
  14254. }
  14255. module.exports = uniqBy;
  14256. });
  14257. var PENDING = 'pending';
  14258. var SETTLED = 'settled';
  14259. var FULFILLED = 'fulfilled';
  14260. var REJECTED = 'rejected';
  14261. var NOOP = function NOOP() {};
  14262. var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
  14263. var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
  14264. var asyncQueue = [];
  14265. var asyncTimer;
  14266. function asyncFlush() {
  14267. // run promise callbacks
  14268. for (var i = 0; i < asyncQueue.length; i++) {
  14269. asyncQueue[i][0](asyncQueue[i][1]);
  14270. } // reset async asyncQueue
  14271. asyncQueue = [];
  14272. asyncTimer = false;
  14273. }
  14274. function asyncCall(callback, arg) {
  14275. asyncQueue.push([callback, arg]);
  14276. if (!asyncTimer) {
  14277. asyncTimer = true;
  14278. asyncSetTimer(asyncFlush, 0);
  14279. }
  14280. }
  14281. function invokeResolver(resolver, promise) {
  14282. function resolvePromise(value) {
  14283. resolve(promise, value);
  14284. }
  14285. function rejectPromise(reason) {
  14286. reject(promise, reason);
  14287. }
  14288. try {
  14289. resolver(resolvePromise, rejectPromise);
  14290. } catch (e) {
  14291. rejectPromise(e);
  14292. }
  14293. }
  14294. function invokeCallback(subscriber) {
  14295. var owner = subscriber.owner;
  14296. var settled = owner._state;
  14297. var value = owner._data;
  14298. var callback = subscriber[settled];
  14299. var promise = subscriber.then;
  14300. if (typeof callback === 'function') {
  14301. settled = FULFILLED;
  14302. try {
  14303. value = callback(value);
  14304. } catch (e) {
  14305. reject(promise, e);
  14306. }
  14307. }
  14308. if (!handleThenable(promise, value)) {
  14309. if (settled === FULFILLED) {
  14310. resolve(promise, value);
  14311. }
  14312. if (settled === REJECTED) {
  14313. reject(promise, value);
  14314. }
  14315. }
  14316. }
  14317. function handleThenable(promise, value) {
  14318. var resolved;
  14319. try {
  14320. if (promise === value) {
  14321. throw new TypeError('A promises callback cannot return that same promise.');
  14322. }
  14323. if (value && (typeof value === 'function' || typeof value === 'object')) {
  14324. // then should be retrieved only once
  14325. var then = value.then;
  14326. if (typeof then === 'function') {
  14327. then.call(value, function (val) {
  14328. if (!resolved) {
  14329. resolved = true;
  14330. if (value === val) {
  14331. fulfill(promise, val);
  14332. } else {
  14333. resolve(promise, val);
  14334. }
  14335. }
  14336. }, function (reason) {
  14337. if (!resolved) {
  14338. resolved = true;
  14339. reject(promise, reason);
  14340. }
  14341. });
  14342. return true;
  14343. }
  14344. }
  14345. } catch (e) {
  14346. if (!resolved) {
  14347. reject(promise, e);
  14348. }
  14349. return true;
  14350. }
  14351. return false;
  14352. }
  14353. function resolve(promise, value) {
  14354. if (promise === value || !handleThenable(promise, value)) {
  14355. fulfill(promise, value);
  14356. }
  14357. }
  14358. function fulfill(promise, value) {
  14359. if (promise._state === PENDING) {
  14360. promise._state = SETTLED;
  14361. promise._data = value;
  14362. asyncCall(publishFulfillment, promise);
  14363. }
  14364. }
  14365. function reject(promise, reason) {
  14366. if (promise._state === PENDING) {
  14367. promise._state = SETTLED;
  14368. promise._data = reason;
  14369. asyncCall(publishRejection, promise);
  14370. }
  14371. }
  14372. function publish(promise) {
  14373. promise._then = promise._then.forEach(invokeCallback);
  14374. }
  14375. function publishFulfillment(promise) {
  14376. promise._state = FULFILLED;
  14377. publish(promise);
  14378. }
  14379. function publishRejection(promise) {
  14380. promise._state = REJECTED;
  14381. publish(promise);
  14382. if (!promise._handled && isNode) {
  14383. global.process.emit('unhandledRejection', promise._data, promise);
  14384. }
  14385. }
  14386. function notifyRejectionHandled(promise) {
  14387. global.process.emit('rejectionHandled', promise);
  14388. }
  14389. /**
  14390. * @class
  14391. */
  14392. function Promise$1(resolver) {
  14393. if (typeof resolver !== 'function') {
  14394. throw new TypeError('Promise resolver ' + resolver + ' is not a function');
  14395. }
  14396. if (this instanceof Promise$1 === false) {
  14397. throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
  14398. }
  14399. this._then = [];
  14400. invokeResolver(resolver, this);
  14401. }
  14402. Promise$1.prototype = {
  14403. constructor: Promise$1,
  14404. _state: PENDING,
  14405. _then: null,
  14406. _data: undefined,
  14407. _handled: false,
  14408. then: function then(onFulfillment, onRejection) {
  14409. var subscriber = {
  14410. owner: this,
  14411. then: new this.constructor(NOOP),
  14412. fulfilled: onFulfillment,
  14413. rejected: onRejection
  14414. };
  14415. if ((onRejection || onFulfillment) && !this._handled) {
  14416. this._handled = true;
  14417. if (this._state === REJECTED && isNode) {
  14418. asyncCall(notifyRejectionHandled, this);
  14419. }
  14420. }
  14421. if (this._state === FULFILLED || this._state === REJECTED) {
  14422. // already resolved, call callback async
  14423. asyncCall(invokeCallback, subscriber);
  14424. } else {
  14425. // subscribe
  14426. this._then.push(subscriber);
  14427. }
  14428. return subscriber.then;
  14429. },
  14430. catch: function _catch(onRejection) {
  14431. return this.then(null, onRejection);
  14432. }
  14433. };
  14434. Promise$1.all = function (promises) {
  14435. if (!Array.isArray(promises)) {
  14436. throw new TypeError('You must pass an array to Promise.all().');
  14437. }
  14438. return new Promise$1(function (resolve, reject) {
  14439. var results = [];
  14440. var remaining = 0;
  14441. function resolver(index) {
  14442. remaining++;
  14443. return function (value) {
  14444. results[index] = value;
  14445. if (! --remaining) {
  14446. resolve(results);
  14447. }
  14448. };
  14449. }
  14450. for (var i = 0, promise; i < promises.length; i++) {
  14451. promise = promises[i];
  14452. if (promise && typeof promise.then === 'function') {
  14453. promise.then(resolver(i), reject);
  14454. } else {
  14455. results[i] = promise;
  14456. }
  14457. }
  14458. if (!remaining) {
  14459. resolve(results);
  14460. }
  14461. });
  14462. };
  14463. Promise$1.race = function (promises) {
  14464. if (!Array.isArray(promises)) {
  14465. throw new TypeError('You must pass an array to Promise.race().');
  14466. }
  14467. return new Promise$1(function (resolve, reject) {
  14468. for (var i = 0, promise; i < promises.length; i++) {
  14469. promise = promises[i];
  14470. if (promise && typeof promise.then === 'function') {
  14471. promise.then(resolve, reject);
  14472. } else {
  14473. resolve(promise);
  14474. }
  14475. }
  14476. });
  14477. };
  14478. Promise$1.resolve = function (value) {
  14479. if (value && typeof value === 'object' && value.constructor === Promise$1) {
  14480. return value;
  14481. }
  14482. return new Promise$1(function (resolve) {
  14483. resolve(value);
  14484. });
  14485. };
  14486. Promise$1.reject = function (reason) {
  14487. return new Promise$1(function (resolve, reject) {
  14488. reject(reason);
  14489. });
  14490. };
  14491. var pinkie = Promise$1;
  14492. var pinkiePromise = typeof Promise === 'function' ? Promise : pinkie;
  14493. var arrayUniq = createCommonjsModule(function (module) {
  14494. 'use strict'; // there's 3 implementations written in increasing order of efficiency
  14495. // 1 - no Set type is defined
  14496. function uniqNoSet(arr) {
  14497. var ret = [];
  14498. for (var i = 0; i < arr.length; i++) {
  14499. if (ret.indexOf(arr[i]) === -1) {
  14500. ret.push(arr[i]);
  14501. }
  14502. }
  14503. return ret;
  14504. } // 2 - a simple Set type is defined
  14505. function uniqSet(arr) {
  14506. var seen = new Set();
  14507. return arr.filter(function (el) {
  14508. if (!seen.has(el)) {
  14509. seen.add(el);
  14510. return true;
  14511. }
  14512. return false;
  14513. });
  14514. } // 3 - a standard Set type is defined and it has a forEach method
  14515. function uniqSetWithForEach(arr) {
  14516. var ret = [];
  14517. new Set(arr).forEach(function (el) {
  14518. ret.push(el);
  14519. });
  14520. return ret;
  14521. } // V8 currently has a broken implementation
  14522. // https://github.com/joyent/node/issues/8449
  14523. function doesForEachActuallyWork() {
  14524. var ret = false;
  14525. new Set([true]).forEach(function (el) {
  14526. ret = el;
  14527. });
  14528. return ret === true;
  14529. }
  14530. if ('Set' in global) {
  14531. if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
  14532. module.exports = uniqSetWithForEach;
  14533. } else {
  14534. module.exports = uniqSet;
  14535. }
  14536. } else {
  14537. module.exports = uniqNoSet;
  14538. }
  14539. });
  14540. var arrayUnion = function arrayUnion() {
  14541. return arrayUniq([].concat.apply([], arguments));
  14542. };
  14543. /*
  14544. object-assign
  14545. (c) Sindre Sorhus
  14546. @license MIT
  14547. */
  14548. /* eslint-disable no-unused-vars */
  14549. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  14550. var hasOwnProperty = Object.prototype.hasOwnProperty;
  14551. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  14552. function toObject(val) {
  14553. if (val === null || val === undefined) {
  14554. throw new TypeError('Object.assign cannot be called with null or undefined');
  14555. }
  14556. return Object(val);
  14557. }
  14558. function shouldUseNative() {
  14559. try {
  14560. if (!Object.assign) {
  14561. return false;
  14562. } // Detect buggy property enumeration order in older V8 versions.
  14563. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  14564. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  14565. test1[5] = 'de';
  14566. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  14567. return false;
  14568. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  14569. var test2 = {};
  14570. for (var i = 0; i < 10; i++) {
  14571. test2['_' + String.fromCharCode(i)] = i;
  14572. }
  14573. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  14574. return test2[n];
  14575. });
  14576. if (order2.join('') !== '0123456789') {
  14577. return false;
  14578. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  14579. var test3 = {};
  14580. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  14581. test3[letter] = letter;
  14582. });
  14583. if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
  14584. return false;
  14585. }
  14586. return true;
  14587. } catch (err) {
  14588. // We don't expect any of the above to throw, but better to be safe.
  14589. return false;
  14590. }
  14591. }
  14592. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  14593. var from;
  14594. var to = toObject(target);
  14595. var symbols;
  14596. for (var s = 1; s < arguments.length; s++) {
  14597. from = Object(arguments[s]);
  14598. for (var key in from) {
  14599. if (hasOwnProperty.call(from, key)) {
  14600. to[key] = from[key];
  14601. }
  14602. }
  14603. if (getOwnPropertySymbols) {
  14604. symbols = getOwnPropertySymbols(from);
  14605. for (var i = 0; i < symbols.length; i++) {
  14606. if (propIsEnumerable.call(from, symbols[i])) {
  14607. to[symbols[i]] = from[symbols[i]];
  14608. }
  14609. }
  14610. }
  14611. }
  14612. return to;
  14613. };
  14614. //
  14615. // Permission is hereby granted, free of charge, to any person obtaining a
  14616. // copy of this software and associated documentation files (the
  14617. // "Software"), to deal in the Software without restriction, including
  14618. // without limitation the rights to use, copy, modify, merge, publish,
  14619. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14620. // persons to whom the Software is furnished to do so, subject to the
  14621. // following conditions:
  14622. //
  14623. // The above copyright notice and this permission notice shall be included
  14624. // in all copies or substantial portions of the Software.
  14625. //
  14626. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14627. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14628. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14629. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14630. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14631. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14632. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14633. var isWindows = process.platform === 'win32'; // JavaScript implementation of realpath, ported from node pre-v6
  14634. var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
  14635. function rethrow() {
  14636. // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
  14637. // is fairly slow to generate.
  14638. var callback;
  14639. if (DEBUG) {
  14640. var backtrace = new Error();
  14641. callback = debugCallback;
  14642. } else callback = missingCallback;
  14643. return callback;
  14644. function debugCallback(err) {
  14645. if (err) {
  14646. backtrace.message = err.message;
  14647. err = backtrace;
  14648. missingCallback(err);
  14649. }
  14650. }
  14651. function missingCallback(err) {
  14652. if (err) {
  14653. if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
  14654. else if (!process.noDeprecation) {
  14655. var msg = 'fs: missing callback ' + (err.stack || err.message);
  14656. if (process.traceDeprecation) console.trace(msg);else console.error(msg);
  14657. }
  14658. }
  14659. }
  14660. }
  14661. function maybeCallback(cb) {
  14662. return typeof cb === 'function' ? cb : rethrow();
  14663. }
  14664. // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
  14665. if (isWindows) {
  14666. var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
  14667. } else {
  14668. var nextPartRe = /(.*?)(?:[\/]+|$)/g;
  14669. } // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
  14670. if (isWindows) {
  14671. var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
  14672. } else {
  14673. var splitRootRe = /^[\/]*/;
  14674. }
  14675. var realpathSync$1 = function realpathSync(p, cache) {
  14676. // make p is absolute
  14677. p = path.resolve(p);
  14678. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  14679. return cache[p];
  14680. }
  14681. var original = p,
  14682. seenLinks = {},
  14683. knownHard = {}; // current character position in p
  14684. var pos; // the partial path so far, including a trailing slash if any
  14685. var current; // the partial path without a trailing slash (except when pointing at a root)
  14686. var base; // the partial path scanned in the previous round, with slash
  14687. var previous;
  14688. start();
  14689. function start() {
  14690. // Skip over roots
  14691. var m = splitRootRe.exec(p);
  14692. pos = m[0].length;
  14693. current = m[0];
  14694. base = m[0];
  14695. previous = ''; // On windows, check that the root exists. On unix there is no need.
  14696. if (isWindows && !knownHard[base]) {
  14697. fs.lstatSync(base);
  14698. knownHard[base] = true;
  14699. }
  14700. } // walk down the path, swapping out linked pathparts for their real
  14701. // values
  14702. // NB: p.length changes.
  14703. while (pos < p.length) {
  14704. // find the next part
  14705. nextPartRe.lastIndex = pos;
  14706. var result = nextPartRe.exec(p);
  14707. previous = current;
  14708. current += result[0];
  14709. base = previous + result[1];
  14710. pos = nextPartRe.lastIndex; // continue if not a symlink
  14711. if (knownHard[base] || cache && cache[base] === base) {
  14712. continue;
  14713. }
  14714. var resolvedLink;
  14715. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  14716. // some known symbolic link. no need to stat again.
  14717. resolvedLink = cache[base];
  14718. } else {
  14719. var stat = fs.lstatSync(base);
  14720. if (!stat.isSymbolicLink()) {
  14721. knownHard[base] = true;
  14722. if (cache) cache[base] = base;
  14723. continue;
  14724. } // read the link if it wasn't read before
  14725. // dev/ino always return 0 on windows, so skip the check.
  14726. var linkTarget = null;
  14727. if (!isWindows) {
  14728. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  14729. if (seenLinks.hasOwnProperty(id)) {
  14730. linkTarget = seenLinks[id];
  14731. }
  14732. }
  14733. if (linkTarget === null) {
  14734. fs.statSync(base);
  14735. linkTarget = fs.readlinkSync(base);
  14736. }
  14737. resolvedLink = path.resolve(previous, linkTarget); // track this, if given a cache.
  14738. if (cache) cache[base] = resolvedLink;
  14739. if (!isWindows) seenLinks[id] = linkTarget;
  14740. } // resolve the link, then start over
  14741. p = path.resolve(resolvedLink, p.slice(pos));
  14742. start();
  14743. }
  14744. if (cache) cache[original] = p;
  14745. return p;
  14746. };
  14747. var realpath$1 = function realpath(p, cache, cb) {
  14748. if (typeof cb !== 'function') {
  14749. cb = maybeCallback(cache);
  14750. cache = null;
  14751. } // make p is absolute
  14752. p = path.resolve(p);
  14753. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  14754. return process.nextTick(cb.bind(null, null, cache[p]));
  14755. }
  14756. var original = p,
  14757. seenLinks = {},
  14758. knownHard = {}; // current character position in p
  14759. var pos; // the partial path so far, including a trailing slash if any
  14760. var current; // the partial path without a trailing slash (except when pointing at a root)
  14761. var base; // the partial path scanned in the previous round, with slash
  14762. var previous;
  14763. start();
  14764. function start() {
  14765. // Skip over roots
  14766. var m = splitRootRe.exec(p);
  14767. pos = m[0].length;
  14768. current = m[0];
  14769. base = m[0];
  14770. previous = ''; // On windows, check that the root exists. On unix there is no need.
  14771. if (isWindows && !knownHard[base]) {
  14772. fs.lstat(base, function (err) {
  14773. if (err) return cb(err);
  14774. knownHard[base] = true;
  14775. LOOP();
  14776. });
  14777. } else {
  14778. process.nextTick(LOOP);
  14779. }
  14780. } // walk down the path, swapping out linked pathparts for their real
  14781. // values
  14782. function LOOP() {
  14783. // stop if scanned past end of path
  14784. if (pos >= p.length) {
  14785. if (cache) cache[original] = p;
  14786. return cb(null, p);
  14787. } // find the next part
  14788. nextPartRe.lastIndex = pos;
  14789. var result = nextPartRe.exec(p);
  14790. previous = current;
  14791. current += result[0];
  14792. base = previous + result[1];
  14793. pos = nextPartRe.lastIndex; // continue if not a symlink
  14794. if (knownHard[base] || cache && cache[base] === base) {
  14795. return process.nextTick(LOOP);
  14796. }
  14797. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  14798. // known symbolic link. no need to stat again.
  14799. return gotResolvedLink(cache[base]);
  14800. }
  14801. return fs.lstat(base, gotStat);
  14802. }
  14803. function gotStat(err, stat) {
  14804. if (err) return cb(err); // if not a symlink, skip to the next path part
  14805. if (!stat.isSymbolicLink()) {
  14806. knownHard[base] = true;
  14807. if (cache) cache[base] = base;
  14808. return process.nextTick(LOOP);
  14809. } // stat & read the link if not read before
  14810. // call gotTarget as soon as the link target is known
  14811. // dev/ino always return 0 on windows, so skip the check.
  14812. if (!isWindows) {
  14813. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  14814. if (seenLinks.hasOwnProperty(id)) {
  14815. return gotTarget(null, seenLinks[id], base);
  14816. }
  14817. }
  14818. fs.stat(base, function (err) {
  14819. if (err) return cb(err);
  14820. fs.readlink(base, function (err, target) {
  14821. if (!isWindows) seenLinks[id] = target;
  14822. gotTarget(err, target);
  14823. });
  14824. });
  14825. }
  14826. function gotTarget(err, target, base) {
  14827. if (err) return cb(err);
  14828. var resolvedLink = path.resolve(previous, target);
  14829. if (cache) cache[base] = resolvedLink;
  14830. gotResolvedLink(resolvedLink);
  14831. }
  14832. function gotResolvedLink(resolvedLink) {
  14833. // resolve the link, then start over
  14834. p = path.resolve(resolvedLink, p.slice(pos));
  14835. start();
  14836. }
  14837. };
  14838. var old = {
  14839. realpathSync: realpathSync$1,
  14840. realpath: realpath$1
  14841. };
  14842. var fs_realpath = realpath;
  14843. realpath.realpath = realpath;
  14844. realpath.sync = realpathSync;
  14845. realpath.realpathSync = realpathSync;
  14846. realpath.monkeypatch = monkeypatch;
  14847. realpath.unmonkeypatch = unmonkeypatch;
  14848. var origRealpath = fs.realpath;
  14849. var origRealpathSync = fs.realpathSync;
  14850. var version$2 = process.version;
  14851. var ok = /^v[0-5]\./.test(version$2);
  14852. function newError(er) {
  14853. return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
  14854. }
  14855. function realpath(p, cache, cb) {
  14856. if (ok) {
  14857. return origRealpath(p, cache, cb);
  14858. }
  14859. if (typeof cache === 'function') {
  14860. cb = cache;
  14861. cache = null;
  14862. }
  14863. origRealpath(p, cache, function (er, result) {
  14864. if (newError(er)) {
  14865. old.realpath(p, cache, cb);
  14866. } else {
  14867. cb(er, result);
  14868. }
  14869. });
  14870. }
  14871. function realpathSync(p, cache) {
  14872. if (ok) {
  14873. return origRealpathSync(p, cache);
  14874. }
  14875. try {
  14876. return origRealpathSync(p, cache);
  14877. } catch (er) {
  14878. if (newError(er)) {
  14879. return old.realpathSync(p, cache);
  14880. } else {
  14881. throw er;
  14882. }
  14883. }
  14884. }
  14885. function monkeypatch() {
  14886. fs.realpath = realpath;
  14887. fs.realpathSync = realpathSync;
  14888. }
  14889. function unmonkeypatch() {
  14890. fs.realpath = origRealpath;
  14891. fs.realpathSync = origRealpathSync;
  14892. }
  14893. var concatMap = function concatMap(xs, fn) {
  14894. var res = [];
  14895. for (var i = 0; i < xs.length; i++) {
  14896. var x = fn(xs[i], i);
  14897. if (isArray(x)) res.push.apply(res, x);else res.push(x);
  14898. }
  14899. return res;
  14900. };
  14901. var isArray = Array.isArray || function (xs) {
  14902. return Object.prototype.toString.call(xs) === '[object Array]';
  14903. };
  14904. var balancedMatch = balanced;
  14905. function balanced(a, b, str) {
  14906. if (a instanceof RegExp) a = maybeMatch(a, str);
  14907. if (b instanceof RegExp) b = maybeMatch(b, str);
  14908. var r = range(a, b, str);
  14909. return r && {
  14910. start: r[0],
  14911. end: r[1],
  14912. pre: str.slice(0, r[0]),
  14913. body: str.slice(r[0] + a.length, r[1]),
  14914. post: str.slice(r[1] + b.length)
  14915. };
  14916. }
  14917. function maybeMatch(reg, str) {
  14918. var m = str.match(reg);
  14919. return m ? m[0] : null;
  14920. }
  14921. balanced.range = range;
  14922. function range(a, b, str) {
  14923. var begs, beg, left, right, result;
  14924. var ai = str.indexOf(a);
  14925. var bi = str.indexOf(b, ai + 1);
  14926. var i = ai;
  14927. if (ai >= 0 && bi > 0) {
  14928. begs = [];
  14929. left = str.length;
  14930. while (i >= 0 && !result) {
  14931. if (i == ai) {
  14932. begs.push(i);
  14933. ai = str.indexOf(a, i + 1);
  14934. } else if (begs.length == 1) {
  14935. result = [begs.pop(), bi];
  14936. } else {
  14937. beg = begs.pop();
  14938. if (beg < left) {
  14939. left = beg;
  14940. right = bi;
  14941. }
  14942. bi = str.indexOf(b, i + 1);
  14943. }
  14944. i = ai < bi && ai >= 0 ? ai : bi;
  14945. }
  14946. if (begs.length) {
  14947. result = [left, right];
  14948. }
  14949. }
  14950. return result;
  14951. }
  14952. var braceExpansion = expandTop;
  14953. var escSlash = '\0SLASH' + Math.random() + '\0';
  14954. var escOpen = '\0OPEN' + Math.random() + '\0';
  14955. var escClose = '\0CLOSE' + Math.random() + '\0';
  14956. var escComma = '\0COMMA' + Math.random() + '\0';
  14957. var escPeriod = '\0PERIOD' + Math.random() + '\0';
  14958. function numeric(str) {
  14959. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  14960. }
  14961. function escapeBraces(str) {
  14962. return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
  14963. }
  14964. function unescapeBraces(str) {
  14965. return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
  14966. } // Basically just str.split(","), but handling cases
  14967. // where we have nested braced sections, which should be
  14968. // treated as individual members, like {a,{b,c},d}
  14969. function parseCommaParts(str) {
  14970. if (!str) return [''];
  14971. var parts = [];
  14972. var m = balancedMatch('{', '}', str);
  14973. if (!m) return str.split(',');
  14974. var pre = m.pre;
  14975. var body = m.body;
  14976. var post = m.post;
  14977. var p = pre.split(',');
  14978. p[p.length - 1] += '{' + body + '}';
  14979. var postParts = parseCommaParts(post);
  14980. if (post.length) {
  14981. p[p.length - 1] += postParts.shift();
  14982. p.push.apply(p, postParts);
  14983. }
  14984. parts.push.apply(parts, p);
  14985. return parts;
  14986. }
  14987. function expandTop(str) {
  14988. if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
  14989. // Anything starting with {} will have the first two bytes preserved
  14990. // but *only* at the top level, so {},a}b will not expand to anything,
  14991. // but a{},b}c will be expanded to [a}c,abc].
  14992. // One could argue that this is a bug in Bash, but since the goal of
  14993. // this module is to match Bash's rules, we escape a leading {}
  14994. if (str.substr(0, 2) === '{}') {
  14995. str = '\\{\\}' + str.substr(2);
  14996. }
  14997. return expand(escapeBraces(str), true).map(unescapeBraces);
  14998. }
  14999. function embrace(str) {
  15000. return '{' + str + '}';
  15001. }
  15002. function isPadded(el) {
  15003. return /^-?0\d/.test(el);
  15004. }
  15005. function lte(i, y) {
  15006. return i <= y;
  15007. }
  15008. function gte(i, y) {
  15009. return i >= y;
  15010. }
  15011. function expand(str, isTop) {
  15012. var expansions = [];
  15013. var m = balancedMatch('{', '}', str);
  15014. if (!m || /\$$/.test(m.pre)) return [str];
  15015. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  15016. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  15017. var isSequence = isNumericSequence || isAlphaSequence;
  15018. var isOptions = m.body.indexOf(',') >= 0;
  15019. if (!isSequence && !isOptions) {
  15020. // {a},b}
  15021. if (m.post.match(/,.*\}/)) {
  15022. str = m.pre + '{' + m.body + escClose + m.post;
  15023. return expand(str);
  15024. }
  15025. return [str];
  15026. }
  15027. var n;
  15028. if (isSequence) {
  15029. n = m.body.split(/\.\./);
  15030. } else {
  15031. n = parseCommaParts(m.body);
  15032. if (n.length === 1) {
  15033. // x{{a,b}}y ==> x{a}y x{b}y
  15034. n = expand(n[0], false).map(embrace);
  15035. if (n.length === 1) {
  15036. var post = m.post.length ? expand(m.post, false) : [''];
  15037. return post.map(function (p) {
  15038. return m.pre + n[0] + p;
  15039. });
  15040. }
  15041. }
  15042. } // at this point, n is the parts, and we know it's not a comma set
  15043. // with a single entry.
  15044. // no need to expand pre, since it is guaranteed to be free of brace-sets
  15045. var pre = m.pre;
  15046. var post = m.post.length ? expand(m.post, false) : [''];
  15047. var N;
  15048. if (isSequence) {
  15049. var x = numeric(n[0]);
  15050. var y = numeric(n[1]);
  15051. var width = Math.max(n[0].length, n[1].length);
  15052. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  15053. var test = lte;
  15054. var reverse = y < x;
  15055. if (reverse) {
  15056. incr *= -1;
  15057. test = gte;
  15058. }
  15059. var pad = n.some(isPadded);
  15060. N = [];
  15061. for (var i = x; test(i, y); i += incr) {
  15062. var c;
  15063. if (isAlphaSequence) {
  15064. c = String.fromCharCode(i);
  15065. if (c === '\\') c = '';
  15066. } else {
  15067. c = String(i);
  15068. if (pad) {
  15069. var need = width - c.length;
  15070. if (need > 0) {
  15071. var z = new Array(need + 1).join('0');
  15072. if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
  15073. }
  15074. }
  15075. }
  15076. N.push(c);
  15077. }
  15078. } else {
  15079. N = concatMap(n, function (el) {
  15080. return expand(el, false);
  15081. });
  15082. }
  15083. for (var j = 0; j < N.length; j++) {
  15084. for (var k = 0; k < post.length; k++) {
  15085. var expansion = pre + N[j] + post[k];
  15086. if (!isTop || isSequence || expansion) expansions.push(expansion);
  15087. }
  15088. }
  15089. return expansions;
  15090. }
  15091. var minimatch_1 = minimatch;
  15092. minimatch.Minimatch = Minimatch$1;
  15093. var path$2 = {
  15094. sep: '/'
  15095. };
  15096. try {
  15097. path$2 = path;
  15098. } catch (er) {}
  15099. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch$1.GLOBSTAR = {};
  15100. var plTypes = {
  15101. '!': {
  15102. open: '(?:(?!(?:',
  15103. close: '))[^/]*?)'
  15104. },
  15105. '?': {
  15106. open: '(?:',
  15107. close: ')?'
  15108. },
  15109. '+': {
  15110. open: '(?:',
  15111. close: ')+'
  15112. },
  15113. '*': {
  15114. open: '(?:',
  15115. close: ')*'
  15116. },
  15117. '@': {
  15118. open: '(?:',
  15119. close: ')'
  15120. } // any single thing other than /
  15121. // don't need to escape / when using new RegExp()
  15122. };
  15123. var qmark = '[^/]'; // * => any number of characters
  15124. var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
  15125. // not (^ or / followed by one or two dots followed by $ or /),
  15126. // followed by anything, any number of times.
  15127. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
  15128. // followed by anything, any number of times.
  15129. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
  15130. var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
  15131. function charSet(s) {
  15132. return s.split('').reduce(function (set, c) {
  15133. set[c] = true;
  15134. return set;
  15135. }, {});
  15136. } // normalizes slashes.
  15137. var slashSplit = /\/+/;
  15138. minimatch.filter = filter;
  15139. function filter(pattern, options) {
  15140. options = options || {};
  15141. return function (p, i, list) {
  15142. return minimatch(p, pattern, options);
  15143. };
  15144. }
  15145. function ext(a, b) {
  15146. a = a || {};
  15147. b = b || {};
  15148. var t = {};
  15149. Object.keys(b).forEach(function (k) {
  15150. t[k] = b[k];
  15151. });
  15152. Object.keys(a).forEach(function (k) {
  15153. t[k] = a[k];
  15154. });
  15155. return t;
  15156. }
  15157. minimatch.defaults = function (def) {
  15158. if (!def || !Object.keys(def).length) return minimatch;
  15159. var orig = minimatch;
  15160. var m = function minimatch(p, pattern, options) {
  15161. return orig.minimatch(p, pattern, ext(def, options));
  15162. };
  15163. m.Minimatch = function Minimatch(pattern, options) {
  15164. return new orig.Minimatch(pattern, ext(def, options));
  15165. };
  15166. return m;
  15167. };
  15168. Minimatch$1.defaults = function (def) {
  15169. if (!def || !Object.keys(def).length) return Minimatch$1;
  15170. return minimatch.defaults(def).Minimatch;
  15171. };
  15172. function minimatch(p, pattern, options) {
  15173. if (typeof pattern !== 'string') {
  15174. throw new TypeError('glob pattern string required');
  15175. }
  15176. if (!options) options = {}; // shortcut: comments match nothing.
  15177. if (!options.nocomment && pattern.charAt(0) === '#') {
  15178. return false;
  15179. } // "" only matches ""
  15180. if (pattern.trim() === '') return p === '';
  15181. return new Minimatch$1(pattern, options).match(p);
  15182. }
  15183. function Minimatch$1(pattern, options) {
  15184. if (!(this instanceof Minimatch$1)) {
  15185. return new Minimatch$1(pattern, options);
  15186. }
  15187. if (typeof pattern !== 'string') {
  15188. throw new TypeError('glob pattern string required');
  15189. }
  15190. if (!options) options = {};
  15191. pattern = pattern.trim(); // windows support: need to use /, not \
  15192. if (path$2.sep !== '/') {
  15193. pattern = pattern.split(path$2.sep).join('/');
  15194. }
  15195. this.options = options;
  15196. this.set = [];
  15197. this.pattern = pattern;
  15198. this.regexp = null;
  15199. this.negate = false;
  15200. this.comment = false;
  15201. this.empty = false; // make the set of regexps etc.
  15202. this.make();
  15203. }
  15204. Minimatch$1.prototype.debug = function () {};
  15205. Minimatch$1.prototype.make = make;
  15206. function make() {
  15207. // don't do it more than once.
  15208. if (this._made) return;
  15209. var pattern = this.pattern;
  15210. var options = this.options; // empty patterns and comments match nothing.
  15211. if (!options.nocomment && pattern.charAt(0) === '#') {
  15212. this.comment = true;
  15213. return;
  15214. }
  15215. if (!pattern) {
  15216. this.empty = true;
  15217. return;
  15218. } // step 1: figure out negation, etc.
  15219. this.parseNegate(); // step 2: expand braces
  15220. var set = this.globSet = this.braceExpand();
  15221. if (options.debug) this.debug = console.error;
  15222. this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  15223. // matching patterns.
  15224. // These will be regexps, except in the case of "**", which is
  15225. // set to the GLOBSTAR object for globstar behavior,
  15226. // and will not contain any / characters
  15227. set = this.globParts = set.map(function (s) {
  15228. return s.split(slashSplit);
  15229. });
  15230. this.debug(this.pattern, set); // glob --> regexps
  15231. set = set.map(function (s, si, set) {
  15232. return s.map(this.parse, this);
  15233. }, this);
  15234. this.debug(this.pattern, set); // filter out everything that didn't compile properly.
  15235. set = set.filter(function (s) {
  15236. return s.indexOf(false) === -1;
  15237. });
  15238. this.debug(this.pattern, set);
  15239. this.set = set;
  15240. }
  15241. Minimatch$1.prototype.parseNegate = parseNegate;
  15242. function parseNegate() {
  15243. var pattern = this.pattern;
  15244. var negate = false;
  15245. var options = this.options;
  15246. var negateOffset = 0;
  15247. if (options.nonegate) return;
  15248. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
  15249. negate = !negate;
  15250. negateOffset++;
  15251. }
  15252. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  15253. this.negate = negate;
  15254. } // Brace expansion:
  15255. // a{b,c}d -> abd acd
  15256. // a{b,}c -> abc ac
  15257. // a{0..3}d -> a0d a1d a2d a3d
  15258. // a{b,c{d,e}f}g -> abg acdfg acefg
  15259. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  15260. //
  15261. // Invalid sets are not expanded.
  15262. // a{2..}b -> a{2..}b
  15263. // a{b}c -> a{b}c
  15264. minimatch.braceExpand = function (pattern, options) {
  15265. return braceExpand(pattern, options);
  15266. };
  15267. Minimatch$1.prototype.braceExpand = braceExpand;
  15268. function braceExpand(pattern, options) {
  15269. if (!options) {
  15270. if (this instanceof Minimatch$1) {
  15271. options = this.options;
  15272. } else {
  15273. options = {};
  15274. }
  15275. }
  15276. pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
  15277. if (typeof pattern === 'undefined') {
  15278. throw new TypeError('undefined pattern');
  15279. }
  15280. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  15281. // shortcut. no need to expand.
  15282. return [pattern];
  15283. }
  15284. return braceExpansion(pattern);
  15285. } // parse a component of the expanded set.
  15286. // At this point, no pattern may contain "/" in it
  15287. // so we're going to return a 2d array, where each entry is the full
  15288. // pattern, split on '/', and then turned into a regular expression.
  15289. // A regexp is made at the end which joins each array with an
  15290. // escaped /, and another full one which joins each regexp with |.
  15291. //
  15292. // Following the lead of Bash 4.1, note that "**" only has special meaning
  15293. // when it is the *only* thing in a path portion. Otherwise, any series
  15294. // of * is equivalent to a single *. Globstar behavior is enabled by
  15295. // default, and can be disabled by setting options.noglobstar.
  15296. Minimatch$1.prototype.parse = parse$3;
  15297. var SUBPARSE = {};
  15298. function parse$3(pattern, isSub) {
  15299. if (pattern.length > 1024 * 64) {
  15300. throw new TypeError('pattern is too long');
  15301. }
  15302. var options = this.options; // shortcuts
  15303. if (!options.noglobstar && pattern === '**') return GLOBSTAR;
  15304. if (pattern === '') return '';
  15305. var re = '';
  15306. var hasMagic = !!options.nocase;
  15307. var escaping = false; // ? => one single character
  15308. var patternListStack = [];
  15309. var negativeLists = [];
  15310. var stateChar;
  15311. var inClass = false;
  15312. var reClassStart = -1;
  15313. var classStart = -1; // . and .. never match anything that doesn't start with .,
  15314. // even when options.dot is set.
  15315. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  15316. // not (start or / followed by . or .. followed by / or end)
  15317. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
  15318. var self = this;
  15319. function clearStateChar() {
  15320. if (stateChar) {
  15321. // we had some state-tracking character
  15322. // that wasn't consumed by this pass.
  15323. switch (stateChar) {
  15324. case '*':
  15325. re += star;
  15326. hasMagic = true;
  15327. break;
  15328. case '?':
  15329. re += qmark;
  15330. hasMagic = true;
  15331. break;
  15332. default:
  15333. re += '\\' + stateChar;
  15334. break;
  15335. }
  15336. self.debug('clearStateChar %j %j', stateChar, re);
  15337. stateChar = false;
  15338. }
  15339. }
  15340. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  15341. this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
  15342. if (escaping && reSpecials[c]) {
  15343. re += '\\' + c;
  15344. escaping = false;
  15345. continue;
  15346. }
  15347. switch (c) {
  15348. case '/':
  15349. // completely not allowed, even escaped.
  15350. // Should already be path-split by now.
  15351. return false;
  15352. case '\\':
  15353. clearStateChar();
  15354. escaping = true;
  15355. continue;
  15356. // the various stateChar values
  15357. // for the "extglob" stuff.
  15358. case '?':
  15359. case '*':
  15360. case '+':
  15361. case '@':
  15362. case '!':
  15363. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
  15364. // the glob [!a] means [^a] in regexp
  15365. if (inClass) {
  15366. this.debug(' in class');
  15367. if (c === '!' && i === classStart + 1) c = '^';
  15368. re += c;
  15369. continue;
  15370. } // if we already have a stateChar, then it means
  15371. // that there was something like ** or +? in there.
  15372. // Handle the stateChar, then proceed with this one.
  15373. self.debug('call clearStateChar %j', stateChar);
  15374. clearStateChar();
  15375. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  15376. // just clear the statechar *now*, rather than even diving into
  15377. // the patternList stuff.
  15378. if (options.noext) clearStateChar();
  15379. continue;
  15380. case '(':
  15381. if (inClass) {
  15382. re += '(';
  15383. continue;
  15384. }
  15385. if (!stateChar) {
  15386. re += '\\(';
  15387. continue;
  15388. }
  15389. patternListStack.push({
  15390. type: stateChar,
  15391. start: i - 1,
  15392. reStart: re.length,
  15393. open: plTypes[stateChar].open,
  15394. close: plTypes[stateChar].close
  15395. }); // negation is (?:(?!js)[^/]*)
  15396. re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
  15397. this.debug('plType %j %j', stateChar, re);
  15398. stateChar = false;
  15399. continue;
  15400. case ')':
  15401. if (inClass || !patternListStack.length) {
  15402. re += '\\)';
  15403. continue;
  15404. }
  15405. clearStateChar();
  15406. hasMagic = true;
  15407. var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
  15408. // The others are (?:<pattern>)<type>
  15409. re += pl.close;
  15410. if (pl.type === '!') {
  15411. negativeLists.push(pl);
  15412. }
  15413. pl.reEnd = re.length;
  15414. continue;
  15415. case '|':
  15416. if (inClass || !patternListStack.length || escaping) {
  15417. re += '\\|';
  15418. escaping = false;
  15419. continue;
  15420. }
  15421. clearStateChar();
  15422. re += '|';
  15423. continue;
  15424. // these are mostly the same in regexp and glob
  15425. case '[':
  15426. // swallow any state-tracking char before the [
  15427. clearStateChar();
  15428. if (inClass) {
  15429. re += '\\' + c;
  15430. continue;
  15431. }
  15432. inClass = true;
  15433. classStart = i;
  15434. reClassStart = re.length;
  15435. re += c;
  15436. continue;
  15437. case ']':
  15438. // a right bracket shall lose its special
  15439. // meaning and represent itself in
  15440. // a bracket expression if it occurs
  15441. // first in the list. -- POSIX.2 2.8.3.2
  15442. if (i === classStart + 1 || !inClass) {
  15443. re += '\\' + c;
  15444. escaping = false;
  15445. continue;
  15446. } // handle the case where we left a class open.
  15447. // "[z-a]" is valid, equivalent to "\[z-a\]"
  15448. if (inClass) {
  15449. // split where the last [ was, make sure we don't have
  15450. // an invalid re. if so, re-walk the contents of the
  15451. // would-be class to re-translate any characters that
  15452. // were passed through as-is
  15453. // TODO: It would probably be faster to determine this
  15454. // without a try/catch and a new RegExp, but it's tricky
  15455. // to do safely. For now, this is safe and works.
  15456. var cs = pattern.substring(classStart + 1, i);
  15457. try {
  15458. RegExp('[' + cs + ']');
  15459. } catch (er) {
  15460. // not a valid class!
  15461. var sp = this.parse(cs, SUBPARSE);
  15462. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
  15463. hasMagic = hasMagic || sp[1];
  15464. inClass = false;
  15465. continue;
  15466. }
  15467. } // finish up the class.
  15468. hasMagic = true;
  15469. inClass = false;
  15470. re += c;
  15471. continue;
  15472. default:
  15473. // swallow any state char that wasn't consumed
  15474. clearStateChar();
  15475. if (escaping) {
  15476. // no need
  15477. escaping = false;
  15478. } else if (reSpecials[c] && !(c === '^' && inClass)) {
  15479. re += '\\';
  15480. }
  15481. re += c;
  15482. } // switch
  15483. } // for
  15484. // handle the case where we left a class open.
  15485. // "[abc" is valid, equivalent to "\[abc"
  15486. if (inClass) {
  15487. // split where the last [ was, and escape it
  15488. // this is a huge pita. We now have to re-walk
  15489. // the contents of the would-be class to re-translate
  15490. // any characters that were passed through as-is
  15491. cs = pattern.substr(classStart + 1);
  15492. sp = this.parse(cs, SUBPARSE);
  15493. re = re.substr(0, reClassStart) + '\\[' + sp[0];
  15494. hasMagic = hasMagic || sp[1];
  15495. } // handle the case where we had a +( thing at the *end*
  15496. // of the pattern.
  15497. // each pattern list stack adds 3 chars, and we need to go through
  15498. // and escape any | chars that were passed through as-is for the regexp.
  15499. // Go through and escape them, taking care not to double-escape any
  15500. // | chars that were already escaped.
  15501. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  15502. var tail = re.slice(pl.reStart + pl.open.length);
  15503. this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
  15504. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  15505. if (!$2) {
  15506. // the | isn't already escaped, so escape it.
  15507. $2 = '\\';
  15508. } // need to escape all those slashes *again*, without escaping the
  15509. // one that we need for escaping the | character. As it works out,
  15510. // escaping an even number of slashes can be done by simply repeating
  15511. // it exactly after itself. That's why this trick works.
  15512. //
  15513. // I am sorry that you have to see this.
  15514. return $1 + $1 + $2 + '|';
  15515. });
  15516. this.debug('tail=%j\n %s', tail, tail, pl, re);
  15517. var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
  15518. hasMagic = true;
  15519. re = re.slice(0, pl.reStart) + t + '\\(' + tail;
  15520. } // handle trailing things that only matter at the very end.
  15521. clearStateChar();
  15522. if (escaping) {
  15523. // trailing \\
  15524. re += '\\\\';
  15525. } // only need to apply the nodot start if the re starts with
  15526. // something that could conceivably capture a dot
  15527. var addPatternStart = false;
  15528. switch (re.charAt(0)) {
  15529. case '.':
  15530. case '[':
  15531. case '(':
  15532. addPatternStart = true;
  15533. } // Hack to work around lack of negative lookbehind in JS
  15534. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  15535. // like 'a.xyz.yz' doesn't match. So, the first negative
  15536. // lookahead, has to look ALL the way ahead, to the end of
  15537. // the pattern.
  15538. for (var n = negativeLists.length - 1; n > -1; n--) {
  15539. var nl = negativeLists[n];
  15540. var nlBefore = re.slice(0, nl.reStart);
  15541. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  15542. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  15543. var nlAfter = re.slice(nl.reEnd);
  15544. nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
  15545. // mean that we should *not* include the ) in the bit that is considered
  15546. // "after" the negated section.
  15547. var openParensBefore = nlBefore.split('(').length - 1;
  15548. var cleanAfter = nlAfter;
  15549. for (i = 0; i < openParensBefore; i++) {
  15550. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
  15551. }
  15552. nlAfter = cleanAfter;
  15553. var dollar = '';
  15554. if (nlAfter === '' && isSub !== SUBPARSE) {
  15555. dollar = '$';
  15556. }
  15557. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  15558. re = newRe;
  15559. } // if the re is not "" at this point, then we need to make sure
  15560. // it doesn't match against an empty path part.
  15561. // Otherwise a/* will match a/, which it should not.
  15562. if (re !== '' && hasMagic) {
  15563. re = '(?=.)' + re;
  15564. }
  15565. if (addPatternStart) {
  15566. re = patternStart + re;
  15567. } // parsing just a piece of a larger pattern.
  15568. if (isSub === SUBPARSE) {
  15569. return [re, hasMagic];
  15570. } // skip the regexp for non-magical patterns
  15571. // unescape anything in it, though, so that it'll be
  15572. // an exact match against a file etc.
  15573. if (!hasMagic) {
  15574. return globUnescape(pattern);
  15575. }
  15576. var flags = options.nocase ? 'i' : '';
  15577. try {
  15578. var regExp = new RegExp('^' + re + '$', flags);
  15579. } catch (er) {
  15580. // If it was an invalid regular expression, then it can't match
  15581. // anything. This trick looks for a character after the end of
  15582. // the string, which is of course impossible, except in multi-line
  15583. // mode, but it's not a /m regex.
  15584. return new RegExp('$.');
  15585. }
  15586. regExp._glob = pattern;
  15587. regExp._src = re;
  15588. return regExp;
  15589. }
  15590. minimatch.makeRe = function (pattern, options) {
  15591. return new Minimatch$1(pattern, options || {}).makeRe();
  15592. };
  15593. Minimatch$1.prototype.makeRe = makeRe;
  15594. function makeRe() {
  15595. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  15596. // pattern strings, or "**".
  15597. //
  15598. // It's better to use .match(). This function shouldn't
  15599. // be used, really, but it's pretty convenient sometimes,
  15600. // when you just want to work with a regex.
  15601. var set = this.set;
  15602. if (!set.length) {
  15603. this.regexp = false;
  15604. return this.regexp;
  15605. }
  15606. var options = this.options;
  15607. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  15608. var flags = options.nocase ? 'i' : '';
  15609. var re = set.map(function (pattern) {
  15610. return pattern.map(function (p) {
  15611. return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
  15612. }).join('\\\/');
  15613. }).join('|'); // must match entire pattern
  15614. // ending in a * or ** will make it less strict.
  15615. re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
  15616. if (this.negate) re = '^(?!' + re + ').*$';
  15617. try {
  15618. this.regexp = new RegExp(re, flags);
  15619. } catch (ex) {
  15620. this.regexp = false;
  15621. }
  15622. return this.regexp;
  15623. }
  15624. minimatch.match = function (list, pattern, options) {
  15625. options = options || {};
  15626. var mm = new Minimatch$1(pattern, options);
  15627. list = list.filter(function (f) {
  15628. return mm.match(f);
  15629. });
  15630. if (mm.options.nonull && !list.length) {
  15631. list.push(pattern);
  15632. }
  15633. return list;
  15634. };
  15635. Minimatch$1.prototype.match = match;
  15636. function match(f, partial) {
  15637. this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
  15638. // comments, etc.
  15639. if (this.comment) return false;
  15640. if (this.empty) return f === '';
  15641. if (f === '/' && partial) return true;
  15642. var options = this.options; // windows: need to use /, not \
  15643. if (path$2.sep !== '/') {
  15644. f = f.split(path$2.sep).join('/');
  15645. } // treat the test path as a set of pathparts.
  15646. f = f.split(slashSplit);
  15647. this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
  15648. // in order for it to be valid. If negating, then just one
  15649. // match means that we have failed.
  15650. // Either way, return on the first hit.
  15651. var set = this.set;
  15652. this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
  15653. var filename;
  15654. var i;
  15655. for (i = f.length - 1; i >= 0; i--) {
  15656. filename = f[i];
  15657. if (filename) break;
  15658. }
  15659. for (i = 0; i < set.length; i++) {
  15660. var pattern = set[i];
  15661. var file = f;
  15662. if (options.matchBase && pattern.length === 1) {
  15663. file = [filename];
  15664. }
  15665. var hit = this.matchOne(file, pattern, partial);
  15666. if (hit) {
  15667. if (options.flipNegate) return true;
  15668. return !this.negate;
  15669. }
  15670. } // didn't get any hits. this is success if it's a negative
  15671. // pattern, failure otherwise.
  15672. if (options.flipNegate) return false;
  15673. return this.negate;
  15674. } // set partial to true to test if, for example,
  15675. // "/a/b" matches the start of "/*/b/*/d"
  15676. // Partial means, if you run out of file before you run
  15677. // out of pattern, then that's fine, as long as all
  15678. // the parts match.
  15679. Minimatch$1.prototype.matchOne = function (file, pattern, partial) {
  15680. var options = this.options;
  15681. this.debug('matchOne', {
  15682. 'this': this,
  15683. file: file,
  15684. pattern: pattern
  15685. });
  15686. this.debug('matchOne', file.length, pattern.length);
  15687. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  15688. this.debug('matchOne loop');
  15689. var p = pattern[pi];
  15690. var f = file[fi];
  15691. this.debug(pattern, p, f); // should be impossible.
  15692. // some invalid regexp stuff in the set.
  15693. if (p === false) return false;
  15694. if (p === GLOBSTAR) {
  15695. this.debug('GLOBSTAR', [pattern, p, f]); // "**"
  15696. // a/**/b/**/c would match the following:
  15697. // a/b/x/y/z/c
  15698. // a/x/y/z/b/c
  15699. // a/b/x/b/x/c
  15700. // a/b/c
  15701. // To do this, take the rest of the pattern after
  15702. // the **, and see if it would match the file remainder.
  15703. // If so, return success.
  15704. // If not, the ** "swallows" a segment, and try again.
  15705. // This is recursively awful.
  15706. //
  15707. // a/**/b/**/c matching a/b/x/y/z/c
  15708. // - a matches a
  15709. // - doublestar
  15710. // - matchOne(b/x/y/z/c, b/**/c)
  15711. // - b matches b
  15712. // - doublestar
  15713. // - matchOne(x/y/z/c, c) -> no
  15714. // - matchOne(y/z/c, c) -> no
  15715. // - matchOne(z/c, c) -> no
  15716. // - matchOne(c, c) yes, hit
  15717. var fr = fi;
  15718. var pr = pi + 1;
  15719. if (pr === pl) {
  15720. this.debug('** at the end'); // a ** at the end will just swallow the rest.
  15721. // We have found a match.
  15722. // however, it will not swallow /.x, unless
  15723. // options.dot is set.
  15724. // . and .. are *never* matched by **, for explosively
  15725. // exponential reasons.
  15726. for (; fi < fl; fi++) {
  15727. if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
  15728. }
  15729. return true;
  15730. } // ok, let's see if we can swallow whatever we can.
  15731. while (fr < fl) {
  15732. var swallowee = file[fr];
  15733. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
  15734. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  15735. this.debug('globstar found match!', fr, fl, swallowee); // found a match.
  15736. return true;
  15737. } else {
  15738. // can't swallow "." or ".." ever.
  15739. // can only swallow ".foo" when explicitly asked.
  15740. if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
  15741. this.debug('dot detected!', file, fr, pattern, pr);
  15742. break;
  15743. } // ** swallows a segment, and continue.
  15744. this.debug('globstar swallow a segment, and continue');
  15745. fr++;
  15746. }
  15747. } // no match was found.
  15748. // However, in partial mode, we can't say this is necessarily over.
  15749. // If there's more *pattern* left, then
  15750. if (partial) {
  15751. // ran out of file
  15752. this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
  15753. if (fr === fl) return true;
  15754. }
  15755. return false;
  15756. } // something other than **
  15757. // non-magic patterns just have to match exactly
  15758. // patterns with magic have been turned into regexps.
  15759. var hit;
  15760. if (typeof p === 'string') {
  15761. if (options.nocase) {
  15762. hit = f.toLowerCase() === p.toLowerCase();
  15763. } else {
  15764. hit = f === p;
  15765. }
  15766. this.debug('string match', p, f, hit);
  15767. } else {
  15768. hit = f.match(p);
  15769. this.debug('pattern match', p, f, hit);
  15770. }
  15771. if (!hit) return false;
  15772. } // Note: ending in / means that we'll get a final ""
  15773. // at the end of the pattern. This can only match a
  15774. // corresponding "" at the end of the file.
  15775. // If the file ends in /, then it can only match a
  15776. // a pattern that ends in /, unless the pattern just
  15777. // doesn't have any more for it. But, a/b/ should *not*
  15778. // match "a/b/*", even though "" matches against the
  15779. // [^/]*? pattern, except in partial mode, where it might
  15780. // simply not be reached yet.
  15781. // However, a/b/ should still satisfy a/*
  15782. // now either we fell off the end of the pattern, or we're done.
  15783. if (fi === fl && pi === pl) {
  15784. // ran out of pattern and filename at the same time.
  15785. // an exact hit!
  15786. return true;
  15787. } else if (fi === fl) {
  15788. // ran out of file, but still had pattern left.
  15789. // this is ok if we're doing the match as part of
  15790. // a glob fs traversal.
  15791. return partial;
  15792. } else if (pi === pl) {
  15793. // ran out of pattern, still have file left.
  15794. // this is only acceptable if we're on the very last
  15795. // empty segment of a file with a trailing slash.
  15796. // a/* should match a/b/
  15797. var emptyFileEnd = fi === fl - 1 && file[fi] === '';
  15798. return emptyFileEnd;
  15799. } // should be unreachable.
  15800. throw new Error('wtf?');
  15801. }; // replace stuff like \* with *
  15802. function globUnescape(s) {
  15803. return s.replace(/\\(.)/g, '$1');
  15804. }
  15805. function regExpEscape(s) {
  15806. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  15807. }
  15808. var inherits_browser = createCommonjsModule(function (module) {
  15809. if (typeof Object.create === 'function') {
  15810. // implementation from standard node.js 'util' module
  15811. module.exports = function inherits(ctor, superCtor) {
  15812. ctor.super_ = superCtor;
  15813. ctor.prototype = Object.create(superCtor.prototype, {
  15814. constructor: {
  15815. value: ctor,
  15816. enumerable: false,
  15817. writable: true,
  15818. configurable: true
  15819. }
  15820. });
  15821. };
  15822. } else {
  15823. // old school shim for old browsers
  15824. module.exports = function inherits(ctor, superCtor) {
  15825. ctor.super_ = superCtor;
  15826. var TempCtor = function TempCtor() {};
  15827. TempCtor.prototype = superCtor.prototype;
  15828. ctor.prototype = new TempCtor();
  15829. ctor.prototype.constructor = ctor;
  15830. };
  15831. }
  15832. });
  15833. var inherits = createCommonjsModule(function (module) {
  15834. try {
  15835. var util$$1 = util;
  15836. if (typeof util$$1.inherits !== 'function') throw '';
  15837. module.exports = util$$1.inherits;
  15838. } catch (e) {
  15839. module.exports = inherits_browser;
  15840. }
  15841. });
  15842. function posix(path$$1) {
  15843. return path$$1.charAt(0) === '/';
  15844. }
  15845. function win32(path$$1) {
  15846. // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
  15847. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
  15848. var result = splitDeviceRe.exec(path$$1);
  15849. var device = result[1] || '';
  15850. var isUnc = Boolean(device && device.charAt(1) !== ':'); // UNC paths are always absolute
  15851. return Boolean(result[2] || isUnc);
  15852. }
  15853. var pathIsAbsolute = process.platform === 'win32' ? win32 : posix;
  15854. var posix_1 = posix;
  15855. var win32_1 = win32;
  15856. pathIsAbsolute.posix = posix_1;
  15857. pathIsAbsolute.win32 = win32_1;
  15858. var alphasort_1 = alphasort$2;
  15859. var alphasorti_1 = alphasorti$2;
  15860. var setopts_1 = setopts$2;
  15861. var ownProp_1 = ownProp$2;
  15862. var makeAbs_1 = makeAbs;
  15863. var finish_1 = finish;
  15864. var mark_1 = mark;
  15865. var isIgnored_1 = isIgnored$2;
  15866. var childrenIgnored_1 = childrenIgnored$2;
  15867. function ownProp$2(obj, field) {
  15868. return Object.prototype.hasOwnProperty.call(obj, field);
  15869. }
  15870. var Minimatch$3 = minimatch_1.Minimatch;
  15871. function alphasorti$2(a, b) {
  15872. return a.toLowerCase().localeCompare(b.toLowerCase());
  15873. }
  15874. function alphasort$2(a, b) {
  15875. return a.localeCompare(b);
  15876. }
  15877. function setupIgnores(self, options) {
  15878. self.ignore = options.ignore || [];
  15879. if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
  15880. if (self.ignore.length) {
  15881. self.ignore = self.ignore.map(ignoreMap);
  15882. }
  15883. } // ignore patterns are always in dot:true mode.
  15884. function ignoreMap(pattern) {
  15885. var gmatcher = null;
  15886. if (pattern.slice(-3) === '/**') {
  15887. var gpattern = pattern.replace(/(\/\*\*)+$/, '');
  15888. gmatcher = new Minimatch$3(gpattern, {
  15889. dot: true
  15890. });
  15891. }
  15892. return {
  15893. matcher: new Minimatch$3(pattern, {
  15894. dot: true
  15895. }),
  15896. gmatcher: gmatcher
  15897. };
  15898. }
  15899. function setopts$2(self, pattern, options) {
  15900. if (!options) options = {}; // base-matching: just use globstar for that.
  15901. if (options.matchBase && -1 === pattern.indexOf("/")) {
  15902. if (options.noglobstar) {
  15903. throw new Error("base matching requires globstar");
  15904. }
  15905. pattern = "**/" + pattern;
  15906. }
  15907. self.silent = !!options.silent;
  15908. self.pattern = pattern;
  15909. self.strict = options.strict !== false;
  15910. self.realpath = !!options.realpath;
  15911. self.realpathCache = options.realpathCache || Object.create(null);
  15912. self.follow = !!options.follow;
  15913. self.dot = !!options.dot;
  15914. self.mark = !!options.mark;
  15915. self.nodir = !!options.nodir;
  15916. if (self.nodir) self.mark = true;
  15917. self.sync = !!options.sync;
  15918. self.nounique = !!options.nounique;
  15919. self.nonull = !!options.nonull;
  15920. self.nosort = !!options.nosort;
  15921. self.nocase = !!options.nocase;
  15922. self.stat = !!options.stat;
  15923. self.noprocess = !!options.noprocess;
  15924. self.absolute = !!options.absolute;
  15925. self.maxLength = options.maxLength || Infinity;
  15926. self.cache = options.cache || Object.create(null);
  15927. self.statCache = options.statCache || Object.create(null);
  15928. self.symlinks = options.symlinks || Object.create(null);
  15929. setupIgnores(self, options);
  15930. self.changedCwd = false;
  15931. var cwd = process.cwd();
  15932. if (!ownProp$2(options, "cwd")) self.cwd = cwd;else {
  15933. self.cwd = path.resolve(options.cwd);
  15934. self.changedCwd = self.cwd !== cwd;
  15935. }
  15936. self.root = options.root || path.resolve(self.cwd, "/");
  15937. self.root = path.resolve(self.root);
  15938. if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); // TODO: is an absolute `cwd` supposed to be resolved against `root`?
  15939. // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
  15940. self.cwdAbs = pathIsAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
  15941. if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
  15942. self.nomount = !!options.nomount; // disable comments and negation in Minimatch.
  15943. // Note that they are not supported in Glob itself anyway.
  15944. options.nonegate = true;
  15945. options.nocomment = true;
  15946. self.minimatch = new Minimatch$3(pattern, options);
  15947. self.options = self.minimatch.options;
  15948. }
  15949. function finish(self) {
  15950. var nou = self.nounique;
  15951. var all = nou ? [] : Object.create(null);
  15952. for (var i = 0, l = self.matches.length; i < l; i++) {
  15953. var matches = self.matches[i];
  15954. if (!matches || Object.keys(matches).length === 0) {
  15955. if (self.nonull) {
  15956. // do like the shell, and spit out the literal glob
  15957. var literal = self.minimatch.globSet[i];
  15958. if (nou) all.push(literal);else all[literal] = true;
  15959. }
  15960. } else {
  15961. // had matches
  15962. var m = Object.keys(matches);
  15963. if (nou) all.push.apply(all, m);else m.forEach(function (m) {
  15964. all[m] = true;
  15965. });
  15966. }
  15967. }
  15968. if (!nou) all = Object.keys(all);
  15969. if (!self.nosort) all = all.sort(self.nocase ? alphasorti$2 : alphasort$2); // at *some* point we statted all of these
  15970. if (self.mark) {
  15971. for (var i = 0; i < all.length; i++) {
  15972. all[i] = self._mark(all[i]);
  15973. }
  15974. if (self.nodir) {
  15975. all = all.filter(function (e) {
  15976. var notDir = !/\/$/.test(e);
  15977. var c = self.cache[e] || self.cache[makeAbs(self, e)];
  15978. if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
  15979. return notDir;
  15980. });
  15981. }
  15982. }
  15983. if (self.ignore.length) all = all.filter(function (m) {
  15984. return !isIgnored$2(self, m);
  15985. });
  15986. self.found = all;
  15987. }
  15988. function mark(self, p) {
  15989. var abs = makeAbs(self, p);
  15990. var c = self.cache[abs];
  15991. var m = p;
  15992. if (c) {
  15993. var isDir = c === 'DIR' || Array.isArray(c);
  15994. var slash = p.slice(-1) === '/';
  15995. if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
  15996. if (m !== p) {
  15997. var mabs = makeAbs(self, m);
  15998. self.statCache[mabs] = self.statCache[abs];
  15999. self.cache[mabs] = self.cache[abs];
  16000. }
  16001. }
  16002. return m;
  16003. } // lotta situps...
  16004. function makeAbs(self, f) {
  16005. var abs = f;
  16006. if (f.charAt(0) === '/') {
  16007. abs = path.join(self.root, f);
  16008. } else if (pathIsAbsolute(f) || f === '') {
  16009. abs = f;
  16010. } else if (self.changedCwd) {
  16011. abs = path.resolve(self.cwd, f);
  16012. } else {
  16013. abs = path.resolve(f);
  16014. }
  16015. if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
  16016. return abs;
  16017. } // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
  16018. // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
  16019. function isIgnored$2(self, path$$2) {
  16020. if (!self.ignore.length) return false;
  16021. return self.ignore.some(function (item) {
  16022. return item.matcher.match(path$$2) || !!(item.gmatcher && item.gmatcher.match(path$$2));
  16023. });
  16024. }
  16025. function childrenIgnored$2(self, path$$2) {
  16026. if (!self.ignore.length) return false;
  16027. return self.ignore.some(function (item) {
  16028. return !!(item.gmatcher && item.gmatcher.match(path$$2));
  16029. });
  16030. }
  16031. var common$4 = {
  16032. alphasort: alphasort_1,
  16033. alphasorti: alphasorti_1,
  16034. setopts: setopts_1,
  16035. ownProp: ownProp_1,
  16036. makeAbs: makeAbs_1,
  16037. finish: finish_1,
  16038. mark: mark_1,
  16039. isIgnored: isIgnored_1,
  16040. childrenIgnored: childrenIgnored_1
  16041. };
  16042. var sync$1 = globSync;
  16043. globSync.GlobSync = GlobSync$1;
  16044. var setopts$1 = common$4.setopts;
  16045. var ownProp$1 = common$4.ownProp;
  16046. var childrenIgnored$1 = common$4.childrenIgnored;
  16047. var isIgnored$1 = common$4.isIgnored;
  16048. function globSync(pattern, options) {
  16049. if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
  16050. return new GlobSync$1(pattern, options).found;
  16051. }
  16052. function GlobSync$1(pattern, options) {
  16053. if (!pattern) throw new Error('must provide pattern');
  16054. if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
  16055. if (!(this instanceof GlobSync$1)) return new GlobSync$1(pattern, options);
  16056. setopts$1(this, pattern, options);
  16057. if (this.noprocess) return this;
  16058. var n = this.minimatch.set.length;
  16059. this.matches = new Array(n);
  16060. for (var i = 0; i < n; i++) {
  16061. this._process(this.minimatch.set[i], i, false);
  16062. }
  16063. this._finish();
  16064. }
  16065. GlobSync$1.prototype._finish = function () {
  16066. assert(this instanceof GlobSync$1);
  16067. if (this.realpath) {
  16068. var self = this;
  16069. this.matches.forEach(function (matchset, index) {
  16070. var set = self.matches[index] = Object.create(null);
  16071. for (var p in matchset) {
  16072. try {
  16073. p = self._makeAbs(p);
  16074. var real = fs_realpath.realpathSync(p, self.realpathCache);
  16075. set[real] = true;
  16076. } catch (er) {
  16077. if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
  16078. }
  16079. }
  16080. });
  16081. }
  16082. common$4.finish(this);
  16083. };
  16084. GlobSync$1.prototype._process = function (pattern, index, inGlobStar) {
  16085. assert(this instanceof GlobSync$1); // Get the first [n] parts of pattern that are all strings.
  16086. var n = 0;
  16087. while (typeof pattern[n] === 'string') {
  16088. n++;
  16089. } // now n is the index of the first one that is *not* a string.
  16090. // See if there's anything else
  16091. var prefix;
  16092. switch (n) {
  16093. // if not, then this is rather simple
  16094. case pattern.length:
  16095. this._processSimple(pattern.join('/'), index);
  16096. return;
  16097. case 0:
  16098. // pattern *starts* with some non-trivial item.
  16099. // going to readdir(cwd), but not include the prefix in matches.
  16100. prefix = null;
  16101. break;
  16102. default:
  16103. // pattern has some string bits in the front.
  16104. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  16105. // or 'relative' like '../baz'
  16106. prefix = pattern.slice(0, n).join('/');
  16107. break;
  16108. }
  16109. var remain = pattern.slice(n); // get the list of entries.
  16110. var read;
  16111. if (prefix === null) read = '.';else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
  16112. if (!prefix || !pathIsAbsolute(prefix)) prefix = '/' + prefix;
  16113. read = prefix;
  16114. } else read = prefix;
  16115. var abs = this._makeAbs(read); //if ignored, skip processing
  16116. if (childrenIgnored$1(this, read)) return;
  16117. var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
  16118. if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
  16119. };
  16120. GlobSync$1.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
  16121. var entries = this._readdir(abs, inGlobStar); // if the abs isn't a dir, then nothing can match!
  16122. if (!entries) return; // It will only match dot entries if it starts with a dot, or if
  16123. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  16124. var pn = remain[0];
  16125. var negate = !!this.minimatch.negate;
  16126. var rawGlob = pn._glob;
  16127. var dotOk = this.dot || rawGlob.charAt(0) === '.';
  16128. var matchedEntries = [];
  16129. for (var i = 0; i < entries.length; i++) {
  16130. var e = entries[i];
  16131. if (e.charAt(0) !== '.' || dotOk) {
  16132. var m;
  16133. if (negate && !prefix) {
  16134. m = !e.match(pn);
  16135. } else {
  16136. m = e.match(pn);
  16137. }
  16138. if (m) matchedEntries.push(e);
  16139. }
  16140. }
  16141. var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
  16142. if (len === 0) return; // if this is the last remaining pattern bit, then no need for
  16143. // an additional stat *unless* the user has specified mark or
  16144. // stat explicitly. We know they exist, since readdir returned
  16145. // them.
  16146. if (remain.length === 1 && !this.mark && !this.stat) {
  16147. if (!this.matches[index]) this.matches[index] = Object.create(null);
  16148. for (var i = 0; i < len; i++) {
  16149. var e = matchedEntries[i];
  16150. if (prefix) {
  16151. if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
  16152. }
  16153. if (e.charAt(0) === '/' && !this.nomount) {
  16154. e = path.join(this.root, e);
  16155. }
  16156. this._emitMatch(index, e);
  16157. } // This was the last one, and no stats were needed
  16158. return;
  16159. } // now test all matched entries as stand-ins for that part
  16160. // of the pattern.
  16161. remain.shift();
  16162. for (var i = 0; i < len; i++) {
  16163. var e = matchedEntries[i];
  16164. var newPattern;
  16165. if (prefix) newPattern = [prefix, e];else newPattern = [e];
  16166. this._process(newPattern.concat(remain), index, inGlobStar);
  16167. }
  16168. };
  16169. GlobSync$1.prototype._emitMatch = function (index, e) {
  16170. if (isIgnored$1(this, e)) return;
  16171. var abs = this._makeAbs(e);
  16172. if (this.mark) e = this._mark(e);
  16173. if (this.absolute) {
  16174. e = abs;
  16175. }
  16176. if (this.matches[index][e]) return;
  16177. if (this.nodir) {
  16178. var c = this.cache[abs];
  16179. if (c === 'DIR' || Array.isArray(c)) return;
  16180. }
  16181. this.matches[index][e] = true;
  16182. if (this.stat) this._stat(e);
  16183. };
  16184. GlobSync$1.prototype._readdirInGlobStar = function (abs) {
  16185. // follow all symlinked directories forever
  16186. // just proceed as if this is a non-globstar situation
  16187. if (this.follow) return this._readdir(abs, false);
  16188. var entries;
  16189. var lstat;
  16190. var stat;
  16191. try {
  16192. lstat = fs.lstatSync(abs);
  16193. } catch (er) {
  16194. if (er.code === 'ENOENT') {
  16195. // lstat failed, doesn't exist
  16196. return null;
  16197. }
  16198. }
  16199. var isSym = lstat && lstat.isSymbolicLink();
  16200. this.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
  16201. // don't bother doing a readdir in that case.
  16202. if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
  16203. return entries;
  16204. };
  16205. GlobSync$1.prototype._readdir = function (abs, inGlobStar) {
  16206. var entries;
  16207. if (inGlobStar && !ownProp$1(this.symlinks, abs)) return this._readdirInGlobStar(abs);
  16208. if (ownProp$1(this.cache, abs)) {
  16209. var c = this.cache[abs];
  16210. if (!c || c === 'FILE') return null;
  16211. if (Array.isArray(c)) return c;
  16212. }
  16213. try {
  16214. return this._readdirEntries(abs, fs.readdirSync(abs));
  16215. } catch (er) {
  16216. this._readdirError(abs, er);
  16217. return null;
  16218. }
  16219. };
  16220. GlobSync$1.prototype._readdirEntries = function (abs, entries) {
  16221. // if we haven't asked to stat everything, then just
  16222. // assume that everything in there exists, so we can avoid
  16223. // having to stat it a second time.
  16224. if (!this.mark && !this.stat) {
  16225. for (var i = 0; i < entries.length; i++) {
  16226. var e = entries[i];
  16227. if (abs === '/') e = abs + e;else e = abs + '/' + e;
  16228. this.cache[e] = true;
  16229. }
  16230. }
  16231. this.cache[abs] = entries; // mark and cache dir-ness
  16232. return entries;
  16233. };
  16234. GlobSync$1.prototype._readdirError = function (f, er) {
  16235. // handle errors, and cache the information
  16236. switch (er.code) {
  16237. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  16238. case 'ENOTDIR':
  16239. // totally normal. means it *does* exist.
  16240. var abs = this._makeAbs(f);
  16241. this.cache[abs] = 'FILE';
  16242. if (abs === this.cwdAbs) {
  16243. var error = new Error(er.code + ' invalid cwd ' + this.cwd);
  16244. error.path = this.cwd;
  16245. error.code = er.code;
  16246. throw error;
  16247. }
  16248. break;
  16249. case 'ENOENT': // not terribly unusual
  16250. case 'ELOOP':
  16251. case 'ENAMETOOLONG':
  16252. case 'UNKNOWN':
  16253. this.cache[this._makeAbs(f)] = false;
  16254. break;
  16255. default:
  16256. // some unusual error. Treat as failure.
  16257. this.cache[this._makeAbs(f)] = false;
  16258. if (this.strict) throw er;
  16259. if (!this.silent) console.error('glob error', er);
  16260. break;
  16261. }
  16262. };
  16263. GlobSync$1.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
  16264. var entries = this._readdir(abs, inGlobStar); // no entries means not a dir, so it can never have matches
  16265. // foo.txt/** doesn't match foo.txt
  16266. if (!entries) return; // test without the globstar, and with every child both below
  16267. // and replacing the globstar.
  16268. var remainWithoutGlobStar = remain.slice(1);
  16269. var gspref = prefix ? [prefix] : [];
  16270. var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
  16271. this._process(noGlobStar, index, false);
  16272. var len = entries.length;
  16273. var isSym = this.symlinks[abs]; // If it's a symlink, and we're in a globstar, then stop
  16274. if (isSym && inGlobStar) return;
  16275. for (var i = 0; i < len; i++) {
  16276. var e = entries[i];
  16277. if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
  16278. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  16279. this._process(instead, index, true);
  16280. var below = gspref.concat(entries[i], remain);
  16281. this._process(below, index, true);
  16282. }
  16283. };
  16284. GlobSync$1.prototype._processSimple = function (prefix, index) {
  16285. // XXX review this. Shouldn't it be doing the mounting etc
  16286. // before doing stat? kinda weird?
  16287. var exists = this._stat(prefix);
  16288. if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
  16289. if (!exists) return;
  16290. if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
  16291. var trail = /[\/\\]$/.test(prefix);
  16292. if (prefix.charAt(0) === '/') {
  16293. prefix = path.join(this.root, prefix);
  16294. } else {
  16295. prefix = path.resolve(this.root, prefix);
  16296. if (trail) prefix += '/';
  16297. }
  16298. }
  16299. if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
  16300. this._emitMatch(index, prefix);
  16301. }; // Returns either 'DIR', 'FILE', or false
  16302. GlobSync$1.prototype._stat = function (f) {
  16303. var abs = this._makeAbs(f);
  16304. var needDir = f.slice(-1) === '/';
  16305. if (f.length > this.maxLength) return false;
  16306. if (!this.stat && ownProp$1(this.cache, abs)) {
  16307. var c = this.cache[abs];
  16308. if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
  16309. if (!needDir || c === 'DIR') return c;
  16310. if (needDir && c === 'FILE') return false; // otherwise we have to stat, because maybe c=true
  16311. // if we know it exists, but not what it is.
  16312. }
  16313. var exists;
  16314. var stat = this.statCache[abs];
  16315. if (!stat) {
  16316. var lstat;
  16317. try {
  16318. lstat = fs.lstatSync(abs);
  16319. } catch (er) {
  16320. if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
  16321. this.statCache[abs] = false;
  16322. return false;
  16323. }
  16324. }
  16325. if (lstat && lstat.isSymbolicLink()) {
  16326. try {
  16327. stat = fs.statSync(abs);
  16328. } catch (er) {
  16329. stat = lstat;
  16330. }
  16331. } else {
  16332. stat = lstat;
  16333. }
  16334. }
  16335. this.statCache[abs] = stat;
  16336. var c = true;
  16337. if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
  16338. this.cache[abs] = this.cache[abs] || c;
  16339. if (needDir && c === 'FILE') return false;
  16340. return c;
  16341. };
  16342. GlobSync$1.prototype._mark = function (p) {
  16343. return common$4.mark(this, p);
  16344. };
  16345. GlobSync$1.prototype._makeAbs = function (f) {
  16346. return common$4.makeAbs(this, f);
  16347. };
  16348. // Returns a wrapper function that returns a wrapped callback
  16349. // The wrapper function should do some stuff, and return a
  16350. // presumably different callback function.
  16351. // This makes sure that own properties are retained, so that
  16352. // decorations and such are not lost along the way.
  16353. var wrappy_1 = wrappy;
  16354. function wrappy(fn, cb) {
  16355. if (fn && cb) return wrappy(fn)(cb);
  16356. if (typeof fn !== 'function') throw new TypeError('need wrapper function');
  16357. Object.keys(fn).forEach(function (k) {
  16358. wrapper[k] = fn[k];
  16359. });
  16360. return wrapper;
  16361. function wrapper() {
  16362. var args = new Array(arguments.length);
  16363. for (var i = 0; i < args.length; i++) {
  16364. args[i] = arguments[i];
  16365. }
  16366. var ret = fn.apply(this, args);
  16367. var cb = args[args.length - 1];
  16368. if (typeof ret === 'function' && ret !== cb) {
  16369. Object.keys(cb).forEach(function (k) {
  16370. ret[k] = cb[k];
  16371. });
  16372. }
  16373. return ret;
  16374. }
  16375. }
  16376. var once_1 = wrappy_1(once);
  16377. var strict = wrappy_1(onceStrict);
  16378. once.proto = once(function () {
  16379. Object.defineProperty(Function.prototype, 'once', {
  16380. value: function value() {
  16381. return once(this);
  16382. },
  16383. configurable: true
  16384. });
  16385. Object.defineProperty(Function.prototype, 'onceStrict', {
  16386. value: function value() {
  16387. return onceStrict(this);
  16388. },
  16389. configurable: true
  16390. });
  16391. });
  16392. function once(fn) {
  16393. var f = function f() {
  16394. if (f.called) return f.value;
  16395. f.called = true;
  16396. return f.value = fn.apply(this, arguments);
  16397. };
  16398. f.called = false;
  16399. return f;
  16400. }
  16401. function onceStrict(fn) {
  16402. var f = function f() {
  16403. if (f.called) throw new Error(f.onceError);
  16404. f.called = true;
  16405. return f.value = fn.apply(this, arguments);
  16406. };
  16407. var name = fn.name || 'Function wrapped with `once`';
  16408. f.onceError = name + " shouldn't be called more than once";
  16409. f.called = false;
  16410. return f;
  16411. }
  16412. once_1.strict = strict;
  16413. var reqs = Object.create(null);
  16414. var inflight_1 = wrappy_1(inflight);
  16415. function inflight(key, cb) {
  16416. if (reqs[key]) {
  16417. reqs[key].push(cb);
  16418. return null;
  16419. } else {
  16420. reqs[key] = [cb];
  16421. return makeres(key);
  16422. }
  16423. }
  16424. function makeres(key) {
  16425. return once_1(function RES() {
  16426. var cbs = reqs[key];
  16427. var len = cbs.length;
  16428. var args = slice(arguments); // XXX It's somewhat ambiguous whether a new callback added in this
  16429. // pass should be queued for later execution if something in the
  16430. // list of callbacks throws, or if it should just be discarded.
  16431. // However, it's such an edge case that it hardly matters, and either
  16432. // choice is likely as surprising as the other.
  16433. // As it happens, we do go ahead and schedule it for later execution.
  16434. try {
  16435. for (var i = 0; i < len; i++) {
  16436. cbs[i].apply(null, args);
  16437. }
  16438. } finally {
  16439. if (cbs.length > len) {
  16440. // added more in the interim.
  16441. // de-zalgo, just in case, but don't call again.
  16442. cbs.splice(0, len);
  16443. process.nextTick(function () {
  16444. RES.apply(null, args);
  16445. });
  16446. } else {
  16447. delete reqs[key];
  16448. }
  16449. }
  16450. });
  16451. }
  16452. function slice(args) {
  16453. var length = args.length;
  16454. var array = [];
  16455. for (var i = 0; i < length; i++) {
  16456. array[i] = args[i];
  16457. }
  16458. return array;
  16459. }
  16460. //
  16461. // 1. Get the minimatch set
  16462. // 2. For each pattern in the set, PROCESS(pattern, false)
  16463. // 3. Store matches per-set, then uniq them
  16464. //
  16465. // PROCESS(pattern, inGlobStar)
  16466. // Get the first [n] items from pattern that are all strings
  16467. // Join these together. This is PREFIX.
  16468. // If there is no more remaining, then stat(PREFIX) and
  16469. // add to matches if it succeeds. END.
  16470. //
  16471. // If inGlobStar and PREFIX is symlink and points to dir
  16472. // set ENTRIES = []
  16473. // else readdir(PREFIX) as ENTRIES
  16474. // If fail, END
  16475. //
  16476. // with ENTRIES
  16477. // If pattern[n] is GLOBSTAR
  16478. // // handle the case where the globstar match is empty
  16479. // // by pruning it out, and testing the resulting pattern
  16480. // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
  16481. // // handle other cases.
  16482. // for ENTRY in ENTRIES (not dotfiles)
  16483. // // attach globstar + tail onto the entry
  16484. // // Mark that this entry is a globstar match
  16485. // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
  16486. //
  16487. // else // not globstar
  16488. // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
  16489. // Test ENTRY against pattern[n]
  16490. // If fails, continue
  16491. // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
  16492. //
  16493. // Caveat:
  16494. // Cache all stats and readdirs results to minimize syscall. Since all
  16495. // we ever care about is existence and directory-ness, we can just keep
  16496. // `true` for files, and [children,...] for directories, or `false` for
  16497. // things that don't exist.
  16498. var glob_1 = glob;
  16499. var EE = events.EventEmitter;
  16500. var setopts = common$4.setopts;
  16501. var ownProp = common$4.ownProp;
  16502. var childrenIgnored = common$4.childrenIgnored;
  16503. var isIgnored = common$4.isIgnored;
  16504. function glob(pattern, options, cb) {
  16505. if (typeof options === 'function') cb = options, options = {};
  16506. if (!options) options = {};
  16507. if (options.sync) {
  16508. if (cb) throw new TypeError('callback provided to sync glob');
  16509. return sync$1(pattern, options);
  16510. }
  16511. return new Glob(pattern, options, cb);
  16512. }
  16513. glob.sync = sync$1;
  16514. var GlobSync = glob.GlobSync = sync$1.GlobSync; // old api surface
  16515. glob.glob = glob;
  16516. function extend(origin, add) {
  16517. if (add === null || typeof add !== 'object') {
  16518. return origin;
  16519. }
  16520. var keys = Object.keys(add);
  16521. var i = keys.length;
  16522. while (i--) {
  16523. origin[keys[i]] = add[keys[i]];
  16524. }
  16525. return origin;
  16526. }
  16527. glob.hasMagic = function (pattern, options_) {
  16528. var options = extend({}, options_);
  16529. options.noprocess = true;
  16530. var g = new Glob(pattern, options);
  16531. var set = g.minimatch.set;
  16532. if (!pattern) return false;
  16533. if (set.length > 1) return true;
  16534. for (var j = 0; j < set[0].length; j++) {
  16535. if (typeof set[0][j] !== 'string') return true;
  16536. }
  16537. return false;
  16538. };
  16539. glob.Glob = Glob;
  16540. inherits(Glob, EE);
  16541. function Glob(pattern, options, cb) {
  16542. if (typeof options === 'function') {
  16543. cb = options;
  16544. options = null;
  16545. }
  16546. if (options && options.sync) {
  16547. if (cb) throw new TypeError('callback provided to sync glob');
  16548. return new GlobSync(pattern, options);
  16549. }
  16550. if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
  16551. setopts(this, pattern, options);
  16552. this._didRealPath = false; // process each pattern in the minimatch set
  16553. var n = this.minimatch.set.length; // The matches are stored as {<filename>: true,...} so that
  16554. // duplicates are automagically pruned.
  16555. // Later, we do an Object.keys() on these.
  16556. // Keep them as a list so we can fill in when nonull is set.
  16557. this.matches = new Array(n);
  16558. if (typeof cb === 'function') {
  16559. cb = once_1(cb);
  16560. this.on('error', cb);
  16561. this.on('end', function (matches) {
  16562. cb(null, matches);
  16563. });
  16564. }
  16565. var self = this;
  16566. this._processing = 0;
  16567. this._emitQueue = [];
  16568. this._processQueue = [];
  16569. this.paused = false;
  16570. if (this.noprocess) return this;
  16571. if (n === 0) return done();
  16572. var sync = true;
  16573. for (var i = 0; i < n; i++) {
  16574. this._process(this.minimatch.set[i], i, false, done);
  16575. }
  16576. sync = false;
  16577. function done() {
  16578. --self._processing;
  16579. if (self._processing <= 0) {
  16580. if (sync) {
  16581. process.nextTick(function () {
  16582. self._finish();
  16583. });
  16584. } else {
  16585. self._finish();
  16586. }
  16587. }
  16588. }
  16589. }
  16590. Glob.prototype._finish = function () {
  16591. assert(this instanceof Glob);
  16592. if (this.aborted) return;
  16593. if (this.realpath && !this._didRealpath) return this._realpath();
  16594. common$4.finish(this);
  16595. this.emit('end', this.found);
  16596. };
  16597. Glob.prototype._realpath = function () {
  16598. if (this._didRealpath) return;
  16599. this._didRealpath = true;
  16600. var n = this.matches.length;
  16601. if (n === 0) return this._finish();
  16602. var self = this;
  16603. for (var i = 0; i < this.matches.length; i++) {
  16604. this._realpathSet(i, next);
  16605. }
  16606. function next() {
  16607. if (--n === 0) self._finish();
  16608. }
  16609. };
  16610. Glob.prototype._realpathSet = function (index, cb) {
  16611. var matchset = this.matches[index];
  16612. if (!matchset) return cb();
  16613. var found = Object.keys(matchset);
  16614. var self = this;
  16615. var n = found.length;
  16616. if (n === 0) return cb();
  16617. var set = this.matches[index] = Object.create(null);
  16618. found.forEach(function (p, i) {
  16619. // If there's a problem with the stat, then it means that
  16620. // one or more of the links in the realpath couldn't be
  16621. // resolved. just return the abs value in that case.
  16622. p = self._makeAbs(p);
  16623. fs_realpath.realpath(p, self.realpathCache, function (er, real) {
  16624. if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
  16625. if (--n === 0) {
  16626. self.matches[index] = set;
  16627. cb();
  16628. }
  16629. });
  16630. });
  16631. };
  16632. Glob.prototype._mark = function (p) {
  16633. return common$4.mark(this, p);
  16634. };
  16635. Glob.prototype._makeAbs = function (f) {
  16636. return common$4.makeAbs(this, f);
  16637. };
  16638. Glob.prototype.abort = function () {
  16639. this.aborted = true;
  16640. this.emit('abort');
  16641. };
  16642. Glob.prototype.pause = function () {
  16643. if (!this.paused) {
  16644. this.paused = true;
  16645. this.emit('pause');
  16646. }
  16647. };
  16648. Glob.prototype.resume = function () {
  16649. if (this.paused) {
  16650. this.emit('resume');
  16651. this.paused = false;
  16652. if (this._emitQueue.length) {
  16653. var eq = this._emitQueue.slice(0);
  16654. this._emitQueue.length = 0;
  16655. for (var i = 0; i < eq.length; i++) {
  16656. var e = eq[i];
  16657. this._emitMatch(e[0], e[1]);
  16658. }
  16659. }
  16660. if (this._processQueue.length) {
  16661. var pq = this._processQueue.slice(0);
  16662. this._processQueue.length = 0;
  16663. for (var i = 0; i < pq.length; i++) {
  16664. var p = pq[i];
  16665. this._processing--;
  16666. this._process(p[0], p[1], p[2], p[3]);
  16667. }
  16668. }
  16669. }
  16670. };
  16671. Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
  16672. assert(this instanceof Glob);
  16673. assert(typeof cb === 'function');
  16674. if (this.aborted) return;
  16675. this._processing++;
  16676. if (this.paused) {
  16677. this._processQueue.push([pattern, index, inGlobStar, cb]);
  16678. return;
  16679. } //console.error('PROCESS %d', this._processing, pattern)
  16680. // Get the first [n] parts of pattern that are all strings.
  16681. var n = 0;
  16682. while (typeof pattern[n] === 'string') {
  16683. n++;
  16684. } // now n is the index of the first one that is *not* a string.
  16685. // see if there's anything else
  16686. var prefix;
  16687. switch (n) {
  16688. // if not, then this is rather simple
  16689. case pattern.length:
  16690. this._processSimple(pattern.join('/'), index, cb);
  16691. return;
  16692. case 0:
  16693. // pattern *starts* with some non-trivial item.
  16694. // going to readdir(cwd), but not include the prefix in matches.
  16695. prefix = null;
  16696. break;
  16697. default:
  16698. // pattern has some string bits in the front.
  16699. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  16700. // or 'relative' like '../baz'
  16701. prefix = pattern.slice(0, n).join('/');
  16702. break;
  16703. }
  16704. var remain = pattern.slice(n); // get the list of entries.
  16705. var read;
  16706. if (prefix === null) read = '.';else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
  16707. if (!prefix || !pathIsAbsolute(prefix)) prefix = '/' + prefix;
  16708. read = prefix;
  16709. } else read = prefix;
  16710. var abs = this._makeAbs(read); //if ignored, skip _processing
  16711. if (childrenIgnored(this, read)) return cb();
  16712. var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
  16713. if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
  16714. };
  16715. Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  16716. var self = this;
  16717. this._readdir(abs, inGlobStar, function (er, entries) {
  16718. return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  16719. });
  16720. };
  16721. Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  16722. // if the abs isn't a dir, then nothing can match!
  16723. if (!entries) return cb(); // It will only match dot entries if it starts with a dot, or if
  16724. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  16725. var pn = remain[0];
  16726. var negate = !!this.minimatch.negate;
  16727. var rawGlob = pn._glob;
  16728. var dotOk = this.dot || rawGlob.charAt(0) === '.';
  16729. var matchedEntries = [];
  16730. for (var i = 0; i < entries.length; i++) {
  16731. var e = entries[i];
  16732. if (e.charAt(0) !== '.' || dotOk) {
  16733. var m;
  16734. if (negate && !prefix) {
  16735. m = !e.match(pn);
  16736. } else {
  16737. m = e.match(pn);
  16738. }
  16739. if (m) matchedEntries.push(e);
  16740. }
  16741. } //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
  16742. var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
  16743. if (len === 0) return cb(); // if this is the last remaining pattern bit, then no need for
  16744. // an additional stat *unless* the user has specified mark or
  16745. // stat explicitly. We know they exist, since readdir returned
  16746. // them.
  16747. if (remain.length === 1 && !this.mark && !this.stat) {
  16748. if (!this.matches[index]) this.matches[index] = Object.create(null);
  16749. for (var i = 0; i < len; i++) {
  16750. var e = matchedEntries[i];
  16751. if (prefix) {
  16752. if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
  16753. }
  16754. if (e.charAt(0) === '/' && !this.nomount) {
  16755. e = path.join(this.root, e);
  16756. }
  16757. this._emitMatch(index, e);
  16758. } // This was the last one, and no stats were needed
  16759. return cb();
  16760. } // now test all matched entries as stand-ins for that part
  16761. // of the pattern.
  16762. remain.shift();
  16763. for (var i = 0; i < len; i++) {
  16764. var e = matchedEntries[i];
  16765. var newPattern;
  16766. if (prefix) {
  16767. if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
  16768. }
  16769. this._process([e].concat(remain), index, inGlobStar, cb);
  16770. }
  16771. cb();
  16772. };
  16773. Glob.prototype._emitMatch = function (index, e) {
  16774. if (this.aborted) return;
  16775. if (isIgnored(this, e)) return;
  16776. if (this.paused) {
  16777. this._emitQueue.push([index, e]);
  16778. return;
  16779. }
  16780. var abs = pathIsAbsolute(e) ? e : this._makeAbs(e);
  16781. if (this.mark) e = this._mark(e);
  16782. if (this.absolute) e = abs;
  16783. if (this.matches[index][e]) return;
  16784. if (this.nodir) {
  16785. var c = this.cache[abs];
  16786. if (c === 'DIR' || Array.isArray(c)) return;
  16787. }
  16788. this.matches[index][e] = true;
  16789. var st = this.statCache[abs];
  16790. if (st) this.emit('stat', e, st);
  16791. this.emit('match', e);
  16792. };
  16793. Glob.prototype._readdirInGlobStar = function (abs, cb) {
  16794. if (this.aborted) return; // follow all symlinked directories forever
  16795. // just proceed as if this is a non-globstar situation
  16796. if (this.follow) return this._readdir(abs, false, cb);
  16797. var lstatkey = 'lstat\0' + abs;
  16798. var self = this;
  16799. var lstatcb = inflight_1(lstatkey, lstatcb_);
  16800. if (lstatcb) fs.lstat(abs, lstatcb);
  16801. function lstatcb_(er, lstat) {
  16802. if (er && er.code === 'ENOENT') return cb();
  16803. var isSym = lstat && lstat.isSymbolicLink();
  16804. self.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
  16805. // don't bother doing a readdir in that case.
  16806. if (!isSym && lstat && !lstat.isDirectory()) {
  16807. self.cache[abs] = 'FILE';
  16808. cb();
  16809. } else self._readdir(abs, false, cb);
  16810. }
  16811. };
  16812. Glob.prototype._readdir = function (abs, inGlobStar, cb) {
  16813. if (this.aborted) return;
  16814. cb = inflight_1('readdir\0' + abs + '\0' + inGlobStar, cb);
  16815. if (!cb) return; //console.error('RD %j %j', +inGlobStar, abs)
  16816. if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
  16817. if (ownProp(this.cache, abs)) {
  16818. var c = this.cache[abs];
  16819. if (!c || c === 'FILE') return cb();
  16820. if (Array.isArray(c)) return cb(null, c);
  16821. }
  16822. var self = this;
  16823. fs.readdir(abs, readdirCb(this, abs, cb));
  16824. };
  16825. function readdirCb(self, abs, cb) {
  16826. return function (er, entries) {
  16827. if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
  16828. };
  16829. }
  16830. Glob.prototype._readdirEntries = function (abs, entries, cb) {
  16831. if (this.aborted) return; // if we haven't asked to stat everything, then just
  16832. // assume that everything in there exists, so we can avoid
  16833. // having to stat it a second time.
  16834. if (!this.mark && !this.stat) {
  16835. for (var i = 0; i < entries.length; i++) {
  16836. var e = entries[i];
  16837. if (abs === '/') e = abs + e;else e = abs + '/' + e;
  16838. this.cache[e] = true;
  16839. }
  16840. }
  16841. this.cache[abs] = entries;
  16842. return cb(null, entries);
  16843. };
  16844. Glob.prototype._readdirError = function (f, er, cb) {
  16845. if (this.aborted) return; // handle errors, and cache the information
  16846. switch (er.code) {
  16847. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  16848. case 'ENOTDIR':
  16849. // totally normal. means it *does* exist.
  16850. var abs = this._makeAbs(f);
  16851. this.cache[abs] = 'FILE';
  16852. if (abs === this.cwdAbs) {
  16853. var error = new Error(er.code + ' invalid cwd ' + this.cwd);
  16854. error.path = this.cwd;
  16855. error.code = er.code;
  16856. this.emit('error', error);
  16857. this.abort();
  16858. }
  16859. break;
  16860. case 'ENOENT': // not terribly unusual
  16861. case 'ELOOP':
  16862. case 'ENAMETOOLONG':
  16863. case 'UNKNOWN':
  16864. this.cache[this._makeAbs(f)] = false;
  16865. break;
  16866. default:
  16867. // some unusual error. Treat as failure.
  16868. this.cache[this._makeAbs(f)] = false;
  16869. if (this.strict) {
  16870. this.emit('error', er); // If the error is handled, then we abort
  16871. // if not, we threw out of here
  16872. this.abort();
  16873. }
  16874. if (!this.silent) console.error('glob error', er);
  16875. break;
  16876. }
  16877. return cb();
  16878. };
  16879. Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  16880. var self = this;
  16881. this._readdir(abs, inGlobStar, function (er, entries) {
  16882. self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  16883. });
  16884. };
  16885. Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  16886. //console.error('pgs2', prefix, remain[0], entries)
  16887. // no entries means not a dir, so it can never have matches
  16888. // foo.txt/** doesn't match foo.txt
  16889. if (!entries) return cb(); // test without the globstar, and with every child both below
  16890. // and replacing the globstar.
  16891. var remainWithoutGlobStar = remain.slice(1);
  16892. var gspref = prefix ? [prefix] : [];
  16893. var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
  16894. this._process(noGlobStar, index, false, cb);
  16895. var isSym = this.symlinks[abs];
  16896. var len = entries.length; // If it's a symlink, and we're in a globstar, then stop
  16897. if (isSym && inGlobStar) return cb();
  16898. for (var i = 0; i < len; i++) {
  16899. var e = entries[i];
  16900. if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
  16901. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  16902. this._process(instead, index, true, cb);
  16903. var below = gspref.concat(entries[i], remain);
  16904. this._process(below, index, true, cb);
  16905. }
  16906. cb();
  16907. };
  16908. Glob.prototype._processSimple = function (prefix, index, cb) {
  16909. // XXX review this. Shouldn't it be doing the mounting etc
  16910. // before doing stat? kinda weird?
  16911. var self = this;
  16912. this._stat(prefix, function (er, exists) {
  16913. self._processSimple2(prefix, index, er, exists, cb);
  16914. });
  16915. };
  16916. Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
  16917. //console.error('ps2', prefix, exists)
  16918. if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
  16919. if (!exists) return cb();
  16920. if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
  16921. var trail = /[\/\\]$/.test(prefix);
  16922. if (prefix.charAt(0) === '/') {
  16923. prefix = path.join(this.root, prefix);
  16924. } else {
  16925. prefix = path.resolve(this.root, prefix);
  16926. if (trail) prefix += '/';
  16927. }
  16928. }
  16929. if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
  16930. this._emitMatch(index, prefix);
  16931. cb();
  16932. }; // Returns either 'DIR', 'FILE', or false
  16933. Glob.prototype._stat = function (f, cb) {
  16934. var abs = this._makeAbs(f);
  16935. var needDir = f.slice(-1) === '/';
  16936. if (f.length > this.maxLength) return cb();
  16937. if (!this.stat && ownProp(this.cache, abs)) {
  16938. var c = this.cache[abs];
  16939. if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
  16940. if (!needDir || c === 'DIR') return cb(null, c);
  16941. if (needDir && c === 'FILE') return cb(); // otherwise we have to stat, because maybe c=true
  16942. // if we know it exists, but not what it is.
  16943. }
  16944. var exists;
  16945. var stat = this.statCache[abs];
  16946. if (stat !== undefined) {
  16947. if (stat === false) return cb(null, stat);else {
  16948. var type = stat.isDirectory() ? 'DIR' : 'FILE';
  16949. if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
  16950. }
  16951. }
  16952. var self = this;
  16953. var statcb = inflight_1('stat\0' + abs, lstatcb_);
  16954. if (statcb) fs.lstat(abs, statcb);
  16955. function lstatcb_(er, lstat) {
  16956. if (lstat && lstat.isSymbolicLink()) {
  16957. // If it's a symlink, then treat it as the target, unless
  16958. // the target does not exist, then treat it as a file.
  16959. return fs.stat(abs, function (er, stat) {
  16960. if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
  16961. });
  16962. } else {
  16963. self._stat2(f, abs, er, lstat, cb);
  16964. }
  16965. }
  16966. };
  16967. Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
  16968. if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
  16969. this.statCache[abs] = false;
  16970. return cb();
  16971. }
  16972. var needDir = f.slice(-1) === '/';
  16973. this.statCache[abs] = stat;
  16974. if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
  16975. var c = true;
  16976. if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
  16977. this.cache[abs] = this.cache[abs] || c;
  16978. if (needDir && c === 'FILE') return cb();
  16979. return cb(null, c, stat);
  16980. };
  16981. var pify_1 = createCommonjsModule(function (module) {
  16982. 'use strict';
  16983. var processFn = function processFn(fn, P, opts) {
  16984. return function () {
  16985. var that = this;
  16986. var args = new Array(arguments.length);
  16987. for (var i = 0; i < arguments.length; i++) {
  16988. args[i] = arguments[i];
  16989. }
  16990. return new P(function (resolve, reject) {
  16991. args.push(function (err, result) {
  16992. if (err) {
  16993. reject(err);
  16994. } else if (opts.multiArgs) {
  16995. var results = new Array(arguments.length - 1);
  16996. for (var i = 1; i < arguments.length; i++) {
  16997. results[i - 1] = arguments[i];
  16998. }
  16999. resolve(results);
  17000. } else {
  17001. resolve(result);
  17002. }
  17003. });
  17004. fn.apply(that, args);
  17005. });
  17006. };
  17007. };
  17008. var pify = module.exports = function (obj, P, opts) {
  17009. if (typeof P !== 'function') {
  17010. opts = P;
  17011. P = Promise;
  17012. }
  17013. opts = opts || {};
  17014. opts.exclude = opts.exclude || [/.+Sync$/];
  17015. var filter = function filter(key) {
  17016. var match = function match(pattern) {
  17017. return typeof pattern === 'string' ? key === pattern : pattern.test(key);
  17018. };
  17019. return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
  17020. };
  17021. var ret = typeof obj === 'function' ? function () {
  17022. if (opts.excludeMain) {
  17023. return obj.apply(this, arguments);
  17024. }
  17025. return processFn(obj, P, opts).apply(this, arguments);
  17026. } : {};
  17027. return Object.keys(obj).reduce(function (ret, key) {
  17028. var x = obj[key];
  17029. ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
  17030. return ret;
  17031. }, ret);
  17032. };
  17033. pify.all = pify;
  17034. });
  17035. var globP = pify_1(glob_1, pinkiePromise).bind(glob_1);
  17036. function isNegative(pattern) {
  17037. return pattern[0] === '!';
  17038. }
  17039. function isString(value) {
  17040. return typeof value === 'string';
  17041. }
  17042. function assertPatternsInput(patterns) {
  17043. if (!patterns.every(isString)) {
  17044. throw new TypeError('patterns must be a string or an array of strings');
  17045. }
  17046. }
  17047. function generateGlobTasks(patterns, opts) {
  17048. patterns = [].concat(patterns);
  17049. assertPatternsInput(patterns);
  17050. var globTasks = [];
  17051. opts = objectAssign({
  17052. cache: Object.create(null),
  17053. statCache: Object.create(null),
  17054. realpathCache: Object.create(null),
  17055. symlinks: Object.create(null),
  17056. ignore: []
  17057. }, opts);
  17058. patterns.forEach(function (pattern, i) {
  17059. if (isNegative(pattern)) {
  17060. return;
  17061. }
  17062. var ignore = patterns.slice(i).filter(isNegative).map(function (pattern) {
  17063. return pattern.slice(1);
  17064. });
  17065. globTasks.push({
  17066. pattern: pattern,
  17067. opts: objectAssign({}, opts, {
  17068. ignore: opts.ignore.concat(ignore)
  17069. })
  17070. });
  17071. });
  17072. return globTasks;
  17073. }
  17074. var globby = function globby(patterns, opts) {
  17075. var globTasks;
  17076. try {
  17077. globTasks = generateGlobTasks(patterns, opts);
  17078. } catch (err) {
  17079. return pinkiePromise.reject(err);
  17080. }
  17081. return pinkiePromise.all(globTasks.map(function (task) {
  17082. return globP(task.pattern, task.opts);
  17083. })).then(function (paths) {
  17084. return arrayUnion.apply(null, paths);
  17085. });
  17086. };
  17087. var sync = function sync(patterns, opts) {
  17088. var globTasks = generateGlobTasks(patterns, opts);
  17089. return globTasks.reduce(function (matches, task) {
  17090. return arrayUnion(matches, glob_1.sync(task.pattern, task.opts));
  17091. }, []);
  17092. };
  17093. var generateGlobTasks_1 = generateGlobTasks;
  17094. var hasMagic = function hasMagic(patterns, opts) {
  17095. return [].concat(patterns).some(function (pattern) {
  17096. return glob_1.hasMagic(pattern, opts);
  17097. });
  17098. };
  17099. globby.sync = sync;
  17100. globby.generateGlobTasks = generateGlobTasks_1;
  17101. globby.hasMagic = hasMagic;
  17102. var assert$2 = true;
  17103. var buffer_ieee754 = "< 0.9.7";
  17104. var buffer = true;
  17105. var child_process = true;
  17106. var cluster = true;
  17107. var console$1 = true;
  17108. var constants = true;
  17109. var crypto = true;
  17110. var _debugger = "< 8";
  17111. var dgram = true;
  17112. var dns = true;
  17113. var domain = true;
  17114. var events$1 = true;
  17115. var freelist = "< 6";
  17116. var fs$2 = true;
  17117. var http = true;
  17118. var http2 = ">= 8.8";
  17119. var https = true;
  17120. var _http_server = ">= 0.11";
  17121. var _linklist = "< 8";
  17122. var module$1 = true;
  17123. var net = true;
  17124. var os$1 = true;
  17125. var path$3 = true;
  17126. var perf_hooks = ">= 8.5";
  17127. var process$1 = ">= 1";
  17128. var punycode = true;
  17129. var querystring = true;
  17130. var readline = true;
  17131. var repl = true;
  17132. var stream = true;
  17133. var string_decoder = true;
  17134. var sys = true;
  17135. var timers = true;
  17136. var tls = true;
  17137. var tty = true;
  17138. var url = true;
  17139. var util$3 = true;
  17140. var v8 = ">= 1";
  17141. var vm = true;
  17142. var zlib = true;
  17143. var core$3 = {
  17144. assert: assert$2,
  17145. buffer_ieee754: buffer_ieee754,
  17146. buffer: buffer,
  17147. child_process: child_process,
  17148. cluster: cluster,
  17149. console: console$1,
  17150. constants: constants,
  17151. crypto: crypto,
  17152. _debugger: _debugger,
  17153. dgram: dgram,
  17154. dns: dns,
  17155. domain: domain,
  17156. events: events$1,
  17157. freelist: freelist,
  17158. fs: fs$2,
  17159. http: http,
  17160. http2: http2,
  17161. https: https,
  17162. _http_server: _http_server,
  17163. _linklist: _linklist,
  17164. module: module$1,
  17165. net: net,
  17166. os: os$1,
  17167. path: path$3,
  17168. perf_hooks: perf_hooks,
  17169. process: process$1,
  17170. punycode: punycode,
  17171. querystring: querystring,
  17172. readline: readline,
  17173. repl: repl,
  17174. stream: stream,
  17175. string_decoder: string_decoder,
  17176. sys: sys,
  17177. timers: timers,
  17178. tls: tls,
  17179. tty: tty,
  17180. url: url,
  17181. util: util$3,
  17182. v8: v8,
  17183. vm: vm,
  17184. zlib: zlib
  17185. };
  17186. var core$4 = Object.freeze({
  17187. assert: assert$2,
  17188. buffer_ieee754: buffer_ieee754,
  17189. buffer: buffer,
  17190. child_process: child_process,
  17191. cluster: cluster,
  17192. console: console$1,
  17193. constants: constants,
  17194. crypto: crypto,
  17195. _debugger: _debugger,
  17196. dgram: dgram,
  17197. dns: dns,
  17198. domain: domain,
  17199. events: events$1,
  17200. freelist: freelist,
  17201. fs: fs$2,
  17202. http: http,
  17203. http2: http2,
  17204. https: https,
  17205. _http_server: _http_server,
  17206. _linklist: _linklist,
  17207. module: module$1,
  17208. net: net,
  17209. os: os$1,
  17210. path: path$3,
  17211. perf_hooks: perf_hooks,
  17212. process: process$1,
  17213. punycode: punycode,
  17214. querystring: querystring,
  17215. readline: readline,
  17216. repl: repl,
  17217. stream: stream,
  17218. string_decoder: string_decoder,
  17219. sys: sys,
  17220. timers: timers,
  17221. tls: tls,
  17222. tty: tty,
  17223. url: url,
  17224. util: util$3,
  17225. v8: v8,
  17226. vm: vm,
  17227. zlib: zlib,
  17228. default: core$3
  17229. });
  17230. var data = ( core$4 && core$3 ) || core$4;
  17231. var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
  17232. function versionIncluded(specifier) {
  17233. if (specifier === true) {
  17234. return true;
  17235. }
  17236. var parts = specifier.split(' ');
  17237. var op = parts[0];
  17238. var versionParts = parts[1].split('.');
  17239. for (var i = 0; i < 3; ++i) {
  17240. var cur = Number(current[i] || 0);
  17241. var ver = Number(versionParts[i] || 0);
  17242. if (cur === ver) {
  17243. continue; // eslint-disable-line no-restricted-syntax, no-continue
  17244. }
  17245. if (op === '<') {
  17246. return cur < ver;
  17247. } else if (op === '>=') {
  17248. return cur >= ver;
  17249. } else {
  17250. return false;
  17251. }
  17252. }
  17253. return false;
  17254. }
  17255. var core$2 = {};
  17256. for (var mod in data) {
  17257. // eslint-disable-line no-restricted-syntax
  17258. if (Object.prototype.hasOwnProperty.call(data, mod)) {
  17259. core$2[mod] = versionIncluded(data[mod]);
  17260. }
  17261. }
  17262. var core_1 = core$2;
  17263. var caller = function caller() {
  17264. // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  17265. var origPrepareStackTrace = Error.prepareStackTrace;
  17266. Error.prepareStackTrace = function (_, stack) {
  17267. return stack;
  17268. };
  17269. var stack = new Error().stack;
  17270. Error.prepareStackTrace = origPrepareStackTrace;
  17271. return stack[2].getFileName();
  17272. };
  17273. var pathParse = createCommonjsModule(function (module) {
  17274. 'use strict';
  17275. var isWindows = process.platform === 'win32'; // Regex to split a windows path into three parts: [*, device, slash,
  17276. // tail] windows-only
  17277. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; // Regex to split the tail part of the above into [*, dir, basename, ext]
  17278. var splitTailRe = /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
  17279. var win32 = {}; // Function to split a filename into [root, dir, basename, ext]
  17280. function win32SplitPath(filename) {
  17281. // Separate device+slash from tail
  17282. var result = splitDeviceRe.exec(filename),
  17283. device = (result[1] || '') + (result[2] || ''),
  17284. tail = result[3] || ''; // Split the tail into dir, basename and extension
  17285. var result2 = splitTailRe.exec(tail),
  17286. dir = result2[1],
  17287. basename = result2[2],
  17288. ext = result2[3];
  17289. return [device, dir, basename, ext];
  17290. }
  17291. win32.parse = function (pathString) {
  17292. if (typeof pathString !== 'string') {
  17293. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  17294. }
  17295. var allParts = win32SplitPath(pathString);
  17296. if (!allParts || allParts.length !== 4) {
  17297. throw new TypeError("Invalid path '" + pathString + "'");
  17298. }
  17299. return {
  17300. root: allParts[0],
  17301. dir: allParts[0] + allParts[1].slice(0, -1),
  17302. base: allParts[2],
  17303. ext: allParts[3],
  17304. name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
  17305. };
  17306. }; // Split a filename into [root, dir, basename, ext], unix version
  17307. // 'root' is just a slash, or nothing.
  17308. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  17309. var posix = {};
  17310. function posixSplitPath(filename) {
  17311. return splitPathRe.exec(filename).slice(1);
  17312. }
  17313. posix.parse = function (pathString) {
  17314. if (typeof pathString !== 'string') {
  17315. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  17316. }
  17317. var allParts = posixSplitPath(pathString);
  17318. if (!allParts || allParts.length !== 4) {
  17319. throw new TypeError("Invalid path '" + pathString + "'");
  17320. }
  17321. allParts[1] = allParts[1] || '';
  17322. allParts[2] = allParts[2] || '';
  17323. allParts[3] = allParts[3] || '';
  17324. return {
  17325. root: allParts[0],
  17326. dir: allParts[0] + allParts[1].slice(0, -1),
  17327. base: allParts[2],
  17328. ext: allParts[3],
  17329. name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
  17330. };
  17331. };
  17332. if (isWindows) module.exports = win32.parse;else
  17333. /* posix */
  17334. module.exports = posix.parse;
  17335. module.exports.posix = posix.parse;
  17336. module.exports.win32 = win32.parse;
  17337. });
  17338. var parse$4 = path.parse || pathParse;
  17339. var nodeModulesPaths = function nodeModulesPaths(start, opts) {
  17340. var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules']; // ensure that `start` is an absolute path at this point,
  17341. // resolving against the process' current working directory
  17342. var absoluteStart = path.resolve(start);
  17343. if (opts && opts.preserveSymlinks === false) {
  17344. try {
  17345. absoluteStart = fs.realpathSync(absoluteStart);
  17346. } catch (err) {
  17347. if (err.code !== 'ENOENT') {
  17348. throw err;
  17349. }
  17350. }
  17351. }
  17352. var prefix = '/';
  17353. if (/^([A-Za-z]:)/.test(absoluteStart)) {
  17354. prefix = '';
  17355. } else if (/^\\\\/.test(absoluteStart)) {
  17356. prefix = '\\\\';
  17357. }
  17358. var paths = [absoluteStart];
  17359. var parsed = parse$4(absoluteStart);
  17360. while (parsed.dir !== paths[paths.length - 1]) {
  17361. paths.push(parsed.dir);
  17362. parsed = parse$4(parsed.dir);
  17363. }
  17364. var dirs = paths.reduce(function (dirs, aPath) {
  17365. return dirs.concat(modules.map(function (moduleDir) {
  17366. return path.join(prefix, aPath, moduleDir);
  17367. }));
  17368. }, []);
  17369. return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
  17370. };
  17371. var async = function resolve(x, options, callback) {
  17372. var cb = callback;
  17373. var opts = options || {};
  17374. if (typeof opts === 'function') {
  17375. cb = opts;
  17376. opts = {};
  17377. }
  17378. if (typeof x !== 'string') {
  17379. var err = new TypeError('Path must be a string.');
  17380. return process.nextTick(function () {
  17381. cb(err);
  17382. });
  17383. }
  17384. var isFile = opts.isFile || function (file, cb) {
  17385. fs.stat(file, function (err, stat) {
  17386. if (!err) {
  17387. return cb(null, stat.isFile() || stat.isFIFO());
  17388. }
  17389. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  17390. return cb(err);
  17391. });
  17392. };
  17393. var readFile = opts.readFile || fs.readFile;
  17394. var extensions = opts.extensions || ['.js'];
  17395. var y = opts.basedir || path.dirname(caller());
  17396. opts.paths = opts.paths || [];
  17397. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  17398. var res = path.resolve(y, x);
  17399. if (x === '..' || x.slice(-1) === '/') res += '/';
  17400. if (/\/$/.test(x) && res === y) {
  17401. loadAsDirectory(res, opts.package, onfile);
  17402. } else loadAsFile(res, opts.package, onfile);
  17403. } else loadNodeModules(x, y, function (err, n, pkg) {
  17404. if (err) cb(err);else if (n) cb(null, n, pkg);else if (core_1[x]) return cb(null, x);else {
  17405. var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17406. moduleError.code = 'MODULE_NOT_FOUND';
  17407. cb(moduleError);
  17408. }
  17409. });
  17410. function onfile(err, m, pkg) {
  17411. if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
  17412. if (err) cb(err);else if (d) cb(null, d, pkg);else {
  17413. var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17414. moduleError.code = 'MODULE_NOT_FOUND';
  17415. cb(moduleError);
  17416. }
  17417. });
  17418. }
  17419. function loadAsFile(x, thePackage, callback) {
  17420. var loadAsFilePackage = thePackage;
  17421. var cb = callback;
  17422. if (typeof loadAsFilePackage === 'function') {
  17423. cb = loadAsFilePackage;
  17424. loadAsFilePackage = undefined;
  17425. }
  17426. var exts = [''].concat(extensions);
  17427. load(exts, x, loadAsFilePackage);
  17428. function load(exts, x, loadPackage) {
  17429. if (exts.length === 0) return cb(null, undefined, loadPackage);
  17430. var file = x + exts[0];
  17431. var pkg = loadPackage;
  17432. if (pkg) onpkg(null, pkg);else loadpkg(path.dirname(file), onpkg);
  17433. function onpkg(err, pkg_, dir) {
  17434. pkg = pkg_;
  17435. if (err) return cb(err);
  17436. if (dir && pkg && opts.pathFilter) {
  17437. var rfile = path.relative(dir, file);
  17438. var rel = rfile.slice(0, rfile.length - exts[0].length);
  17439. var r = opts.pathFilter(pkg, x, rel);
  17440. if (r) return load([''].concat(extensions.slice()), path.resolve(dir, r), pkg);
  17441. }
  17442. isFile(file, onex);
  17443. }
  17444. function onex(err, ex) {
  17445. if (err) return cb(err);
  17446. if (ex) return cb(null, file, pkg);
  17447. load(exts.slice(1), x, pkg);
  17448. }
  17449. }
  17450. }
  17451. function loadpkg(dir, cb) {
  17452. if (dir === '' || dir === '/') return cb(null);
  17453. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  17454. return cb(null);
  17455. }
  17456. if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
  17457. var pkgfile = path.join(dir, 'package.json');
  17458. isFile(pkgfile, function (err, ex) {
  17459. // on err, ex is false
  17460. if (!ex) return loadpkg(path.dirname(dir), cb);
  17461. readFile(pkgfile, function (err, body) {
  17462. if (err) cb(err);
  17463. try {
  17464. var pkg = JSON.parse(body);
  17465. } catch (jsonErr) {}
  17466. if (pkg && opts.packageFilter) {
  17467. pkg = opts.packageFilter(pkg, pkgfile);
  17468. }
  17469. cb(null, pkg, dir);
  17470. });
  17471. });
  17472. }
  17473. function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
  17474. var cb = callback;
  17475. var fpkg = loadAsDirectoryPackage;
  17476. if (typeof fpkg === 'function') {
  17477. cb = fpkg;
  17478. fpkg = opts.package;
  17479. }
  17480. var pkgfile = path.join(x, 'package.json');
  17481. isFile(pkgfile, function (err, ex) {
  17482. if (err) return cb(err);
  17483. if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
  17484. readFile(pkgfile, function (err, body) {
  17485. if (err) return cb(err);
  17486. try {
  17487. var pkg = JSON.parse(body);
  17488. } catch (jsonErr) {}
  17489. if (opts.packageFilter) {
  17490. pkg = opts.packageFilter(pkg, pkgfile);
  17491. }
  17492. if (pkg.main) {
  17493. if (pkg.main === '.' || pkg.main === './') {
  17494. pkg.main = 'index';
  17495. }
  17496. loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) {
  17497. if (err) return cb(err);
  17498. if (m) return cb(null, m, pkg);
  17499. if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb);
  17500. var dir = path.resolve(x, pkg.main);
  17501. loadAsDirectory(dir, pkg, function (err, n, pkg) {
  17502. if (err) return cb(err);
  17503. if (n) return cb(null, n, pkg);
  17504. loadAsFile(path.join(x, 'index'), pkg, cb);
  17505. });
  17506. });
  17507. return;
  17508. }
  17509. loadAsFile(path.join(x, '/index'), pkg, cb);
  17510. });
  17511. });
  17512. }
  17513. function processDirs(cb, dirs) {
  17514. if (dirs.length === 0) return cb(null, undefined);
  17515. var dir = dirs[0];
  17516. var file = path.join(dir, x);
  17517. loadAsFile(file, undefined, onfile);
  17518. function onfile(err, m, pkg) {
  17519. if (err) return cb(err);
  17520. if (m) return cb(null, m, pkg);
  17521. loadAsDirectory(path.join(dir, x), undefined, ondir);
  17522. }
  17523. function ondir(err, n, pkg) {
  17524. if (err) return cb(err);
  17525. if (n) return cb(null, n, pkg);
  17526. processDirs(cb, dirs.slice(1));
  17527. }
  17528. }
  17529. function loadNodeModules(x, start, cb) {
  17530. processDirs(cb, nodeModulesPaths(start, opts));
  17531. }
  17532. };
  17533. var sync$3 = function sync(x, options) {
  17534. if (typeof x !== 'string') {
  17535. throw new TypeError('Path must be a string.');
  17536. }
  17537. var opts = options || {};
  17538. var isFile = opts.isFile || function (file) {
  17539. try {
  17540. var stat = fs.statSync(file);
  17541. } catch (e) {
  17542. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  17543. throw e;
  17544. }
  17545. return stat.isFile() || stat.isFIFO();
  17546. };
  17547. var readFileSync = opts.readFileSync || fs.readFileSync;
  17548. var extensions = opts.extensions || ['.js'];
  17549. var y = opts.basedir || path.dirname(caller());
  17550. opts.paths = opts.paths || [];
  17551. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  17552. var res = path.resolve(y, x);
  17553. if (x === '..' || x.slice(-1) === '/') res += '/';
  17554. var m = loadAsFileSync(res) || loadAsDirectorySync(res);
  17555. if (m) return m;
  17556. } else {
  17557. var n = loadNodeModulesSync(x, y);
  17558. if (n) return n;
  17559. }
  17560. if (core_1[x]) return x;
  17561. var err = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17562. err.code = 'MODULE_NOT_FOUND';
  17563. throw err;
  17564. function loadAsFileSync(x) {
  17565. if (isFile(x)) {
  17566. return x;
  17567. }
  17568. for (var i = 0; i < extensions.length; i++) {
  17569. var file = x + extensions[i];
  17570. if (isFile(file)) {
  17571. return file;
  17572. }
  17573. }
  17574. }
  17575. function loadAsDirectorySync(x) {
  17576. var pkgfile = path.join(x, '/package.json');
  17577. if (isFile(pkgfile)) {
  17578. try {
  17579. var body = readFileSync(pkgfile, 'UTF8');
  17580. var pkg = JSON.parse(body);
  17581. if (opts.packageFilter) {
  17582. pkg = opts.packageFilter(pkg, x);
  17583. }
  17584. if (pkg.main) {
  17585. if (pkg.main === '.' || pkg.main === './') {
  17586. pkg.main = 'index';
  17587. }
  17588. var m = loadAsFileSync(path.resolve(x, pkg.main));
  17589. if (m) return m;
  17590. var n = loadAsDirectorySync(path.resolve(x, pkg.main));
  17591. if (n) return n;
  17592. }
  17593. } catch (e) {}
  17594. }
  17595. return loadAsFileSync(path.join(x, '/index'));
  17596. }
  17597. function loadNodeModulesSync(x, start) {
  17598. var dirs = nodeModulesPaths(start, opts);
  17599. for (var i = 0; i < dirs.length; i++) {
  17600. var dir = dirs[i];
  17601. var m = loadAsFileSync(path.join(dir, '/', x));
  17602. if (m) return m;
  17603. var n = loadAsDirectorySync(path.join(dir, '/', x));
  17604. if (n) return n;
  17605. }
  17606. }
  17607. };
  17608. var resolve$1 = createCommonjsModule(function (module, exports) {
  17609. async.core = core_1;
  17610. async.isCore = function isCore(x) {
  17611. return core_1[x];
  17612. };
  17613. async.sync = sync$3;
  17614. exports = async;
  17615. module.exports = async;
  17616. });
  17617. var addLeadingComment$2 = utilShared.addLeadingComment;
  17618. var addTrailingComment$2 = utilShared.addTrailingComment;
  17619. var addDanglingComment$2 = utilShared.addDanglingComment;
  17620. function handleOwnLineComment(comment, text, options, ast, isLastComment) {
  17621. var precedingNode = comment.precedingNode,
  17622. enclosingNode = comment.enclosingNode,
  17623. followingNode = comment.followingNode;
  17624. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
  17625. return true;
  17626. }
  17627. return false;
  17628. }
  17629. function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
  17630. var precedingNode = comment.precedingNode,
  17631. enclosingNode = comment.enclosingNode,
  17632. followingNode = comment.followingNode;
  17633. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
  17634. return true;
  17635. }
  17636. return false;
  17637. }
  17638. function handleRemainingComment(comment, text, options, ast, isLastComment) {
  17639. var precedingNode = comment.precedingNode,
  17640. enclosingNode = comment.enclosingNode,
  17641. followingNode = comment.followingNode;
  17642. if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
  17643. return true;
  17644. }
  17645. return false;
  17646. }
  17647. function addBlockStatementFirstComment(node, comment) {
  17648. var body = node.body.filter(function (n) {
  17649. return n.type !== "EmptyStatement";
  17650. });
  17651. if (body.length === 0) {
  17652. addDanglingComment$2(node, comment);
  17653. } else {
  17654. addLeadingComment$2(body[0], comment);
  17655. }
  17656. }
  17657. function addBlockOrNotComment(node, comment) {
  17658. if (node.type === "BlockStatement") {
  17659. addBlockStatementFirstComment(node, comment);
  17660. } else {
  17661. addLeadingComment$2(node, comment);
  17662. }
  17663. } // There are often comments before the else clause of if statements like
  17664. //
  17665. // if (1) { ... }
  17666. // // comment
  17667. // else { ... }
  17668. //
  17669. // They are being attached as leading comments of the BlockExpression which
  17670. // is not well printed. What we want is to instead move the comment inside
  17671. // of the block and make it leadingComment of the first element of the block
  17672. // or dangling comment of the block if there is nothing inside
  17673. //
  17674. // if (1) { ... }
  17675. // else {
  17676. // // comment
  17677. // ...
  17678. // }
  17679. function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17680. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  17681. return false;
  17682. } // We unfortunately have no way using the AST or location of nodes to know
  17683. // if the comment is positioned before the condition parenthesis:
  17684. // if (a /* comment */) {}
  17685. // The only workaround I found is to look at the next character to see if
  17686. // it is a ).
  17687. var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17688. if (nextCharacter === ")") {
  17689. addTrailingComment$2(precedingNode, comment);
  17690. return true;
  17691. } // Comments before `else`:
  17692. // - treat as trailing comments of the consequent, if it's a BlockStatement
  17693. // - treat as a dangling comment otherwise
  17694. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  17695. if (precedingNode.type === "BlockStatement") {
  17696. addTrailingComment$2(precedingNode, comment);
  17697. } else {
  17698. addDanglingComment$2(enclosingNode, comment);
  17699. }
  17700. return true;
  17701. }
  17702. if (followingNode.type === "BlockStatement") {
  17703. addBlockStatementFirstComment(followingNode, comment);
  17704. return true;
  17705. }
  17706. if (followingNode.type === "IfStatement") {
  17707. addBlockOrNotComment(followingNode.consequent, comment);
  17708. return true;
  17709. } // For comments positioned after the condition parenthesis in an if statement
  17710. // before the consequent without brackets on, such as
  17711. // if (a) /* comment */ true,
  17712. // we look at the next character to see if the following node
  17713. // is the consequent for the if statement
  17714. if (enclosingNode.consequent === followingNode) {
  17715. addLeadingComment$2(followingNode, comment);
  17716. return true;
  17717. }
  17718. return false;
  17719. }
  17720. function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17721. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  17722. return false;
  17723. } // We unfortunately have no way using the AST or location of nodes to know
  17724. // if the comment is positioned before the condition parenthesis:
  17725. // while (a /* comment */) {}
  17726. // The only workaround I found is to look at the next character to see if
  17727. // it is a ).
  17728. var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17729. if (nextCharacter === ")") {
  17730. addTrailingComment$2(precedingNode, comment);
  17731. return true;
  17732. }
  17733. if (followingNode.type === "BlockStatement") {
  17734. addBlockStatementFirstComment(followingNode, comment);
  17735. return true;
  17736. }
  17737. return false;
  17738. } // Same as IfStatement but for TryStatement
  17739. function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
  17740. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  17741. return false;
  17742. }
  17743. if (enclosingNode.type === "CatchClause" && precedingNode) {
  17744. addTrailingComment$2(precedingNode, comment);
  17745. return true;
  17746. }
  17747. if (followingNode.type === "BlockStatement") {
  17748. addBlockStatementFirstComment(followingNode, comment);
  17749. return true;
  17750. }
  17751. if (followingNode.type === "TryStatement") {
  17752. addBlockOrNotComment(followingNode.finalizer, comment);
  17753. return true;
  17754. }
  17755. if (followingNode.type === "CatchClause") {
  17756. addBlockOrNotComment(followingNode.body, comment);
  17757. return true;
  17758. }
  17759. return false;
  17760. }
  17761. function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
  17762. if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
  17763. addLeadingComment$2(enclosingNode, comment);
  17764. return true;
  17765. }
  17766. return false;
  17767. }
  17768. function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
  17769. var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
  17770. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
  17771. addLeadingComment$2(followingNode, comment);
  17772. return true;
  17773. }
  17774. return false;
  17775. }
  17776. function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
  17777. if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  17778. addTrailingComment$2(enclosingNode.value.left, comment);
  17779. return true;
  17780. }
  17781. return false;
  17782. }
  17783. function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
  17784. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
  17785. if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
  17786. addLeadingComment$2(enclosingNode, comment);
  17787. } else {
  17788. addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
  17789. }
  17790. return true;
  17791. }
  17792. return false;
  17793. }
  17794. function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
  17795. // This is only needed for estree parsers (flow, typescript) to attach
  17796. // after a method name:
  17797. // obj = { fn /*comment*/() {} };
  17798. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  17799. // comment should be attached to value instead of key
  17800. util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
  17801. addTrailingComment$2(precedingNode, comment);
  17802. return true;
  17803. } // Print comments between decorators and class methods as a trailing comment
  17804. // on the decorator node instead of the method node
  17805. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
  17806. addTrailingComment$2(precedingNode, comment);
  17807. return true;
  17808. }
  17809. return false;
  17810. }
  17811. function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
  17812. if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
  17813. return false;
  17814. }
  17815. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  17816. addTrailingComment$2(precedingNode, comment);
  17817. return true;
  17818. }
  17819. return false;
  17820. }
  17821. function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
  17822. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  17823. return false;
  17824. }
  17825. var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
  17826. if (text.substr(index, 2) === "=>") {
  17827. addDanglingComment$2(enclosingNode, comment);
  17828. return true;
  17829. }
  17830. return false;
  17831. }
  17832. function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
  17833. if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
  17834. return false;
  17835. } // Only add dangling comments to fix the case when no params are present,
  17836. // i.e. a function without any argument.
  17837. if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
  17838. addDanglingComment$2(enclosingNode, comment);
  17839. return true;
  17840. }
  17841. if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
  17842. addDanglingComment$2(enclosingNode.value, comment);
  17843. return true;
  17844. }
  17845. return false;
  17846. }
  17847. function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17848. // Type definitions functions
  17849. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  17850. addTrailingComment$2(precedingNode, comment);
  17851. return true;
  17852. } // Real functions
  17853. if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
  17854. addTrailingComment$2(precedingNode, comment);
  17855. return true;
  17856. }
  17857. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  17858. var functionParamRightParenIndex = function () {
  17859. if (enclosingNode.params.length !== 0) {
  17860. return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params)));
  17861. }
  17862. var functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
  17863. return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  17864. }();
  17865. if (options.locStart(comment) > functionParamRightParenIndex) {
  17866. addBlockStatementFirstComment(followingNode, comment);
  17867. return true;
  17868. }
  17869. }
  17870. return false;
  17871. }
  17872. function handleImportSpecifierComments(enclosingNode, comment) {
  17873. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  17874. addLeadingComment$2(enclosingNode, comment);
  17875. return true;
  17876. }
  17877. return false;
  17878. }
  17879. function handleLabeledStatementComments(enclosingNode, comment) {
  17880. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  17881. addLeadingComment$2(enclosingNode, comment);
  17882. return true;
  17883. }
  17884. return false;
  17885. }
  17886. function handleBreakAndContinueStatementComments(enclosingNode, comment) {
  17887. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  17888. addTrailingComment$2(enclosingNode, comment);
  17889. return true;
  17890. }
  17891. return false;
  17892. }
  17893. function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
  17894. if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  17895. addLeadingComment$2(enclosingNode.arguments[0], comment);
  17896. return true;
  17897. }
  17898. return false;
  17899. }
  17900. function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
  17901. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  17902. addTrailingComment$2(precedingNode, comment);
  17903. return true;
  17904. }
  17905. return false;
  17906. }
  17907. function handlePropertyComments(enclosingNode, comment) {
  17908. if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
  17909. addLeadingComment$2(enclosingNode, comment);
  17910. return true;
  17911. }
  17912. return false;
  17913. }
  17914. function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
  17915. // With Flow the enclosingNode is undefined so use the AST instead.
  17916. if (ast && ast.body && ast.body.length === 0) {
  17917. if (isLastComment) {
  17918. addDanglingComment$2(ast, comment);
  17919. } else {
  17920. addLeadingComment$2(ast, comment);
  17921. }
  17922. return true;
  17923. } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
  17924. if (isLastComment) {
  17925. addDanglingComment$2(enclosingNode, comment);
  17926. } else {
  17927. addLeadingComment$2(enclosingNode, comment);
  17928. }
  17929. return true;
  17930. }
  17931. return false;
  17932. }
  17933. function handleForComments(enclosingNode, precedingNode, comment) {
  17934. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  17935. addLeadingComment$2(enclosingNode, comment);
  17936. return true;
  17937. }
  17938. return false;
  17939. }
  17940. function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
  17941. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
  17942. addTrailingComment$2(precedingNode, comment);
  17943. return true;
  17944. }
  17945. return false;
  17946. }
  17947. function handleAssignmentPatternComments(enclosingNode, comment) {
  17948. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  17949. addLeadingComment$2(enclosingNode, comment);
  17950. return true;
  17951. }
  17952. return false;
  17953. }
  17954. function handleTypeAliasComments(enclosingNode, followingNode, comment) {
  17955. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  17956. addLeadingComment$2(enclosingNode, comment);
  17957. return true;
  17958. }
  17959. return false;
  17960. }
  17961. function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
  17962. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
  17963. addLeadingComment$2(followingNode, comment);
  17964. return true;
  17965. }
  17966. return false;
  17967. }
  17968. function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
  17969. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  17970. return false;
  17971. }
  17972. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  17973. addLeadingComment$2(followingNode.name, comment);
  17974. return true;
  17975. }
  17976. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  17977. addTrailingComment$2(precedingNode.constraint, comment);
  17978. return true;
  17979. }
  17980. return false;
  17981. }
  17982. function isBlockComment$1(comment) {
  17983. return comment.type === "Block" || comment.type === "CommentBlock";
  17984. }
  17985. function hasLeadingComment$2(node) {
  17986. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  17987. return true;
  17988. };
  17989. if (node.leadingComments) {
  17990. return node.leadingComments.some(fn);
  17991. }
  17992. if (node.comments) {
  17993. return node.comments.some(function (comment) {
  17994. return comment.leading && fn(comment);
  17995. });
  17996. }
  17997. return false;
  17998. }
  17999. var comments$3 = {
  18000. handleOwnLineComment,
  18001. handleEndOfLineComment,
  18002. handleRemainingComment,
  18003. hasLeadingComment: hasLeadingComment$2,
  18004. isBlockComment: isBlockComment$1
  18005. };
  18006. var isBlockComment = comments$3.isBlockComment;
  18007. var hasLeadingComment$1 = comments$3.hasLeadingComment;
  18008. var _require$$1$builders = doc.builders;
  18009. var indent$3 = _require$$1$builders.indent;
  18010. var join$3 = _require$$1$builders.join;
  18011. var hardline$4 = _require$$1$builders.hardline;
  18012. var softline$2 = _require$$1$builders.softline;
  18013. var literalline$2 = _require$$1$builders.literalline;
  18014. var concat$5 = _require$$1$builders.concat;
  18015. var group$2 = _require$$1$builders.group;
  18016. var dedentToRoot$1 = _require$$1$builders.dedentToRoot;
  18017. var _require$$1$utils = doc.utils;
  18018. var mapDoc$3 = _require$$1$utils.mapDoc;
  18019. var stripTrailingHardline$1 = _require$$1$utils.stripTrailingHardline;
  18020. function embed(path$$1, print, textToDoc, options) {
  18021. var node = path$$1.getValue();
  18022. var parent = path$$1.getParentNode();
  18023. var parentParent = path$$1.getParentNode(1);
  18024. switch (node.type) {
  18025. case "TemplateLiteral":
  18026. {
  18027. var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
  18028. return isIt(path$$1);
  18029. });
  18030. if (isCss) {
  18031. // Get full template literal with expressions replaced by placeholders
  18032. var rawQuasis = node.quasis.map(function (q) {
  18033. return q.value.raw;
  18034. });
  18035. var placeholderID = 0;
  18036. var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
  18037. return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
  18038. }, "");
  18039. var doc$$2 = textToDoc(text, {
  18040. parser: "css"
  18041. });
  18042. return transformCssDoc(doc$$2, path$$1, print);
  18043. }
  18044. /*
  18045. * react-relay and graphql-tag
  18046. * graphql`...`
  18047. * graphql.experimental`...`
  18048. * gql`...`
  18049. *
  18050. * This intentionally excludes Relay Classic tags, as Prettier does not
  18051. * support Relay Classic formatting.
  18052. */
  18053. if (isGraphQL(path$$1)) {
  18054. var expressionDocs = node.expressions ? path$$1.map(print, "expressions") : [];
  18055. var numQuasis = node.quasis.length;
  18056. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  18057. return "``";
  18058. }
  18059. var parts = [];
  18060. for (var i = 0; i < numQuasis; i++) {
  18061. var templateElement = node.quasis[i];
  18062. var isFirst = i === 0;
  18063. var isLast = i === numQuasis - 1;
  18064. var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
  18065. // (which would make the `cooked` value be `null` or `undefined`)
  18066. if (typeof _text !== "string") {
  18067. return null;
  18068. }
  18069. var lines = _text.split("\n");
  18070. var numLines = lines.length;
  18071. var expressionDoc = expressionDocs[i];
  18072. var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  18073. var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  18074. var commentsAndWhitespaceOnly = lines.every(function (line) {
  18075. return /^\s*(?:#[^\r\n]*)?$/.test(line);
  18076. }); // Bail out if an interpolation occurs within a comment.
  18077. if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
  18078. return null;
  18079. }
  18080. var _doc = null;
  18081. if (commentsAndWhitespaceOnly) {
  18082. _doc = printGraphqlComments(lines);
  18083. } else {
  18084. _doc = stripTrailingHardline$1(textToDoc(_text, {
  18085. parser: "graphql"
  18086. }));
  18087. }
  18088. if (_doc) {
  18089. _doc = escapeTemplateCharacters(_doc, false);
  18090. if (!isFirst && startsWithBlankLine) {
  18091. parts.push("");
  18092. }
  18093. parts.push(_doc);
  18094. if (!isLast && endsWithBlankLine) {
  18095. parts.push("");
  18096. }
  18097. } else if (!isFirst && !isLast && startsWithBlankLine) {
  18098. parts.push("");
  18099. }
  18100. if (expressionDoc) {
  18101. parts.push(concat$5(["${", expressionDoc, "}"]));
  18102. }
  18103. }
  18104. return concat$5(["`", indent$3(concat$5([hardline$4, join$3(hardline$4, parts)])), hardline$4, "`"]);
  18105. }
  18106. var htmlParser = isHtml(path$$1) ? "html" : isAngularComponentTemplate(path$$1) ? "angular" : undefined;
  18107. if (htmlParser) {
  18108. return printHtmlTemplateLiteral(path$$1, print, textToDoc, htmlParser, options.embeddedInHtml);
  18109. }
  18110. break;
  18111. }
  18112. case "TemplateElement":
  18113. {
  18114. /**
  18115. * md`...`
  18116. * markdown`...`
  18117. */
  18118. if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
  18119. var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
  18120. return "\\".repeat(backslashes.length / 2) + "`";
  18121. });
  18122. var indentation = getIndentation(_text2);
  18123. var hasIndent = indentation !== "";
  18124. return concat$5([hasIndent ? indent$3(concat$5([softline$2, printMarkdown(_text2.replace(new RegExp(`^${indentation}`, "gm"), ""))])) : concat$5([literalline$2, dedentToRoot$1(printMarkdown(_text2))]), softline$2]);
  18125. }
  18126. break;
  18127. }
  18128. }
  18129. function printMarkdown(text) {
  18130. var doc$$2 = textToDoc(text, {
  18131. parser: "markdown",
  18132. __inJsTemplate: true
  18133. });
  18134. return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
  18135. }
  18136. }
  18137. function getIndentation(str) {
  18138. var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  18139. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  18140. }
  18141. function uncook(cookedValue) {
  18142. return cookedValue.replace(/([\\`]|\$\{)/g, "\\$1");
  18143. }
  18144. function escapeTemplateCharacters(doc$$2, raw) {
  18145. return mapDoc$3(doc$$2, function (currentDoc) {
  18146. if (!currentDoc.parts) {
  18147. return currentDoc;
  18148. }
  18149. var parts = [];
  18150. currentDoc.parts.forEach(function (part) {
  18151. if (typeof part === "string") {
  18152. parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : uncook(part));
  18153. } else {
  18154. parts.push(part);
  18155. }
  18156. });
  18157. return Object.assign({}, currentDoc, {
  18158. parts
  18159. });
  18160. });
  18161. }
  18162. function transformCssDoc(quasisDoc, path$$1, print) {
  18163. var parentNode = path$$1.getValue();
  18164. var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  18165. if (isEmpty) {
  18166. return "``";
  18167. }
  18168. var expressionDocs = parentNode.expressions ? path$$1.map(print, "expressions") : [];
  18169. var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  18170. /* istanbul ignore if */
  18171. if (!newDoc) {
  18172. throw new Error("Couldn't insert all the expressions");
  18173. }
  18174. return concat$5(["`", indent$3(concat$5([hardline$4, stripTrailingHardline$1(newDoc)])), softline$2, "`"]);
  18175. } // Search all the placeholders in the quasisDoc tree
  18176. // and replace them with the expression docs one by one
  18177. // returns a new doc with all the placeholders replaced,
  18178. // or null if it couldn't replace any expression
  18179. function replacePlaceholders(quasisDoc, expressionDocs) {
  18180. if (!expressionDocs || !expressionDocs.length) {
  18181. return quasisDoc;
  18182. }
  18183. var expressions = expressionDocs.slice();
  18184. var replaceCounter = 0;
  18185. var newDoc = mapDoc$3(quasisDoc, function (doc$$2) {
  18186. if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
  18187. return doc$$2;
  18188. }
  18189. var parts = doc$$2.parts;
  18190. var atIndex = parts.indexOf("@");
  18191. var placeholderIndex = atIndex + 1;
  18192. if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
  18193. // If placeholder is split, join it
  18194. var at = parts[atIndex];
  18195. var placeholder = parts[placeholderIndex];
  18196. var rest = parts.slice(placeholderIndex + 1);
  18197. parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
  18198. }
  18199. var atPlaceholderIndex = parts.findIndex(function (part) {
  18200. return typeof part === "string" && part.startsWith("@prettier-placeholder");
  18201. });
  18202. if (atPlaceholderIndex > -1) {
  18203. var _placeholder = parts[atPlaceholderIndex];
  18204. var _rest = parts.slice(atPlaceholderIndex + 1);
  18205. var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
  18206. var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
  18207. // animation: linear ${time}s ease-out;
  18208. var suffix = placeholderMatch[2];
  18209. var expression = expressions[placeholderID];
  18210. replaceCounter++;
  18211. parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
  18212. }
  18213. return Object.assign({}, doc$$2, {
  18214. parts: parts
  18215. });
  18216. });
  18217. return expressions.length === replaceCounter ? newDoc : null;
  18218. }
  18219. function printGraphqlComments(lines) {
  18220. var parts = [];
  18221. var seenComment = false;
  18222. lines.map(function (textLine) {
  18223. return textLine.trim();
  18224. }).forEach(function (textLine, i, array) {
  18225. // Lines are either whitespace only, or a comment (with poential whitespace
  18226. // around it). Drop whitespace-only lines.
  18227. if (textLine === "") {
  18228. return;
  18229. }
  18230. if (array[i - 1] === "" && seenComment) {
  18231. // If a non-first comment is preceded by a blank (whitespace only) line,
  18232. // add in a blank line.
  18233. parts.push(concat$5([hardline$4, textLine]));
  18234. } else {
  18235. parts.push(textLine);
  18236. }
  18237. seenComment = true;
  18238. }); // If `lines` was whitespace only, return `null`.
  18239. return parts.length === 0 ? null : join$3(hardline$4, parts);
  18240. }
  18241. /**
  18242. * Template literal in these contexts:
  18243. * <style jsx>{`div{color:red}`}</style>
  18244. * css``
  18245. * css.global``
  18246. * css.resolve``
  18247. */
  18248. function isStyledJsx(path$$1) {
  18249. var node = path$$1.getValue();
  18250. var parent = path$$1.getParentNode();
  18251. var parentParent = path$$1.getParentNode(1);
  18252. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
  18253. return attribute.name.name === "jsx";
  18254. }) || 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");
  18255. }
  18256. /**
  18257. * Angular Components can have:
  18258. * - Inline HTML template
  18259. * - Inline CSS styles
  18260. *
  18261. * ...which are both within template literals somewhere
  18262. * inside of the Component decorator factory.
  18263. *
  18264. * E.g.
  18265. * @Component({
  18266. * template: `<div>...</div>`,
  18267. * styles: [`h1 { color: blue; }`]
  18268. * })
  18269. */
  18270. function isAngularComponentStyles(path$$1) {
  18271. return isPathMatch(path$$1, [function (node) {
  18272. return node.type === "TemplateLiteral";
  18273. }, function (node, name) {
  18274. return node.type === "ArrayExpression" && name === "elements";
  18275. }, function (node, name) {
  18276. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value";
  18277. }].concat(getAngularComponentObjectExpressionPredicates()));
  18278. }
  18279. function isAngularComponentTemplate(path$$1) {
  18280. return isPathMatch(path$$1, [function (node) {
  18281. return node.type === "TemplateLiteral";
  18282. }, function (node, name) {
  18283. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value";
  18284. }].concat(getAngularComponentObjectExpressionPredicates()));
  18285. }
  18286. function getAngularComponentObjectExpressionPredicates() {
  18287. return [function (node, name) {
  18288. return node.type === "ObjectExpression" && name === "properties";
  18289. }, function (node, name) {
  18290. return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments";
  18291. }, function (node, name) {
  18292. return node.type === "Decorator" && name === "expression";
  18293. }];
  18294. }
  18295. /**
  18296. * styled-components template literals
  18297. */
  18298. function isStyledComponents(path$$1) {
  18299. var parent = path$$1.getParentNode();
  18300. if (!parent || parent.type !== "TaggedTemplateExpression") {
  18301. return false;
  18302. }
  18303. var tag = parent.tag;
  18304. switch (tag.type) {
  18305. case "MemberExpression":
  18306. return (// styled.foo``
  18307. isStyledIdentifier(tag.object) || // Component.extend``
  18308. isStyledExtend(tag)
  18309. );
  18310. case "CallExpression":
  18311. return (// styled(Component)``
  18312. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})``
  18313. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
  18314. isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})``
  18315. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  18316. );
  18317. case "Identifier":
  18318. // css``
  18319. return tag.name === "css";
  18320. default:
  18321. return false;
  18322. }
  18323. }
  18324. /**
  18325. * JSX element with CSS prop
  18326. */
  18327. function isCssProp(path$$1) {
  18328. var parent = path$$1.getParentNode();
  18329. var parentParent = path$$1.getParentNode(1);
  18330. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  18331. }
  18332. function isStyledIdentifier(node) {
  18333. return node.type === "Identifier" && node.name === "styled";
  18334. }
  18335. function isStyledExtend(node) {
  18336. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  18337. }
  18338. /*
  18339. * react-relay and graphql-tag
  18340. * graphql`...`
  18341. * graphql.experimental`...`
  18342. * gql`...`
  18343. * GraphQL comment block
  18344. *
  18345. * This intentionally excludes Relay Classic tags, as Prettier does not
  18346. * support Relay Classic formatting.
  18347. */
  18348. function isGraphQL(path$$1) {
  18349. var node = path$$1.getValue();
  18350. var parent = path$$1.getParentNode();
  18351. 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");
  18352. }
  18353. function hasLanguageComment(node, languageName) {
  18354. // This checks for a leading comment that is exactly `/* GraphQL */`
  18355. // In order to be in line with other implementations of this comment tag
  18356. // we will not trim the comment value and we will expect exactly one space on
  18357. // either side of the GraphQL string
  18358. // Also see ./clean.js
  18359. return hasLeadingComment$1(node, function (comment) {
  18360. return isBlockComment(comment) && comment.value === ` ${languageName} `;
  18361. });
  18362. }
  18363. function isPathMatch(path$$1, predicateStack) {
  18364. var stack = path$$1.stack.slice();
  18365. var name = null;
  18366. var node = stack.pop();
  18367. var _iteratorNormalCompletion = true;
  18368. var _didIteratorError = false;
  18369. var _iteratorError = undefined;
  18370. try {
  18371. for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18372. var predicate = _step.value;
  18373. if (node === undefined) {
  18374. return false;
  18375. } // skip index/array
  18376. if (typeof name === "number") {
  18377. name = stack.pop();
  18378. node = stack.pop();
  18379. }
  18380. if (!predicate(node, name)) {
  18381. return false;
  18382. }
  18383. name = stack.pop();
  18384. node = stack.pop();
  18385. }
  18386. } catch (err) {
  18387. _didIteratorError = true;
  18388. _iteratorError = err;
  18389. } finally {
  18390. try {
  18391. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18392. _iterator.return();
  18393. }
  18394. } finally {
  18395. if (_didIteratorError) {
  18396. throw _iteratorError;
  18397. }
  18398. }
  18399. }
  18400. return true;
  18401. }
  18402. /**
  18403. * - html`...`
  18404. * - HTML comment block
  18405. */
  18406. function isHtml(path$$1) {
  18407. var node = path$$1.getValue();
  18408. return hasLanguageComment(node, "HTML") || isPathMatch(path$$1, [function (node) {
  18409. return node.type === "TemplateLiteral";
  18410. }, function (node, name) {
  18411. return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi";
  18412. }]);
  18413. } // The counter is needed to distinguish nested embeds.
  18414. var htmlTemplateLiteralCounter = 0;
  18415. function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser, escapeClosingScriptTag) {
  18416. var node = path$$1.getValue();
  18417. var counter = htmlTemplateLiteralCounter;
  18418. htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
  18419. var composePlaceholder = function composePlaceholder(index) {
  18420. return `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
  18421. };
  18422. var text = node.quasis.map(function (quasi, index, quasis) {
  18423. return index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index);
  18424. }).join("");
  18425. var expressionDocs = path$$1.map(print, "expressions");
  18426. if (expressionDocs.length === 0 && text.trim().length === 0) {
  18427. return "``";
  18428. }
  18429. var placeholderRegex = RegExp(composePlaceholder("(\\d+)"), "g");
  18430. var contentDoc = mapDoc$3(stripTrailingHardline$1(textToDoc(text, {
  18431. parser
  18432. })), function (doc$$2) {
  18433. if (typeof doc$$2 !== "string") {
  18434. return doc$$2;
  18435. }
  18436. var parts = [];
  18437. var components = doc$$2.split(placeholderRegex);
  18438. for (var i = 0; i < components.length; i++) {
  18439. var component = components[i];
  18440. if (i % 2 === 0) {
  18441. if (component) {
  18442. component = uncook(component);
  18443. if (escapeClosingScriptTag) {
  18444. component = component.replace(/<\/(script)\b/gi, "<\\/$1");
  18445. }
  18446. parts.push(component);
  18447. }
  18448. continue;
  18449. }
  18450. var placeholderIndex = +component;
  18451. parts.push(concat$5(["${", group$2(expressionDocs[placeholderIndex]), "}"]));
  18452. }
  18453. return concat$5(parts);
  18454. });
  18455. return group$2(concat$5(["`", indent$3(concat$5([hardline$4, group$2(contentDoc)])), softline$2, "`"]));
  18456. }
  18457. var embed_1 = embed;
  18458. function clean(ast, newObj, parent) {
  18459. ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
  18460. delete newObj[name];
  18461. });
  18462. if (ast.type === "BigIntLiteral") {
  18463. newObj.value = newObj.value.toLowerCase();
  18464. } // We remove extra `;` and add them when needed
  18465. if (ast.type === "EmptyStatement") {
  18466. return null;
  18467. } // We move text around, including whitespaces and add {" "}
  18468. if (ast.type === "JSXText") {
  18469. return null;
  18470. }
  18471. if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
  18472. return null;
  18473. } // (TypeScript) Ignore `static` in `constructor(static p) {}`
  18474. // and `export` in `constructor(export p) {}`
  18475. if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
  18476. return {
  18477. type: "Identifier",
  18478. name: ast.parameter.name,
  18479. typeAnnotation: newObj.parameter.typeAnnotation,
  18480. decorators: newObj.decorators
  18481. };
  18482. } // (TypeScript) ignore empty `specifiers` array
  18483. if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
  18484. delete newObj.specifiers;
  18485. } // (TypeScript) bypass TSParenthesizedType
  18486. if (ast.type === "TSParenthesizedType") {
  18487. return newObj.typeAnnotation;
  18488. } // We convert <div></div> to <div />
  18489. if (ast.type === "JSXOpeningElement") {
  18490. delete newObj.selfClosing;
  18491. }
  18492. if (ast.type === "JSXElement") {
  18493. delete newObj.closingElement;
  18494. } // We change {'key': value} into {key: value}
  18495. if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
  18496. delete newObj.key;
  18497. }
  18498. if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
  18499. newObj.type = "MemberExpression";
  18500. delete newObj.optional;
  18501. } // Remove raw and cooked values from TemplateElement when it's CSS
  18502. // styled-jsx
  18503. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) {
  18504. return attr.name.name === "jsx";
  18505. })) {
  18506. var templateLiterals = newObj.children.filter(function (child) {
  18507. return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
  18508. }).map(function (container) {
  18509. return container.expression;
  18510. });
  18511. var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
  18512. return quasis.concat(templateLiteral.quasis);
  18513. }, []);
  18514. quasis.forEach(function (q) {
  18515. return delete q.value;
  18516. });
  18517. } // CSS template literals in css prop
  18518. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  18519. newObj.value.expression.quasis.forEach(function (q) {
  18520. return delete q.value;
  18521. });
  18522. } // Angular Components: Inline HTML template and Inline CSS styles
  18523. var expression = ast.expression || ast.callee;
  18524. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  18525. var astProps = ast.expression.arguments[0].properties;
  18526. newObj.expression.arguments[0].properties.forEach(function (prop, index) {
  18527. var templateLiteral = null;
  18528. switch (astProps[index].key.name) {
  18529. case "styles":
  18530. if (prop.value.type === "ArrayExpression") {
  18531. templateLiteral = prop.value.elements[0];
  18532. }
  18533. break;
  18534. case "template":
  18535. if (prop.value.type === "TemplateLiteral") {
  18536. templateLiteral = prop.value;
  18537. }
  18538. break;
  18539. }
  18540. if (templateLiteral) {
  18541. templateLiteral.quasis.forEach(function (q) {
  18542. return delete q.value;
  18543. });
  18544. }
  18545. });
  18546. } // styled-components, graphql, markdown
  18547. 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")) {
  18548. newObj.quasi.quasis.forEach(function (quasi) {
  18549. return delete quasi.value;
  18550. });
  18551. }
  18552. if (ast.type === "TemplateLiteral") {
  18553. // This checks for a leading comment that is exactly `/* GraphQL */`
  18554. // In order to be in line with other implementations of this comment tag
  18555. // we will not trim the comment value and we will expect exactly one space on
  18556. // either side of the GraphQL string
  18557. // Also see ./embed.js
  18558. var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
  18559. return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) {
  18560. return comment.value === ` ${languageName} `;
  18561. });
  18562. });
  18563. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
  18564. newObj.quasis.forEach(function (quasi) {
  18565. return delete quasi.value;
  18566. });
  18567. }
  18568. }
  18569. }
  18570. var clean_1 = clean;
  18571. var detectNewline = createCommonjsModule(function (module) {
  18572. 'use strict';
  18573. module.exports = function (str) {
  18574. if (typeof str !== 'string') {
  18575. throw new TypeError('Expected a string');
  18576. }
  18577. var newlines = str.match(/(?:\r?\n)/g) || [];
  18578. if (newlines.length === 0) {
  18579. return null;
  18580. }
  18581. var crlf = newlines.filter(function (el) {
  18582. return el === '\r\n';
  18583. }).length;
  18584. var lf = newlines.length - crlf;
  18585. return crlf > lf ? '\r\n' : '\n';
  18586. };
  18587. module.exports.graceful = function (str) {
  18588. return module.exports(str) || '\n';
  18589. };
  18590. });
  18591. var build$1 = createCommonjsModule(function (module, exports) {
  18592. 'use strict';
  18593. Object.defineProperty(exports, '__esModule', {
  18594. value: true
  18595. });
  18596. exports.extract = extract;
  18597. exports.strip = strip;
  18598. exports.parse = parse;
  18599. exports.parseWithComments = parseWithComments;
  18600. exports.print = print;
  18601. var _detectNewline;
  18602. function _load_detectNewline() {
  18603. return _detectNewline = _interopRequireDefault(detectNewline);
  18604. }
  18605. var _os;
  18606. function _load_os() {
  18607. return _os = os;
  18608. }
  18609. function _interopRequireDefault(obj) {
  18610. return obj && obj.__esModule ? obj : {
  18611. default: obj
  18612. };
  18613. }
  18614. /**
  18615. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  18616. *
  18617. * This source code is licensed under the MIT license found in the
  18618. * LICENSE file in the root directory of this source tree.
  18619. *
  18620. *
  18621. */
  18622. var commentEndRe = /\*\/$/;
  18623. var commentStartRe = /^\/\*\*/;
  18624. var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  18625. var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  18626. var ltrimNewlineRe = /^(\r?\n)+/;
  18627. var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  18628. var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  18629. var stringStartRe = /(\r?\n|^) *\* ?/g;
  18630. function extract(contents) {
  18631. var match = contents.match(docblockRe);
  18632. return match ? match[0].trimLeft() : '';
  18633. }
  18634. function strip(contents) {
  18635. var match = contents.match(docblockRe);
  18636. return match && match[0] ? contents.substring(match[0].length) : contents;
  18637. }
  18638. function parse(docblock) {
  18639. return parseWithComments(docblock).pragmas;
  18640. }
  18641. function parseWithComments(docblock) {
  18642. var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
  18643. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  18644. var prev = '';
  18645. while (prev !== docblock) {
  18646. prev = docblock;
  18647. docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
  18648. }
  18649. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  18650. var result = Object.create(null);
  18651. var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  18652. var match;
  18653. while (match = propertyRe.exec(docblock)) {
  18654. // strip linecomments from pragmas
  18655. var nextPragma = match[2].replace(lineCommentRe, '');
  18656. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  18657. result[match[1]] = [].concat(result[match[1]], nextPragma);
  18658. } else {
  18659. result[match[1]] = nextPragma;
  18660. }
  18661. }
  18662. return {
  18663. comments,
  18664. pragmas: result
  18665. };
  18666. }
  18667. function print(_ref) {
  18668. var _ref$comments = _ref.comments;
  18669. var comments = _ref$comments === undefined ? '' : _ref$comments;
  18670. var _ref$pragmas = _ref.pragmas;
  18671. var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
  18672. var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
  18673. var head = '/**';
  18674. var start = ' *';
  18675. var tail = ' */';
  18676. var keys = Object.keys(pragmas);
  18677. var printedObject = keys.map(function (key) {
  18678. return printKeyValues(key, pragmas[key]);
  18679. }).reduce(function (arr, next) {
  18680. return arr.concat(next);
  18681. }, []).map(function (keyValue) {
  18682. return start + ' ' + keyValue + line;
  18683. }).join('');
  18684. if (!comments) {
  18685. if (keys.length === 0) {
  18686. return '';
  18687. }
  18688. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  18689. var value = pragmas[keys[0]];
  18690. return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
  18691. }
  18692. }
  18693. var printedComments = comments.split(line).map(function (textLine) {
  18694. return `${start} ${textLine}`;
  18695. }).join(line) + line;
  18696. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  18697. }
  18698. function printKeyValues(key, valueOrArray) {
  18699. return [].concat(valueOrArray).map(function (value) {
  18700. return `@${key} ${value}`.trim();
  18701. });
  18702. }
  18703. });
  18704. unwrapExports(build$1);
  18705. function hasPragma(text) {
  18706. var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
  18707. return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
  18708. }
  18709. function insertPragma$1(text) {
  18710. var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
  18711. var pragmas = Object.assign({
  18712. format: ""
  18713. }, parsedDocblock.pragmas);
  18714. var newDocblock = build$1.print({
  18715. pragmas,
  18716. comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
  18717. }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
  18718. var strippedText = build$1.strip(text);
  18719. var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
  18720. return newDocblock + separatingNewlines + strippedText;
  18721. }
  18722. var pragma = {
  18723. hasPragma,
  18724. insertPragma: insertPragma$1
  18725. };
  18726. // Flow annotation comments cannot be split across lines. For example:
  18727. //
  18728. // (this /*
  18729. // : any */).foo = 5;
  18730. //
  18731. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  18732. // removing the newline would create a type annotation that the user did not intend
  18733. // to create.
  18734. var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  18735. var FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
  18736. var FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
  18737. function hasFlowShorthandAnnotationComment$2(node) {
  18738. // https://flow.org/en/docs/types/comments/
  18739. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  18740. return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
  18741. }
  18742. function hasFlowAnnotationComment$1(comments) {
  18743. return comments && comments[0].value.match(FLOW_ANNOTATION);
  18744. }
  18745. function hasNode$1(node, fn) {
  18746. if (!node || typeof node !== "object") {
  18747. return false;
  18748. }
  18749. if (Array.isArray(node)) {
  18750. return node.some(function (value) {
  18751. return hasNode$1(value, fn);
  18752. });
  18753. }
  18754. var result = fn(node);
  18755. return typeof result === "boolean" ? result : Object.keys(node).some(function (key) {
  18756. return hasNode$1(node[key], fn);
  18757. });
  18758. }
  18759. function hasNakedLeftSide$2(node) {
  18760. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
  18761. }
  18762. function getLeftSide$1(node) {
  18763. if (node.expressions) {
  18764. return node.expressions[0];
  18765. }
  18766. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  18767. }
  18768. function getLeftSidePathName$2(path$$1, node) {
  18769. if (node.expressions) {
  18770. return ["expressions", 0];
  18771. }
  18772. if (node.left) {
  18773. return ["left"];
  18774. }
  18775. if (node.test) {
  18776. return ["test"];
  18777. }
  18778. if (node.object) {
  18779. return ["object"];
  18780. }
  18781. if (node.callee) {
  18782. return ["callee"];
  18783. }
  18784. if (node.tag) {
  18785. return ["tag"];
  18786. }
  18787. if (node.argument) {
  18788. return ["argument"];
  18789. }
  18790. if (node.expression) {
  18791. return ["expression"];
  18792. }
  18793. throw new Error("Unexpected node has no left side", node);
  18794. }
  18795. var utils$4 = {
  18796. getLeftSide: getLeftSide$1,
  18797. getLeftSidePathName: getLeftSidePathName$2,
  18798. hasNakedLeftSide: hasNakedLeftSide$2,
  18799. hasNode: hasNode$1,
  18800. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  18801. hasFlowAnnotationComment: hasFlowAnnotationComment$1
  18802. };
  18803. var getLeftSidePathName$1 = utils$4.getLeftSidePathName;
  18804. var hasNakedLeftSide$1 = utils$4.hasNakedLeftSide;
  18805. var hasFlowShorthandAnnotationComment$1 = utils$4.hasFlowShorthandAnnotationComment;
  18806. function hasClosureCompilerTypeCastComment(text, path$$1) {
  18807. // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
  18808. // Syntax example: var x = /** @type {string} */ (fruit);
  18809. var n = path$$1.getValue();
  18810. return isParenthesized(n) && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
  18811. function hasAncestorTypeCastComment(index) {
  18812. var ancestor = path$$1.getParentNode(index);
  18813. return ancestor && !isParenthesized(ancestor) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
  18814. }
  18815. function hasTypeCastComment(node) {
  18816. return node.comments && node.comments.some(function (comment) {
  18817. return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value);
  18818. });
  18819. }
  18820. function isParenthesized(node) {
  18821. // Closure typecast comments only really make sense when _not_ using
  18822. // typescript or flow parsers, so we take advantage of the babel parser's
  18823. // parenthesized expressions.
  18824. return node.extra && node.extra.parenthesized;
  18825. }
  18826. function isTypeCastComment(comment) {
  18827. var cleaned = comment.trim().split("\n").map(function (line) {
  18828. return line.replace(/^[\s*]+/, "");
  18829. }).join(" ").trim();
  18830. if (!/^@type\s*\{[^]+\}$/.test(cleaned)) {
  18831. return false;
  18832. }
  18833. var isCompletelyClosed = false;
  18834. var unpairedBracketCount = 0;
  18835. var _iteratorNormalCompletion = true;
  18836. var _didIteratorError = false;
  18837. var _iteratorError = undefined;
  18838. try {
  18839. for (var _iterator = cleaned[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18840. var char = _step.value;
  18841. if (char === "{") {
  18842. if (isCompletelyClosed) {
  18843. return false;
  18844. }
  18845. unpairedBracketCount++;
  18846. } else if (char === "}") {
  18847. if (unpairedBracketCount === 0) {
  18848. return false;
  18849. }
  18850. unpairedBracketCount--;
  18851. if (unpairedBracketCount === 0) {
  18852. isCompletelyClosed = true;
  18853. }
  18854. }
  18855. }
  18856. } catch (err) {
  18857. _didIteratorError = true;
  18858. _iteratorError = err;
  18859. } finally {
  18860. try {
  18861. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18862. _iterator.return();
  18863. }
  18864. } finally {
  18865. if (_didIteratorError) {
  18866. throw _iteratorError;
  18867. }
  18868. }
  18869. }
  18870. return unpairedBracketCount === 0;
  18871. }
  18872. }
  18873. function needsParens(path$$1, options) {
  18874. var parent = path$$1.getParentNode();
  18875. if (!parent) {
  18876. return false;
  18877. }
  18878. var name = path$$1.getName();
  18879. var node = path$$1.getNode(); // If the value of this path is some child of a Node and not a Node
  18880. // itself, then it doesn't need parentheses. Only Node objects (in
  18881. // fact, only Expression nodes) need parentheses.
  18882. if (path$$1.getValue() !== node) {
  18883. return false;
  18884. } // to avoid unexpected `}}` in HTML interpolations
  18885. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path$$1)) {
  18886. return true;
  18887. } // Only statements don't need parentheses.
  18888. if (isStatement(node)) {
  18889. return false;
  18890. } // Closure compiler requires that type casted expressions to be surrounded by
  18891. // parentheses.
  18892. if (hasClosureCompilerTypeCastComment(options.originalText, path$$1)) {
  18893. return true;
  18894. }
  18895. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  18896. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  18897. // AST, which we handle separately.
  18898. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path$$1.getValue())) {
  18899. return true;
  18900. } // Identifiers never need parentheses.
  18901. if (node.type === "Identifier") {
  18902. // ...unless those identifiers are embed placeholders. They might be substituted by complex
  18903. // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
  18904. // let tpl = html`<script> f((${expr}) / 2); </script>`;
  18905. // If the inner JS formatter removes the parens, the expression might change its meaning:
  18906. // f((a + b) / 2) vs f(a + b / 2)
  18907. if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
  18908. return true;
  18909. }
  18910. return false;
  18911. }
  18912. if (parent.type === "ParenthesizedExpression") {
  18913. return false;
  18914. } // Add parens around the extends clause of a class. It is needed for almost
  18915. // all expressions.
  18916. if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (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")) {
  18917. return true;
  18918. } // `export default function` or `export default class` can't be followed by
  18919. // anything after. So an expression like `export default (function(){}).toString()`
  18920. // needs to be followed by a parentheses
  18921. if (parent.type === "ExportDefaultDeclaration") {
  18922. return shouldWrapFunctionForExportDefault(path$$1, options);
  18923. }
  18924. if (parent.type === "Decorator" && parent.expression === node) {
  18925. var hasCallExpression = false;
  18926. var hasMemberExpression = false;
  18927. var current = node;
  18928. while (current) {
  18929. switch (current.type) {
  18930. case "MemberExpression":
  18931. hasMemberExpression = true;
  18932. current = current.object;
  18933. break;
  18934. case "CallExpression":
  18935. if (
  18936. /** @(x().y) */
  18937. hasMemberExpression ||
  18938. /** @(x().y()) */
  18939. hasCallExpression) {
  18940. return true;
  18941. }
  18942. hasCallExpression = true;
  18943. current = current.callee;
  18944. break;
  18945. case "Identifier":
  18946. return false;
  18947. default:
  18948. return true;
  18949. }
  18950. }
  18951. return true;
  18952. }
  18953. if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
  18954. util$1.startsWithNoLookaheadToken(node,
  18955. /* forbidFunctionClassAndDoExpr */
  18956. false) || parent.type === "ExpressionStatement" && util$1.startsWithNoLookaheadToken(node,
  18957. /* forbidFunctionClassAndDoExpr */
  18958. true)) {
  18959. return true;
  18960. }
  18961. switch (node.type) {
  18962. case "CallExpression":
  18963. {
  18964. var firstParentNotMemberExpression = parent;
  18965. var i = 0; // tagged templates are basically member expressions from a grammar perspective
  18966. // see https://tc39.github.io/ecma262/#prod-MemberExpression
  18967. // so are typescript's non-null assertions, though there's no grammar to point to
  18968. while (firstParentNotMemberExpression && (firstParentNotMemberExpression.type === "MemberExpression" && firstParentNotMemberExpression.object === path$$1.getParentNode(i - 1) || firstParentNotMemberExpression.type === "TaggedTemplateExpression" || firstParentNotMemberExpression.type === "TSNonNullExpression")) {
  18969. firstParentNotMemberExpression = path$$1.getParentNode(++i);
  18970. }
  18971. if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path$$1.getParentNode(i - 1)) {
  18972. return true;
  18973. }
  18974. if (parent.type === "BindExpression" && parent.callee === node) {
  18975. return true;
  18976. }
  18977. return false;
  18978. }
  18979. case "SpreadElement":
  18980. case "SpreadProperty":
  18981. return parent.type === "MemberExpression" && name === "object" && parent.object === node;
  18982. case "UpdateExpression":
  18983. if (parent.type === "UnaryExpression") {
  18984. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  18985. }
  18986. // else fallthrough
  18987. case "UnaryExpression":
  18988. switch (parent.type) {
  18989. case "UnaryExpression":
  18990. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  18991. case "BindExpression":
  18992. return true;
  18993. case "MemberExpression":
  18994. return name === "object" && parent.object === node;
  18995. case "TaggedTemplateExpression":
  18996. return true;
  18997. case "NewExpression":
  18998. case "CallExpression":
  18999. return name === "callee" && parent.callee === node;
  19000. case "BinaryExpression":
  19001. return parent.operator === "**" && name === "left";
  19002. case "TSNonNullExpression":
  19003. return true;
  19004. default:
  19005. return false;
  19006. }
  19007. case "BinaryExpression":
  19008. {
  19009. if (parent.type === "UpdateExpression") {
  19010. return true;
  19011. }
  19012. var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
  19013. var i = 0;
  19014. while (node) {
  19015. var _parent = path$$1.getParentNode(i++);
  19016. if (!_parent) {
  19017. return false;
  19018. }
  19019. if (_parent.type === "ForStatement" && _parent.init === node) {
  19020. return true;
  19021. }
  19022. node = _parent;
  19023. }
  19024. return false;
  19025. };
  19026. if (node.operator === "in" && isLeftOfAForStatement(node)) {
  19027. return true;
  19028. }
  19029. }
  19030. // fallthrough
  19031. case "TSTypeAssertion":
  19032. case "TSAsExpression":
  19033. case "LogicalExpression":
  19034. switch (parent.type) {
  19035. case "ConditionalExpression":
  19036. return node.type === "TSAsExpression";
  19037. case "CallExpression":
  19038. case "NewExpression":
  19039. return name === "callee" && parent.callee === node;
  19040. case "ClassExpression":
  19041. case "ClassDeclaration":
  19042. return name === "superClass" && parent.superClass === node;
  19043. case "TSTypeAssertion":
  19044. case "TaggedTemplateExpression":
  19045. case "UnaryExpression":
  19046. case "JSXSpreadAttribute":
  19047. case "SpreadElement":
  19048. case "SpreadProperty":
  19049. case "BindExpression":
  19050. case "AwaitExpression":
  19051. case "TSAsExpression":
  19052. case "TSNonNullExpression":
  19053. case "UpdateExpression":
  19054. return true;
  19055. case "MemberExpression":
  19056. case "OptionalMemberExpression":
  19057. return name === "object" && parent.object === node;
  19058. case "AssignmentExpression":
  19059. return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  19060. case "BinaryExpression":
  19061. case "LogicalExpression":
  19062. {
  19063. if (!node.operator && node.type !== "TSTypeAssertion") {
  19064. return true;
  19065. }
  19066. var po = parent.operator;
  19067. var pp = util$1.getPrecedence(po);
  19068. var no = node.operator;
  19069. var np = util$1.getPrecedence(no);
  19070. if (pp > np) {
  19071. return true;
  19072. }
  19073. if ((po === "||" || po === "??") && no === "&&") {
  19074. return true;
  19075. }
  19076. if (pp === np && name === "right") {
  19077. assert.strictEqual(parent.right, node);
  19078. return true;
  19079. }
  19080. if (pp === np && !util$1.shouldFlatten(po, no)) {
  19081. return true;
  19082. }
  19083. if (pp < np && no === "%") {
  19084. return po === "+" || po === "-";
  19085. } // Add parenthesis when working with bitwise operators
  19086. // It's not stricly needed but helps with code understanding
  19087. if (util$1.isBitwiseOperator(po)) {
  19088. return true;
  19089. }
  19090. return false;
  19091. }
  19092. default:
  19093. return false;
  19094. }
  19095. case "TSParenthesizedType":
  19096. {
  19097. var grandParent = path$$1.getParentNode(1);
  19098. /**
  19099. * const foo = (): (() => void) => (): void => null;
  19100. * ^ ^
  19101. */
  19102. if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
  19103. return true;
  19104. }
  19105. if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
  19106. return false;
  19107. } // Delegate to inner TSParenthesizedType
  19108. if (node.typeAnnotation.type === "TSParenthesizedType" && parent.type !== "TSArrayType") {
  19109. return false;
  19110. }
  19111. return true;
  19112. }
  19113. case "SequenceExpression":
  19114. switch (parent.type) {
  19115. case "ReturnStatement":
  19116. return false;
  19117. case "ForStatement":
  19118. // Although parentheses wouldn't hurt around sequence
  19119. // expressions in the head of for loops, traditional style
  19120. // dictates that e.g. i++, j++ should not be wrapped with
  19121. // parentheses.
  19122. return false;
  19123. case "ExpressionStatement":
  19124. return name !== "expression";
  19125. case "ArrowFunctionExpression":
  19126. // We do need parentheses, but SequenceExpressions are handled
  19127. // specially when printing bodies of arrow functions.
  19128. return name !== "body";
  19129. default:
  19130. // Otherwise err on the side of overparenthesization, adding
  19131. // explicit exceptions above if this proves overzealous.
  19132. return true;
  19133. }
  19134. case "YieldExpression":
  19135. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  19136. return true;
  19137. }
  19138. // else fallthrough
  19139. case "AwaitExpression":
  19140. switch (parent.type) {
  19141. case "TaggedTemplateExpression":
  19142. case "UnaryExpression":
  19143. case "BinaryExpression":
  19144. case "LogicalExpression":
  19145. case "SpreadElement":
  19146. case "SpreadProperty":
  19147. case "TSAsExpression":
  19148. case "TSNonNullExpression":
  19149. case "BindExpression":
  19150. case "OptionalMemberExpression":
  19151. return true;
  19152. case "MemberExpression":
  19153. return parent.object === node;
  19154. case "NewExpression":
  19155. case "CallExpression":
  19156. return parent.callee === node;
  19157. case "ConditionalExpression":
  19158. return parent.test === node;
  19159. default:
  19160. return false;
  19161. }
  19162. case "ArrayTypeAnnotation":
  19163. return parent.type === "NullableTypeAnnotation";
  19164. case "IntersectionTypeAnnotation":
  19165. case "UnionTypeAnnotation":
  19166. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
  19167. case "NullableTypeAnnotation":
  19168. return parent.type === "ArrayTypeAnnotation";
  19169. case "FunctionTypeAnnotation":
  19170. {
  19171. var ancestor = parent.type === "NullableTypeAnnotation" ? path$$1.getParentNode(1) : parent;
  19172. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
  19173. // are really needed, but since ??T doesn't make sense this check
  19174. // will almost never be true.
  19175. ancestor.type === "NullableTypeAnnotation";
  19176. }
  19177. case "StringLiteral":
  19178. case "NumericLiteral":
  19179. case "Literal":
  19180. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  19181. // See corresponding workaround in printer.js case: "Literal"
  19182. options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) {
  19183. // To avoid becoming a directive
  19184. var _grandParent = path$$1.getParentNode(1);
  19185. return _grandParent.type === "Program" || _grandParent.type === "BlockStatement";
  19186. }
  19187. return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
  19188. case "AssignmentExpression":
  19189. {
  19190. var _grandParent2 = path$$1.getParentNode(1);
  19191. if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
  19192. return true;
  19193. } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
  19194. return false;
  19195. } else if (parent.type === "TSPropertySignature" && parent.name === node) {
  19196. return false;
  19197. } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
  19198. return false;
  19199. } else if (parent.type === "ExpressionStatement") {
  19200. return node.left.type === "ObjectPattern";
  19201. } else if (parent.type === "TSPropertySignature" && parent.key === node) {
  19202. return false;
  19203. } else if (parent.type === "AssignmentExpression") {
  19204. return false;
  19205. } else if (parent.type === "SequenceExpression" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.update === parent)) {
  19206. return false;
  19207. } else if (parent.type === "Property" && parent.value === node) {
  19208. return false;
  19209. } else if (parent.type === "NGChainedExpression") {
  19210. return false;
  19211. }
  19212. return true;
  19213. }
  19214. case "ConditionalExpression":
  19215. switch (parent.type) {
  19216. case "TaggedTemplateExpression":
  19217. case "UnaryExpression":
  19218. case "SpreadElement":
  19219. case "SpreadProperty":
  19220. case "BinaryExpression":
  19221. case "LogicalExpression":
  19222. case "NGPipeExpression":
  19223. case "ExportDefaultDeclaration":
  19224. case "AwaitExpression":
  19225. case "JSXSpreadAttribute":
  19226. case "TSTypeAssertion":
  19227. case "TypeCastExpression":
  19228. case "TSAsExpression":
  19229. case "TSNonNullExpression":
  19230. case "OptionalMemberExpression":
  19231. return true;
  19232. case "NewExpression":
  19233. case "CallExpression":
  19234. return name === "callee" && parent.callee === node;
  19235. case "ConditionalExpression":
  19236. return name === "test" && parent.test === node;
  19237. case "MemberExpression":
  19238. return name === "object" && parent.object === node;
  19239. default:
  19240. return false;
  19241. }
  19242. case "FunctionExpression":
  19243. switch (parent.type) {
  19244. case "NewExpression":
  19245. case "CallExpression":
  19246. return name === "callee";
  19247. // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  19248. case "TaggedTemplateExpression":
  19249. return true;
  19250. // This is basically a kind of IIFE.
  19251. default:
  19252. return false;
  19253. }
  19254. case "ArrowFunctionExpression":
  19255. switch (parent.type) {
  19256. case "CallExpression":
  19257. return name === "callee";
  19258. case "NewExpression":
  19259. return name === "callee";
  19260. case "MemberExpression":
  19261. return name === "object";
  19262. case "TSAsExpression":
  19263. case "BindExpression":
  19264. case "TaggedTemplateExpression":
  19265. case "UnaryExpression":
  19266. case "LogicalExpression":
  19267. case "BinaryExpression":
  19268. case "AwaitExpression":
  19269. case "TSTypeAssertion":
  19270. return true;
  19271. case "ConditionalExpression":
  19272. return name === "test";
  19273. default:
  19274. return false;
  19275. }
  19276. case "ClassExpression":
  19277. switch (parent.type) {
  19278. case "NewExpression":
  19279. return name === "callee" && parent.callee === node;
  19280. default:
  19281. return false;
  19282. }
  19283. case "OptionalMemberExpression":
  19284. return parent.type === "MemberExpression";
  19285. case "MemberExpression":
  19286. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node) {
  19287. var object = node.object;
  19288. while (object) {
  19289. if (object.type === "CallExpression") {
  19290. return true;
  19291. }
  19292. if (object.type !== "MemberExpression" && object.type !== "BindExpression") {
  19293. break;
  19294. }
  19295. object = object.object;
  19296. }
  19297. }
  19298. return false;
  19299. case "BindExpression":
  19300. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node || parent.type === "MemberExpression" && name === "object" && parent.object === node || parent.type === "NewExpression" && name === "callee" && parent.callee === node) {
  19301. return true;
  19302. }
  19303. return false;
  19304. case "NGPipeExpression":
  19305. if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
  19306. return false;
  19307. }
  19308. return true;
  19309. }
  19310. return false;
  19311. }
  19312. function isStatement(node) {
  19313. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || 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 === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || 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";
  19314. }
  19315. function getUnparenthesizedNode(node) {
  19316. return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
  19317. }
  19318. function endsWithRightBracket(node) {
  19319. switch (node.type) {
  19320. case "ObjectExpression":
  19321. return true;
  19322. default:
  19323. return false;
  19324. }
  19325. }
  19326. function isFollowedByRightBracket(path$$1) {
  19327. var node = path$$1.getValue();
  19328. var parent = path$$1.getParentNode();
  19329. var name = path$$1.getName();
  19330. switch (parent.type) {
  19331. case "NGPipeExpression":
  19332. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  19333. return path$$1.callParent(isFollowedByRightBracket);
  19334. }
  19335. break;
  19336. case "ObjectProperty":
  19337. if (name === "value") {
  19338. var parentParent = path$$1.getParentNode(1);
  19339. return parentParent.properties[parentParent.properties.length - 1] === parent;
  19340. }
  19341. break;
  19342. case "BinaryExpression":
  19343. case "LogicalExpression":
  19344. if (name === "right") {
  19345. return path$$1.callParent(isFollowedByRightBracket);
  19346. }
  19347. break;
  19348. case "ConditionalExpression":
  19349. if (name === "alternate") {
  19350. return path$$1.callParent(isFollowedByRightBracket);
  19351. }
  19352. break;
  19353. case "UnaryExpression":
  19354. if (parent.prefix) {
  19355. return path$$1.callParent(isFollowedByRightBracket);
  19356. }
  19357. break;
  19358. }
  19359. return false;
  19360. }
  19361. function shouldWrapFunctionForExportDefault(path$$1, options) {
  19362. var node = path$$1.getValue();
  19363. var parent = path$$1.getParentNode();
  19364. if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
  19365. return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
  19366. // (e.g. `export default (function() {})();`)
  19367. // in this case we don't need to add extra parens
  19368. !needsParens(path$$1, options);
  19369. }
  19370. if (!hasNakedLeftSide$1(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path$$1, options)) {
  19371. return false;
  19372. }
  19373. return path$$1.call.apply(path$$1, [function (childPath) {
  19374. return shouldWrapFunctionForExportDefault(childPath, options);
  19375. }].concat(getLeftSidePathName$1(path$$1, node)));
  19376. }
  19377. var needsParens_1 = needsParens;
  19378. var _require$$0$builders$1 = doc.builders;
  19379. var concat$6 = _require$$0$builders$1.concat;
  19380. var join$4 = _require$$0$builders$1.join;
  19381. var line$4 = _require$$0$builders$1.line;
  19382. function printHtmlBinding$1(path$$1, options, print) {
  19383. var node = path$$1.getValue();
  19384. if (options.__onHtmlBindingRoot && path$$1.getName() === null) {
  19385. options.__onHtmlBindingRoot(node);
  19386. }
  19387. if (node.type !== "File") {
  19388. return;
  19389. }
  19390. if (options.__isVueForBindingLeft) {
  19391. return path$$1.call(function (functionDeclarationPath) {
  19392. var _functionDeclarationP = functionDeclarationPath.getValue(),
  19393. params = _functionDeclarationP.params;
  19394. return concat$6([params.length > 1 ? "(" : "", join$4(concat$6([",", line$4]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
  19395. }, "program", "body", 0);
  19396. }
  19397. if (options.__isVueSlotScope) {
  19398. return path$$1.call(function (functionDeclarationPath) {
  19399. return join$4(concat$6([",", line$4]), functionDeclarationPath.map(print, "params"));
  19400. }, "program", "body", 0);
  19401. }
  19402. } // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
  19403. function isVueEventBindingExpression$1(node) {
  19404. switch (node.type) {
  19405. case "MemberExpression":
  19406. switch (node.property.type) {
  19407. case "Identifier":
  19408. case "NumericLiteral":
  19409. case "StringLiteral":
  19410. return isVueEventBindingExpression$1(node.object);
  19411. }
  19412. return false;
  19413. case "Identifier":
  19414. return true;
  19415. default:
  19416. return false;
  19417. }
  19418. }
  19419. var htmlBinding = {
  19420. isVueEventBindingExpression: isVueEventBindingExpression$1,
  19421. printHtmlBinding: printHtmlBinding$1
  19422. };
  19423. function preprocess(ast, options) {
  19424. switch (options.parser) {
  19425. case "json":
  19426. case "json5":
  19427. case "json-stringify":
  19428. case "__js_expression":
  19429. case "__vue_expression":
  19430. return Object.assign({}, ast, {
  19431. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  19432. node: ast,
  19433. comments: []
  19434. });
  19435. default:
  19436. return ast;
  19437. }
  19438. }
  19439. var preprocess_1 = preprocess;
  19440. var getParentExportDeclaration$1 = util$1.getParentExportDeclaration;
  19441. var isExportDeclaration$1 = util$1.isExportDeclaration;
  19442. var shouldFlatten$1 = util$1.shouldFlatten;
  19443. var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
  19444. var hasNewline$2 = util$1.hasNewline;
  19445. var hasNewlineInRange$1 = util$1.hasNewlineInRange;
  19446. var getLast$3 = util$1.getLast;
  19447. var getStringWidth$2 = util$1.getStringWidth;
  19448. var printString$1 = util$1.printString;
  19449. var printNumber$1 = util$1.printNumber;
  19450. var hasIgnoreComment$1 = util$1.hasIgnoreComment;
  19451. var skipWhitespace$1 = util$1.skipWhitespace;
  19452. var hasNodeIgnoreComment$1 = util$1.hasNodeIgnoreComment;
  19453. var getPenultimate$1 = util$1.getPenultimate;
  19454. var startsWithNoLookaheadToken$1 = util$1.startsWithNoLookaheadToken;
  19455. var getIndentSize$1 = util$1.getIndentSize;
  19456. var matchAncestorTypes$1 = util$1.matchAncestorTypes;
  19457. var getPreferredQuote$1 = util$1.getPreferredQuote;
  19458. var isNextLineEmpty$2 = utilShared.isNextLineEmpty;
  19459. var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
  19460. var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
  19461. var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
  19462. var insertPragma = pragma.insertPragma;
  19463. var printHtmlBinding = htmlBinding.printHtmlBinding;
  19464. var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
  19465. var getLeftSide = utils$4.getLeftSide;
  19466. var getLeftSidePathName = utils$4.getLeftSidePathName;
  19467. var hasNakedLeftSide = utils$4.hasNakedLeftSide;
  19468. var hasNode = utils$4.hasNode;
  19469. var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
  19470. var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
  19471. var needsQuoteProps = new WeakMap();
  19472. var _require$$6$builders = doc.builders;
  19473. var concat$4 = _require$$6$builders.concat;
  19474. var join$2 = _require$$6$builders.join;
  19475. var line$3 = _require$$6$builders.line;
  19476. var hardline$3 = _require$$6$builders.hardline;
  19477. var softline$1 = _require$$6$builders.softline;
  19478. var literalline$1 = _require$$6$builders.literalline;
  19479. var group$1 = _require$$6$builders.group;
  19480. var indent$2 = _require$$6$builders.indent;
  19481. var align$1 = _require$$6$builders.align;
  19482. var conditionalGroup$1 = _require$$6$builders.conditionalGroup;
  19483. var fill$2 = _require$$6$builders.fill;
  19484. var ifBreak$1 = _require$$6$builders.ifBreak;
  19485. var breakParent$2 = _require$$6$builders.breakParent;
  19486. var lineSuffixBoundary$1 = _require$$6$builders.lineSuffixBoundary;
  19487. var addAlignmentToDoc$2 = _require$$6$builders.addAlignmentToDoc;
  19488. var dedent$2 = _require$$6$builders.dedent;
  19489. var _require$$6$utils = doc.utils;
  19490. var willBreak$1 = _require$$6$utils.willBreak;
  19491. var isLineNext$1 = _require$$6$utils.isLineNext;
  19492. var isEmpty$1 = _require$$6$utils.isEmpty;
  19493. var removeLines$1 = _require$$6$utils.removeLines;
  19494. var printDocToString$2 = doc.printer.printDocToString;
  19495. var uid = 0;
  19496. function shouldPrintComma(options, level) {
  19497. level = level || "es5";
  19498. switch (options.trailingComma) {
  19499. case "all":
  19500. if (level === "all") {
  19501. return true;
  19502. }
  19503. // fallthrough
  19504. case "es5":
  19505. if (level === "es5") {
  19506. return true;
  19507. }
  19508. // fallthrough
  19509. case "none":
  19510. default:
  19511. return false;
  19512. }
  19513. }
  19514. function genericPrint(path$$1, options, printPath, args) {
  19515. var node = path$$1.getValue();
  19516. var needsParens = false;
  19517. var linesWithoutParens = printPathNoParens(path$$1, options, printPath, args);
  19518. if (!node || isEmpty$1(linesWithoutParens)) {
  19519. return linesWithoutParens;
  19520. }
  19521. var parentExportDecl = getParentExportDeclaration$1(path$$1);
  19522. var decorators = [];
  19523. if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
  19524. } else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
  19525. // was written before the export, the export will be responsible
  19526. // for printing the decorators.
  19527. !(parentExportDecl && options.locStart(parentExportDecl, {
  19528. ignoreDecorators: true
  19529. }) > options.locStart(node.decorators[0]))) {
  19530. var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  19531. var separator = shouldBreak ? hardline$3 : line$3;
  19532. path$$1.each(function (decoratorPath) {
  19533. var decorator = decoratorPath.getValue();
  19534. if (decorator.expression) {
  19535. decorator = decorator.expression;
  19536. } else {
  19537. decorator = decorator.callee;
  19538. }
  19539. decorators.push(printPath(decoratorPath), separator);
  19540. }, "decorators");
  19541. if (parentExportDecl) {
  19542. decorators.unshift(hardline$3);
  19543. }
  19544. } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 && // Only print decorators here if they were written before the export,
  19545. // otherwise they are printed by the node.declaration
  19546. options.locStart(node, {
  19547. ignoreDecorators: true
  19548. }) > options.locStart(node.declaration.decorators[0])) {
  19549. // Export declarations are responsible for printing any decorators
  19550. // that logically apply to node.declaration.
  19551. path$$1.each(function (decoratorPath) {
  19552. var decorator = decoratorPath.getValue();
  19553. var prefix = decorator.type === "Decorator" ? "" : "@";
  19554. decorators.push(prefix, printPath(decoratorPath), hardline$3);
  19555. }, "declaration", "decorators");
  19556. } else {
  19557. // Nodes with decorators can't have parentheses, so we can avoid
  19558. // computing pathNeedsParens() except in this case.
  19559. needsParens = needsParens_1(path$$1, options);
  19560. }
  19561. var parts = [];
  19562. if (needsParens) {
  19563. parts.unshift("(");
  19564. }
  19565. parts.push(linesWithoutParens);
  19566. if (needsParens) {
  19567. var _node = path$$1.getValue();
  19568. if (hasFlowShorthandAnnotationComment(_node)) {
  19569. parts.push(" /*");
  19570. parts.push(_node.trailingComments[0].value.trimLeft());
  19571. parts.push("*/");
  19572. _node.trailingComments[0].printed = true;
  19573. }
  19574. parts.push(")");
  19575. }
  19576. if (decorators.length > 0) {
  19577. return group$1(concat$4(decorators.concat(parts)));
  19578. }
  19579. return concat$4(parts);
  19580. }
  19581. function hasNewlineBetweenOrAfterDecorators(node, options) {
  19582. return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$3(node.decorators))) || hasNewline$2(options.originalText, options.locEnd(getLast$3(node.decorators)));
  19583. }
  19584. function printDecorators(path$$1, options, print) {
  19585. var node = path$$1.getValue();
  19586. return group$1(concat$4([join$2(line$3, path$$1.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$3 : line$3]));
  19587. }
  19588. function hasPrettierIgnore(path$$1) {
  19589. return hasIgnoreComment$1(path$$1) || hasJsxIgnoreComment(path$$1);
  19590. }
  19591. function hasJsxIgnoreComment(path$$1) {
  19592. var node = path$$1.getValue();
  19593. var parent = path$$1.getParentNode();
  19594. if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
  19595. return false;
  19596. } // Lookup the previous sibling, ignoring any empty JSXText elements
  19597. var index = parent.children.indexOf(node);
  19598. var prevSibling = null;
  19599. for (var i = index; i > 0; i--) {
  19600. var candidate = parent.children[i - 1];
  19601. if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
  19602. continue;
  19603. }
  19604. prevSibling = candidate;
  19605. break;
  19606. }
  19607. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) {
  19608. return comment.value.trim() === "prettier-ignore";
  19609. });
  19610. }
  19611. /**
  19612. * The following is the shared logic for
  19613. * ternary operators, namely ConditionalExpression
  19614. * and TSConditionalType
  19615. * @typedef {Object} OperatorOptions
  19616. * @property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
  19617. * @property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print after the conditional expression.
  19618. * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode.
  19619. * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType".
  19620. * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent".
  19621. * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate".
  19622. * @property {string} testNodePropertyName - The property at which the test node can be found on the main node, eg "test".
  19623. * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks.
  19624. * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node.
  19625. * @param {Options} options - Prettier options
  19626. * @param {Function} print - Print function to call recursively
  19627. * @param {OperatorOptions} operatorOptions
  19628. * @returns Doc
  19629. */
  19630. function printTernaryOperator(path$$1, options, print, operatorOptions) {
  19631. var node = path$$1.getValue();
  19632. var testNode = node[operatorOptions.testNodePropertyName];
  19633. var consequentNode = node[operatorOptions.consequentNodePropertyName];
  19634. var alternateNode = node[operatorOptions.alternateNodePropertyName];
  19635. var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  19636. // See tests/jsx/conditional-expression.js for more info.
  19637. var jsxMode = false;
  19638. var parent = path$$1.getParentNode();
  19639. var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost
  19640. // ConditionalExpression parent. We'll use these to determine if we should
  19641. // print in JSX mode.
  19642. var currentParent;
  19643. var previousParent;
  19644. var i = 0;
  19645. do {
  19646. previousParent = currentParent || node;
  19647. currentParent = path$$1.getParentNode(i);
  19648. i++;
  19649. } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType);
  19650. var firstNonConditionalParent = currentParent || parent;
  19651. var lastConditionalParent = previousParent;
  19652. if (operatorOptions.shouldCheckJsx && (isJSXNode(testNode) || isJSXNode(consequentNode) || isJSXNode(alternateNode) || conditionalExpressionChainContainsJSX(lastConditionalParent))) {
  19653. jsxMode = true;
  19654. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  19655. // parens when using ?: within JSX, because the parens are analogous to
  19656. // curly braces in an if statement.
  19657. var wrap = function wrap(doc$$2) {
  19658. return concat$4([ifBreak$1("(", ""), indent$2(concat$4([softline$1, doc$$2])), softline$1, ifBreak$1(")", "")]);
  19659. }; // The only things we don't wrap are:
  19660. // * Nested conditional expressions in alternates
  19661. // * null
  19662. var isNull = function isNull(node) {
  19663. return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
  19664. };
  19665. parts.push(" ? ", isNull(consequentNode) ? path$$1.call(print, operatorOptions.consequentNodePropertyName) : wrap(path$$1.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNull(alternateNode) ? path$$1.call(print, operatorOptions.alternateNodePropertyName) : wrap(path$$1.call(print, operatorOptions.alternateNodePropertyName)));
  19666. } else {
  19667. // normal mode
  19668. var part = concat$4([line$3, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", "(") : "", align$1(2, path$$1.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", ")") : "", line$3, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path$$1.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path$$1.call(print, operatorOptions.alternateNodePropertyName))]);
  19669. parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node ? part : options.useTabs ? dedent$2(indent$2(part)) : align$1(Math.max(0, options.tabWidth - 2), part));
  19670. } // We want a whole chain of ConditionalExpressions to all
  19671. // break if any of them break. That means we should only group around the
  19672. // outer-most ConditionalExpression.
  19673. var maybeGroup = function maybeGroup(doc$$2) {
  19674. return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$1(doc$$2) : doc$$2 : group$1(doc$$2);
  19675. }; // Break the closing paren to keep the chain right after it:
  19676. // (a
  19677. // ? b
  19678. // : c
  19679. // ).call()
  19680. var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
  19681. return maybeGroup(concat$4([].concat(function (testDoc) {
  19682. return (
  19683. /**
  19684. * a
  19685. * ? b
  19686. * : multiline
  19687. * test
  19688. * node
  19689. * ^^ align(2)
  19690. * ? d
  19691. * : e
  19692. */
  19693. parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc
  19694. );
  19695. }(concat$4(operatorOptions.beforeParts())), forceNoIndent ? concat$4(parts) : indent$2(concat$4(parts)), operatorOptions.afterParts(breakClosingParen))));
  19696. }
  19697. function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
  19698. if (tokenNode === "+") {
  19699. return "+" + keyword;
  19700. } else if (tokenNode === "-") {
  19701. return "-" + keyword;
  19702. }
  19703. return keyword;
  19704. }
  19705. function printPathNoParens(path$$1, options, print, args) {
  19706. var n = path$$1.getValue();
  19707. var semi = options.semi ? ";" : "";
  19708. if (!n) {
  19709. return "";
  19710. }
  19711. if (typeof n === "string") {
  19712. return n;
  19713. }
  19714. var htmlBinding$$1 = printHtmlBinding(path$$1, options, print);
  19715. if (htmlBinding$$1) {
  19716. return htmlBinding$$1;
  19717. }
  19718. var parts = [];
  19719. switch (n.type) {
  19720. case "JsExpressionRoot":
  19721. return path$$1.call(print, "node");
  19722. case "JsonRoot":
  19723. return concat$4([path$$1.call(print, "node"), hardline$3]);
  19724. case "File":
  19725. // Print @babel/parser's InterpreterDirective here so that
  19726. // leading comments on the `Program` node get printed after the hashbang.
  19727. if (n.program && n.program.interpreter) {
  19728. parts.push(path$$1.call(function (programPath) {
  19729. return programPath.call(print, "interpreter");
  19730. }, "program"));
  19731. }
  19732. parts.push(path$$1.call(print, "program"));
  19733. return concat$4(parts);
  19734. case "Program":
  19735. // Babel 6
  19736. if (n.directives) {
  19737. path$$1.each(function (childPath) {
  19738. parts.push(print(childPath), semi, hardline$3);
  19739. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  19740. parts.push(hardline$3);
  19741. }
  19742. }, "directives");
  19743. }
  19744. parts.push(path$$1.call(function (bodyPath) {
  19745. return printStatementSequence(bodyPath, options, print);
  19746. }, "body"));
  19747. parts.push(comments.printDanglingComments(path$$1, options,
  19748. /* sameIndent */
  19749. true)); // Only force a trailing newline if there were any contents.
  19750. if (n.body.length || n.comments) {
  19751. parts.push(hardline$3);
  19752. }
  19753. return concat$4(parts);
  19754. // Babel extension.
  19755. case "EmptyStatement":
  19756. return "";
  19757. case "ExpressionStatement":
  19758. // Detect Flow-parsed directives
  19759. if (n.directive) {
  19760. return concat$4([nodeStr(n.expression, options, true), semi]);
  19761. }
  19762. if (options.parser === "__vue_event_binding") {
  19763. var parent = path$$1.getParentNode();
  19764. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
  19765. return concat$4([path$$1.call(print, "expression"), isVueEventBindingExpression(n.expression) ? ";" : ""]);
  19766. }
  19767. } // Do not append semicolon after the only JSX element in a program
  19768. return concat$4([path$$1.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path$$1) ? "" : semi]);
  19769. // Babel extension.
  19770. case "ParenthesizedExpression":
  19771. return concat$4(["(", path$$1.call(print, "expression"), ")"]);
  19772. case "AssignmentExpression":
  19773. return printAssignment(n.left, path$$1.call(print, "left"), concat$4([" ", n.operator]), n.right, path$$1.call(print, "right"), options);
  19774. case "BinaryExpression":
  19775. case "LogicalExpression":
  19776. case "NGPipeExpression":
  19777. {
  19778. var _parent = path$$1.getParentNode();
  19779. var parentParent = path$$1.getParentNode(1);
  19780. var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "DoWhileStatement");
  19781. var _parts = printBinaryishExpressions(path$$1, print, options,
  19782. /* isNested */
  19783. false, isInsideParenthesis); // if (
  19784. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  19785. // ) {
  19786. //
  19787. // looks super weird, we want to break the children if the parent breaks
  19788. //
  19789. // if (
  19790. // this.hasPlugin("dynamicImports") &&
  19791. // this.lookahead().type === tt.parenLeft
  19792. // ) {
  19793. if (isInsideParenthesis) {
  19794. return concat$4(_parts);
  19795. } // Break between the parens in unaries or in a member expression, i.e.
  19796. //
  19797. // (
  19798. // a &&
  19799. // b &&
  19800. // c
  19801. // ).call()
  19802. if (_parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) {
  19803. return group$1(concat$4([indent$2(concat$4([softline$1, concat$4(_parts)])), softline$1]));
  19804. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  19805. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  19806. var shouldNotIndent = _parent.type === "ReturnStatement" || _parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.type !== "NGPipeExpression" && (_parent.type === "NGRoot" && options.parser === "__ng_binding" || _parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === _parent.body && _parent.type === "ArrowFunctionExpression" || n !== _parent.body && _parent.type === "ForStatement" || _parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "CallExpression";
  19807. var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property";
  19808. var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
  19809. if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
  19810. return group$1(concat$4(_parts));
  19811. }
  19812. if (_parts.length === 0) {
  19813. return "";
  19814. } // If the right part is a JSX node, we include it in a separate group to
  19815. // prevent it breaking the whole chain, so we can print the expression like:
  19816. //
  19817. // foo && bar && (
  19818. // <Foo>
  19819. // <Bar />
  19820. // </Foo>
  19821. // )
  19822. var hasJSX = isJSXNode(n.right);
  19823. var rest = concat$4(hasJSX ? _parts.slice(1, -1) : _parts.slice(1));
  19824. var groupId = Symbol("logicalChain-" + ++uid);
  19825. var chain = group$1(concat$4([// Don't include the initial expression in the indentation
  19826. // level. The first item is guaranteed to be the first
  19827. // left-most expression.
  19828. _parts.length > 0 ? _parts[0] : "", indent$2(rest)]), {
  19829. id: groupId
  19830. });
  19831. if (!hasJSX) {
  19832. return chain;
  19833. }
  19834. var jsxPart = getLast$3(_parts);
  19835. return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
  19836. groupId
  19837. })]));
  19838. }
  19839. case "AssignmentPattern":
  19840. return concat$4([path$$1.call(print, "left"), " = ", path$$1.call(print, "right")]);
  19841. case "TSTypeAssertion":
  19842. {
  19843. var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
  19844. var castGroup = group$1(concat$4(["<", indent$2(concat$4([softline$1, path$$1.call(print, "typeAnnotation")])), softline$1, ">"]));
  19845. var exprContents = concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, path$$1.call(print, "expression")])), softline$1, ifBreak$1(")")]);
  19846. if (shouldBreakAfterCast) {
  19847. return conditionalGroup$1([concat$4([castGroup, path$$1.call(print, "expression")]), concat$4([castGroup, group$1(exprContents, {
  19848. shouldBreak: true
  19849. })]), concat$4([castGroup, path$$1.call(print, "expression")])]);
  19850. }
  19851. return group$1(concat$4([castGroup, path$$1.call(print, "expression")]));
  19852. }
  19853. case "OptionalMemberExpression":
  19854. case "MemberExpression":
  19855. {
  19856. var _parent2 = path$$1.getParentNode();
  19857. var firstNonMemberParent;
  19858. var i = 0;
  19859. do {
  19860. firstNonMemberParent = path$$1.getParentNode(i);
  19861. i++;
  19862. } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
  19863. var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent2.type !== "MemberExpression" && _parent2.type !== "OptionalMemberExpression";
  19864. return concat$4([path$$1.call(print, "object"), shouldInline ? printMemberLookup(path$$1, options, print) : group$1(indent$2(concat$4([softline$1, printMemberLookup(path$$1, options, print)])))]);
  19865. }
  19866. case "MetaProperty":
  19867. return concat$4([path$$1.call(print, "meta"), ".", path$$1.call(print, "property")]);
  19868. case "BindExpression":
  19869. if (n.object) {
  19870. parts.push(path$$1.call(print, "object"));
  19871. }
  19872. parts.push(group$1(indent$2(concat$4([softline$1, printBindExpressionCallee(path$$1, options, print)]))));
  19873. return concat$4(parts);
  19874. case "Identifier":
  19875. {
  19876. return concat$4([n.name, printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print)]);
  19877. }
  19878. case "SpreadElement":
  19879. case "SpreadElementPattern":
  19880. case "RestProperty":
  19881. case "SpreadProperty":
  19882. case "SpreadPropertyPattern":
  19883. case "RestElement":
  19884. case "ObjectTypeSpreadProperty":
  19885. return concat$4(["...", path$$1.call(print, "argument"), printTypeAnnotation(path$$1, options, print)]);
  19886. case "FunctionDeclaration":
  19887. case "FunctionExpression":
  19888. parts.push(printFunctionDeclaration(path$$1, print, options));
  19889. if (!n.body) {
  19890. parts.push(semi);
  19891. }
  19892. return concat$4(parts);
  19893. case "ArrowFunctionExpression":
  19894. {
  19895. if (n.async) {
  19896. parts.push("async ");
  19897. }
  19898. if (shouldPrintParamsWithoutParens(path$$1, options)) {
  19899. parts.push(path$$1.call(print, "params", 0));
  19900. } else {
  19901. parts.push(group$1(concat$4([printFunctionParams(path$$1, print, options,
  19902. /* expandLast */
  19903. args && (args.expandLastArg || args.expandFirstArg),
  19904. /* printTypeParams */
  19905. true), printReturnType(path$$1, print, options)])));
  19906. }
  19907. var dangling = comments.printDanglingComments(path$$1, options,
  19908. /* sameIndent */
  19909. true, function (comment) {
  19910. var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
  19911. return options.originalText.substr(nextCharacter, 2) === "=>";
  19912. });
  19913. if (dangling) {
  19914. parts.push(" ", dangling);
  19915. }
  19916. parts.push(" =>");
  19917. var body = path$$1.call(function (bodyPath) {
  19918. return print(bodyPath, args);
  19919. }, "body"); // We want to always keep these types of nodes on the same line
  19920. // as the arrow.
  19921. if (!hasLeadingOwnLineComment(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode(n.body) || isTemplateOnItsOwnLine(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
  19922. return group$1(concat$4([concat$4(parts), " ", body]));
  19923. } // We handle sequence expressions as the body of arrows specially,
  19924. // so that the required parentheses end up on their own lines.
  19925. if (n.body.type === "SequenceExpression") {
  19926. return group$1(concat$4([concat$4(parts), group$1(concat$4([" (", indent$2(concat$4([softline$1, body])), softline$1, ")"]))]));
  19927. } // if the arrow function is expanded as last argument, we are adding a
  19928. // level of indentation and need to add a softline to align the closing )
  19929. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  19930. // we should align the expression's closing } with the line with the opening {.
  19931. var shouldAddSoftLine = (args && args.expandLastArg || path$$1.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
  19932. var printTrailingComma = args && args.expandLastArg && shouldPrintComma(options, "all"); // In order to avoid confusion between
  19933. // a => a ? a : a
  19934. // a <= a ? a : a
  19935. var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
  19936. /* forbidFunctionAndClass */
  19937. false);
  19938. return group$1(concat$4([concat$4(parts), group$1(concat$4([indent$2(concat$4([line$3, shouldAddParens ? ifBreak$1("", "(") : "", body, shouldAddParens ? ifBreak$1("", ")") : ""])), shouldAddSoftLine ? concat$4([ifBreak$1(printTrailingComma ? "," : ""), softline$1]) : ""]))]));
  19939. }
  19940. case "MethodDefinition":
  19941. case "TSAbstractMethodDefinition":
  19942. if (n.decorators && n.decorators.length !== 0) {
  19943. parts.push(printDecorators(path$$1, options, print));
  19944. }
  19945. if (n.accessibility) {
  19946. parts.push(n.accessibility + " ");
  19947. }
  19948. if (n.static) {
  19949. parts.push("static ");
  19950. }
  19951. if (n.type === "TSAbstractMethodDefinition") {
  19952. parts.push("abstract ");
  19953. }
  19954. parts.push(printMethod(path$$1, options, print));
  19955. return concat$4(parts);
  19956. case "YieldExpression":
  19957. parts.push("yield");
  19958. if (n.delegate) {
  19959. parts.push("*");
  19960. }
  19961. if (n.argument) {
  19962. parts.push(" ", path$$1.call(print, "argument"));
  19963. }
  19964. return concat$4(parts);
  19965. case "AwaitExpression":
  19966. return concat$4(["await ", path$$1.call(print, "argument")]);
  19967. case "ImportSpecifier":
  19968. if (n.importKind) {
  19969. parts.push(path$$1.call(print, "importKind"), " ");
  19970. }
  19971. parts.push(path$$1.call(print, "imported"));
  19972. if (n.local && n.local.name !== n.imported.name) {
  19973. parts.push(" as ", path$$1.call(print, "local"));
  19974. }
  19975. return concat$4(parts);
  19976. case "ExportSpecifier":
  19977. parts.push(path$$1.call(print, "local"));
  19978. if (n.exported && n.exported.name !== n.local.name) {
  19979. parts.push(" as ", path$$1.call(print, "exported"));
  19980. }
  19981. return concat$4(parts);
  19982. case "ImportNamespaceSpecifier":
  19983. parts.push("* as ");
  19984. parts.push(path$$1.call(print, "local"));
  19985. return concat$4(parts);
  19986. case "ImportDefaultSpecifier":
  19987. return path$$1.call(print, "local");
  19988. case "TSExportAssignment":
  19989. return concat$4(["export = ", path$$1.call(print, "expression"), semi]);
  19990. case "ExportDefaultDeclaration":
  19991. case "ExportNamedDeclaration":
  19992. return printExportDeclaration(path$$1, options, print);
  19993. case "ExportAllDeclaration":
  19994. parts.push("export ");
  19995. if (n.exportKind === "type") {
  19996. parts.push("type ");
  19997. }
  19998. parts.push("* from ", path$$1.call(print, "source"), semi);
  19999. return concat$4(parts);
  20000. case "ExportNamespaceSpecifier":
  20001. case "ExportDefaultSpecifier":
  20002. return path$$1.call(print, "exported");
  20003. case "ImportDeclaration":
  20004. {
  20005. parts.push("import ");
  20006. if (n.importKind && n.importKind !== "value") {
  20007. parts.push(n.importKind + " ");
  20008. }
  20009. var standalones = [];
  20010. var grouped = [];
  20011. if (n.specifiers && n.specifiers.length > 0) {
  20012. path$$1.each(function (specifierPath) {
  20013. var value = specifierPath.getValue();
  20014. if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
  20015. standalones.push(print(specifierPath));
  20016. } else {
  20017. grouped.push(print(specifierPath));
  20018. }
  20019. }, "specifiers");
  20020. if (standalones.length > 0) {
  20021. parts.push(join$2(", ", standalones));
  20022. }
  20023. if (standalones.length > 0 && grouped.length > 0) {
  20024. parts.push(", ");
  20025. }
  20026. if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
  20027. return node.comments;
  20028. })) {
  20029. parts.push(concat$4(["{", options.bracketSpacing ? " " : "", concat$4(grouped), options.bracketSpacing ? " " : "", "}"]));
  20030. } else if (grouped.length >= 1) {
  20031. parts.push(group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), grouped)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])));
  20032. }
  20033. parts.push(" from ");
  20034. } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
  20035. /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
  20036. parts.push("{} from ");
  20037. }
  20038. parts.push(path$$1.call(print, "source"), semi);
  20039. return concat$4(parts);
  20040. }
  20041. case "Import":
  20042. return "import";
  20043. case "TSModuleBlock":
  20044. case "BlockStatement":
  20045. {
  20046. var naked = path$$1.call(function (bodyPath) {
  20047. return printStatementSequence(bodyPath, options, print);
  20048. }, "body");
  20049. var hasContent = n.body.find(function (node) {
  20050. return node.type !== "EmptyStatement";
  20051. });
  20052. var hasDirectives = n.directives && n.directives.length > 0;
  20053. var _parent3 = path$$1.getParentNode();
  20054. var _parentParent = path$$1.getParentNode(1);
  20055. if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ClassPrivateMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
  20056. return "{}";
  20057. }
  20058. parts.push("{"); // Babel 6
  20059. if (hasDirectives) {
  20060. path$$1.each(function (childPath) {
  20061. parts.push(indent$2(concat$4([hardline$3, print(childPath), semi])));
  20062. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  20063. parts.push(hardline$3);
  20064. }
  20065. }, "directives");
  20066. }
  20067. if (hasContent) {
  20068. parts.push(indent$2(concat$4([hardline$3, naked])));
  20069. }
  20070. parts.push(comments.printDanglingComments(path$$1, options));
  20071. parts.push(hardline$3, "}");
  20072. return concat$4(parts);
  20073. }
  20074. case "ReturnStatement":
  20075. parts.push("return");
  20076. if (n.argument) {
  20077. if (returnArgumentHasLeadingComment(options, n.argument)) {
  20078. parts.push(concat$4([" (", indent$2(concat$4([hardline$3, path$$1.call(print, "argument")])), hardline$3, ")"]));
  20079. } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
  20080. parts.push(group$1(concat$4([ifBreak$1(" (", " "), indent$2(concat$4([softline$1, path$$1.call(print, "argument")])), softline$1, ifBreak$1(")")])));
  20081. } else {
  20082. parts.push(" ", path$$1.call(print, "argument"));
  20083. }
  20084. }
  20085. if (hasDanglingComments(n)) {
  20086. parts.push(" ", comments.printDanglingComments(path$$1, options,
  20087. /* sameIndent */
  20088. true));
  20089. }
  20090. parts.push(semi);
  20091. return concat$4(parts);
  20092. case "NewExpression":
  20093. case "OptionalCallExpression":
  20094. case "CallExpression":
  20095. {
  20096. var isNew = n.type === "NewExpression";
  20097. var optional = printOptionalToken(path$$1);
  20098. if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  20099. // define calls, as a unit.
  20100. // e.g. `define(["some/lib", (lib) => {`
  20101. !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
  20102. n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
  20103. // e.g. `it('long name', () => {`
  20104. !isNew && isTestCall(n, path$$1.getParentNode())) {
  20105. return concat$4([isNew ? "new " : "", path$$1.call(print, "callee"), optional, printFunctionTypeParameters(path$$1, options, print), concat$4(["(", join$2(", ", path$$1.map(print, "arguments")), ")"])]);
  20106. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  20107. // stay with the Identifier. For example:
  20108. //
  20109. // foo /*:: <SomeGeneric> */(bar);
  20110. //
  20111. // Here, we ensure that such comments stay between the Identifier and the Callee.
  20112. var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment(n.callee.trailingComments);
  20113. if (isIdentifierWithFlowAnnotation) {
  20114. n.callee.trailingComments[0].printed = true;
  20115. } // We detect calls on member lookups and possibly print them in a
  20116. // special chain format. See `printMemberChain` for more info.
  20117. if (!isNew && isMemberish(n.callee)) {
  20118. return printMemberChain(path$$1, options, print);
  20119. }
  20120. return concat$4([isNew ? "new " : "", path$$1.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${n.callee.trailingComments[0].value.substring(2).trim()} */` : "", printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)]);
  20121. }
  20122. case "TSInterfaceDeclaration":
  20123. if (isNodeStartingWithDeclare(n, options)) {
  20124. parts.push("declare ");
  20125. }
  20126. parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path$$1, options, print), "interface ", path$$1.call(print, "id"), n.typeParameters ? path$$1.call(print, "typeParameters") : "", " ");
  20127. if (n.extends && n.extends.length) {
  20128. parts.push(group$1(indent$2(concat$4([softline$1, "extends ", (n.extends.length === 1 ? identity$1 : indent$2)(join$2(concat$4([",", line$3]), path$$1.map(print, "extends"))), " "]))));
  20129. }
  20130. parts.push(path$$1.call(print, "body"));
  20131. return concat$4(parts);
  20132. case "ObjectTypeInternalSlot":
  20133. return concat$4([n.static ? "static " : "", "[[", path$$1.call(print, "id"), "]]", printOptionalToken(path$$1), n.method ? "" : ": ", path$$1.call(print, "value")]);
  20134. case "ObjectExpression":
  20135. case "ObjectPattern":
  20136. case "ObjectTypeAnnotation":
  20137. case "TSInterfaceBody":
  20138. case "TSTypeLiteral":
  20139. {
  20140. var propertiesField;
  20141. if (n.type === "TSTypeLiteral") {
  20142. propertiesField = "members";
  20143. } else if (n.type === "TSInterfaceBody") {
  20144. propertiesField = "body";
  20145. } else {
  20146. propertiesField = "properties";
  20147. }
  20148. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  20149. var fields = [];
  20150. if (isTypeAnnotation) {
  20151. fields.push("indexers", "callProperties", "internalSlots");
  20152. }
  20153. fields.push(propertiesField);
  20154. var firstProperty = fields.map(function (field) {
  20155. return n[field][0];
  20156. }).sort(function (a, b) {
  20157. return options.locStart(a) - options.locStart(b);
  20158. })[0];
  20159. var _parent4 = path$$1.getParentNode(0);
  20160. var isFlowInterfaceLikeBody = isTypeAnnotation && _parent4 && (_parent4.type === "InterfaceDeclaration" || _parent4.type === "DeclareInterface" || _parent4.type === "DeclareClass") && path$$1.getName() === "body";
  20161. var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent4.type !== "FunctionDeclaration" && _parent4.type !== "FunctionExpression" && _parent4.type !== "ArrowFunctionExpression" && _parent4.type !== "AssignmentPattern" && _parent4.type !== "CatchClause" && n.properties.some(function (property) {
  20162. return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
  20163. }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
  20164. var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$1(semi, ";") : ",";
  20165. var leftBrace = n.exact ? "{|" : "{";
  20166. var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  20167. // interleaved in the source code. So we need to reorder them before
  20168. // printing them.
  20169. var propsAndLoc = [];
  20170. fields.forEach(function (field) {
  20171. path$$1.each(function (childPath) {
  20172. var node = childPath.getValue();
  20173. propsAndLoc.push({
  20174. node: node,
  20175. printed: print(childPath),
  20176. loc: options.locStart(node)
  20177. });
  20178. }, field);
  20179. });
  20180. var separatorParts = [];
  20181. var props = propsAndLoc.sort(function (a, b) {
  20182. return a.loc - b.loc;
  20183. }).map(function (prop) {
  20184. var result = concat$4(separatorParts.concat(group$1(prop.printed)));
  20185. separatorParts = [separator, line$3];
  20186. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
  20187. separatorParts.shift();
  20188. }
  20189. if (isNextLineEmpty$2(options.originalText, prop.node, options)) {
  20190. separatorParts.push(hardline$3);
  20191. }
  20192. return result;
  20193. });
  20194. if (n.inexact) {
  20195. props.push(concat$4(separatorParts.concat(group$1("..."))));
  20196. }
  20197. var lastElem = getLast$3(n[propertiesField]);
  20198. var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
  20199. var content;
  20200. if (props.length === 0 && !n.typeAnnotation) {
  20201. if (!hasDanglingComments(n)) {
  20202. return concat$4([leftBrace, rightBrace]);
  20203. }
  20204. content = group$1(concat$4([leftBrace, comments.printDanglingComments(path$$1, options), softline$1, rightBrace, printOptionalToken(path$$1)]));
  20205. } else {
  20206. content = concat$4([leftBrace, indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, concat$4(props)])), ifBreak$1(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options)) ? separator : ""), concat$4([options.bracketSpacing ? line$3 : softline$1, rightBrace]), printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print)]);
  20207. } // If we inline the object as first argument of the parent, we don't want
  20208. // to create another group so that the object breaks before the return
  20209. // type
  20210. var parentParentParent = path$$1.getParentNode(2);
  20211. if (n.type === "ObjectPattern" && _parent4 && shouldHugArguments(_parent4) && _parent4.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
  20212. return content;
  20213. }
  20214. return group$1(content, {
  20215. shouldBreak
  20216. });
  20217. }
  20218. // Babel 6
  20219. case "ObjectProperty": // Non-standard AST node type.
  20220. case "Property":
  20221. if (n.method || n.kind === "get" || n.kind === "set") {
  20222. return printMethod(path$$1, options, print);
  20223. }
  20224. if (n.shorthand) {
  20225. parts.push(path$$1.call(print, "value"));
  20226. } else {
  20227. var printedLeft;
  20228. if (n.computed) {
  20229. printedLeft = concat$4(["[", path$$1.call(print, "key"), "]"]);
  20230. } else {
  20231. printedLeft = printPropertyKey(path$$1, options, print);
  20232. }
  20233. parts.push(printAssignment(n.key, printedLeft, ":", n.value, path$$1.call(print, "value"), options));
  20234. }
  20235. return concat$4(parts);
  20236. // Babel 6
  20237. case "ClassMethod":
  20238. case "ClassPrivateMethod":
  20239. if (n.decorators && n.decorators.length !== 0) {
  20240. parts.push(printDecorators(path$$1, options, print));
  20241. }
  20242. if (n.static) {
  20243. parts.push("static ");
  20244. }
  20245. parts = parts.concat(printObjectMethod(path$$1, options, print));
  20246. return concat$4(parts);
  20247. // Babel 6
  20248. case "ObjectMethod":
  20249. return printObjectMethod(path$$1, options, print);
  20250. case "Decorator":
  20251. return concat$4(["@", path$$1.call(print, "expression"), path$$1.call(print, "callee")]);
  20252. case "ArrayExpression":
  20253. case "ArrayPattern":
  20254. if (n.elements.length === 0) {
  20255. if (!hasDanglingComments(n)) {
  20256. parts.push("[]");
  20257. } else {
  20258. parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
  20259. }
  20260. } else {
  20261. var _lastElem = getLast$3(n.elements);
  20262. var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  20263. // changes its length based on the number of commas. The algorithm
  20264. // is that if the last argument is null, we need to force insert
  20265. // a comma to ensure JavaScript recognizes it.
  20266. // [,].length === 1
  20267. // [1,].length === 1
  20268. // [1,,].length === 2
  20269. //
  20270. // Note that getLast returns null if the array is empty, but
  20271. // we already check for an empty array just above so we are safe
  20272. var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
  20273. parts.push(group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path$$1, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$1(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path$$1, options,
  20274. /* sameIndent */
  20275. true), softline$1, "]"])));
  20276. }
  20277. parts.push(printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print));
  20278. return concat$4(parts);
  20279. case "SequenceExpression":
  20280. {
  20281. var _parent5 = path$$1.getParentNode(0);
  20282. if (_parent5.type === "ExpressionStatement" || _parent5.type === "ForStatement") {
  20283. // For ExpressionStatements and for-loop heads, which are among
  20284. // the few places a SequenceExpression appears unparenthesized, we want
  20285. // to indent expressions after the first.
  20286. var _parts2 = [];
  20287. path$$1.each(function (p) {
  20288. if (p.getName() === 0) {
  20289. _parts2.push(print(p));
  20290. } else {
  20291. _parts2.push(",", indent$2(concat$4([line$3, print(p)])));
  20292. }
  20293. }, "expressions");
  20294. return group$1(concat$4(_parts2));
  20295. }
  20296. return group$1(concat$4([join$2(concat$4([",", line$3]), path$$1.map(print, "expressions"))]));
  20297. }
  20298. case "ThisExpression":
  20299. return "this";
  20300. case "Super":
  20301. return "super";
  20302. case "NullLiteral":
  20303. // Babel 6 Literal split
  20304. return "null";
  20305. case "RegExpLiteral":
  20306. // Babel 6 Literal split
  20307. return printRegex(n);
  20308. case "NumericLiteral":
  20309. // Babel 6 Literal split
  20310. return printNumber$1(n.extra.raw);
  20311. case "BigIntLiteral":
  20312. return concat$4([printNumber$1(n.extra ? n.extra.rawValue : // TypeScript
  20313. n.value), "n"]);
  20314. case "BooleanLiteral": // Babel 6 Literal split
  20315. case "StringLiteral": // Babel 6 Literal split
  20316. case "Literal":
  20317. {
  20318. if (n.regex) {
  20319. return printRegex(n.regex);
  20320. }
  20321. if (typeof n.value === "number") {
  20322. return printNumber$1(n.raw);
  20323. }
  20324. if (typeof n.value !== "string") {
  20325. return "" + n.value;
  20326. } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  20327. // See corresponding workaround in needs-parens.js
  20328. var grandParent = path$$1.getParentNode(1);
  20329. var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
  20330. return nodeStr(n, options, isTypeScriptDirective);
  20331. }
  20332. case "Directive":
  20333. return path$$1.call(print, "value");
  20334. // Babel 6
  20335. case "DirectiveLiteral":
  20336. return nodeStr(n, options);
  20337. case "UnaryExpression":
  20338. parts.push(n.operator);
  20339. if (/[a-z]$/.test(n.operator)) {
  20340. parts.push(" ");
  20341. }
  20342. parts.push(path$$1.call(print, "argument"));
  20343. return concat$4(parts);
  20344. case "UpdateExpression":
  20345. parts.push(path$$1.call(print, "argument"), n.operator);
  20346. if (n.prefix) {
  20347. parts.reverse();
  20348. }
  20349. return concat$4(parts);
  20350. case "ConditionalExpression":
  20351. return printTernaryOperator(path$$1, options, print, {
  20352. beforeParts: function beforeParts() {
  20353. return [path$$1.call(print, "test")];
  20354. },
  20355. afterParts: function afterParts(breakClosingParen) {
  20356. return [breakClosingParen ? softline$1 : ""];
  20357. },
  20358. shouldCheckJsx: true,
  20359. conditionalNodeType: "ConditionalExpression",
  20360. consequentNodePropertyName: "consequent",
  20361. alternateNodePropertyName: "alternate",
  20362. testNodePropertyName: "test",
  20363. breakNested: true
  20364. });
  20365. case "VariableDeclaration":
  20366. {
  20367. var printed = path$$1.map(function (childPath) {
  20368. return print(childPath);
  20369. }, "declarations"); // We generally want to terminate all variable declarations with a
  20370. // semicolon, except when they in the () part of for loops.
  20371. var parentNode = path$$1.getParentNode();
  20372. var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
  20373. var hasValue = n.declarations.some(function (decl) {
  20374. return decl.init;
  20375. });
  20376. var firstVariable;
  20377. if (printed.length === 1 && !n.declarations[0].comments) {
  20378. firstVariable = printed[0];
  20379. } else if (printed.length > 0) {
  20380. // Indent first var to comply with eslint one-var rule
  20381. firstVariable = indent$2(printed[0]);
  20382. }
  20383. parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$4([" ", firstVariable]) : "", indent$2(concat$4(printed.slice(1).map(function (p) {
  20384. return concat$4([",", hasValue && !isParentForLoop ? hardline$3 : line$3, p]);
  20385. })))];
  20386. if (!(isParentForLoop && parentNode.body !== n)) {
  20387. parts.push(semi);
  20388. }
  20389. return group$1(concat$4(parts));
  20390. }
  20391. case "TSTypeAliasDeclaration":
  20392. {
  20393. if (n.declare) {
  20394. parts.push("declare ");
  20395. }
  20396. var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path$$1.call(print, "typeAnnotation"), options);
  20397. parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed, semi);
  20398. return group$1(concat$4(parts));
  20399. }
  20400. case "VariableDeclarator":
  20401. return printAssignment(n.id, path$$1.call(print, "id"), " =", n.init, n.init && path$$1.call(print, "init"), options);
  20402. case "WithStatement":
  20403. return group$1(concat$4(["with (", path$$1.call(print, "object"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20404. case "IfStatement":
  20405. {
  20406. var con = adjustClause(n.consequent, path$$1.call(print, "consequent"));
  20407. var opening = group$1(concat$4(["if (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", con]));
  20408. parts.push(opening);
  20409. if (n.alternate) {
  20410. var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
  20411. return comment.trailing && !comments$3.isBlockComment(comment);
  20412. }) || needsHardlineAfterDanglingComment(n);
  20413. var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
  20414. parts.push(elseOnSameLine ? " " : hardline$3);
  20415. if (hasDanglingComments(n)) {
  20416. parts.push(comments.printDanglingComments(path$$1, options, true), commentOnOwnLine ? hardline$3 : " ");
  20417. }
  20418. parts.push("else", group$1(adjustClause(n.alternate, path$$1.call(print, "alternate"), n.alternate.type === "IfStatement")));
  20419. }
  20420. return concat$4(parts);
  20421. }
  20422. case "ForStatement":
  20423. {
  20424. var _body = adjustClause(n.body, path$$1.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
  20425. // Any comment positioned between the for statement and the parentheses
  20426. // is going to be printed before the statement.
  20427. var _dangling = comments.printDanglingComments(path$$1, options,
  20428. /* sameLine */
  20429. true);
  20430. var printedComments = _dangling ? concat$4([_dangling, softline$1]) : "";
  20431. if (!n.init && !n.test && !n.update) {
  20432. return concat$4([printedComments, group$1(concat$4(["for (;;)", _body]))]);
  20433. }
  20434. return concat$4([printedComments, group$1(concat$4(["for (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "init"), ";", line$3, path$$1.call(print, "test"), ";", line$3, path$$1.call(print, "update")])), softline$1])), ")", _body]))]);
  20435. }
  20436. case "WhileStatement":
  20437. return group$1(concat$4(["while (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20438. case "ForInStatement":
  20439. // Note: esprima can't actually parse "for each (".
  20440. return group$1(concat$4([n.each ? "for each (" : "for (", path$$1.call(print, "left"), " in ", path$$1.call(print, "right"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20441. case "ForOfStatement":
  20442. case "ForAwaitStatement":
  20443. {
  20444. // Babel 7 removed ForAwaitStatement in favor of ForOfStatement
  20445. // with `"await": true`:
  20446. // https://github.com/estree/estree/pull/138
  20447. var isAwait = n.type === "ForAwaitStatement" || n.await;
  20448. return group$1(concat$4(["for", isAwait ? " await" : "", " (", path$$1.call(print, "left"), " of ", path$$1.call(print, "right"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20449. }
  20450. case "DoWhileStatement":
  20451. {
  20452. var clause = adjustClause(n.body, path$$1.call(print, "body"));
  20453. var doBody = group$1(concat$4(["do", clause]));
  20454. parts = [doBody];
  20455. if (n.body.type === "BlockStatement") {
  20456. parts.push(" ");
  20457. } else {
  20458. parts.push(hardline$3);
  20459. }
  20460. parts.push("while (");
  20461. parts.push(group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", semi);
  20462. return concat$4(parts);
  20463. }
  20464. case "DoExpression":
  20465. return concat$4(["do ", path$$1.call(print, "body")]);
  20466. case "BreakStatement":
  20467. parts.push("break");
  20468. if (n.label) {
  20469. parts.push(" ", path$$1.call(print, "label"));
  20470. }
  20471. parts.push(semi);
  20472. return concat$4(parts);
  20473. case "ContinueStatement":
  20474. parts.push("continue");
  20475. if (n.label) {
  20476. parts.push(" ", path$$1.call(print, "label"));
  20477. }
  20478. parts.push(semi);
  20479. return concat$4(parts);
  20480. case "LabeledStatement":
  20481. if (n.body.type === "EmptyStatement") {
  20482. return concat$4([path$$1.call(print, "label"), ":;"]);
  20483. }
  20484. return concat$4([path$$1.call(print, "label"), ": ", path$$1.call(print, "body")]);
  20485. case "TryStatement":
  20486. return concat$4(["try ", path$$1.call(print, "block"), n.handler ? concat$4([" ", path$$1.call(print, "handler")]) : "", n.finalizer ? concat$4([" finally ", path$$1.call(print, "finalizer")]) : ""]);
  20487. case "CatchClause":
  20488. if (n.param) {
  20489. var hasComments = n.param.comments && n.param.comments.some(function (comment) {
  20490. return !comments$3.isBlockComment(comment) || comment.leading && hasNewline$2(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$2(options.originalText, options.locStart(comment), {
  20491. backwards: true
  20492. });
  20493. });
  20494. var param = path$$1.call(print, "param");
  20495. return concat$4(["catch ", hasComments ? concat$4(["(", indent$2(concat$4([softline$1, param])), softline$1, ") "]) : concat$4(["(", param, ") "]), path$$1.call(print, "body")]);
  20496. }
  20497. return concat$4(["catch ", path$$1.call(print, "body")]);
  20498. case "ThrowStatement":
  20499. return concat$4(["throw ", path$$1.call(print, "argument"), semi]);
  20500. // Note: ignoring n.lexical because it has no printing consequences.
  20501. case "SwitchStatement":
  20502. return concat$4([group$1(concat$4(["switch (", indent$2(concat$4([softline$1, path$$1.call(print, "discriminant")])), softline$1, ")"])), " {", n.cases.length > 0 ? indent$2(concat$4([hardline$3, join$2(hardline$3, path$$1.map(function (casePath) {
  20503. var caseNode = casePath.getValue();
  20504. return concat$4([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$2(options.originalText, caseNode, options) ? hardline$3 : ""]);
  20505. }, "cases"))])) : "", hardline$3, "}"]);
  20506. case "SwitchCase":
  20507. {
  20508. if (n.test) {
  20509. parts.push("case ", path$$1.call(print, "test"), ":");
  20510. } else {
  20511. parts.push("default:");
  20512. }
  20513. var consequent = n.consequent.filter(function (node) {
  20514. return node.type !== "EmptyStatement";
  20515. });
  20516. if (consequent.length > 0) {
  20517. var cons = path$$1.call(function (consequentPath) {
  20518. return printStatementSequence(consequentPath, options, print);
  20519. }, "consequent");
  20520. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$4([" ", cons]) : indent$2(concat$4([hardline$3, cons])));
  20521. }
  20522. return concat$4(parts);
  20523. }
  20524. // JSX extensions below.
  20525. case "DebuggerStatement":
  20526. return concat$4(["debugger", semi]);
  20527. case "JSXAttribute":
  20528. parts.push(path$$1.call(print, "name"));
  20529. if (n.value) {
  20530. var res;
  20531. if (isStringLiteral(n.value)) {
  20532. var raw = rawText(n.value); // Unescape all quotes so we get an accurate preferred quote
  20533. var final = raw.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  20534. var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
  20535. var _escape = quote === "'" ? "&apos;" : "&quot;";
  20536. final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape);
  20537. res = concat$4([quote, final, quote]);
  20538. } else {
  20539. res = path$$1.call(print, "value");
  20540. }
  20541. parts.push("=", res);
  20542. }
  20543. return concat$4(parts);
  20544. case "JSXIdentifier":
  20545. return "" + n.name;
  20546. case "JSXNamespacedName":
  20547. return join$2(":", [path$$1.call(print, "namespace"), path$$1.call(print, "name")]);
  20548. case "JSXMemberExpression":
  20549. return join$2(".", [path$$1.call(print, "object"), path$$1.call(print, "property")]);
  20550. case "TSQualifiedName":
  20551. return join$2(".", [path$$1.call(print, "left"), path$$1.call(print, "right")]);
  20552. case "JSXSpreadAttribute":
  20553. case "JSXSpreadChild":
  20554. {
  20555. return concat$4(["{", path$$1.call(function (p) {
  20556. var printed = concat$4(["...", print(p)]);
  20557. var n = p.getValue();
  20558. if (!n.comments || !n.comments.length) {
  20559. return printed;
  20560. }
  20561. return concat$4([indent$2(concat$4([softline$1, comments.printComments(p, function () {
  20562. return printed;
  20563. }, options)])), softline$1]);
  20564. }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
  20565. }
  20566. case "JSXExpressionContainer":
  20567. {
  20568. var _parent6 = path$$1.getParentNode(0);
  20569. var preventInline = _parent6.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
  20570. var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent6) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
  20571. if (_shouldInline) {
  20572. return group$1(concat$4(["{", path$$1.call(print, "expression"), lineSuffixBoundary$1, "}"]));
  20573. }
  20574. return group$1(concat$4(["{", indent$2(concat$4([softline$1, path$$1.call(print, "expression")])), softline$1, lineSuffixBoundary$1, "}"]));
  20575. }
  20576. case "JSXFragment":
  20577. case "JSXElement":
  20578. {
  20579. var elem = comments.printComments(path$$1, function () {
  20580. return printJSXElement(path$$1, options, print);
  20581. }, options);
  20582. return maybeWrapJSXElementInParens(path$$1, elem);
  20583. }
  20584. case "JSXOpeningElement":
  20585. {
  20586. var _n = path$$1.getValue();
  20587. var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
  20588. if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
  20589. return concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " />"]);
  20590. } // don't break up opening elements with a single long text attribute
  20591. if (_n.attributes && _n.attributes.length === 1 && _n.attributes[0].value && isStringLiteral(_n.attributes[0].value) && !_n.attributes[0].value.value.includes("\n") && // We should break for the following cases:
  20592. // <div
  20593. // // comment
  20594. // attr="value"
  20595. // >
  20596. // <div
  20597. // attr="value"
  20598. // // comment
  20599. // >
  20600. !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) {
  20601. return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
  20602. }
  20603. var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
  20604. var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  20605. // kept unbroken regardless of `jsxBracketSameLine`
  20606. !_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
  20607. // <div
  20608. // // comment
  20609. // >
  20610. // <div
  20611. // attr // comment
  20612. // >
  20613. !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  20614. // string literal with newlines
  20615. var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
  20616. return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
  20617. });
  20618. return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), concat$4([indent$2(concat$4(path$$1.map(function (attr) {
  20619. return concat$4([line$3, print(attr)]);
  20620. }, "attributes"))), _n.selfClosing ? line$3 : bracketSameLine ? ">" : softline$1]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
  20621. shouldBreak: _shouldBreak
  20622. });
  20623. }
  20624. case "JSXClosingElement":
  20625. return concat$4(["</", path$$1.call(print, "name"), ">"]);
  20626. case "JSXOpeningFragment":
  20627. case "JSXClosingFragment":
  20628. {
  20629. var hasComment = n.comments && n.comments.length;
  20630. var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
  20631. var isOpeningFragment = n.type === "JSXOpeningFragment";
  20632. return concat$4([isOpeningFragment ? "<" : "</", indent$2(concat$4([hasOwnLineComment ? hardline$3 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path$$1, options, true)])), hasOwnLineComment ? hardline$3 : "", ">"]);
  20633. }
  20634. case "JSXText":
  20635. /* istanbul ignore next */
  20636. throw new Error("JSXTest should be handled by JSXElement");
  20637. case "JSXEmptyExpression":
  20638. {
  20639. var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
  20640. return concat$4([comments.printDanglingComments(path$$1, options,
  20641. /* sameIndent */
  20642. !requiresHardline), requiresHardline ? hardline$3 : ""]);
  20643. }
  20644. case "ClassBody":
  20645. if (!n.comments && n.body.length === 0) {
  20646. return "{}";
  20647. }
  20648. return concat$4(["{", n.body.length > 0 ? indent$2(concat$4([hardline$3, path$$1.call(function (bodyPath) {
  20649. return printStatementSequence(bodyPath, options, print);
  20650. }, "body")])) : comments.printDanglingComments(path$$1, options), hardline$3, "}"]);
  20651. case "ClassProperty":
  20652. case "TSAbstractClassProperty":
  20653. case "ClassPrivateProperty":
  20654. {
  20655. if (n.decorators && n.decorators.length !== 0) {
  20656. parts.push(printDecorators(path$$1, options, print));
  20657. }
  20658. if (n.accessibility) {
  20659. parts.push(n.accessibility + " ");
  20660. }
  20661. if (n.static) {
  20662. parts.push("static ");
  20663. }
  20664. if (n.type === "TSAbstractClassProperty") {
  20665. parts.push("abstract ");
  20666. }
  20667. if (n.readonly) {
  20668. parts.push("readonly ");
  20669. }
  20670. var variance = getFlowVariance(n);
  20671. if (variance) {
  20672. parts.push(variance);
  20673. }
  20674. if (n.computed) {
  20675. parts.push("[", path$$1.call(print, "key"), "]");
  20676. } else {
  20677. parts.push(printPropertyKey(path$$1, options, print));
  20678. }
  20679. parts.push(printOptionalToken(path$$1));
  20680. parts.push(printTypeAnnotation(path$$1, options, print));
  20681. if (n.value) {
  20682. parts.push(" =", printAssignmentRight(n.key, n.value, path$$1.call(print, "value"), options));
  20683. }
  20684. parts.push(semi);
  20685. return group$1(concat$4(parts));
  20686. }
  20687. case "ClassDeclaration":
  20688. case "ClassExpression":
  20689. if (isNodeStartingWithDeclare(n, options)) {
  20690. parts.push("declare ");
  20691. }
  20692. parts.push(concat$4(printClass(path$$1, options, print)));
  20693. return concat$4(parts);
  20694. case "TSInterfaceHeritage":
  20695. parts.push(path$$1.call(print, "expression"));
  20696. if (n.typeParameters) {
  20697. parts.push(path$$1.call(print, "typeParameters"));
  20698. }
  20699. return concat$4(parts);
  20700. case "TemplateElement":
  20701. return join$2(literalline$1, n.value.raw.split(/\r?\n/g));
  20702. case "TemplateLiteral":
  20703. {
  20704. var expressions = path$$1.map(print, "expressions");
  20705. var _parentNode = path$$1.getParentNode();
  20706. if (isJestEachTemplateLiteral(n, _parentNode)) {
  20707. var _printed2 = printJestEachTemplateLiteral(n, expressions, options);
  20708. if (_printed2) {
  20709. return _printed2;
  20710. }
  20711. }
  20712. var isSimple = isSimpleTemplateLiteral(n);
  20713. if (isSimple) {
  20714. expressions = expressions.map(function (doc$$2) {
  20715. return printDocToString$2(doc$$2, Object.assign({}, options, {
  20716. printWidth: Infinity
  20717. })).formatted;
  20718. });
  20719. }
  20720. parts.push("`");
  20721. path$$1.each(function (childPath) {
  20722. var i = childPath.getName();
  20723. parts.push(print(childPath));
  20724. if (i < expressions.length) {
  20725. // For a template literal of the following form:
  20726. // `someQuery {
  20727. // ${call({
  20728. // a,
  20729. // b,
  20730. // })}
  20731. // }`
  20732. // the expression is on its own line (there is a \n in the previous
  20733. // quasi literal), therefore we want to indent the JavaScript
  20734. // expression inside at the beginning of ${ instead of the beginning
  20735. // of the `.
  20736. var tabWidth = options.tabWidth;
  20737. var quasi = childPath.getValue();
  20738. var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
  20739. var _printed3 = expressions[i];
  20740. if (!isSimple) {
  20741. // Breaks at the template element boundaries (${ and }) are preferred to breaking
  20742. // in the middle of a MemberExpression
  20743. if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression") {
  20744. _printed3 = concat$4([indent$2(concat$4([softline$1, _printed3])), softline$1]);
  20745. }
  20746. }
  20747. var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed3) : addAlignmentToDoc$2(_printed3, indentSize, tabWidth);
  20748. parts.push(group$1(concat$4(["${", aligned, lineSuffixBoundary$1, "}"])));
  20749. }
  20750. }, "quasis");
  20751. parts.push("`");
  20752. return concat$4(parts);
  20753. }
  20754. // These types are unprintable because they serve as abstract
  20755. // supertypes for other (printable) types.
  20756. case "TaggedTemplateExpression":
  20757. return concat$4([path$$1.call(print, "tag"), path$$1.call(print, "typeParameters"), path$$1.call(print, "quasi")]);
  20758. case "Node":
  20759. case "Printable":
  20760. case "SourceLocation":
  20761. case "Position":
  20762. case "Statement":
  20763. case "Function":
  20764. case "Pattern":
  20765. case "Expression":
  20766. case "Declaration":
  20767. case "Specifier":
  20768. case "NamedSpecifier":
  20769. case "Comment":
  20770. case "MemberTypeAnnotation": // Flow
  20771. case "Type":
  20772. /* istanbul ignore next */
  20773. throw new Error("unprintable type: " + JSON.stringify(n.type));
  20774. // Type Annotations for Facebook Flow, typically stripped out or
  20775. // transformed away before printing.
  20776. case "TypeAnnotation":
  20777. case "TSTypeAnnotation":
  20778. if (n.typeAnnotation) {
  20779. return path$$1.call(print, "typeAnnotation");
  20780. }
  20781. /* istanbul ignore next */
  20782. return "";
  20783. case "TSTupleType":
  20784. case "TupleTypeAnnotation":
  20785. {
  20786. var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
  20787. return group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path$$1, options, typesField, print)])), ifBreak$1(shouldPrintComma(options, "all") ? "," : ""), comments.printDanglingComments(path$$1, options,
  20788. /* sameIndent */
  20789. true), softline$1, "]"]));
  20790. }
  20791. case "ExistsTypeAnnotation":
  20792. return "*";
  20793. case "EmptyTypeAnnotation":
  20794. return "empty";
  20795. case "AnyTypeAnnotation":
  20796. return "any";
  20797. case "MixedTypeAnnotation":
  20798. return "mixed";
  20799. case "ArrayTypeAnnotation":
  20800. return concat$4([path$$1.call(print, "elementType"), "[]"]);
  20801. case "BooleanTypeAnnotation":
  20802. return "boolean";
  20803. case "BooleanLiteralTypeAnnotation":
  20804. return "" + n.value;
  20805. case "DeclareClass":
  20806. return printFlowDeclaration(path$$1, printClass(path$$1, options, print));
  20807. case "TSDeclareFunction":
  20808. // For TypeScript the TSDeclareFunction node shares the AST
  20809. // structure with FunctionDeclaration
  20810. return concat$4([n.declare ? "declare " : "", printFunctionDeclaration(path$$1, print, options), semi]);
  20811. case "DeclareFunction":
  20812. return printFlowDeclaration(path$$1, ["function ", path$$1.call(print, "id"), n.predicate ? " " : "", path$$1.call(print, "predicate"), semi]);
  20813. case "DeclareModule":
  20814. return printFlowDeclaration(path$$1, ["module ", path$$1.call(print, "id"), " ", path$$1.call(print, "body")]);
  20815. case "DeclareModuleExports":
  20816. return printFlowDeclaration(path$$1, ["module.exports", ": ", path$$1.call(print, "typeAnnotation"), semi]);
  20817. case "DeclareVariable":
  20818. return printFlowDeclaration(path$$1, ["var ", path$$1.call(print, "id"), semi]);
  20819. case "DeclareExportAllDeclaration":
  20820. return concat$4(["declare export * from ", path$$1.call(print, "source")]);
  20821. case "DeclareExportDeclaration":
  20822. return concat$4(["declare ", printExportDeclaration(path$$1, options, print)]);
  20823. case "DeclareOpaqueType":
  20824. case "OpaqueType":
  20825. {
  20826. parts.push("opaque type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"));
  20827. if (n.supertype) {
  20828. parts.push(": ", path$$1.call(print, "supertype"));
  20829. }
  20830. if (n.impltype) {
  20831. parts.push(" = ", path$$1.call(print, "impltype"));
  20832. }
  20833. parts.push(semi);
  20834. if (n.type === "DeclareOpaqueType") {
  20835. return printFlowDeclaration(path$$1, parts);
  20836. }
  20837. return concat$4(parts);
  20838. }
  20839. case "FunctionTypeAnnotation":
  20840. case "TSFunctionType":
  20841. {
  20842. // FunctionTypeAnnotation is ambiguous:
  20843. // declare function foo(a: B): void; OR
  20844. // var A: (a: B) => void;
  20845. var _parent7 = path$$1.getParentNode(0);
  20846. var _parentParent2 = path$$1.getParentNode(1);
  20847. var _parentParentParent = path$$1.getParentNode(2);
  20848. var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent7.type === "ObjectTypeProperty" || _parent7.type === "ObjectTypeInternalSlot") && !getFlowVariance(_parent7) && !_parent7.optional && options.locStart(_parent7) === options.locStart(n) || _parent7.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
  20849. var needsColon = isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
  20850. // printing ":" as part of the expression and it would put parenthesis
  20851. // around :(
  20852. var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
  20853. if (isObjectTypePropertyAFunction(_parent7, options)) {
  20854. isArrowFunctionTypeAnnotation = true;
  20855. needsColon = true;
  20856. }
  20857. if (needsParens) {
  20858. parts.push("(");
  20859. }
  20860. parts.push(printFunctionParams(path$$1, print, options,
  20861. /* expandArg */
  20862. false,
  20863. /* printTypeParams */
  20864. true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
  20865. // needs to be added separately.
  20866. if (n.returnType || n.predicate || n.typeAnnotation) {
  20867. parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path$$1.call(print, "returnType"), path$$1.call(print, "predicate"), path$$1.call(print, "typeAnnotation"));
  20868. }
  20869. if (needsParens) {
  20870. parts.push(")");
  20871. }
  20872. return group$1(concat$4(parts));
  20873. }
  20874. case "TSRestType":
  20875. return concat$4(["...", path$$1.call(print, "typeAnnotation")]);
  20876. case "TSOptionalType":
  20877. return concat$4([path$$1.call(print, "typeAnnotation"), "?"]);
  20878. case "FunctionTypeParam":
  20879. return concat$4([path$$1.call(print, "name"), printOptionalToken(path$$1), n.name ? ": " : "", path$$1.call(print, "typeAnnotation")]);
  20880. case "GenericTypeAnnotation":
  20881. return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
  20882. case "DeclareInterface":
  20883. case "InterfaceDeclaration":
  20884. case "InterfaceTypeAnnotation":
  20885. {
  20886. if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
  20887. parts.push("declare ");
  20888. }
  20889. parts.push("interface");
  20890. if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
  20891. parts.push(" ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"));
  20892. }
  20893. if (n["extends"].length > 0) {
  20894. parts.push(group$1(indent$2(concat$4([line$3, "extends ", (n.extends.length === 1 ? identity$1 : indent$2)(join$2(concat$4([",", line$3]), path$$1.map(print, "extends")))]))));
  20895. }
  20896. parts.push(" ", path$$1.call(print, "body"));
  20897. return group$1(concat$4(parts));
  20898. }
  20899. case "ClassImplements":
  20900. case "InterfaceExtends":
  20901. return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
  20902. case "TSClassImplements":
  20903. return concat$4([path$$1.call(print, "expression"), path$$1.call(print, "typeParameters")]);
  20904. case "TSIntersectionType":
  20905. case "IntersectionTypeAnnotation":
  20906. {
  20907. var types = path$$1.map(print, "types");
  20908. var result = [];
  20909. var wasIndented = false;
  20910. for (var _i = 0; _i < types.length; ++_i) {
  20911. if (_i === 0) {
  20912. result.push(types[_i]);
  20913. } else if (isObjectType(n.types[_i - 1]) && isObjectType(n.types[_i])) {
  20914. // If both are objects, don't indent
  20915. result.push(concat$4([" & ", wasIndented ? indent$2(types[_i]) : types[_i]]));
  20916. } else if (!isObjectType(n.types[_i - 1]) && !isObjectType(n.types[_i])) {
  20917. // If no object is involved, go to the next line if it breaks
  20918. result.push(indent$2(concat$4([" &", line$3, types[_i]])));
  20919. } else {
  20920. // If you go from object to non-object or vis-versa, then inline it
  20921. if (_i > 1) {
  20922. wasIndented = true;
  20923. }
  20924. result.push(" & ", _i > 1 ? indent$2(types[_i]) : types[_i]);
  20925. }
  20926. }
  20927. return group$1(concat$4(result));
  20928. }
  20929. case "TSUnionType":
  20930. case "UnionTypeAnnotation":
  20931. {
  20932. // single-line variation
  20933. // A | B | C
  20934. // multi-line variation
  20935. // | A
  20936. // | B
  20937. // | C
  20938. var _parent8 = path$$1.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  20939. var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && _parent8.type !== "TSTypeAssertion" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) && !((_parent8.type === "TypeAlias" || _parent8.type === "VariableDeclarator" || _parent8.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
  20940. // a: string
  20941. // } | null | void
  20942. // should be inlined and not be printed in the multi-line variant
  20943. var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
  20944. // | child1
  20945. // // comment
  20946. // | child2
  20947. var _printed4 = path$$1.map(function (typePath) {
  20948. var printedType = typePath.call(print);
  20949. if (!shouldHug) {
  20950. printedType = align$1(2, printedType);
  20951. }
  20952. return comments.printComments(typePath, function () {
  20953. return printedType;
  20954. }, options);
  20955. }, "types");
  20956. if (shouldHug) {
  20957. return join$2(" | ", _printed4);
  20958. }
  20959. var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
  20960. var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]), _printed4)]);
  20961. var hasParens;
  20962. if (n.type === "TSUnionType") {
  20963. var greatGrandParent = path$$1.getParentNode(2);
  20964. var greatGreatGrandParent = path$$1.getParentNode(3);
  20965. hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
  20966. } else {
  20967. hasParens = needsParens_1(path$$1, options);
  20968. }
  20969. if (hasParens) {
  20970. return group$1(concat$4([indent$2(code), softline$1]));
  20971. }
  20972. return group$1(shouldIndent ? indent$2(code) : code);
  20973. }
  20974. case "NullableTypeAnnotation":
  20975. return concat$4(["?", path$$1.call(print, "typeAnnotation")]);
  20976. case "TSNullKeyword":
  20977. case "NullLiteralTypeAnnotation":
  20978. return "null";
  20979. case "ThisTypeAnnotation":
  20980. return "this";
  20981. case "NumberTypeAnnotation":
  20982. return "number";
  20983. case "ObjectTypeCallProperty":
  20984. if (n.static) {
  20985. parts.push("static ");
  20986. }
  20987. parts.push(path$$1.call(print, "value"));
  20988. return concat$4(parts);
  20989. case "ObjectTypeIndexer":
  20990. {
  20991. var _variance = getFlowVariance(n);
  20992. return concat$4([_variance || "", "[", path$$1.call(print, "id"), n.id ? ": " : "", path$$1.call(print, "key"), "]: ", path$$1.call(print, "value")]);
  20993. }
  20994. case "ObjectTypeProperty":
  20995. {
  20996. var _variance2 = getFlowVariance(n);
  20997. var modifier = "";
  20998. if (n.proto) {
  20999. modifier = "proto ";
  21000. } else if (n.static) {
  21001. modifier = "static ";
  21002. }
  21003. return concat$4([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path$$1, options, print), printOptionalToken(path$$1), isFunctionNotation(n, options) ? "" : ": ", path$$1.call(print, "value")]);
  21004. }
  21005. case "QualifiedTypeIdentifier":
  21006. return concat$4([path$$1.call(print, "qualification"), ".", path$$1.call(print, "id")]);
  21007. case "StringLiteralTypeAnnotation":
  21008. return nodeStr(n, options);
  21009. case "NumberLiteralTypeAnnotation":
  21010. assert.strictEqual(typeof n.value, "number");
  21011. if (n.extra != null) {
  21012. return printNumber$1(n.extra.raw);
  21013. }
  21014. return printNumber$1(n.raw);
  21015. case "StringTypeAnnotation":
  21016. return "string";
  21017. case "DeclareTypeAlias":
  21018. case "TypeAlias":
  21019. {
  21020. if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
  21021. parts.push("declare ");
  21022. }
  21023. var _printed5 = printAssignmentRight(n.id, n.right, path$$1.call(print, "right"), options);
  21024. parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed5, semi);
  21025. return group$1(concat$4(parts));
  21026. }
  21027. case "TypeCastExpression":
  21028. {
  21029. var value = path$$1.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.
  21030. // Unfortunately, its parser doesn't differentiate between comment annotations and regular
  21031. // annotations when producing an AST. So to preserve parentheses around type casts that use
  21032. // the comment syntax, we need to hackily read the source itself to see if the code contains
  21033. // a type annotation comment.
  21034. //
  21035. // Note that we're able to use the normal whitespace regex here because the Flow parser has
  21036. // already deemed this AST node to be a type cast. Only the Babel parser needs the
  21037. // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
  21038. // implemented differently.
  21039. var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/);
  21040. return concat$4(["(", path$$1.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path$$1.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]);
  21041. }
  21042. case "TypeParameterDeclaration":
  21043. case "TypeParameterInstantiation":
  21044. {
  21045. var _value = path$$1.getValue();
  21046. var commentStart = _value.range ? options.originalText.substring(0, _value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here
  21047. // because we know for sure that this is a type definition.
  21048. var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/);
  21049. if (_commentSyntax) {
  21050. return concat$4(["/*:: ", printTypeParameters(path$$1, options, print, "params"), " */"]);
  21051. }
  21052. return printTypeParameters(path$$1, options, print, "params");
  21053. }
  21054. case "TSTypeParameterDeclaration":
  21055. case "TSTypeParameterInstantiation":
  21056. return printTypeParameters(path$$1, options, print, "params");
  21057. case "TSTypeParameter":
  21058. case "TypeParameter":
  21059. {
  21060. var _parent9 = path$$1.getParentNode();
  21061. if (_parent9.type === "TSMappedType") {
  21062. parts.push("[", path$$1.call(print, "name"));
  21063. if (n.constraint) {
  21064. parts.push(" in ", path$$1.call(print, "constraint"));
  21065. }
  21066. parts.push("]");
  21067. return concat$4(parts);
  21068. }
  21069. var _variance3 = getFlowVariance(n);
  21070. if (_variance3) {
  21071. parts.push(_variance3);
  21072. }
  21073. parts.push(path$$1.call(print, "name"));
  21074. if (n.bound) {
  21075. parts.push(": ");
  21076. parts.push(path$$1.call(print, "bound"));
  21077. }
  21078. if (n.constraint) {
  21079. parts.push(" extends ", path$$1.call(print, "constraint"));
  21080. }
  21081. if (n["default"]) {
  21082. parts.push(" = ", path$$1.call(print, "default"));
  21083. } // Keep comma if the file extension is .tsx and
  21084. // has one type parameter that isn't extend with any types.
  21085. // Because, otherwise formatted result will be invalid as tsx.
  21086. var _grandParent = path$$1.getNode(2);
  21087. if (_parent9.params && _parent9.params.length === 1 && options.filepath && /\.tsx$/i.test(options.filepath) && !n.constraint && _grandParent.type === "ArrowFunctionExpression") {
  21088. parts.push(",");
  21089. }
  21090. return concat$4(parts);
  21091. }
  21092. case "TypeofTypeAnnotation":
  21093. return concat$4(["typeof ", path$$1.call(print, "argument")]);
  21094. case "VoidTypeAnnotation":
  21095. return "void";
  21096. case "InferredPredicate":
  21097. return "%checks";
  21098. // Unhandled types below. If encountered, nodes of these types should
  21099. // be either left alone or desugared into AST types that are fully
  21100. // supported by the pretty-printer.
  21101. case "DeclaredPredicate":
  21102. return concat$4(["%checks(", path$$1.call(print, "value"), ")"]);
  21103. case "TSAbstractKeyword":
  21104. return "abstract";
  21105. case "TSAnyKeyword":
  21106. return "any";
  21107. case "TSAsyncKeyword":
  21108. return "async";
  21109. case "TSBooleanKeyword":
  21110. return "boolean";
  21111. case "TSBigIntKeyword":
  21112. return "bigint";
  21113. case "TSConstKeyword":
  21114. return "const";
  21115. case "TSDeclareKeyword":
  21116. return "declare";
  21117. case "TSExportKeyword":
  21118. return "export";
  21119. case "TSNeverKeyword":
  21120. return "never";
  21121. case "TSNumberKeyword":
  21122. return "number";
  21123. case "TSObjectKeyword":
  21124. return "object";
  21125. case "TSProtectedKeyword":
  21126. return "protected";
  21127. case "TSPrivateKeyword":
  21128. return "private";
  21129. case "TSPublicKeyword":
  21130. return "public";
  21131. case "TSReadonlyKeyword":
  21132. return "readonly";
  21133. case "TSSymbolKeyword":
  21134. return "symbol";
  21135. case "TSStaticKeyword":
  21136. return "static";
  21137. case "TSStringKeyword":
  21138. return "string";
  21139. case "TSUndefinedKeyword":
  21140. return "undefined";
  21141. case "TSUnknownKeyword":
  21142. return "unknown";
  21143. case "TSVoidKeyword":
  21144. return "void";
  21145. case "TSAsExpression":
  21146. return concat$4([path$$1.call(print, "expression"), " as ", path$$1.call(print, "typeAnnotation")]);
  21147. case "TSArrayType":
  21148. return concat$4([path$$1.call(print, "elementType"), "[]"]);
  21149. case "TSPropertySignature":
  21150. {
  21151. if (n.export) {
  21152. parts.push("export ");
  21153. }
  21154. if (n.accessibility) {
  21155. parts.push(n.accessibility + " ");
  21156. }
  21157. if (n.static) {
  21158. parts.push("static ");
  21159. }
  21160. if (n.readonly) {
  21161. parts.push("readonly ");
  21162. }
  21163. if (n.computed) {
  21164. parts.push("[");
  21165. }
  21166. parts.push(printPropertyKey(path$$1, options, print));
  21167. if (n.computed) {
  21168. parts.push("]");
  21169. }
  21170. parts.push(printOptionalToken(path$$1));
  21171. if (n.typeAnnotation) {
  21172. parts.push(": ");
  21173. parts.push(path$$1.call(print, "typeAnnotation"));
  21174. } // This isn't valid semantically, but it's in the AST so we can print it.
  21175. if (n.initializer) {
  21176. parts.push(" = ", path$$1.call(print, "initializer"));
  21177. }
  21178. return concat$4(parts);
  21179. }
  21180. case "TSParameterProperty":
  21181. if (n.accessibility) {
  21182. parts.push(n.accessibility + " ");
  21183. }
  21184. if (n.export) {
  21185. parts.push("export ");
  21186. }
  21187. if (n.static) {
  21188. parts.push("static ");
  21189. }
  21190. if (n.readonly) {
  21191. parts.push("readonly ");
  21192. }
  21193. parts.push(path$$1.call(print, "parameter"));
  21194. return concat$4(parts);
  21195. case "TSTypeReference":
  21196. return concat$4([path$$1.call(print, "typeName"), printTypeParameters(path$$1, options, print, "typeParameters")]);
  21197. case "TSTypeQuery":
  21198. return concat$4(["typeof ", path$$1.call(print, "exprName")]);
  21199. case "TSParenthesizedType":
  21200. {
  21201. return path$$1.call(print, "typeAnnotation");
  21202. }
  21203. case "TSIndexSignature":
  21204. {
  21205. var _parent10 = path$$1.getParentNode();
  21206. return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? concat$4(path$$1.map(print, "parameters")) : "", "]: ", path$$1.call(print, "typeAnnotation"), _parent10.type === "ClassBody" ? semi : ""]);
  21207. }
  21208. case "TSTypePredicate":
  21209. return concat$4([path$$1.call(print, "parameterName"), " is ", path$$1.call(print, "typeAnnotation")]);
  21210. case "TSNonNullExpression":
  21211. return concat$4([path$$1.call(print, "expression"), "!"]);
  21212. case "TSThisType":
  21213. return "this";
  21214. case "TSImportType":
  21215. return concat$4([!n.isTypeOf ? "" : "typeof ", "import(", path$$1.call(print, "parameter"), ")", !n.qualifier ? "" : concat$4([".", path$$1.call(print, "qualifier")]), printTypeParameters(path$$1, options, print, "typeParameters")]);
  21216. case "TSLiteralType":
  21217. return path$$1.call(print, "literal");
  21218. case "TSIndexedAccessType":
  21219. return concat$4([path$$1.call(print, "objectType"), "[", path$$1.call(print, "indexType"), "]"]);
  21220. case "TSConstructSignatureDeclaration":
  21221. case "TSCallSignatureDeclaration":
  21222. case "TSConstructorType":
  21223. {
  21224. if (n.type !== "TSCallSignatureDeclaration") {
  21225. parts.push("new ");
  21226. }
  21227. parts.push(group$1(printFunctionParams(path$$1, print, options,
  21228. /* expandArg */
  21229. false,
  21230. /* printTypeParams */
  21231. true)));
  21232. if (n.returnType) {
  21233. var isType = n.type === "TSConstructorType";
  21234. parts.push(isType ? " => " : ": ", path$$1.call(print, "returnType"));
  21235. }
  21236. return concat$4(parts);
  21237. }
  21238. case "TSTypeOperator":
  21239. return concat$4([n.operator, " ", path$$1.call(print, "typeAnnotation")]);
  21240. case "TSMappedType":
  21241. {
  21242. var _shouldBreak2 = hasNewlineInRange$1(options.originalText, options.locStart(n), options.locEnd(n));
  21243. return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.readonly ? concat$4([getTypeScriptMappedTypeModifier(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path$$1, options, print), path$$1.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier(n.optional, "?") : "", ": ", path$$1.call(print, "typeAnnotation"), _shouldBreak2 && options.semi ? ";" : ""])), comments.printDanglingComments(path$$1, options,
  21244. /* sameIndent */
  21245. true), options.bracketSpacing ? line$3 : softline$1, "}"]), {
  21246. shouldBreak: _shouldBreak2
  21247. });
  21248. }
  21249. case "TSMethodSignature":
  21250. parts.push(n.accessibility ? concat$4([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path$$1.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path$$1), printFunctionParams(path$$1, print, options,
  21251. /* expandArg */
  21252. false,
  21253. /* printTypeParams */
  21254. true));
  21255. if (n.returnType) {
  21256. parts.push(": ", path$$1.call(print, "returnType"));
  21257. }
  21258. return group$1(concat$4(parts));
  21259. case "TSNamespaceExportDeclaration":
  21260. parts.push("export as namespace ", path$$1.call(print, "id"));
  21261. if (options.semi) {
  21262. parts.push(";");
  21263. }
  21264. return group$1(concat$4(parts));
  21265. case "TSEnumDeclaration":
  21266. if (isNodeStartingWithDeclare(n, options)) {
  21267. parts.push("declare ");
  21268. }
  21269. if (n.modifiers) {
  21270. parts.push(printTypeScriptModifiers(path$$1, options, print));
  21271. }
  21272. if (n.const) {
  21273. parts.push("const ");
  21274. }
  21275. parts.push("enum ", path$$1.call(print, "id"), " ");
  21276. if (n.members.length === 0) {
  21277. parts.push(group$1(concat$4(["{", comments.printDanglingComments(path$$1, options), softline$1, "}"])));
  21278. } else {
  21279. parts.push(group$1(concat$4(["{", indent$2(concat$4([hardline$3, printArrayItems(path$$1, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path$$1, options,
  21280. /* sameIndent */
  21281. true), hardline$3, "}"])));
  21282. }
  21283. return concat$4(parts);
  21284. case "TSEnumMember":
  21285. parts.push(path$$1.call(print, "id"));
  21286. if (n.initializer) {
  21287. parts.push(" = ", path$$1.call(print, "initializer"));
  21288. }
  21289. return concat$4(parts);
  21290. case "TSImportEqualsDeclaration":
  21291. if (n.isExport) {
  21292. parts.push("export ");
  21293. }
  21294. parts.push("import ", path$$1.call(print, "id"), " = ", path$$1.call(print, "moduleReference"));
  21295. if (options.semi) {
  21296. parts.push(";");
  21297. }
  21298. return group$1(concat$4(parts));
  21299. case "TSExternalModuleReference":
  21300. return concat$4(["require(", path$$1.call(print, "expression"), ")"]);
  21301. case "TSModuleDeclaration":
  21302. {
  21303. var _parent11 = path$$1.getParentNode();
  21304. var isExternalModule = isLiteral(n.id);
  21305. var parentIsDeclaration = _parent11.type === "TSModuleDeclaration";
  21306. var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
  21307. if (parentIsDeclaration) {
  21308. parts.push(".");
  21309. } else {
  21310. if (n.declare === true) {
  21311. parts.push("declare ");
  21312. }
  21313. parts.push(printTypeScriptModifiers(path$$1, options, print));
  21314. var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
  21315. // (declare)? global { ... }
  21316. var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  21317. if (!isGlobalDeclaration) {
  21318. parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  21319. }
  21320. }
  21321. parts.push(path$$1.call(print, "id"));
  21322. if (bodyIsDeclaration) {
  21323. parts.push(path$$1.call(print, "body"));
  21324. } else if (n.body) {
  21325. parts.push(" ", group$1(path$$1.call(print, "body")));
  21326. } else {
  21327. parts.push(semi);
  21328. }
  21329. return concat$4(parts);
  21330. }
  21331. case "PrivateName":
  21332. return concat$4(["#", path$$1.call(print, "id")]);
  21333. case "TSConditionalType":
  21334. return printTernaryOperator(path$$1, options, print, {
  21335. beforeParts: function beforeParts() {
  21336. return [path$$1.call(print, "checkType"), " ", "extends", " ", path$$1.call(print, "extendsType")];
  21337. },
  21338. afterParts: function afterParts() {
  21339. return [];
  21340. },
  21341. shouldCheckJsx: false,
  21342. conditionalNodeType: "TSConditionalType",
  21343. consequentNodePropertyName: "trueType",
  21344. alternateNodePropertyName: "falseType",
  21345. testNodePropertyName: "checkType",
  21346. breakNested: true
  21347. });
  21348. case "TSInferType":
  21349. return concat$4(["infer", " ", path$$1.call(print, "typeParameter")]);
  21350. case "InterpreterDirective":
  21351. parts.push("#!", n.value, hardline$3);
  21352. if (isNextLineEmpty$2(options.originalText, n, options)) {
  21353. parts.push(hardline$3);
  21354. }
  21355. return concat$4(parts);
  21356. case "NGRoot":
  21357. return concat$4([].concat(path$$1.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$4([" //", n.node.comments[0].value.trimRight()])));
  21358. case "NGChainedExpression":
  21359. return group$1(join$2(concat$4([";", line$3]), path$$1.map(function (childPath) {
  21360. return hasNgSideEffect(childPath) ? print(childPath) : concat$4(["(", print(childPath), ")"]);
  21361. }, "expressions")));
  21362. case "NGEmptyExpression":
  21363. return "";
  21364. case "NGQuotedExpression":
  21365. return concat$4([n.prefix, ":", n.value]);
  21366. case "NGMicrosyntax":
  21367. return concat$4(path$$1.map(function (childPath, index) {
  21368. return concat$4([index === 0 ? "" : isNgForOf(childPath.getValue(), index, n) ? " " : concat$4([";", line$3]), print(childPath)]);
  21369. }, "body"));
  21370. case "NGMicrosyntaxKey":
  21371. return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
  21372. case "NGMicrosyntaxExpression":
  21373. return concat$4([path$$1.call(print, "expression"), n.alias === null ? "" : concat$4([" as ", path$$1.call(print, "alias")])]);
  21374. case "NGMicrosyntaxKeyedExpression":
  21375. {
  21376. var index = path$$1.getName();
  21377. var _parentNode2 = path$$1.getParentNode();
  21378. var shouldNotPrintColon = isNgForOf(n, index, _parentNode2) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && _parentNode2.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && _parentNode2.body[index - 1].key.name === "then") && _parentNode2.body[0].type === "NGMicrosyntaxExpression";
  21379. return concat$4([path$$1.call(print, "key"), shouldNotPrintColon ? " " : ": ", path$$1.call(print, "expression")]);
  21380. }
  21381. case "NGMicrosyntaxLet":
  21382. return concat$4(["let ", path$$1.call(print, "key"), n.value === null ? "" : concat$4([" = ", path$$1.call(print, "value")])]);
  21383. case "NGMicrosyntaxAs":
  21384. return concat$4([path$$1.call(print, "key"), " as ", path$$1.call(print, "alias")]);
  21385. default:
  21386. /* istanbul ignore next */
  21387. throw new Error("unknown type: " + JSON.stringify(n.type));
  21388. }
  21389. }
  21390. function isNgForOf(node, index, parentNode) {
  21391. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  21392. }
  21393. /** identify if an angular expression seems to have side effects */
  21394. function hasNgSideEffect(path$$1) {
  21395. return hasNode(path$$1.getValue(), function (node) {
  21396. switch (node.type) {
  21397. case undefined:
  21398. return false;
  21399. case "CallExpression":
  21400. case "OptionalCallExpression":
  21401. case "AssignmentExpression":
  21402. return true;
  21403. }
  21404. });
  21405. }
  21406. function printStatementSequence(path$$1, options, print) {
  21407. var printed = [];
  21408. var bodyNode = path$$1.getNode();
  21409. var isClass = bodyNode.type === "ClassBody";
  21410. path$$1.map(function (stmtPath, i) {
  21411. var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
  21412. // "statements," it's safer simply to skip them.
  21413. /* istanbul ignore if */
  21414. if (!stmt) {
  21415. return;
  21416. } // Skip printing EmptyStatement nodes to avoid leaving stray
  21417. // semicolons lying around.
  21418. if (stmt.type === "EmptyStatement") {
  21419. return;
  21420. }
  21421. var stmtPrinted = print(stmtPath);
  21422. var text = options.originalText;
  21423. var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
  21424. // don't prepend the only JSX element in a program with semicolon
  21425. if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
  21426. if (stmt.comments && stmt.comments.some(function (comment) {
  21427. return comment.leading;
  21428. })) {
  21429. parts.push(print(stmtPath, {
  21430. needsSemi: true
  21431. }));
  21432. } else {
  21433. parts.push(";", stmtPrinted);
  21434. }
  21435. } else {
  21436. parts.push(stmtPrinted);
  21437. }
  21438. if (!options.semi && isClass) {
  21439. if (classPropMayCauseASIProblems(stmtPath)) {
  21440. parts.push(";");
  21441. } else if (stmt.type === "ClassProperty") {
  21442. var nextChild = bodyNode.body[i + 1];
  21443. if (classChildNeedsASIProtection(nextChild)) {
  21444. parts.push(";");
  21445. }
  21446. }
  21447. }
  21448. if (isNextLineEmpty$2(text, stmt, options) && !isLastStatement(stmtPath)) {
  21449. parts.push(hardline$3);
  21450. }
  21451. printed.push(concat$4(parts));
  21452. });
  21453. return join$2(hardline$3, printed);
  21454. }
  21455. function printPropertyKey(path$$1, options, print) {
  21456. var node = path$$1.getNode();
  21457. var parent = path$$1.getParentNode();
  21458. var key = node.key;
  21459. if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
  21460. var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
  21461. return !prop.computed && prop.key && isStringLiteral(prop.key) && !isStringPropSafeToCoerceToIdentifier(prop, options);
  21462. });
  21463. needsQuoteProps.set(parent, objectHasStringProp);
  21464. }
  21465. if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
  21466. // a -> "a"
  21467. var prop = printString$1(JSON.stringify(key.name), options);
  21468. return path$$1.call(function (keyPath) {
  21469. return comments.printComments(keyPath, function () {
  21470. return prop;
  21471. }, options);
  21472. }, "key");
  21473. }
  21474. if (!node.computed && isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
  21475. // 'a' -> a
  21476. return path$$1.call(function (keyPath) {
  21477. return comments.printComments(keyPath, function () {
  21478. return key.value;
  21479. }, options);
  21480. }, "key");
  21481. }
  21482. return path$$1.call(print, "key");
  21483. }
  21484. function printMethod(path$$1, options, print) {
  21485. var node = path$$1.getNode();
  21486. var semi = options.semi ? ";" : "";
  21487. var kind = node.kind;
  21488. var parts = [];
  21489. if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
  21490. node.value = node;
  21491. }
  21492. if (node.value.async) {
  21493. parts.push("async ");
  21494. }
  21495. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  21496. if (node.value.generator) {
  21497. parts.push("*");
  21498. }
  21499. } else {
  21500. assert.ok(kind === "get" || kind === "set");
  21501. parts.push(kind, " ");
  21502. }
  21503. var key = printPropertyKey(path$$1, options, print);
  21504. if (node.computed) {
  21505. key = concat$4(["[", key, "]"]);
  21506. }
  21507. parts.push(key, concat$4(path$$1.call(function (valuePath) {
  21508. return [printFunctionTypeParameters(valuePath, options, print), group$1(concat$4([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
  21509. }, "value")));
  21510. if (!node.value.body || node.value.body.length === 0) {
  21511. parts.push(semi);
  21512. } else {
  21513. parts.push(" ", path$$1.call(print, "value", "body"));
  21514. }
  21515. return concat$4(parts);
  21516. }
  21517. function couldGroupArg(arg) {
  21518. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
  21519. // https://github.com/prettier/prettier/issues/4070
  21520. // export class Thing implements OtherThing {
  21521. // do: (type: Type) => Provider<Prop> = memoize(
  21522. // (type: ObjectType): Provider<Opts> => {}
  21523. // );
  21524. // }
  21525. // https://github.com/prettier/prettier/issues/6099
  21526. // app.get("/", (req, res): void => {
  21527. // res.send("Hello World!");
  21528. // });
  21529. !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode(arg.body));
  21530. }
  21531. function shouldGroupLastArg(args) {
  21532. var lastArg = getLast$3(args);
  21533. var penultimateArg = getPenultimate$1(args);
  21534. return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  21535. // disable last element expansion.
  21536. !penultimateArg || penultimateArg.type !== lastArg.type);
  21537. }
  21538. function shouldGroupFirstArg(args) {
  21539. if (args.length !== 2) {
  21540. return false;
  21541. }
  21542. var firstArg = args[0];
  21543. var secondArg = args[1];
  21544. return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
  21545. }
  21546. function isSimpleFlowType(node) {
  21547. var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
  21548. return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
  21549. }
  21550. function isJestEachTemplateLiteral(node, parentNode) {
  21551. /**
  21552. * describe.each`table`(name, fn)
  21553. * describe.only.each`table`(name, fn)
  21554. * describe.skip.each`table`(name, fn)
  21555. * test.each`table`(name, fn)
  21556. * test.only.each`table`(name, fn)
  21557. * test.skip.each`table`(name, fn)
  21558. *
  21559. * Ref: https://github.com/facebook/jest/pull/6102
  21560. */
  21561. var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
  21562. 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));
  21563. }
  21564. function printJestEachTemplateLiteral(node, expressions, options) {
  21565. /**
  21566. * a | b | expected
  21567. * ${1} | ${1} | ${2}
  21568. * ${1} | ${2} | ${3}
  21569. * ${2} | ${1} | ${3}
  21570. */
  21571. var headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  21572. if (headerNames.length > 1 || headerNames.some(function (headerName) {
  21573. return headerName.length !== 0;
  21574. })) {
  21575. var parts = [];
  21576. var stringifiedExpressions = expressions.map(function (doc$$2) {
  21577. return "${" + printDocToString$2(doc$$2, Object.assign({}, options, {
  21578. printWidth: Infinity,
  21579. endOfLine: "lf"
  21580. })).formatted + "}";
  21581. });
  21582. var tableBody = [{
  21583. hasLineBreak: false,
  21584. cells: []
  21585. }];
  21586. for (var i = 1; i < node.quasis.length; i++) {
  21587. var row = tableBody[tableBody.length - 1];
  21588. var correspondingExpression = stringifiedExpressions[i - 1];
  21589. row.cells.push(correspondingExpression);
  21590. if (correspondingExpression.indexOf("\n") !== -1) {
  21591. row.hasLineBreak = true;
  21592. }
  21593. if (node.quasis[i].value.raw.indexOf("\n") !== -1) {
  21594. tableBody.push({
  21595. hasLineBreak: false,
  21596. cells: []
  21597. });
  21598. }
  21599. }
  21600. var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
  21601. return Math.max(maxColumnCount, row.cells.length);
  21602. }, headerNames.length);
  21603. var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
  21604. return 0;
  21605. });
  21606. var table = [{
  21607. cells: headerNames
  21608. }].concat(tableBody.filter(function (row) {
  21609. return row.cells.length !== 0;
  21610. }));
  21611. table.filter(function (row) {
  21612. return !row.hasLineBreak;
  21613. }).forEach(function (row) {
  21614. row.cells.forEach(function (cell, index) {
  21615. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  21616. });
  21617. });
  21618. parts.push("`", indent$2(concat$4([hardline$3, join$2(hardline$3, table.map(function (row) {
  21619. return join$2(" | ", row.cells.map(function (cell, index) {
  21620. return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell));
  21621. }));
  21622. }))])), hardline$3, "`");
  21623. return concat$4(parts);
  21624. }
  21625. }
  21626. /** @param node {import("estree").TemplateLiteral} */
  21627. function isSimpleTemplateLiteral(node) {
  21628. if (node.expressions.length === 0) {
  21629. return false;
  21630. }
  21631. return node.expressions.every(function (expr) {
  21632. // Disallow comments since printDocToString can't print them here
  21633. if (expr.comments) {
  21634. return false;
  21635. } // Allow `x` and `this`
  21636. if (expr.type === "Identifier" || expr.type === "ThisExpression") {
  21637. return true;
  21638. } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
  21639. if ((expr.type === "MemberExpression" || expr.type === "OptionalMemberExpression") && (expr.property.type === "Identifier" || expr.property.type === "Literal")) {
  21640. var ancestor = expr;
  21641. while (ancestor.type === "MemberExpression" || ancestor.type === "OptionalMemberExpression") {
  21642. ancestor = ancestor.object;
  21643. if (ancestor.comments) {
  21644. return false;
  21645. }
  21646. }
  21647. if (ancestor.type === "Identifier" || ancestor.type === "ThisExpression") {
  21648. return true;
  21649. }
  21650. return false;
  21651. }
  21652. return false;
  21653. });
  21654. }
  21655. var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
  21656. "pipeP", // Ramda
  21657. "pipeK", // Ramda
  21658. "compose", // Ramda, Redux
  21659. "composeFlipped", // Not from any library, but common in Haskell, so supported
  21660. "composeP", // Ramda
  21661. "composeK", // Ramda
  21662. "flow", // Lodash
  21663. "flowRight", // Lodash
  21664. "connect", // Redux
  21665. "createSelector" // Reselect
  21666. ]);
  21667. var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
  21668. ]);
  21669. function isFunctionCompositionFunction(node) {
  21670. switch (node.type) {
  21671. case "OptionalMemberExpression":
  21672. case "MemberExpression":
  21673. {
  21674. return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
  21675. }
  21676. case "Identifier":
  21677. {
  21678. return functionCompositionFunctionNames.has(node.name);
  21679. }
  21680. case "StringLiteral":
  21681. case "Literal":
  21682. {
  21683. return functionCompositionFunctionNames.has(node.value);
  21684. }
  21685. }
  21686. }
  21687. function printArgumentsList(path$$1, options, print) {
  21688. var node = path$$1.getValue();
  21689. var args = node.arguments;
  21690. if (args.length === 0) {
  21691. return concat$4(["(", comments.printDanglingComments(path$$1, options,
  21692. /* sameIndent */
  21693. true), ")"]);
  21694. } // useEffect(() => { ... }, [foo, bar, baz])
  21695. if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
  21696. return arg.leadingComments || arg.trailingComments;
  21697. })) {
  21698. return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
  21699. }
  21700. var anyArgEmptyLine = false;
  21701. var hasEmptyLineFollowingFirstArg = false;
  21702. var lastArgIndex = args.length - 1;
  21703. var printedArguments = path$$1.map(function (argPath, index) {
  21704. var arg = argPath.getNode();
  21705. var parts = [print(argPath)];
  21706. if (index === lastArgIndex) {// do nothing
  21707. } else if (isNextLineEmpty$2(options.originalText, arg, options)) {
  21708. if (index === 0) {
  21709. hasEmptyLineFollowingFirstArg = true;
  21710. }
  21711. anyArgEmptyLine = true;
  21712. parts.push(",", hardline$3, hardline$3);
  21713. } else {
  21714. parts.push(",", line$3);
  21715. }
  21716. return concat$4(parts);
  21717. }, "arguments");
  21718. var maybeTrailingComma = // Dynamic imports cannot have trailing commas
  21719. !(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
  21720. function allArgsBrokenOut() {
  21721. return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
  21722. shouldBreak: true
  21723. });
  21724. } // We want to get
  21725. // pipe(
  21726. // x => x + 1,
  21727. // x => x - 1
  21728. // )
  21729. // here, but not
  21730. // process.stdout.pipe(socket)
  21731. if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
  21732. return allArgsBrokenOut();
  21733. }
  21734. var shouldGroupFirst = shouldGroupFirstArg(args);
  21735. var shouldGroupLast = shouldGroupLastArg(args);
  21736. if (shouldGroupFirst || shouldGroupLast) {
  21737. var shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine; // We want to print the last argument with a special flag
  21738. var printedExpanded;
  21739. var i = 0;
  21740. path$$1.each(function (argPath) {
  21741. if (shouldGroupFirst && i === 0) {
  21742. printedExpanded = [concat$4([argPath.call(function (p) {
  21743. return print(p, {
  21744. expandFirstArg: true
  21745. });
  21746. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$3 : line$3, hasEmptyLineFollowingFirstArg ? hardline$3 : ""])].concat(printedArguments.slice(1));
  21747. }
  21748. if (shouldGroupLast && i === args.length - 1) {
  21749. printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
  21750. return print(p, {
  21751. expandLastArg: true
  21752. });
  21753. }));
  21754. }
  21755. i++;
  21756. }, "arguments");
  21757. var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
  21758. return concat$4([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([concat$4([ifBreak$1(indent$2(concat$4(["(", softline$1, concat$4(printedExpanded)])), concat$4(["(", concat$4(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$4([ifBreak$1(maybeTrailingComma), softline$1]) : "", ")"]), shouldGroupFirst ? concat$4(["(", group$1(printedExpanded[0], {
  21759. shouldBreak: true
  21760. }), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$3(printedExpanded), {
  21761. shouldBreak: true
  21762. }), ")"]), allArgsBrokenOut()], {
  21763. shouldBreak
  21764. })]);
  21765. }
  21766. return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$1, ")"]), {
  21767. shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
  21768. });
  21769. }
  21770. function printTypeAnnotation(path$$1, options, print) {
  21771. var node = path$$1.getValue();
  21772. if (!node.typeAnnotation) {
  21773. return "";
  21774. }
  21775. var parentNode = path$$1.getParentNode();
  21776. var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  21777. var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  21778. if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
  21779. return concat$4([" /*: ", path$$1.call(print, "typeAnnotation"), " */"]);
  21780. }
  21781. return concat$4([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path$$1.call(print, "typeAnnotation")]);
  21782. }
  21783. function printFunctionTypeParameters(path$$1, options, print) {
  21784. var fun = path$$1.getValue();
  21785. if (fun.typeArguments) {
  21786. return path$$1.call(print, "typeArguments");
  21787. }
  21788. if (fun.typeParameters) {
  21789. return path$$1.call(print, "typeParameters");
  21790. }
  21791. return "";
  21792. }
  21793. function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
  21794. var fun = path$$1.getValue();
  21795. var parent = path$$1.getParentNode();
  21796. var paramsField = fun.parameters ? "parameters" : "params";
  21797. var isParametersInTestCall = isTestCall(parent);
  21798. var shouldHugParameters = shouldHugArguments(fun);
  21799. var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
  21800. return n.comments;
  21801. }));
  21802. var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
  21803. var printed = [];
  21804. if (fun[paramsField]) {
  21805. var lastArgIndex = fun[paramsField].length - 1;
  21806. printed = path$$1.map(function (childPath, index) {
  21807. var parts = [];
  21808. var param = childPath.getValue();
  21809. parts.push(print(childPath));
  21810. if (index === lastArgIndex) {
  21811. if (fun.rest) {
  21812. parts.push(",", line$3);
  21813. }
  21814. } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
  21815. parts.push(", ");
  21816. } else if (isNextLineEmpty$2(options.originalText, param, options)) {
  21817. parts.push(",", hardline$3, hardline$3);
  21818. } else {
  21819. parts.push(",", line$3);
  21820. }
  21821. return concat$4(parts);
  21822. }, paramsField);
  21823. }
  21824. if (fun.rest) {
  21825. printed.push(concat$4(["...", path$$1.call(print, "rest")]));
  21826. }
  21827. if (printed.length === 0) {
  21828. return concat$4([typeParams, "(", comments.printDanglingComments(path$$1, options,
  21829. /* sameIndent */
  21830. true, function (comment) {
  21831. return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
  21832. }), ")"]);
  21833. }
  21834. var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
  21835. // params of the first/last argument, we dont want the arguments to break and instead
  21836. // want the whole expression to be on a new line.
  21837. //
  21838. // Good: Bad:
  21839. // verylongcall( verylongcall((
  21840. // (a, b) => { a,
  21841. // } b,
  21842. // }) ) => {
  21843. // })
  21844. if (shouldExpandParameters) {
  21845. return group$1(concat$4([removeLines$1(typeParams), "(", concat$4(printed.map(removeLines$1)), ")"]));
  21846. } // Single object destructuring should hug
  21847. //
  21848. // function({
  21849. // a,
  21850. // b,
  21851. // c
  21852. // }) {}
  21853. if (shouldHugParameters) {
  21854. return concat$4([typeParams, "(", concat$4(printed), ")"]);
  21855. } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  21856. if (isParametersInTestCall) {
  21857. return concat$4([typeParams, "(", concat$4(printed), ")"]);
  21858. }
  21859. var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
  21860. if (isFlowShorthandWithOneArg) {
  21861. if (options.arrowParens === "always") {
  21862. return concat$4(["(", concat$4(printed), ")"]);
  21863. }
  21864. return concat$4(printed);
  21865. }
  21866. var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
  21867. return concat$4([typeParams, "(", indent$2(concat$4([softline$1, concat$4(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
  21868. }
  21869. function shouldPrintParamsWithoutParens(path$$1, options) {
  21870. if (options.arrowParens === "always") {
  21871. return false;
  21872. }
  21873. if (options.arrowParens === "avoid") {
  21874. var node = path$$1.getValue();
  21875. return canPrintParamsWithoutParens(node);
  21876. } // Fallback default; should be unreachable
  21877. return false;
  21878. }
  21879. function canPrintParamsWithoutParens(node) {
  21880. return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
  21881. }
  21882. function printFunctionDeclaration(path$$1, print, options) {
  21883. var n = path$$1.getValue();
  21884. var parts = [];
  21885. if (n.async) {
  21886. parts.push("async ");
  21887. }
  21888. parts.push("function");
  21889. if (n.generator) {
  21890. parts.push("*");
  21891. }
  21892. if (n.id) {
  21893. parts.push(" ", path$$1.call(print, "id"));
  21894. }
  21895. parts.push(printFunctionTypeParameters(path$$1, options, print), group$1(concat$4([printFunctionParams(path$$1, print, options), printReturnType(path$$1, print, options)])), n.body ? " " : "", path$$1.call(print, "body"));
  21896. return concat$4(parts);
  21897. }
  21898. function printObjectMethod(path$$1, options, print) {
  21899. var objMethod = path$$1.getValue();
  21900. var parts = [];
  21901. if (objMethod.async) {
  21902. parts.push("async ");
  21903. }
  21904. if (objMethod.generator) {
  21905. parts.push("*");
  21906. }
  21907. if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
  21908. return printMethod(path$$1, options, print);
  21909. }
  21910. var key = printPropertyKey(path$$1, options, print);
  21911. if (objMethod.computed) {
  21912. parts.push("[", key, "]");
  21913. } else {
  21914. parts.push(key);
  21915. }
  21916. parts.push(printFunctionTypeParameters(path$$1, options, print), group$1(concat$4([printFunctionParams(path$$1, print, options), printReturnType(path$$1, print, options)])), " ", path$$1.call(print, "body"));
  21917. return concat$4(parts);
  21918. }
  21919. function printReturnType(path$$1, print, options) {
  21920. var n = path$$1.getValue();
  21921. var returnType = path$$1.call(print, "returnType");
  21922. if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
  21923. return concat$4([" /*: ", returnType, " */"]);
  21924. }
  21925. var parts = [returnType]; // prepend colon to TypeScript type annotation
  21926. if (n.returnType && n.returnType.typeAnnotation) {
  21927. parts.unshift(": ");
  21928. }
  21929. if (n.predicate) {
  21930. // The return type will already add the colon, but otherwise we
  21931. // need to do it ourselves
  21932. parts.push(n.returnType ? " " : ": ", path$$1.call(print, "predicate"));
  21933. }
  21934. return concat$4(parts);
  21935. }
  21936. function printExportDeclaration(path$$1, options, print) {
  21937. var decl = path$$1.getValue();
  21938. var semi = options.semi ? ";" : "";
  21939. var parts = ["export "];
  21940. var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
  21941. if (isDefault) {
  21942. parts.push("default ");
  21943. }
  21944. parts.push(comments.printDanglingComments(path$$1, options,
  21945. /* sameIndent */
  21946. true));
  21947. if (needsHardlineAfterDanglingComment(decl)) {
  21948. parts.push(hardline$3);
  21949. }
  21950. if (decl.declaration) {
  21951. parts.push(path$$1.call(print, "declaration"));
  21952. if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
  21953. parts.push(semi);
  21954. }
  21955. } else {
  21956. if (decl.specifiers && decl.specifiers.length > 0) {
  21957. var specifiers = [];
  21958. var defaultSpecifiers = [];
  21959. var namespaceSpecifiers = [];
  21960. path$$1.each(function (specifierPath) {
  21961. var specifierType = path$$1.getValue().type;
  21962. if (specifierType === "ExportSpecifier") {
  21963. specifiers.push(print(specifierPath));
  21964. } else if (specifierType === "ExportDefaultSpecifier") {
  21965. defaultSpecifiers.push(print(specifierPath));
  21966. } else if (specifierType === "ExportNamespaceSpecifier") {
  21967. namespaceSpecifiers.push(concat$4(["* as ", print(specifierPath)]));
  21968. }
  21969. }, "specifiers");
  21970. var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
  21971. var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
  21972. parts.push(decl.exportKind === "type" ? "type " : "", concat$4(defaultSpecifiers), concat$4([isDefaultFollowed ? ", " : ""]), concat$4(namespaceSpecifiers), concat$4([isNamespaceFollowed ? ", " : ""]), specifiers.length !== 0 ? group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])) : "");
  21973. } else {
  21974. parts.push("{}");
  21975. }
  21976. if (decl.source) {
  21977. parts.push(" from ", path$$1.call(print, "source"));
  21978. }
  21979. parts.push(semi);
  21980. }
  21981. return concat$4(parts);
  21982. }
  21983. function printFlowDeclaration(path$$1, parts) {
  21984. var parentExportDecl = getParentExportDeclaration$1(path$$1);
  21985. if (parentExportDecl) {
  21986. assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  21987. } else {
  21988. // If the parent node has type DeclareExportDeclaration, then it
  21989. // will be responsible for printing the "declare" token. Otherwise
  21990. // it needs to be printed with this non-exported declaration node.
  21991. parts.unshift("declare ");
  21992. }
  21993. return concat$4(parts);
  21994. }
  21995. function getFlowVariance(path$$1) {
  21996. if (!path$$1.variance) {
  21997. return null;
  21998. } // Babel 7.0 currently uses variance node type, and flow should
  21999. // follow suit soon:
  22000. // https://github.com/babel/babel/issues/4722
  22001. var variance = path$$1.variance.kind || path$$1.variance;
  22002. switch (variance) {
  22003. case "plus":
  22004. return "+";
  22005. case "minus":
  22006. return "-";
  22007. default:
  22008. /* istanbul ignore next */
  22009. return variance;
  22010. }
  22011. }
  22012. function printTypeScriptModifiers(path$$1, options, print) {
  22013. var n = path$$1.getValue();
  22014. if (!n.modifiers || !n.modifiers.length) {
  22015. return "";
  22016. }
  22017. return concat$4([join$2(" ", path$$1.map(print, "modifiers")), " "]);
  22018. }
  22019. function printTypeParameters(path$$1, options, print, paramsKey) {
  22020. var n = path$$1.getValue();
  22021. if (!n[paramsKey]) {
  22022. return "";
  22023. } // for TypeParameterDeclaration typeParameters is a single node
  22024. if (!Array.isArray(n[paramsKey])) {
  22025. return path$$1.call(print, paramsKey);
  22026. }
  22027. var grandparent = path$$1.getNode(2);
  22028. var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
  22029. var shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation");
  22030. if (shouldInline) {
  22031. return concat$4(["<", join$2(", ", path$$1.map(print, paramsKey)), ">"]);
  22032. }
  22033. return group$1(concat$4(["<", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), path$$1.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && shouldPrintComma(options, "all") ? "," : ""), softline$1, ">"]));
  22034. }
  22035. function printClass(path$$1, options, print) {
  22036. var n = path$$1.getValue();
  22037. var parts = [];
  22038. if (n.abstract) {
  22039. parts.push("abstract ");
  22040. }
  22041. parts.push("class");
  22042. if (n.id) {
  22043. parts.push(" ", path$$1.call(print, "id"));
  22044. }
  22045. parts.push(path$$1.call(print, "typeParameters"));
  22046. var partsGroup = [];
  22047. if (n.superClass) {
  22048. var printed = concat$4(["extends ", path$$1.call(print, "superClass"), path$$1.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
  22049. // If there is only on extends and there are not comments
  22050. if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
  22051. parts.push(concat$4([" ", path$$1.call(function (superClass) {
  22052. return comments.printComments(superClass, function () {
  22053. return printed;
  22054. }, options);
  22055. }, "superClass")]));
  22056. } else {
  22057. partsGroup.push(group$1(concat$4([line$3, path$$1.call(function (superClass) {
  22058. return comments.printComments(superClass, function () {
  22059. return printed;
  22060. }, options);
  22061. }, "superClass")])));
  22062. }
  22063. } else if (n.extends && n.extends.length > 0) {
  22064. parts.push(" extends ", join$2(", ", path$$1.map(print, "extends")));
  22065. }
  22066. if (n["mixins"] && n["mixins"].length > 0) {
  22067. partsGroup.push(line$3, "mixins ", group$1(indent$2(join$2(concat$4([",", line$3]), path$$1.map(print, "mixins")))));
  22068. }
  22069. if (n["implements"] && n["implements"].length > 0) {
  22070. partsGroup.push(line$3, "implements", group$1(indent$2(concat$4([line$3, join$2(concat$4([",", line$3]), path$$1.map(print, "implements"))]))));
  22071. }
  22072. if (partsGroup.length > 0) {
  22073. parts.push(group$1(indent$2(concat$4(partsGroup))));
  22074. }
  22075. if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
  22076. parts.push(hardline$3);
  22077. } else {
  22078. parts.push(" ");
  22079. }
  22080. parts.push(path$$1.call(print, "body"));
  22081. return parts;
  22082. }
  22083. function printOptionalToken(path$$1) {
  22084. var node = path$$1.getValue();
  22085. if (!node.optional) {
  22086. return "";
  22087. }
  22088. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  22089. return "?.";
  22090. }
  22091. return "?";
  22092. }
  22093. function printMemberLookup(path$$1, options, print) {
  22094. var property = path$$1.call(print, "property");
  22095. var n = path$$1.getValue();
  22096. var optional = printOptionalToken(path$$1);
  22097. if (!n.computed) {
  22098. return concat$4([optional, ".", property]);
  22099. }
  22100. if (!n.property || isNumericLiteral(n.property)) {
  22101. return concat$4([optional, "[", property, "]"]);
  22102. }
  22103. return group$1(concat$4([optional, "[", indent$2(concat$4([softline$1, property])), softline$1, "]"]));
  22104. }
  22105. function printBindExpressionCallee(path$$1, options, print) {
  22106. return concat$4(["::", path$$1.call(print, "callee")]);
  22107. } // We detect calls on member expressions specially to format a
  22108. // common pattern better. The pattern we are looking for is this:
  22109. //
  22110. // arr
  22111. // .map(x => x + 1)
  22112. // .filter(x => x > 10)
  22113. // .some(x => x % 2)
  22114. //
  22115. // The way it is structured in the AST is via a nested sequence of
  22116. // MemberExpression and CallExpression. We need to traverse the AST
  22117. // and make groups out of it to print it in the desired way.
  22118. function printMemberChain(path$$1, options, print) {
  22119. // The first phase is to linearize the AST by traversing it down.
  22120. //
  22121. // a().b()
  22122. // has the following AST structure:
  22123. // CallExpression(MemberExpression(CallExpression(Identifier)))
  22124. // and we transform it into
  22125. // [Identifier, CallExpression, MemberExpression, CallExpression]
  22126. var printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  22127. // the first group whether it is in parentheses or not
  22128. function shouldInsertEmptyLineAfter(node) {
  22129. var originalText = options.originalText;
  22130. var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
  22131. var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  22132. // line after that parenthesis
  22133. if (nextChar == ")") {
  22134. return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options);
  22135. }
  22136. return isNextLineEmpty$2(originalText, node, options);
  22137. }
  22138. function rec(path$$1) {
  22139. var node = path$$1.getValue();
  22140. if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
  22141. printedNodes.unshift({
  22142. node: node,
  22143. printed: concat$4([comments.printComments(path$$1, function () {
  22144. return concat$4([printOptionalToken(path$$1), printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)]);
  22145. }, options), shouldInsertEmptyLineAfter(node) ? hardline$3 : ""])
  22146. });
  22147. path$$1.call(function (callee) {
  22148. return rec(callee);
  22149. }, "callee");
  22150. } else if (isMemberish(node)) {
  22151. printedNodes.unshift({
  22152. node: node,
  22153. needsParens: needsParens_1(path$$1, options),
  22154. printed: comments.printComments(path$$1, function () {
  22155. return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path$$1, options, print) : printBindExpressionCallee(path$$1, options, print);
  22156. }, options)
  22157. });
  22158. path$$1.call(function (object) {
  22159. return rec(object);
  22160. }, "object");
  22161. } else if (node.type === "TSNonNullExpression") {
  22162. printedNodes.unshift({
  22163. node: node,
  22164. printed: comments.printComments(path$$1, function () {
  22165. return "!";
  22166. }, options)
  22167. });
  22168. path$$1.call(function (expression) {
  22169. return rec(expression);
  22170. }, "expression");
  22171. } else {
  22172. printedNodes.unshift({
  22173. node: node,
  22174. printed: path$$1.call(print)
  22175. });
  22176. }
  22177. } // Note: the comments of the root node have already been printed, so we
  22178. // need to extract this first call without printing them as they would
  22179. // if handled inside of the recursive call.
  22180. var node = path$$1.getValue();
  22181. printedNodes.unshift({
  22182. node,
  22183. printed: concat$4([printOptionalToken(path$$1), printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)])
  22184. });
  22185. path$$1.call(function (callee) {
  22186. return rec(callee);
  22187. }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out
  22188. // of it.
  22189. //
  22190. // a().b.c().d().e
  22191. // will be grouped as
  22192. // [
  22193. // [Identifier, CallExpression],
  22194. // [MemberExpression, MemberExpression, CallExpression],
  22195. // [MemberExpression, CallExpression],
  22196. // [MemberExpression],
  22197. // ]
  22198. // so that we can print it as
  22199. // a()
  22200. // .b.c()
  22201. // .d()
  22202. // .e
  22203. // The first group is the first node followed by
  22204. // - as many CallExpression as possible
  22205. // < fn()()() >.something()
  22206. // - as many array acessors as possible
  22207. // < fn()[0][1][2] >.something()
  22208. // - then, as many MemberExpression as possible but the last one
  22209. // < this.items >.something()
  22210. var groups = [];
  22211. var currentGroup = [printedNodes[0]];
  22212. var i = 1;
  22213. for (; i < printedNodes.length; ++i) {
  22214. if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  22215. currentGroup.push(printedNodes[i]);
  22216. } else {
  22217. break;
  22218. }
  22219. }
  22220. if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
  22221. for (; i + 1 < printedNodes.length; ++i) {
  22222. if (isMemberish(printedNodes[i].node) && isMemberish(printedNodes[i + 1].node)) {
  22223. currentGroup.push(printedNodes[i]);
  22224. } else {
  22225. break;
  22226. }
  22227. }
  22228. }
  22229. groups.push(currentGroup);
  22230. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  22231. // a sequence of CallExpression. To compute it, we keep adding things to the
  22232. // group until we has seen a CallExpression in the past and reach a
  22233. // MemberExpression
  22234. var hasSeenCallExpression = false;
  22235. for (; i < printedNodes.length; ++i) {
  22236. if (hasSeenCallExpression && isMemberish(printedNodes[i].node)) {
  22237. // [0] should be appended at the end of the group instead of the
  22238. // beginning of the next one
  22239. if (printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  22240. currentGroup.push(printedNodes[i]);
  22241. continue;
  22242. }
  22243. groups.push(currentGroup);
  22244. currentGroup = [];
  22245. hasSeenCallExpression = false;
  22246. }
  22247. if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
  22248. hasSeenCallExpression = true;
  22249. }
  22250. currentGroup.push(printedNodes[i]);
  22251. if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) {
  22252. return comment.trailing;
  22253. })) {
  22254. groups.push(currentGroup);
  22255. currentGroup = [];
  22256. hasSeenCallExpression = false;
  22257. }
  22258. }
  22259. if (currentGroup.length > 0) {
  22260. groups.push(currentGroup);
  22261. } // There are cases like Object.keys(), Observable.of(), _.values() where
  22262. // they are the subject of all the chained calls and therefore should
  22263. // be kept on the same line:
  22264. //
  22265. // Object.keys(items)
  22266. // .filter(x => x)
  22267. // .map(x => x)
  22268. //
  22269. // In order to detect those cases, we use an heuristic: if the first
  22270. // node is an identifier with the name starting with a capital
  22271. // letter or just a sequence of _$. The rationale is that they are
  22272. // likely to be factories.
  22273. function isFactory(name) {
  22274. return /^[A-Z]|^[_$]+$/.test(name);
  22275. } // In case the Identifier is shorter than tab width, we can keep the
  22276. // first call in a single line, if it's an ExpressionStatement.
  22277. //
  22278. // d3.scaleLinear()
  22279. // .domain([0, 100])
  22280. // .range([0, width]);
  22281. //
  22282. function isShort(name) {
  22283. return name.length <= options.tabWidth;
  22284. }
  22285. function shouldNotWrap(groups) {
  22286. var parent = path$$1.getParentNode();
  22287. var isExpression = parent && parent.type === "ExpressionStatement";
  22288. var hasComputed = groups[1].length && groups[1][0].node.computed;
  22289. if (groups[0].length === 1) {
  22290. var firstNode = groups[0][0].node;
  22291. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
  22292. }
  22293. var lastNode = getLast$3(groups[0]).node;
  22294. return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  22295. }
  22296. var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
  22297. function printGroup(printedGroup) {
  22298. var printed = printedGroup.map(function (tuple) {
  22299. return tuple.printed;
  22300. }); // Checks if the last node (i.e. the parent node) needs parens and print
  22301. // accordingly
  22302. if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
  22303. return concat$4(["("].concat(_toConsumableArray(printed), [")"]));
  22304. }
  22305. return concat$4(printed);
  22306. }
  22307. function printIndentedGroup(groups) {
  22308. if (groups.length === 0) {
  22309. return "";
  22310. }
  22311. return indent$2(group$1(concat$4([hardline$3, join$2(hardline$3, groups.map(printGroup))])));
  22312. }
  22313. var printedGroups = groups.map(printGroup);
  22314. var oneLine = concat$4(printedGroups);
  22315. var cutoff = shouldMerge ? 3 : 2;
  22316. var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
  22317. return res.concat(group);
  22318. }, []);
  22319. var hasComment = flatGroups.slice(1, -1).some(function (node) {
  22320. return hasLeadingComment(node.node);
  22321. }) || flatGroups.slice(0, -1).some(function (node) {
  22322. return hasTrailingComment(node.node);
  22323. }) || groups[cutoff] && hasLeadingComment(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
  22324. // render everything concatenated together.
  22325. if (groups.length <= cutoff && !hasComment) {
  22326. return group$1(oneLine);
  22327. } // Find out the last node in the first group and check if it has an
  22328. // empty line after
  22329. var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
  22330. var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  22331. var expanded = concat$4([printGroup(groups[0]), shouldMerge ? concat$4(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$3 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
  22332. var callExpressions = printedNodes.map(function (_ref) {
  22333. var node = _ref.node;
  22334. return node;
  22335. }).filter(isCallOrOptionalCallExpression); // We don't want to print in one line if there's:
  22336. // * A comment.
  22337. // * 3 or more chained calls.
  22338. // * Any group but the last one has a hard line.
  22339. // If the last group is a function it's okay to inline if it fits.
  22340. if (hasComment || callExpressions.length >= 3 || printedGroups.slice(0, -1).some(willBreak$1) ||
  22341. /**
  22342. * scopes.filter(scope => scope.value !== '').map((scope, i) => {
  22343. * // multi line content
  22344. * })
  22345. */
  22346. function (lastGroupDoc, lastGroupNode) {
  22347. return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
  22348. }(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
  22349. return n.arguments.some(isFunctionOrArrowExpression);
  22350. })) {
  22351. return group$1(expanded);
  22352. }
  22353. return concat$4([// We only need to check `oneLine` because if `expanded` is chosen
  22354. // that means that the parent group has already been broken
  22355. // naturally
  22356. willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
  22357. }
  22358. function isCallOrOptionalCallExpression(node) {
  22359. return node.type === "CallExpression" || node.type === "OptionalCallExpression";
  22360. }
  22361. function isJSXNode(node) {
  22362. return node.type === "JSXElement" || node.type === "JSXFragment";
  22363. }
  22364. function isEmptyJSXElement(node) {
  22365. if (node.children.length === 0) {
  22366. return true;
  22367. }
  22368. if (node.children.length > 1) {
  22369. return false;
  22370. } // if there is one text child and does not contain any meaningful text
  22371. // we can treat the element as empty.
  22372. var child = node.children[0];
  22373. return isLiteral(child) && !isMeaningfulJSXText(child);
  22374. } // Only space, newline, carriage return, and tab are treated as whitespace
  22375. // inside JSX.
  22376. var jsxWhitespaceChars = " \n\r\t";
  22377. var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  22378. var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); // Meaningful if it contains non-whitespace characters,
  22379. // or it contains whitespace without a new line.
  22380. function isMeaningfulJSXText(node) {
  22381. return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
  22382. }
  22383. function conditionalExpressionChainContainsJSX(node) {
  22384. return Boolean(getConditionalChainContents(node).find(isJSXNode));
  22385. } // If we have nested conditional expressions, we want to print them in JSX mode
  22386. // if there's at least one JSXElement somewhere in the tree.
  22387. //
  22388. // A conditional expression chain like this should be printed in normal mode,
  22389. // because there aren't JSXElements anywhere in it:
  22390. //
  22391. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  22392. //
  22393. // But a conditional expression chain like this should be printed in JSX mode,
  22394. // because there is a JSXElement in the last ConditionalExpression:
  22395. //
  22396. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  22397. //
  22398. // This type of ConditionalExpression chain is structured like this in the AST:
  22399. //
  22400. // ConditionalExpression {
  22401. // test: ...,
  22402. // consequent: ...,
  22403. // alternate: ConditionalExpression {
  22404. // test: ...,
  22405. // consequent: ...,
  22406. // alternate: ConditionalExpression {
  22407. // test: ...,
  22408. // consequent: ...,
  22409. // alternate: ...,
  22410. // }
  22411. // }
  22412. // }
  22413. //
  22414. // We want to traverse over that shape and convert it into a flat structure so
  22415. // that we can find if there's a JSXElement somewhere inside.
  22416. function getConditionalChainContents(node) {
  22417. // Given this code:
  22418. //
  22419. // // Using a ConditionalExpression as the consequent is uncommon, but should
  22420. // // be handled.
  22421. // A ? B : C ? D : E ? F ? G : H : I
  22422. //
  22423. // which has this AST:
  22424. //
  22425. // ConditionalExpression {
  22426. // test: Identifier(A),
  22427. // consequent: Identifier(B),
  22428. // alternate: ConditionalExpression {
  22429. // test: Identifier(C),
  22430. // consequent: Identifier(D),
  22431. // alternate: ConditionalExpression {
  22432. // test: Identifier(E),
  22433. // consequent: ConditionalExpression {
  22434. // test: Identifier(F),
  22435. // consequent: Identifier(G),
  22436. // alternate: Identifier(H),
  22437. // },
  22438. // alternate: Identifier(I),
  22439. // }
  22440. // }
  22441. // }
  22442. //
  22443. // we should return this Array:
  22444. //
  22445. // [
  22446. // Identifier(A),
  22447. // Identifier(B),
  22448. // Identifier(C),
  22449. // Identifier(D),
  22450. // Identifier(E),
  22451. // Identifier(F),
  22452. // Identifier(G),
  22453. // Identifier(H),
  22454. // Identifier(I)
  22455. // ];
  22456. //
  22457. // This loses the information about whether each node was the test,
  22458. // consequent, or alternate, but we don't care about that here- we are only
  22459. // flattening this structure to find if there's any JSXElements inside.
  22460. var nonConditionalExpressions = [];
  22461. function recurse(node) {
  22462. if (node.type === "ConditionalExpression") {
  22463. recurse(node.test);
  22464. recurse(node.consequent);
  22465. recurse(node.alternate);
  22466. } else {
  22467. nonConditionalExpressions.push(node);
  22468. }
  22469. }
  22470. recurse(node);
  22471. return nonConditionalExpressions;
  22472. } // Detect an expression node representing `{" "}`
  22473. function isJSXWhitespaceExpression(node) {
  22474. return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
  22475. }
  22476. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22477. if (isFacebookTranslationTag) {
  22478. return "";
  22479. }
  22480. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  22481. return child.length === 1 ? softline$1 : hardline$3;
  22482. }
  22483. return softline$1;
  22484. }
  22485. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22486. if (isFacebookTranslationTag) {
  22487. return hardline$3;
  22488. }
  22489. if (child.length === 1) {
  22490. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$3 : softline$1;
  22491. }
  22492. return hardline$3;
  22493. } // JSX Children are strange, mostly for two reasons:
  22494. // 1. JSX reads newlines into string values, instead of skipping them like JS
  22495. // 2. up to one whitespace between elements within a line is significant,
  22496. // but not between lines.
  22497. //
  22498. // Leading, trailing, and lone whitespace all need to
  22499. // turn themselves into the rather ugly `{' '}` when breaking.
  22500. //
  22501. // We print JSX using the `fill` doc primitive.
  22502. // This requires that we give it an array of alternating
  22503. // content and whitespace elements.
  22504. // To ensure this we add dummy `""` content elements as needed.
  22505. function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTranslationTag) {
  22506. var n = path$$1.getValue();
  22507. var children = []; // using `map` instead of `each` because it provides `i`
  22508. path$$1.map(function (childPath, i) {
  22509. var child = childPath.getValue();
  22510. if (isLiteral(child)) {
  22511. var text = rawText(child); // Contains a non-whitespace character
  22512. if (isMeaningfulJSXText(child)) {
  22513. var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  22514. if (words[0] === "") {
  22515. children.push("");
  22516. words.shift();
  22517. if (/\n/.test(words[0])) {
  22518. var next = n.children[i + 1];
  22519. children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  22520. } else {
  22521. children.push(jsxWhitespace);
  22522. }
  22523. words.shift();
  22524. }
  22525. var endWhitespace; // Ends with whitespace
  22526. if (getLast$3(words) === "") {
  22527. words.pop();
  22528. endWhitespace = words.pop();
  22529. } // This was whitespace only without a new line.
  22530. if (words.length === 0) {
  22531. return;
  22532. }
  22533. words.forEach(function (word, i) {
  22534. if (i % 2 === 1) {
  22535. children.push(line$3);
  22536. } else {
  22537. children.push(word);
  22538. }
  22539. });
  22540. if (endWhitespace !== undefined) {
  22541. if (/\n/.test(endWhitespace)) {
  22542. var _next = n.children[i + 1];
  22543. children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
  22544. } else {
  22545. children.push(jsxWhitespace);
  22546. }
  22547. } else {
  22548. var _next2 = n.children[i + 1];
  22549. children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
  22550. }
  22551. } else if (/\n/.test(text)) {
  22552. // Keep (up to one) blank line between tags/expressions/text.
  22553. // Note: We don't keep blank lines between text elements.
  22554. if (text.match(/\n/g).length > 1) {
  22555. children.push("");
  22556. children.push(hardline$3);
  22557. }
  22558. } else {
  22559. children.push("");
  22560. children.push(jsxWhitespace);
  22561. }
  22562. } else {
  22563. var printedChild = print(childPath);
  22564. children.push(printedChild);
  22565. var _next3 = n.children[i + 1];
  22566. var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText(_next3);
  22567. if (directlyFollowedByMeaningfulText) {
  22568. var firstWord = rawText(_next3).trim().split(matchJsxWhitespaceRegex)[0];
  22569. children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3));
  22570. } else {
  22571. children.push(hardline$3);
  22572. }
  22573. }
  22574. }, "children");
  22575. return children;
  22576. } // JSX expands children from the inside-out, instead of the outside-in.
  22577. // This is both to break children before attributes,
  22578. // and to ensure that when children break, their parents do as well.
  22579. //
  22580. // Any element that is written without any newlines and fits on a single line
  22581. // is left that way.
  22582. // Not only that, any user-written-line containing multiple JSX siblings
  22583. // should also be kept on one line if possible,
  22584. // so each user-written-line is wrapped in its own group.
  22585. //
  22586. // Elements that contain newlines or don't fit on a single line (recursively)
  22587. // are fully-split, using hardline and shouldBreak: true.
  22588. //
  22589. // To support that case properly, all leading and trailing spaces
  22590. // are stripped from the list of children, and replaced with a single hardline.
  22591. function printJSXElement(path$$1, options, print) {
  22592. var n = path$$1.getValue();
  22593. if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
  22594. return concat$4([path$$1.call(print, "openingElement"), path$$1.call(print, "closingElement")]);
  22595. }
  22596. var openingLines = n.type === "JSXElement" ? path$$1.call(print, "openingElement") : path$$1.call(print, "openingFragment");
  22597. var closingLines = n.type === "JSXElement" ? path$$1.call(print, "closingElement") : path$$1.call(print, "closingFragment");
  22598. if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
  22599. return concat$4([openingLines, concat$4(path$$1.map(print, "children")), closingLines]);
  22600. } // Convert `{" "}` to text nodes containing a space.
  22601. // This makes it easy to turn them into `jsxWhitespace` which
  22602. // can then print as either a space or `{" "}` when breaking.
  22603. n.children = n.children.map(function (child) {
  22604. if (isJSXWhitespaceExpression(child)) {
  22605. return {
  22606. type: "JSXText",
  22607. value: " ",
  22608. raw: " "
  22609. };
  22610. }
  22611. return child;
  22612. });
  22613. var containsTag = n.children.filter(isJSXNode).length > 0;
  22614. var containsMultipleExpressions = n.children.filter(function (child) {
  22615. return child.type === "JSXExpressionContainer";
  22616. }).length > 1;
  22617. var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  22618. var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  22619. var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  22620. var jsxWhitespace = ifBreak$1(concat$4([rawJsxWhitespace, softline$1]), " ");
  22621. var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
  22622. var children = printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTranslationTag);
  22623. var containsText = n.children.filter(function (child) {
  22624. return isMeaningfulJSXText(child);
  22625. }).length > 0; // We can end up we multiple whitespace elements with empty string
  22626. // content between them.
  22627. // We need to remove empty whitespace and softlines before JSX whitespace
  22628. // to get the correct output.
  22629. for (var i = children.length - 2; i >= 0; i--) {
  22630. var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  22631. var isPairOfHardlines = children[i] === hardline$3 && children[i + 1] === "" && children[i + 2] === hardline$3;
  22632. var isLineFollowedByJSXWhitespace = (children[i] === softline$1 || children[i] === hardline$3) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22633. var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$1 || children[i + 2] === hardline$3);
  22634. var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22635. var isPairOfHardOrSoftLines = children[i] === softline$1 && children[i + 1] === "" && children[i + 2] === hardline$3 || children[i] === hardline$3 && children[i + 1] === "" && children[i + 2] === softline$1;
  22636. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
  22637. children.splice(i, 2);
  22638. } else if (isJSXWhitespaceFollowedByLine) {
  22639. children.splice(i + 1, 2);
  22640. }
  22641. } // Trim trailing lines (or empty strings)
  22642. while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
  22643. children.pop();
  22644. } // Trim leading lines (or empty strings)
  22645. while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
  22646. children.shift();
  22647. children.shift();
  22648. } // Tweak how we format children if outputting this element over multiple lines.
  22649. // Also detect whether we will force this element to output over multiple lines.
  22650. var multilineChildren = [];
  22651. children.forEach(function (child, i) {
  22652. // There are a number of situations where we need to ensure we display
  22653. // whitespace as `{" "}` when outputting this element over multiple lines.
  22654. if (child === jsxWhitespace) {
  22655. if (i === 1 && children[i - 1] === "") {
  22656. if (children.length === 2) {
  22657. // Solitary whitespace
  22658. multilineChildren.push(rawJsxWhitespace);
  22659. return;
  22660. } // Leading whitespace
  22661. multilineChildren.push(concat$4([rawJsxWhitespace, hardline$3]));
  22662. return;
  22663. } else if (i === children.length - 1) {
  22664. // Trailing whitespace
  22665. multilineChildren.push(rawJsxWhitespace);
  22666. return;
  22667. } else if (children[i - 1] === "" && children[i - 2] === hardline$3) {
  22668. // Whitespace after line break
  22669. multilineChildren.push(rawJsxWhitespace);
  22670. return;
  22671. }
  22672. }
  22673. multilineChildren.push(child);
  22674. if (willBreak$1(child)) {
  22675. forcedBreak = true;
  22676. }
  22677. }); // If there is text we use `fill` to fit as much onto each line as possible.
  22678. // When there is no text (just tags and expressions) we use `group`
  22679. // to output each on a separate line.
  22680. var content = containsText ? fill$2(multilineChildren) : group$1(concat$4(multilineChildren), {
  22681. shouldBreak: true
  22682. });
  22683. var multiLineElem = group$1(concat$4([openingLines, indent$2(concat$4([hardline$3, content])), hardline$3, closingLines]));
  22684. if (forcedBreak) {
  22685. return multiLineElem;
  22686. }
  22687. return conditionalGroup$1([group$1(concat$4([openingLines, concat$4(children), closingLines])), multiLineElem]);
  22688. }
  22689. function maybeWrapJSXElementInParens(path$$1, elem) {
  22690. var parent = path$$1.getParentNode();
  22691. if (!parent) {
  22692. return elem;
  22693. }
  22694. var NO_WRAP_PARENTS = {
  22695. ArrayExpression: true,
  22696. JSXAttribute: true,
  22697. JSXElement: true,
  22698. JSXExpressionContainer: true,
  22699. JSXFragment: true,
  22700. ExpressionStatement: true,
  22701. CallExpression: true,
  22702. OptionalCallExpression: true,
  22703. ConditionalExpression: true,
  22704. JsExpressionRoot: true
  22705. };
  22706. if (NO_WRAP_PARENTS[parent.type]) {
  22707. return elem;
  22708. }
  22709. var shouldBreak = matchAncestorTypes$1(path$$1, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]);
  22710. return group$1(concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, elem])), softline$1, ifBreak$1(")")]), {
  22711. shouldBreak
  22712. });
  22713. }
  22714. function isBinaryish(node) {
  22715. return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression";
  22716. }
  22717. function isMemberish(node) {
  22718. return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
  22719. }
  22720. function shouldInlineLogicalExpression(node) {
  22721. if (node.type !== "LogicalExpression") {
  22722. return false;
  22723. }
  22724. if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
  22725. return true;
  22726. }
  22727. if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
  22728. return true;
  22729. }
  22730. if (isJSXNode(node.right)) {
  22731. return true;
  22732. }
  22733. return false;
  22734. } // For binary expressions to be consistent, we need to group
  22735. // subsequent operators with the same precedence level under a single
  22736. // group. Otherwise they will be nested such that some of them break
  22737. // onto new lines but not all. Operators with the same precedence
  22738. // level should either all break or not. Because we group them by
  22739. // precedence level and the AST is structured based on precedence
  22740. // level, things are naturally broken up correctly, i.e. `&&` is
  22741. // broken before `+`.
  22742. function printBinaryishExpressions(path$$1, print, options, isNested, isInsideParenthesis) {
  22743. var parts = [];
  22744. var node = path$$1.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  22745. if (isBinaryish(node)) {
  22746. // Put all operators with the same precedence level in the same
  22747. // group. The reason we only need to do this with the `left`
  22748. // expression is because given an expression like `1 + 2 - 3`, it
  22749. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  22750. // is where the rest of the expression will exist. Binary
  22751. // expressions on the right side mean they have a difference
  22752. // precedence level and should be treated as a separate group, so
  22753. // print them normally. (This doesn't hold for the `**` operator,
  22754. // which is unique in that it is right-associative.)
  22755. if (shouldFlatten$1(node.operator, node.left.operator)) {
  22756. // Flatten them out by recursively calling this function.
  22757. parts = parts.concat(path$$1.call(function (left) {
  22758. return printBinaryishExpressions(left, print, options,
  22759. /* isNested */
  22760. true, isInsideParenthesis);
  22761. }, "left"));
  22762. } else {
  22763. parts.push(path$$1.call(print, "left"));
  22764. }
  22765. var shouldInline = shouldInlineLogicalExpression(node);
  22766. var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right, options);
  22767. var operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  22768. var rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$1(indent$2(concat$4([softline$1, ": ", join$2(concat$4([softline$1, ":", ifBreak$1(" ")]), path$$1.map(print, "arguments").map(function (arg) {
  22769. return align$1(2, group$1(arg));
  22770. }))]))) : "";
  22771. var right = shouldInline ? concat$4([operator, " ", path$$1.call(print, "right"), rightSuffix]) : concat$4([lineBeforeOperator ? softline$1 : "", operator, lineBeforeOperator ? " " : line$3, path$$1.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group
  22772. // in order to avoid having a small right part like -1 be on its own line.
  22773. var parent = path$$1.getParentNode();
  22774. var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  22775. parts.push(" ", shouldGroup ? group$1(right) : right); // The root comments are already printed, but we need to manually print
  22776. // the other ones since we don't call the normal print on BinaryExpression,
  22777. // only for the left and right parts
  22778. if (isNested && node.comments) {
  22779. parts = comments.printComments(path$$1, function () {
  22780. return concat$4(parts);
  22781. }, options);
  22782. }
  22783. } else {
  22784. // Our stopping case. Simply print the node normally.
  22785. parts.push(path$$1.call(print));
  22786. }
  22787. return parts;
  22788. }
  22789. function printAssignmentRight(leftNode, rightNode, printedRight, options) {
  22790. if (hasLeadingOwnLineComment(options.originalText, rightNode, options)) {
  22791. return indent$2(concat$4([hardline$3, printedRight]));
  22792. }
  22793. var canBreak = isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral(rightNode) || isMemberExpressionChain(rightNode)) && // do not put values on a separate line from the key in json
  22794. options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression";
  22795. if (canBreak) {
  22796. return group$1(indent$2(concat$4([line$3, printedRight])));
  22797. }
  22798. return concat$4([" ", printedRight]);
  22799. }
  22800. function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
  22801. if (!rightNode) {
  22802. return printedLeft;
  22803. }
  22804. var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
  22805. return group$1(concat$4([printedLeft, operator, printed]));
  22806. }
  22807. function adjustClause(node, clause, forceSpace) {
  22808. if (node.type === "EmptyStatement") {
  22809. return ";";
  22810. }
  22811. if (node.type === "BlockStatement" || forceSpace) {
  22812. return concat$4([" ", clause]);
  22813. }
  22814. return indent$2(concat$4([line$3, clause]));
  22815. }
  22816. function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
  22817. var raw = rawText(node);
  22818. var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
  22819. return printString$1(raw, options, isDirectiveLiteral);
  22820. }
  22821. function printRegex(node) {
  22822. var flags = node.flags.split("").sort().join("");
  22823. return `/${node.pattern}/${flags}`;
  22824. }
  22825. function isLastStatement(path$$1) {
  22826. var parent = path$$1.getParentNode();
  22827. if (!parent) {
  22828. return true;
  22829. }
  22830. var node = path$$1.getValue();
  22831. var body = (parent.body || parent.consequent).filter(function (stmt) {
  22832. return stmt.type !== "EmptyStatement";
  22833. });
  22834. return body && body[body.length - 1] === node;
  22835. }
  22836. function hasLeadingComment(node) {
  22837. return node.comments && node.comments.some(function (comment) {
  22838. return comment.leading;
  22839. });
  22840. }
  22841. function hasTrailingComment(node) {
  22842. return node.comments && node.comments.some(function (comment) {
  22843. return comment.trailing;
  22844. });
  22845. }
  22846. function hasLeadingOwnLineComment(text, node, options) {
  22847. if (isJSXNode(node)) {
  22848. return hasNodeIgnoreComment$1(node);
  22849. }
  22850. var res = node.comments && node.comments.some(function (comment) {
  22851. return comment.leading && hasNewline$2(text, options.locEnd(comment));
  22852. });
  22853. return res;
  22854. }
  22855. function isFlowAnnotationComment(text, typeAnnotation, options) {
  22856. var start = options.locStart(typeAnnotation);
  22857. var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
  22858. return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
  22859. }
  22860. function exprNeedsASIProtection(path$$1, options) {
  22861. var node = path$$1.getValue();
  22862. var maybeASIProblem = needsParens_1(path$$1, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path$$1, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
  22863. if (maybeASIProblem) {
  22864. return true;
  22865. }
  22866. if (!hasNakedLeftSide(node)) {
  22867. return false;
  22868. }
  22869. return path$$1.call.apply(path$$1, [function (childPath) {
  22870. return exprNeedsASIProtection(childPath, options);
  22871. }].concat(getLeftSidePathName(path$$1, node)));
  22872. }
  22873. function stmtNeedsASIProtection(path$$1, options) {
  22874. var node = path$$1.getNode();
  22875. if (node.type !== "ExpressionStatement") {
  22876. return false;
  22877. }
  22878. return path$$1.call(function (childPath) {
  22879. return exprNeedsASIProtection(childPath, options);
  22880. }, "expression");
  22881. }
  22882. function classPropMayCauseASIProblems(path$$1) {
  22883. var node = path$$1.getNode();
  22884. if (node.type !== "ClassProperty") {
  22885. return false;
  22886. }
  22887. var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  22888. // so isn't properly tested yet.
  22889. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  22890. return true;
  22891. }
  22892. }
  22893. function classChildNeedsASIProtection(node) {
  22894. if (!node) {
  22895. return;
  22896. }
  22897. if (node.static || node.accessibility // TypeScript
  22898. ) {
  22899. return false;
  22900. }
  22901. if (!node.computed) {
  22902. var name = node.key && node.key.name;
  22903. if (name === "in" || name === "instanceof") {
  22904. return true;
  22905. }
  22906. }
  22907. switch (node.type) {
  22908. case "ClassProperty":
  22909. case "TSAbstractClassProperty":
  22910. return node.computed;
  22911. case "MethodDefinition": // Flow
  22912. case "TSAbstractMethodDefinition": // TypeScript
  22913. case "ClassMethod":
  22914. case "ClassPrivateMethod":
  22915. {
  22916. // Babel
  22917. var isAsync = node.value ? node.value.async : node.async;
  22918. var isGenerator = node.value ? node.value.generator : node.generator;
  22919. if (isAsync || node.kind === "get" || node.kind === "set") {
  22920. return false;
  22921. }
  22922. if (node.computed || isGenerator) {
  22923. return true;
  22924. }
  22925. return false;
  22926. }
  22927. default:
  22928. /* istanbul ignore next */
  22929. return false;
  22930. }
  22931. } // This recurses the return argument, looking for the first token
  22932. // (the leftmost leaf node) and, if it (or its parents) has any
  22933. // leadingComments, returns true (so it can be wrapped in parens).
  22934. function returnArgumentHasLeadingComment(options, argument) {
  22935. if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
  22936. return true;
  22937. }
  22938. if (hasNakedLeftSide(argument)) {
  22939. var leftMost = argument;
  22940. var newLeftMost;
  22941. while (newLeftMost = getLeftSide(leftMost)) {
  22942. leftMost = newLeftMost;
  22943. if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
  22944. return true;
  22945. }
  22946. }
  22947. }
  22948. return false;
  22949. }
  22950. function isMemberExpressionChain(node) {
  22951. if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
  22952. return false;
  22953. }
  22954. if (node.object.type === "Identifier") {
  22955. return true;
  22956. }
  22957. return isMemberExpressionChain(node.object);
  22958. } // Hack to differentiate between the following two which have the same ast
  22959. // type T = { method: () => void };
  22960. // type T = { method(): void };
  22961. function isObjectTypePropertyAFunction(node, options) {
  22962. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
  22963. } // TODO: This is a bad hack and we need a better way to distinguish between
  22964. // arrow functions and otherwise
  22965. function isFunctionNotation(node, options) {
  22966. return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
  22967. }
  22968. function isGetterOrSetter(node) {
  22969. return node.kind === "get" || node.kind === "set";
  22970. }
  22971. function sameLocStart(nodeA, nodeB, options) {
  22972. return options.locStart(nodeA) === options.locStart(nodeB);
  22973. } // Hack to differentiate between the following two which have the same ast
  22974. // declare function f(a): void;
  22975. // var f: (a) => void;
  22976. function isTypeAnnotationAFunction(node, options) {
  22977. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
  22978. }
  22979. function isNodeStartingWithDeclare(node, options) {
  22980. if (!(options.parser === "flow" || options.parser === "typescript")) {
  22981. return false;
  22982. }
  22983. return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
  22984. }
  22985. function shouldHugType(node) {
  22986. if (isSimpleFlowType(node) || isObjectType(node)) {
  22987. return true;
  22988. }
  22989. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  22990. var voidCount = node.types.filter(function (n) {
  22991. return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
  22992. }).length;
  22993. var objectCount = node.types.filter(function (n) {
  22994. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  22995. n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
  22996. }).length;
  22997. if (node.types.length - 1 === voidCount && objectCount > 0) {
  22998. return true;
  22999. }
  23000. }
  23001. return false;
  23002. }
  23003. function shouldHugArguments(fun) {
  23004. return fun && fun.params && fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "ArrayPattern" || fun.params[0].type === "Identifier" && fun.params[0].typeAnnotation && (fun.params[0].typeAnnotation.type === "TypeAnnotation" || fun.params[0].typeAnnotation.type === "TSTypeAnnotation") && isObjectType(fun.params[0].typeAnnotation.typeAnnotation) || fun.params[0].type === "FunctionTypeParam" && isObjectType(fun.params[0].typeAnnotation) || fun.params[0].type === "AssignmentPattern" && (fun.params[0].left.type === "ObjectPattern" || fun.params[0].left.type === "ArrayPattern") && (fun.params[0].right.type === "Identifier" || fun.params[0].right.type === "ObjectExpression" && fun.params[0].right.properties.length === 0 || fun.params[0].right.type === "ArrayExpression" && fun.params[0].right.elements.length === 0)) && !fun.rest;
  23005. }
  23006. function templateLiteralHasNewLines(template) {
  23007. return template.quasis.some(function (quasi) {
  23008. return quasi.value.raw.includes("\n");
  23009. });
  23010. }
  23011. function isTemplateOnItsOwnLine(n, text, options) {
  23012. return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$2(text, options.locStart(n), {
  23013. backwards: true
  23014. });
  23015. }
  23016. function printArrayItems(path$$1, options, printPath, print) {
  23017. var printedElements = [];
  23018. var separatorParts = [];
  23019. path$$1.each(function (childPath) {
  23020. printedElements.push(concat$4(separatorParts));
  23021. printedElements.push(group$1(print(childPath)));
  23022. separatorParts = [",", line$3];
  23023. if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  23024. separatorParts.push(softline$1);
  23025. }
  23026. }, printPath);
  23027. return concat$4(printedElements);
  23028. }
  23029. function hasDanglingComments(node) {
  23030. return node.comments && node.comments.some(function (comment) {
  23031. return !comment.leading && !comment.trailing;
  23032. });
  23033. }
  23034. function needsHardlineAfterDanglingComment(node) {
  23035. if (!node.comments) {
  23036. return false;
  23037. }
  23038. var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
  23039. return !comment.leading && !comment.trailing;
  23040. }));
  23041. return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
  23042. }
  23043. function isLiteral(node) {
  23044. return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
  23045. }
  23046. function isStringPropSafeToCoerceToIdentifier(node, options) {
  23047. return isStringLiteral(node.key) && isIdentifierName(node.key.value) && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
  23048. }
  23049. function isNumericLiteral(node) {
  23050. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  23051. }
  23052. function isStringLiteral(node) {
  23053. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  23054. }
  23055. function isObjectType(n) {
  23056. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
  23057. }
  23058. var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // eg; `describe("some string", (done) => {})`
  23059. function isTestCall(n, parent) {
  23060. if (n.type !== "CallExpression") {
  23061. return false;
  23062. }
  23063. if (n.arguments.length === 1) {
  23064. if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
  23065. return isFunctionOrArrowExpression(n.arguments[0]);
  23066. }
  23067. if (isUnitTestSetUp(n)) {
  23068. return isAngularTestWrapper(n.arguments[0]);
  23069. }
  23070. } else if (n.arguments.length === 2 || n.arguments.length === 3) {
  23071. if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
  23072. // it("name", () => { ... }, 2500)
  23073. if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
  23074. return false;
  23075. }
  23076. return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
  23077. }
  23078. }
  23079. return false;
  23080. }
  23081. function isSkipOrOnlyBlock(node) {
  23082. return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && 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");
  23083. }
  23084. function isTemplateLiteral(node) {
  23085. return node.type === "TemplateLiteral";
  23086. } // `inject` is used in AngularJS 1.x, `async` in Angular 2+
  23087. // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  23088. function isAngularTestWrapper(node) {
  23089. return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  23090. }
  23091. function isFunctionOrArrowExpression(node) {
  23092. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  23093. }
  23094. function isFunctionOrArrowExpressionWithBody(node) {
  23095. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  23096. }
  23097. function isUnitTestSetUp(n) {
  23098. var unitTestSetUpRe = /^(before|after)(Each|All)$/;
  23099. return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
  23100. }
  23101. function isTheOnlyJSXElementInMarkdown(options, path$$1) {
  23102. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  23103. return false;
  23104. }
  23105. var node = path$$1.getNode();
  23106. if (!node.expression || !isJSXNode(node.expression)) {
  23107. return false;
  23108. }
  23109. var parent = path$$1.getParentNode();
  23110. return parent.type === "Program" && parent.body.length == 1;
  23111. }
  23112. function willPrintOwnComments(path$$1
  23113. /*, options */
  23114. ) {
  23115. var node = path$$1.getValue();
  23116. var parent = path$$1.getParentNode();
  23117. return (node && (isJSXNode(node) || hasFlowShorthandAnnotationComment(node) || parent && parent.type === "CallExpression" && (hasFlowAnnotationComment(node.leadingComments) || hasFlowAnnotationComment(node.trailingComments))) || 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$$1);
  23118. }
  23119. function canAttachComment(node) {
  23120. return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
  23121. }
  23122. function printComment$1(commentPath, options) {
  23123. var comment = commentPath.getValue();
  23124. switch (comment.type) {
  23125. case "CommentBlock":
  23126. case "Block":
  23127. {
  23128. if (isIndentableBlockComment(comment)) {
  23129. var printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  23130. // printed as a `lineSuffix` which causes the comments to be
  23131. // interleaved. See https://github.com/prettier/prettier/issues/4412
  23132. if (comment.trailing && !hasNewline$2(options.originalText, options.locStart(comment), {
  23133. backwards: true
  23134. })) {
  23135. return concat$4([hardline$3, printed]);
  23136. }
  23137. return printed;
  23138. }
  23139. var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
  23140. return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
  23141. }
  23142. case "CommentLine":
  23143. case "Line":
  23144. // Print shebangs with the proper comment characters
  23145. if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
  23146. return "#!" + comment.value.trimRight();
  23147. }
  23148. return "//" + comment.value.trimRight();
  23149. default:
  23150. throw new Error("Not a comment: " + JSON.stringify(comment));
  23151. }
  23152. }
  23153. function isIndentableBlockComment(comment) {
  23154. // If the comment has multiple lines and every line starts with a star
  23155. // we can fix the indentation of each line. The stars in the `/*` and
  23156. // `*/` delimiters are not included in the comment value, so add them
  23157. // back first.
  23158. var lines = `*${comment.value}*`.split("\n");
  23159. return lines.length > 1 && lines.every(function (line) {
  23160. return line.trim()[0] === "*";
  23161. });
  23162. }
  23163. function printIndentableBlockComment(comment) {
  23164. var lines = comment.value.split("\n");
  23165. return concat$4(["/*", join$2(hardline$3, lines.map(function (line, index) {
  23166. return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft());
  23167. })), "*/"]);
  23168. }
  23169. function rawText(node) {
  23170. return node.extra ? node.extra.raw : node.raw;
  23171. }
  23172. function identity$1(x) {
  23173. return x;
  23174. }
  23175. var printerEstree = {
  23176. preprocess: preprocess_1,
  23177. print: genericPrint,
  23178. embed: embed_1,
  23179. insertPragma,
  23180. massageAstNode: clean_1,
  23181. hasPrettierIgnore,
  23182. willPrintOwnComments,
  23183. canAttachComment,
  23184. printComment: printComment$1,
  23185. isBlockComment: comments$3.isBlockComment,
  23186. handleComments: {
  23187. ownLine: comments$3.handleOwnLineComment,
  23188. endOfLine: comments$3.handleEndOfLineComment,
  23189. remaining: comments$3.handleRemainingComment
  23190. }
  23191. };
  23192. var _require$$0$builders$2 = doc.builders;
  23193. var concat$7 = _require$$0$builders$2.concat;
  23194. var hardline$5 = _require$$0$builders$2.hardline;
  23195. var indent$4 = _require$$0$builders$2.indent;
  23196. var join$5 = _require$$0$builders$2.join;
  23197. function genericPrint$1(path$$1, options, print) {
  23198. var node = path$$1.getValue();
  23199. switch (node.type) {
  23200. case "JsonRoot":
  23201. return concat$7([path$$1.call(print, "node"), hardline$5]);
  23202. case "ArrayExpression":
  23203. return node.elements.length === 0 ? "[]" : concat$7(["[", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path$$1.map(print, "elements"))])), hardline$5, "]"]);
  23204. case "ObjectExpression":
  23205. return node.properties.length === 0 ? "{}" : concat$7(["{", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path$$1.map(print, "properties"))])), hardline$5, "}"]);
  23206. case "ObjectProperty":
  23207. return concat$7([path$$1.call(print, "key"), ": ", path$$1.call(print, "value")]);
  23208. case "UnaryExpression":
  23209. return concat$7([node.operator === "+" ? "" : node.operator, path$$1.call(print, "argument")]);
  23210. case "NullLiteral":
  23211. return "null";
  23212. case "BooleanLiteral":
  23213. return node.value ? "true" : "false";
  23214. case "StringLiteral":
  23215. case "NumericLiteral":
  23216. return JSON.stringify(node.value);
  23217. case "Identifier":
  23218. return JSON.stringify(node.name);
  23219. default:
  23220. /* istanbul ignore next */
  23221. throw new Error("unknown type: " + JSON.stringify(node.type));
  23222. }
  23223. }
  23224. function clean$2(node, newNode
  23225. /*, parent*/
  23226. ) {
  23227. delete newNode.start;
  23228. delete newNode.end;
  23229. delete newNode.extra;
  23230. delete newNode.loc;
  23231. delete newNode.comments;
  23232. if (node.type === "Identifier") {
  23233. return {
  23234. type: "StringLiteral",
  23235. value: node.name
  23236. };
  23237. }
  23238. if (node.type === "UnaryExpression" && node.operator === "+") {
  23239. return newNode.argument;
  23240. }
  23241. }
  23242. var printerEstreeJson = {
  23243. preprocess: preprocess_1,
  23244. print: genericPrint$1,
  23245. massageAstNode: clean$2
  23246. };
  23247. var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  23248. var commonOptions = {
  23249. bracketSpacing: {
  23250. since: "0.0.0",
  23251. category: CATEGORY_COMMON,
  23252. type: "boolean",
  23253. default: true,
  23254. description: "Print spaces between brackets.",
  23255. oppositeDescription: "Do not print spaces between brackets."
  23256. },
  23257. singleQuote: {
  23258. since: "0.0.0",
  23259. category: CATEGORY_COMMON,
  23260. type: "boolean",
  23261. default: false,
  23262. description: "Use single quotes instead of double quotes."
  23263. },
  23264. proseWrap: {
  23265. since: "1.8.2",
  23266. category: CATEGORY_COMMON,
  23267. type: "choice",
  23268. default: [{
  23269. since: "1.8.2",
  23270. value: true
  23271. }, {
  23272. since: "1.9.0",
  23273. value: "preserve"
  23274. }],
  23275. description: "How to wrap prose.",
  23276. choices: [{
  23277. since: "1.9.0",
  23278. value: "always",
  23279. description: "Wrap prose if it exceeds the print width."
  23280. }, {
  23281. since: "1.9.0",
  23282. value: "never",
  23283. description: "Do not wrap prose."
  23284. }, {
  23285. since: "1.9.0",
  23286. value: "preserve",
  23287. description: "Wrap prose as-is."
  23288. }, {
  23289. value: false,
  23290. deprecated: "1.9.0",
  23291. redirect: "never"
  23292. }, {
  23293. value: true,
  23294. deprecated: "1.9.0",
  23295. redirect: "always"
  23296. }]
  23297. }
  23298. };
  23299. var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  23300. var options$4 = {
  23301. arrowParens: {
  23302. since: "1.9.0",
  23303. category: CATEGORY_JAVASCRIPT,
  23304. type: "choice",
  23305. default: "avoid",
  23306. description: "Include parentheses around a sole arrow function parameter.",
  23307. choices: [{
  23308. value: "avoid",
  23309. description: "Omit parens when possible. Example: `x => x`"
  23310. }, {
  23311. value: "always",
  23312. description: "Always include parens. Example: `(x) => x`"
  23313. }]
  23314. },
  23315. bracketSpacing: commonOptions.bracketSpacing,
  23316. jsxBracketSameLine: {
  23317. since: "0.17.0",
  23318. category: CATEGORY_JAVASCRIPT,
  23319. type: "boolean",
  23320. default: false,
  23321. description: "Put > on the last line instead of at a new line."
  23322. },
  23323. semi: {
  23324. since: "1.0.0",
  23325. category: CATEGORY_JAVASCRIPT,
  23326. type: "boolean",
  23327. default: true,
  23328. description: "Print semicolons.",
  23329. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  23330. },
  23331. singleQuote: commonOptions.singleQuote,
  23332. jsxSingleQuote: {
  23333. since: "1.15.0",
  23334. category: CATEGORY_JAVASCRIPT,
  23335. type: "boolean",
  23336. default: false,
  23337. description: "Use single quotes in JSX."
  23338. },
  23339. quoteProps: {
  23340. since: "1.17.0",
  23341. category: CATEGORY_JAVASCRIPT,
  23342. type: "choice",
  23343. default: "as-needed",
  23344. description: "Change when properties in objects are quoted.",
  23345. choices: [{
  23346. value: "as-needed",
  23347. description: "Only add quotes around object properties where required."
  23348. }, {
  23349. value: "consistent",
  23350. description: "If at least one property in an object requires quotes, quote all properties."
  23351. }, {
  23352. value: "preserve",
  23353. description: "Respect the input use of quotes in object properties."
  23354. }]
  23355. },
  23356. trailingComma: {
  23357. since: "0.0.0",
  23358. category: CATEGORY_JAVASCRIPT,
  23359. type: "choice",
  23360. default: [{
  23361. since: "0.0.0",
  23362. value: false
  23363. }, {
  23364. since: "0.19.0",
  23365. value: "none"
  23366. }],
  23367. description: "Print trailing commas wherever possible when multi-line.",
  23368. choices: [{
  23369. value: "none",
  23370. description: "No trailing commas."
  23371. }, {
  23372. value: "es5",
  23373. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  23374. }, {
  23375. value: "all",
  23376. description: "Trailing commas wherever possible (including function arguments)."
  23377. }, {
  23378. value: true,
  23379. deprecated: "0.19.0",
  23380. redirect: "es5"
  23381. }, {
  23382. value: false,
  23383. deprecated: "0.19.0",
  23384. redirect: "none"
  23385. }]
  23386. }
  23387. };
  23388. var createLanguage = function createLanguage(linguistData, _ref) {
  23389. var extend = _ref.extend,
  23390. override = _ref.override;
  23391. var language = {};
  23392. for (var key in linguistData) {
  23393. var newKey = key === "languageId" ? "linguistLanguageId" : key;
  23394. language[newKey] = linguistData[key];
  23395. }
  23396. if (extend) {
  23397. for (var _key in extend) {
  23398. language[_key] = (language[_key] || []).concat(extend[_key]);
  23399. }
  23400. }
  23401. for (var _key2 in override) {
  23402. language[_key2] = override[_key2];
  23403. }
  23404. return language;
  23405. };
  23406. var name$1 = "JavaScript";
  23407. var type = "programming";
  23408. var tmScope = "source.js";
  23409. var aceMode = "javascript";
  23410. var codemirrorMode = "javascript";
  23411. var codemirrorMimeType = "text/javascript";
  23412. var color = "#f1e05a";
  23413. var aliases = ["js", "node"];
  23414. var extensions = [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"];
  23415. var filenames = ["Jakefile"];
  23416. var interpreters = ["node"];
  23417. var languageId = 183;
  23418. var javascript = {
  23419. name: name$1,
  23420. type: type,
  23421. tmScope: tmScope,
  23422. aceMode: aceMode,
  23423. codemirrorMode: codemirrorMode,
  23424. codemirrorMimeType: codemirrorMimeType,
  23425. color: color,
  23426. aliases: aliases,
  23427. extensions: extensions,
  23428. filenames: filenames,
  23429. interpreters: interpreters,
  23430. languageId: languageId
  23431. };
  23432. var javascript$1 = Object.freeze({
  23433. name: name$1,
  23434. type: type,
  23435. tmScope: tmScope,
  23436. aceMode: aceMode,
  23437. codemirrorMode: codemirrorMode,
  23438. codemirrorMimeType: codemirrorMimeType,
  23439. color: color,
  23440. aliases: aliases,
  23441. extensions: extensions,
  23442. filenames: filenames,
  23443. interpreters: interpreters,
  23444. languageId: languageId,
  23445. default: javascript
  23446. });
  23447. var name$2 = "JSX";
  23448. var type$1 = "programming";
  23449. var group$3 = "JavaScript";
  23450. var extensions$1 = [".jsx"];
  23451. var tmScope$1 = "source.js.jsx";
  23452. var aceMode$1 = "javascript";
  23453. var codemirrorMode$1 = "jsx";
  23454. var codemirrorMimeType$1 = "text/jsx";
  23455. var languageId$1 = 178;
  23456. var jsx = {
  23457. name: name$2,
  23458. type: type$1,
  23459. group: group$3,
  23460. extensions: extensions$1,
  23461. tmScope: tmScope$1,
  23462. aceMode: aceMode$1,
  23463. codemirrorMode: codemirrorMode$1,
  23464. codemirrorMimeType: codemirrorMimeType$1,
  23465. languageId: languageId$1
  23466. };
  23467. var jsx$1 = Object.freeze({
  23468. name: name$2,
  23469. type: type$1,
  23470. group: group$3,
  23471. extensions: extensions$1,
  23472. tmScope: tmScope$1,
  23473. aceMode: aceMode$1,
  23474. codemirrorMode: codemirrorMode$1,
  23475. codemirrorMimeType: codemirrorMimeType$1,
  23476. languageId: languageId$1,
  23477. default: jsx
  23478. });
  23479. var name$3 = "TypeScript";
  23480. var type$2 = "programming";
  23481. var color$1 = "#2b7489";
  23482. var aliases$1 = ["ts"];
  23483. var extensions$2 = [".ts", ".tsx"];
  23484. var tmScope$2 = "source.ts";
  23485. var aceMode$2 = "typescript";
  23486. var codemirrorMode$2 = "javascript";
  23487. var codemirrorMimeType$2 = "application/typescript";
  23488. var languageId$2 = 378;
  23489. var typescript = {
  23490. name: name$3,
  23491. type: type$2,
  23492. color: color$1,
  23493. aliases: aliases$1,
  23494. extensions: extensions$2,
  23495. tmScope: tmScope$2,
  23496. aceMode: aceMode$2,
  23497. codemirrorMode: codemirrorMode$2,
  23498. codemirrorMimeType: codemirrorMimeType$2,
  23499. languageId: languageId$2
  23500. };
  23501. var typescript$1 = Object.freeze({
  23502. name: name$3,
  23503. type: type$2,
  23504. color: color$1,
  23505. aliases: aliases$1,
  23506. extensions: extensions$2,
  23507. tmScope: tmScope$2,
  23508. aceMode: aceMode$2,
  23509. codemirrorMode: codemirrorMode$2,
  23510. codemirrorMimeType: codemirrorMimeType$2,
  23511. languageId: languageId$2,
  23512. default: typescript
  23513. });
  23514. var name$4 = "JSON";
  23515. var type$3 = "data";
  23516. var tmScope$3 = "source.json";
  23517. var group$4 = "JavaScript";
  23518. var aceMode$3 = "json";
  23519. var codemirrorMode$3 = "javascript";
  23520. var codemirrorMimeType$3 = "application/json";
  23521. var searchable = false;
  23522. var extensions$3 = [".json", ".avsc", ".geojson", ".gltf", ".JSON-tmLanguage", ".jsonl", ".tfstate", ".tfstate.backup", ".topojson", ".webapp", ".webmanifest"];
  23523. var filenames$1 = [".arcconfig", ".htmlhintrc", ".tern-config", ".tern-project", "composer.lock", "mcmod.info"];
  23524. var languageId$3 = 174;
  23525. var json$2 = {
  23526. name: name$4,
  23527. type: type$3,
  23528. tmScope: tmScope$3,
  23529. group: group$4,
  23530. aceMode: aceMode$3,
  23531. codemirrorMode: codemirrorMode$3,
  23532. codemirrorMimeType: codemirrorMimeType$3,
  23533. searchable: searchable,
  23534. extensions: extensions$3,
  23535. filenames: filenames$1,
  23536. languageId: languageId$3
  23537. };
  23538. var json$3 = Object.freeze({
  23539. name: name$4,
  23540. type: type$3,
  23541. tmScope: tmScope$3,
  23542. group: group$4,
  23543. aceMode: aceMode$3,
  23544. codemirrorMode: codemirrorMode$3,
  23545. codemirrorMimeType: codemirrorMimeType$3,
  23546. searchable: searchable,
  23547. extensions: extensions$3,
  23548. filenames: filenames$1,
  23549. languageId: languageId$3,
  23550. default: json$2
  23551. });
  23552. var name$5 = "JSON with Comments";
  23553. var type$4 = "data";
  23554. var group$5 = "JSON";
  23555. var tmScope$4 = "source.js";
  23556. var aceMode$4 = "javascript";
  23557. var codemirrorMode$4 = "javascript";
  23558. var codemirrorMimeType$4 = "text/javascript";
  23559. var aliases$2 = ["jsonc"];
  23560. var extensions$4 = [".sublime-build", ".sublime-commands", ".sublime-completions", ".sublime-keymap", ".sublime-macro", ".sublime-menu", ".sublime-mousemap", ".sublime-project", ".sublime-settings", ".sublime-theme", ".sublime-workspace", ".sublime_metrics", ".sublime_session"];
  23561. var filenames$2 = [".babelrc", ".eslintrc.json", ".jscsrc", ".jshintrc", ".jslintrc", "tsconfig.json"];
  23562. var languageId$4 = 423;
  23563. var jsonWithComments = {
  23564. name: name$5,
  23565. type: type$4,
  23566. group: group$5,
  23567. tmScope: tmScope$4,
  23568. aceMode: aceMode$4,
  23569. codemirrorMode: codemirrorMode$4,
  23570. codemirrorMimeType: codemirrorMimeType$4,
  23571. aliases: aliases$2,
  23572. extensions: extensions$4,
  23573. filenames: filenames$2,
  23574. languageId: languageId$4
  23575. };
  23576. var jsonWithComments$1 = Object.freeze({
  23577. name: name$5,
  23578. type: type$4,
  23579. group: group$5,
  23580. tmScope: tmScope$4,
  23581. aceMode: aceMode$4,
  23582. codemirrorMode: codemirrorMode$4,
  23583. codemirrorMimeType: codemirrorMimeType$4,
  23584. aliases: aliases$2,
  23585. extensions: extensions$4,
  23586. filenames: filenames$2,
  23587. languageId: languageId$4,
  23588. default: jsonWithComments
  23589. });
  23590. var name$6 = "JSON5";
  23591. var type$5 = "data";
  23592. var extensions$5 = [".json5"];
  23593. var tmScope$5 = "source.js";
  23594. var aceMode$5 = "javascript";
  23595. var codemirrorMode$5 = "javascript";
  23596. var codemirrorMimeType$5 = "application/json";
  23597. var languageId$5 = 175;
  23598. var json5 = {
  23599. name: name$6,
  23600. type: type$5,
  23601. extensions: extensions$5,
  23602. tmScope: tmScope$5,
  23603. aceMode: aceMode$5,
  23604. codemirrorMode: codemirrorMode$5,
  23605. codemirrorMimeType: codemirrorMimeType$5,
  23606. languageId: languageId$5
  23607. };
  23608. var json5$1 = Object.freeze({
  23609. name: name$6,
  23610. type: type$5,
  23611. extensions: extensions$5,
  23612. tmScope: tmScope$5,
  23613. aceMode: aceMode$5,
  23614. codemirrorMode: codemirrorMode$5,
  23615. codemirrorMimeType: codemirrorMimeType$5,
  23616. languageId: languageId$5,
  23617. default: json5
  23618. });
  23619. var require$$0$21 = ( javascript$1 && javascript ) || javascript$1;
  23620. var require$$1$10 = ( jsx$1 && jsx ) || jsx$1;
  23621. var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
  23622. var require$$3$3 = ( json$3 && json$2 ) || json$3;
  23623. var require$$4$2 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComments$1;
  23624. var require$$5$1 = ( json5$1 && json5 ) || json5$1;
  23625. var languages = [createLanguage(require$$0$21, {
  23626. override: {
  23627. since: "0.0.0",
  23628. parsers: ["babel", "flow"],
  23629. vscodeLanguageIds: ["javascript"]
  23630. },
  23631. extend: {
  23632. interpreters: ["nodejs"]
  23633. }
  23634. }), createLanguage(require$$0$21, {
  23635. override: {
  23636. name: "Flow",
  23637. since: "0.0.0",
  23638. parsers: ["babel", "flow"],
  23639. vscodeLanguageIds: ["javascript"],
  23640. aliases: [],
  23641. filenames: [],
  23642. extensions: [".js.flow"]
  23643. }
  23644. }), createLanguage(require$$1$10, {
  23645. override: {
  23646. since: "0.0.0",
  23647. parsers: ["babel", "flow"],
  23648. vscodeLanguageIds: ["javascriptreact"]
  23649. }
  23650. }), createLanguage(require$$2$10, {
  23651. override: {
  23652. since: "1.4.0",
  23653. parsers: ["typescript"],
  23654. vscodeLanguageIds: ["typescript", "typescriptreact"]
  23655. }
  23656. }), createLanguage(require$$3$3, {
  23657. override: {
  23658. name: "JSON.stringify",
  23659. since: "1.13.0",
  23660. parsers: ["json-stringify"],
  23661. vscodeLanguageIds: ["json"],
  23662. extensions: [],
  23663. // .json file defaults to json instead of json-stringify
  23664. filenames: ["package.json", "package-lock.json", "composer.json"]
  23665. }
  23666. }), createLanguage(require$$3$3, {
  23667. override: {
  23668. since: "1.5.0",
  23669. parsers: ["json"],
  23670. vscodeLanguageIds: ["json"]
  23671. },
  23672. extend: {
  23673. filenames: [".prettierrc"]
  23674. }
  23675. }), createLanguage(require$$4$2, {
  23676. override: {
  23677. since: "1.5.0",
  23678. parsers: ["json"],
  23679. vscodeLanguageIds: ["jsonc"]
  23680. },
  23681. extend: {
  23682. filenames: [".eslintrc"]
  23683. }
  23684. }), createLanguage(require$$5$1, {
  23685. override: {
  23686. since: "1.13.0",
  23687. parsers: ["json5"],
  23688. vscodeLanguageIds: ["json5"]
  23689. }
  23690. })];
  23691. var printers = {
  23692. estree: printerEstree,
  23693. "estree-json": printerEstreeJson
  23694. };
  23695. var languageJs = {
  23696. languages,
  23697. options: options$4,
  23698. printers
  23699. };
  23700. var index$12 = ["a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "command", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "isindex", "kbd", "keygen", "label", "legend", "li", "link", "listing", "main", "map", "mark", "marquee", "math", "menu", "menuitem", "meta", "meter", "multicol", "nav", "nextid", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "pre", "progress", "q", "rb", "rbc", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "svg", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp"];
  23701. var htmlTagNames = Object.freeze({
  23702. default: index$12
  23703. });
  23704. var htmlTagNames$1 = ( htmlTagNames && index$12 ) || htmlTagNames;
  23705. function clean$3(ast, newObj, parent) {
  23706. ["raw", // front-matter
  23707. "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) {
  23708. delete newObj[name];
  23709. });
  23710. if (ast.type === "yaml") {
  23711. delete newObj.value;
  23712. } // --insert-pragma
  23713. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
  23714. parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
  23715. /**
  23716. * something
  23717. *
  23718. * @format
  23719. */
  23720. delete newObj.text; // standalone pragma
  23721. if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
  23722. return null;
  23723. }
  23724. }
  23725. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  23726. delete newObj.value;
  23727. }
  23728. if (ast.type === "css-rule") {
  23729. delete newObj.params;
  23730. }
  23731. if (ast.type === "selector-combinator") {
  23732. newObj.value = newObj.value.replace(/\s+/g, " ");
  23733. }
  23734. if (ast.type === "media-feature") {
  23735. newObj.value = newObj.value.replace(/ /g, "");
  23736. }
  23737. if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].indexOf(newObj.value.replace().toLowerCase()) !== -1) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
  23738. newObj.value = newObj.value.toLowerCase();
  23739. }
  23740. if (ast.type === "css-decl") {
  23741. newObj.prop = newObj.prop.toLowerCase();
  23742. }
  23743. if (ast.type === "css-atrule" || ast.type === "css-import") {
  23744. newObj.name = newObj.name.toLowerCase();
  23745. }
  23746. if (ast.type === "value-number") {
  23747. newObj.unit = newObj.unit.toLowerCase();
  23748. }
  23749. 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) {
  23750. newObj.value = cleanCSSStrings(newObj.value);
  23751. }
  23752. if (ast.type === "selector-attribute") {
  23753. newObj.attribute = newObj.attribute.trim();
  23754. if (newObj.namespace) {
  23755. if (typeof newObj.namespace === "string") {
  23756. newObj.namespace = newObj.namespace.trim();
  23757. if (newObj.namespace.length === 0) {
  23758. newObj.namespace = true;
  23759. }
  23760. }
  23761. }
  23762. if (newObj.value) {
  23763. newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
  23764. delete newObj.quoted;
  23765. }
  23766. }
  23767. 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) {
  23768. newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) {
  23769. var num = Number(numStr);
  23770. return isNaN(num) ? match : num + unit.toLowerCase();
  23771. });
  23772. }
  23773. if (ast.type === "selector-tag") {
  23774. var lowercasedValue = ast.value.toLowerCase();
  23775. if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) {
  23776. newObj.value = lowercasedValue;
  23777. }
  23778. if (["from", "to"].indexOf(lowercasedValue) !== -1) {
  23779. newObj.value = lowercasedValue;
  23780. }
  23781. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  23782. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  23783. delete newObj.value;
  23784. } // Workaround for SCSS nested properties
  23785. if (ast.type === "selector-unknown") {
  23786. delete newObj.value;
  23787. }
  23788. }
  23789. function cleanCSSStrings(value) {
  23790. return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
  23791. }
  23792. var clean_1$2 = clean$3;
  23793. var _require$$0$builders$3 = doc.builders;
  23794. var hardline$7 = _require$$0$builders$3.hardline;
  23795. var literalline$3 = _require$$0$builders$3.literalline;
  23796. var concat$9 = _require$$0$builders$3.concat;
  23797. var markAsRoot$1 = _require$$0$builders$3.markAsRoot;
  23798. var mapDoc$4 = doc.utils.mapDoc;
  23799. function embed$2(path$$1, print, textToDoc
  23800. /*, options */
  23801. ) {
  23802. var node = path$$1.getValue();
  23803. if (node.type === "yaml") {
  23804. return markAsRoot$1(concat$9(["---", hardline$7, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  23805. parser: "yaml"
  23806. })) : "", "---", hardline$7]));
  23807. }
  23808. return null;
  23809. function replaceNewlinesWithLiterallines(doc$$2) {
  23810. return mapDoc$4(doc$$2, function (currentDoc) {
  23811. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$9(currentDoc.split(/(\n)/g).map(function (v, i) {
  23812. return i % 2 === 0 ? v : literalline$3;
  23813. })) : currentDoc;
  23814. });
  23815. }
  23816. }
  23817. var embed_1$2 = embed$2;
  23818. var DELIMITER_MAP = {
  23819. "---": "yaml",
  23820. "+++": "toml"
  23821. };
  23822. function parse$5(text) {
  23823. var delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp).join("|");
  23824. var match = text.match( // trailing spaces after delimiters are allowed
  23825. new RegExp(`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`));
  23826. if (match === null) {
  23827. return {
  23828. frontMatter: null,
  23829. content: text
  23830. };
  23831. }
  23832. var raw = match[0].replace(/\n$/, "");
  23833. var delimiter = match[1];
  23834. var value = match[2];
  23835. return {
  23836. frontMatter: {
  23837. type: DELIMITER_MAP[delimiter],
  23838. value,
  23839. raw
  23840. },
  23841. content: match[0].replace(/[^\n]/g, " ") + text.slice(match[0].length)
  23842. };
  23843. }
  23844. var frontMatter = parse$5;
  23845. function hasPragma$1(text) {
  23846. return pragma.hasPragma(frontMatter(text).content);
  23847. }
  23848. function insertPragma$3(text) {
  23849. var _parseFrontMatter = frontMatter(text),
  23850. frontMatter$$1 = _parseFrontMatter.frontMatter,
  23851. content = _parseFrontMatter.content;
  23852. return (frontMatter$$1 ? frontMatter$$1.raw + "\n\n" : "") + pragma.insertPragma(content);
  23853. }
  23854. var pragma$2 = {
  23855. hasPragma: hasPragma$1,
  23856. insertPragma: insertPragma$3
  23857. };
  23858. var colorAdjusterFunctions = ["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"];
  23859. function getAncestorCounter(path$$1, typeOrTypes) {
  23860. var types = [].concat(typeOrTypes);
  23861. var counter = -1;
  23862. var ancestorNode;
  23863. while (ancestorNode = path$$1.getParentNode(++counter)) {
  23864. if (types.indexOf(ancestorNode.type) !== -1) {
  23865. return counter;
  23866. }
  23867. }
  23868. return -1;
  23869. }
  23870. function getAncestorNode$1(path$$1, typeOrTypes) {
  23871. var counter = getAncestorCounter(path$$1, typeOrTypes);
  23872. return counter === -1 ? null : path$$1.getParentNode(counter);
  23873. }
  23874. function getPropOfDeclNode$1(path$$1) {
  23875. var declAncestorNode = getAncestorNode$1(path$$1, "css-decl");
  23876. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  23877. }
  23878. function isSCSS$1(parser, text) {
  23879. var hasExplicitParserChoice = parser === "less" || parser === "scss";
  23880. var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
  23881. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  23882. }
  23883. function isWideKeywords$1(value) {
  23884. return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1;
  23885. }
  23886. function isKeyframeAtRuleKeywords$1(path$$1, value) {
  23887. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23888. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1;
  23889. }
  23890. function maybeToLowerCase$1(value) {
  23891. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  23892. }
  23893. function insideValueFunctionNode$1(path$$1, functionName) {
  23894. var funcAncestorNode = getAncestorNode$1(path$$1, "value-func");
  23895. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  23896. }
  23897. function insideICSSRuleNode$1(path$$1) {
  23898. var ruleAncestorNode = getAncestorNode$1(path$$1, "css-rule");
  23899. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  23900. }
  23901. function insideAtRuleNode$1(path$$1, atRuleNameOrAtRuleNames) {
  23902. var atRuleNames = [].concat(atRuleNameOrAtRuleNames);
  23903. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23904. return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1;
  23905. }
  23906. function insideURLFunctionInImportAtRuleNode$1(path$$1) {
  23907. var node = path$$1.getValue();
  23908. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23909. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  23910. }
  23911. function isURLFunctionNode$1(node) {
  23912. return node.type === "value-func" && node.value.toLowerCase() === "url";
  23913. }
  23914. function isLastNode$1(path$$1, node) {
  23915. var parentNode = path$$1.getParentNode();
  23916. if (!parentNode) {
  23917. return false;
  23918. }
  23919. var nodes = parentNode.nodes;
  23920. return nodes && nodes.indexOf(node) === nodes.length - 1;
  23921. }
  23922. function isHTMLTag$1(value) {
  23923. return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1;
  23924. }
  23925. function isDetachedRulesetDeclarationNode$1(node) {
  23926. // If a Less file ends up being parsed with the SCSS parser, Less
  23927. // variable declarations will be parsed as atrules with names ending
  23928. // with a colon, so keep the original case then.
  23929. if (!node.selector) {
  23930. return false;
  23931. }
  23932. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  23933. }
  23934. function isForKeywordNode$1(node) {
  23935. return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1;
  23936. }
  23937. function isIfElseKeywordNode$1(node) {
  23938. return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1;
  23939. }
  23940. function isEachKeywordNode$1(node) {
  23941. return node.type === "value-word" && node.value === "in";
  23942. }
  23943. function isMultiplicationNode$1(node) {
  23944. return node.type === "value-operator" && node.value === "*";
  23945. }
  23946. function isDivisionNode$1(node) {
  23947. return node.type === "value-operator" && node.value === "/";
  23948. }
  23949. function isAdditionNode$1(node) {
  23950. return node.type === "value-operator" && node.value === "+";
  23951. }
  23952. function isSubtractionNode$1(node) {
  23953. return node.type === "value-operator" && node.value === "-";
  23954. }
  23955. function isModuloNode(node) {
  23956. return node.type === "value-operator" && node.value === "%";
  23957. }
  23958. function isMathOperatorNode$1(node) {
  23959. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  23960. }
  23961. function isEqualityOperatorNode$1(node) {
  23962. return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
  23963. }
  23964. function isRelationalOperatorNode$1(node) {
  23965. return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1;
  23966. }
  23967. function isSCSSControlDirectiveNode$1(node) {
  23968. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1;
  23969. }
  23970. function isSCSSNestedPropertyNode(node) {
  23971. if (!node.selector) {
  23972. return false;
  23973. }
  23974. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  23975. }
  23976. function isDetachedRulesetCallNode$1(node) {
  23977. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  23978. }
  23979. function isTemplatePlaceholderNode$1(node) {
  23980. return node.name.startsWith("prettier-placeholder");
  23981. }
  23982. function isTemplatePropNode$1(node) {
  23983. return node.prop.startsWith("@prettier-placeholder");
  23984. }
  23985. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  23986. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  23987. }
  23988. function hasComposesNode$1(node) {
  23989. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  23990. }
  23991. function hasParensAroundNode$1(node) {
  23992. 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;
  23993. }
  23994. function hasEmptyRawBefore$1(node) {
  23995. return node.raws && node.raws.before === "";
  23996. }
  23997. function isKeyValuePairNode$1(node) {
  23998. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  23999. }
  24000. function isKeyValuePairInParenGroupNode(node) {
  24001. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  24002. }
  24003. function isSCSSMapItemNode$1(path$$1) {
  24004. var node = path$$1.getValue(); // Ignore empty item (i.e. `$key: ()`)
  24005. if (node.groups.length === 0) {
  24006. return false;
  24007. }
  24008. var parentParentNode = path$$1.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  24009. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  24010. return false;
  24011. }
  24012. var declNode = getAncestorNode$1(path$$1, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  24013. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  24014. return true;
  24015. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  24016. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  24017. return true;
  24018. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  24019. if (parentParentNode.type === "value-func") {
  24020. return true;
  24021. }
  24022. return false;
  24023. }
  24024. function isInlineValueCommentNode$1(node) {
  24025. return node.type === "value-comment" && node.inline;
  24026. }
  24027. function isHashNode$1(node) {
  24028. return node.type === "value-word" && node.value === "#";
  24029. }
  24030. function isLeftCurlyBraceNode$1(node) {
  24031. return node.type === "value-word" && node.value === "{";
  24032. }
  24033. function isRightCurlyBraceNode$1(node) {
  24034. return node.type === "value-word" && node.value === "}";
  24035. }
  24036. function isWordNode$1(node) {
  24037. return ["value-word", "value-atword"].indexOf(node.type) !== -1;
  24038. }
  24039. function isColonNode$1(node) {
  24040. return node.type === "value-colon";
  24041. }
  24042. function isMediaAndSupportsKeywords$1(node) {
  24043. return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
  24044. }
  24045. function isColorAdjusterFuncNode$1(node) {
  24046. if (node.type !== "value-func") {
  24047. return false;
  24048. }
  24049. return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
  24050. }
  24051. var utils$6 = {
  24052. getAncestorCounter,
  24053. getAncestorNode: getAncestorNode$1,
  24054. getPropOfDeclNode: getPropOfDeclNode$1,
  24055. maybeToLowerCase: maybeToLowerCase$1,
  24056. insideValueFunctionNode: insideValueFunctionNode$1,
  24057. insideICSSRuleNode: insideICSSRuleNode$1,
  24058. insideAtRuleNode: insideAtRuleNode$1,
  24059. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  24060. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  24061. isHTMLTag: isHTMLTag$1,
  24062. isWideKeywords: isWideKeywords$1,
  24063. isSCSS: isSCSS$1,
  24064. isLastNode: isLastNode$1,
  24065. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  24066. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  24067. isRelationalOperatorNode: isRelationalOperatorNode$1,
  24068. isEqualityOperatorNode: isEqualityOperatorNode$1,
  24069. isMultiplicationNode: isMultiplicationNode$1,
  24070. isDivisionNode: isDivisionNode$1,
  24071. isAdditionNode: isAdditionNode$1,
  24072. isSubtractionNode: isSubtractionNode$1,
  24073. isModuloNode,
  24074. isMathOperatorNode: isMathOperatorNode$1,
  24075. isEachKeywordNode: isEachKeywordNode$1,
  24076. isForKeywordNode: isForKeywordNode$1,
  24077. isURLFunctionNode: isURLFunctionNode$1,
  24078. isIfElseKeywordNode: isIfElseKeywordNode$1,
  24079. hasComposesNode: hasComposesNode$1,
  24080. hasParensAroundNode: hasParensAroundNode$1,
  24081. hasEmptyRawBefore: hasEmptyRawBefore$1,
  24082. isSCSSNestedPropertyNode,
  24083. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  24084. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  24085. isTemplatePropNode: isTemplatePropNode$1,
  24086. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  24087. isKeyValuePairNode: isKeyValuePairNode$1,
  24088. isKeyValuePairInParenGroupNode,
  24089. isSCSSMapItemNode: isSCSSMapItemNode$1,
  24090. isInlineValueCommentNode: isInlineValueCommentNode$1,
  24091. isHashNode: isHashNode$1,
  24092. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  24093. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  24094. isWordNode: isWordNode$1,
  24095. isColonNode: isColonNode$1,
  24096. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  24097. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
  24098. };
  24099. var insertPragma$2 = pragma$2.insertPragma;
  24100. var printNumber$2 = util$1.printNumber;
  24101. var printString$2 = util$1.printString;
  24102. var hasIgnoreComment$2 = util$1.hasIgnoreComment;
  24103. var hasNewline$3 = util$1.hasNewline;
  24104. var isNextLineEmpty$3 = utilShared.isNextLineEmpty;
  24105. var _require$$3$builders = doc.builders;
  24106. var concat$8 = _require$$3$builders.concat;
  24107. var join$6 = _require$$3$builders.join;
  24108. var line$5 = _require$$3$builders.line;
  24109. var hardline$6 = _require$$3$builders.hardline;
  24110. var softline$3 = _require$$3$builders.softline;
  24111. var group$6 = _require$$3$builders.group;
  24112. var fill$3 = _require$$3$builders.fill;
  24113. var indent$5 = _require$$3$builders.indent;
  24114. var dedent$3 = _require$$3$builders.dedent;
  24115. var ifBreak$2 = _require$$3$builders.ifBreak;
  24116. var removeLines$2 = doc.utils.removeLines;
  24117. var getAncestorNode = utils$6.getAncestorNode;
  24118. var getPropOfDeclNode = utils$6.getPropOfDeclNode;
  24119. var maybeToLowerCase = utils$6.maybeToLowerCase;
  24120. var insideValueFunctionNode = utils$6.insideValueFunctionNode;
  24121. var insideICSSRuleNode = utils$6.insideICSSRuleNode;
  24122. var insideAtRuleNode = utils$6.insideAtRuleNode;
  24123. var insideURLFunctionInImportAtRuleNode = utils$6.insideURLFunctionInImportAtRuleNode;
  24124. var isKeyframeAtRuleKeywords = utils$6.isKeyframeAtRuleKeywords;
  24125. var isHTMLTag = utils$6.isHTMLTag;
  24126. var isWideKeywords = utils$6.isWideKeywords;
  24127. var isSCSS = utils$6.isSCSS;
  24128. var isLastNode = utils$6.isLastNode;
  24129. var isSCSSControlDirectiveNode = utils$6.isSCSSControlDirectiveNode;
  24130. var isDetachedRulesetDeclarationNode = utils$6.isDetachedRulesetDeclarationNode;
  24131. var isRelationalOperatorNode = utils$6.isRelationalOperatorNode;
  24132. var isEqualityOperatorNode = utils$6.isEqualityOperatorNode;
  24133. var isMultiplicationNode = utils$6.isMultiplicationNode;
  24134. var isDivisionNode = utils$6.isDivisionNode;
  24135. var isAdditionNode = utils$6.isAdditionNode;
  24136. var isSubtractionNode = utils$6.isSubtractionNode;
  24137. var isMathOperatorNode = utils$6.isMathOperatorNode;
  24138. var isEachKeywordNode = utils$6.isEachKeywordNode;
  24139. var isForKeywordNode = utils$6.isForKeywordNode;
  24140. var isURLFunctionNode = utils$6.isURLFunctionNode;
  24141. var isIfElseKeywordNode = utils$6.isIfElseKeywordNode;
  24142. var hasComposesNode = utils$6.hasComposesNode;
  24143. var hasParensAroundNode = utils$6.hasParensAroundNode;
  24144. var hasEmptyRawBefore = utils$6.hasEmptyRawBefore;
  24145. var isKeyValuePairNode = utils$6.isKeyValuePairNode;
  24146. var isDetachedRulesetCallNode = utils$6.isDetachedRulesetCallNode;
  24147. var isTemplatePlaceholderNode = utils$6.isTemplatePlaceholderNode;
  24148. var isTemplatePropNode = utils$6.isTemplatePropNode;
  24149. var isPostcssSimpleVarNode = utils$6.isPostcssSimpleVarNode;
  24150. var isSCSSMapItemNode = utils$6.isSCSSMapItemNode;
  24151. var isInlineValueCommentNode = utils$6.isInlineValueCommentNode;
  24152. var isHashNode = utils$6.isHashNode;
  24153. var isLeftCurlyBraceNode = utils$6.isLeftCurlyBraceNode;
  24154. var isRightCurlyBraceNode = utils$6.isRightCurlyBraceNode;
  24155. var isWordNode = utils$6.isWordNode;
  24156. var isColonNode = utils$6.isColonNode;
  24157. var isMediaAndSupportsKeywords = utils$6.isMediaAndSupportsKeywords;
  24158. var isColorAdjusterFuncNode = utils$6.isColorAdjusterFuncNode;
  24159. function shouldPrintComma$1(options) {
  24160. switch (options.trailingComma) {
  24161. case "all":
  24162. case "es5":
  24163. return true;
  24164. case "none":
  24165. default:
  24166. return false;
  24167. }
  24168. }
  24169. function genericPrint$2(path$$1, options, print) {
  24170. var node = path$$1.getValue();
  24171. /* istanbul ignore if */
  24172. if (!node) {
  24173. return "";
  24174. }
  24175. if (typeof node === "string") {
  24176. return node;
  24177. }
  24178. switch (node.type) {
  24179. case "yaml":
  24180. case "toml":
  24181. return concat$8([node.raw, hardline$6]);
  24182. case "css-root":
  24183. {
  24184. var nodes = printNodeSequence(path$$1, options, print);
  24185. if (nodes.parts.length) {
  24186. return concat$8([nodes, hardline$6]);
  24187. }
  24188. return nodes;
  24189. }
  24190. case "css-comment":
  24191. {
  24192. if (node.raws.content) {
  24193. return node.raws.content;
  24194. }
  24195. var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
  24196. var rawText = node.raws.text || node.text; // Workaround a bug where the location is off.
  24197. // https://github.com/postcss/postcss-scss/issues/63
  24198. if (text.indexOf(rawText) === -1) {
  24199. if (node.raws.inline) {
  24200. return concat$8(["// ", rawText]);
  24201. }
  24202. return concat$8(["/* ", rawText, " */"]);
  24203. }
  24204. return text;
  24205. }
  24206. case "css-rule":
  24207. {
  24208. return concat$8([path$$1.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$8([" {", node.nodes.length > 0 ? indent$5(concat$8([hardline$6, printNodeSequence(path$$1, options, print)])) : "", hardline$6, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""]) : ";"]);
  24209. }
  24210. case "css-decl":
  24211. {
  24212. var parentNode = path$$1.getParentNode();
  24213. return concat$8([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path$$1) ? node.prop : maybeToLowerCase(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode(node) ? removeLines$2(path$$1.call(print, "value")) : path$$1.call(print, "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 ? concat$8([" {", indent$5(concat$8([softline$3, printNodeSequence(path$$1, options, print)])), softline$3, "}"]) : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  24214. }
  24215. case "css-atrule":
  24216. {
  24217. var _parentNode = path$$1.getParentNode();
  24218. return concat$8(["@", // If a Less file ends up being parsed with the SCSS parser, Less
  24219. // variable declarations will be parsed as at-rules with names ending
  24220. // with a colon, so keep the original case then.
  24221. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$8([isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) && /^\s*\n/.test(node.raws.afterName) ? /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$8([hardline$6, hardline$6]) : hardline$6 : " ", path$$1.call(print, "params")]) : "", node.selector ? indent$5(concat$8([" ", path$$1.call(print, "selector")])) : "", node.value ? group$6(concat$8([" ", path$$1.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$5 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$8([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$5(concat$8([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path$$1, options, print)])), softline$3, "}"]) : isTemplatePlaceholderNode(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  24222. }
  24223. // postcss-media-query-parser
  24224. case "media-query-list":
  24225. {
  24226. var parts = [];
  24227. path$$1.each(function (childPath) {
  24228. var node = childPath.getValue();
  24229. if (node.type === "media-query" && node.value === "") {
  24230. return;
  24231. }
  24232. parts.push(childPath.call(print));
  24233. }, "nodes");
  24234. return group$6(indent$5(join$6(line$5, parts)));
  24235. }
  24236. case "media-query":
  24237. {
  24238. return concat$8([join$6(" ", path$$1.map(print, "nodes")), isLastNode(path$$1, node) ? "" : ","]);
  24239. }
  24240. case "media-type":
  24241. {
  24242. return adjustNumbers(adjustStrings(node.value, options));
  24243. }
  24244. case "media-feature-expression":
  24245. {
  24246. if (!node.nodes) {
  24247. return node.value;
  24248. }
  24249. return concat$8(["(", concat$8(path$$1.map(print, "nodes")), ")"]);
  24250. }
  24251. case "media-feature":
  24252. {
  24253. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  24254. }
  24255. case "media-colon":
  24256. {
  24257. return concat$8([node.value, " "]);
  24258. }
  24259. case "media-value":
  24260. {
  24261. return adjustNumbers(adjustStrings(node.value, options));
  24262. }
  24263. case "media-keyword":
  24264. {
  24265. return adjustStrings(node.value, options);
  24266. }
  24267. case "media-url":
  24268. {
  24269. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
  24270. }
  24271. case "media-unknown":
  24272. {
  24273. return node.value;
  24274. }
  24275. // postcss-selector-parser
  24276. case "selector-root":
  24277. {
  24278. return group$6(concat$8([insideAtRuleNode(path$$1, "custom-selector") ? concat$8([getAncestorNode(path$$1, "css-atrule").customSelector, line$5]) : "", join$6(concat$8([",", insideAtRuleNode(path$$1, ["extend", "custom-selector", "nest"]) ? line$5 : hardline$6]), path$$1.map(print, "nodes"))]));
  24279. }
  24280. case "selector-selector":
  24281. {
  24282. return group$6(indent$5(concat$8(path$$1.map(print, "nodes"))));
  24283. }
  24284. case "selector-comment":
  24285. {
  24286. return node.value;
  24287. }
  24288. case "selector-string":
  24289. {
  24290. return adjustStrings(node.value, options);
  24291. }
  24292. case "selector-tag":
  24293. {
  24294. var _parentNode2 = path$$1.getParentNode();
  24295. var index = _parentNode2 && _parentNode2.nodes.indexOf(node);
  24296. var prevNode = index && _parentNode2.nodes[index - 1];
  24297. return concat$8([node.namespace ? concat$8([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isHTMLTag(node.value) || isKeyframeAtRuleKeywords(path$$1, node.value) ? node.value.toLowerCase() : node.value)]);
  24298. }
  24299. case "selector-id":
  24300. {
  24301. return concat$8(["#", node.value]);
  24302. }
  24303. case "selector-class":
  24304. {
  24305. return concat$8([".", adjustNumbers(adjustStrings(node.value, options))]);
  24306. }
  24307. case "selector-attribute":
  24308. {
  24309. return concat$8(["[", node.namespace ? concat$8([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" : "", "]"]);
  24310. }
  24311. case "selector-combinator":
  24312. {
  24313. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  24314. var _parentNode3 = path$$1.getParentNode();
  24315. var _leading = _parentNode3.type === "selector-selector" && _parentNode3.nodes[0] === node ? "" : line$5;
  24316. return concat$8([_leading, node.value, isLastNode(path$$1, node) ? "" : " "]);
  24317. }
  24318. var leading = node.value.trim().startsWith("(") ? line$5 : "";
  24319. var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$5;
  24320. return concat$8([leading, value]);
  24321. }
  24322. case "selector-universal":
  24323. {
  24324. return concat$8([node.namespace ? concat$8([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
  24325. }
  24326. case "selector-pseudo":
  24327. {
  24328. return concat$8([maybeToLowerCase(node.value), node.nodes && node.nodes.length > 0 ? concat$8(["(", join$6(", ", path$$1.map(print, "nodes")), ")"]) : ""]);
  24329. }
  24330. case "selector-nesting":
  24331. {
  24332. return node.value;
  24333. }
  24334. case "selector-unknown":
  24335. {
  24336. var ruleAncestorNode = getAncestorNode(path$$1, "css-rule"); // Nested SCSS property
  24337. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  24338. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  24339. }
  24340. return node.value;
  24341. }
  24342. // postcss-values-parser
  24343. case "value-value":
  24344. case "value-root":
  24345. {
  24346. return path$$1.call(print, "group");
  24347. }
  24348. case "value-comment":
  24349. {
  24350. return concat$8([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]);
  24351. }
  24352. case "value-comma_group":
  24353. {
  24354. var _parentNode4 = path$$1.getParentNode();
  24355. var parentParentNode = path$$1.getParentNode(1);
  24356. var declAncestorProp = getPropOfDeclNode(path$$1);
  24357. var isGridValue = declAncestorProp && _parentNode4.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  24358. var atRuleAncestorNode = getAncestorNode(path$$1, "css-atrule");
  24359. var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  24360. var printed = path$$1.map(print, "groups");
  24361. var _parts = [];
  24362. var insideURLFunction = insideValueFunctionNode(path$$1, "url");
  24363. var insideSCSSInterpolationInString = false;
  24364. var didBreak = false;
  24365. for (var i = 0; i < node.groups.length; ++i) {
  24366. _parts.push(printed[i]); // Ignore value inside `url()`
  24367. if (insideURLFunction) {
  24368. continue;
  24369. }
  24370. var iPrevNode = node.groups[i - 1];
  24371. var iNode = node.groups[i];
  24372. var iNextNode = node.groups[i + 1];
  24373. var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon)
  24374. if (!iNextNode) {
  24375. continue;
  24376. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  24377. var isStartSCSSinterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  24378. var isEndingSCSSinterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  24379. if (isStartSCSSinterpolationInString || isEndingSCSSinterpolationInString) {
  24380. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  24381. continue;
  24382. }
  24383. if (insideSCSSInterpolationInString) {
  24384. continue;
  24385. } // Ignore colon (i.e. `:`)
  24386. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  24387. continue;
  24388. } // Ignore `@` in Less (i.e. `@@var;`)
  24389. if (iNode.type === "value-atword" && iNode.value === "") {
  24390. continue;
  24391. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  24392. if (iNode.value === "~") {
  24393. continue;
  24394. } // Ignore escape `\`
  24395. if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
  24396. continue;
  24397. } // Ignore escaped `/`
  24398. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  24399. continue;
  24400. } // Ignore `\` (i.e. `$variable: \@small;`)
  24401. if (iNode.value === "\\") {
  24402. continue;
  24403. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  24404. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  24405. continue;
  24406. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  24407. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  24408. continue;
  24409. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  24410. if (iNode.value === "--" && isHashNode(iNextNode)) {
  24411. continue;
  24412. } // Formatting math operations
  24413. var isMathOperator = isMathOperatorNode(iNode);
  24414. var isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  24415. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  24416. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  24417. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  24418. continue;
  24419. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  24420. // due to the fact that it is not valid syntax
  24421. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  24422. if (insideValueFunctionNode(path$$1, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  24423. continue;
  24424. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  24425. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  24426. var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  24427. var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  24428. var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  24429. if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "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)))) {
  24430. continue;
  24431. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  24432. if (isInlineValueCommentNode(iNode)) {
  24433. _parts.push(hardline$6);
  24434. continue;
  24435. } // Handle keywords in SCSS control directive
  24436. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  24437. _parts.push(" ");
  24438. continue;
  24439. } // At-rule `namespace` should be in one line
  24440. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  24441. _parts.push(" ");
  24442. continue;
  24443. } // Formatting `grid` property
  24444. if (isGridValue) {
  24445. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  24446. _parts.push(hardline$6);
  24447. didBreak = true;
  24448. } else {
  24449. _parts.push(" ");
  24450. }
  24451. continue;
  24452. } // Add `space` before next math operation
  24453. // Note: `grip` property have `/` delimiter and it is not math operation, so
  24454. // `grid` property handles above
  24455. if (isNextMathOperator) {
  24456. _parts.push(" ");
  24457. continue;
  24458. } // Be default all values go through `line`
  24459. _parts.push(line$5);
  24460. }
  24461. if (didBreak) {
  24462. _parts.unshift(hardline$6);
  24463. }
  24464. if (isControlDirective) {
  24465. return group$6(indent$5(concat$8(_parts)));
  24466. } // Indent is not needed for import url when url is very long
  24467. // and node has two groups
  24468. // when type is value-comma_group
  24469. // example @import url("verylongurl") projection,tv
  24470. if (insideURLFunctionInImportAtRuleNode(path$$1)) {
  24471. return group$6(fill$3(_parts));
  24472. }
  24473. return group$6(indent$5(fill$3(_parts)));
  24474. }
  24475. case "value-paren_group":
  24476. {
  24477. var _parentNode5 = path$$1.getParentNode();
  24478. if (_parentNode5 && isURLFunctionNode(_parentNode5) && (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:"))) {
  24479. return concat$8([node.open ? path$$1.call(print, "open") : "", join$6(",", path$$1.map(print, "groups")), node.close ? path$$1.call(print, "close") : ""]);
  24480. }
  24481. if (!node.open) {
  24482. var _printed = path$$1.map(print, "groups");
  24483. var res = [];
  24484. for (var _i = 0; _i < _printed.length; _i++) {
  24485. if (_i !== 0) {
  24486. res.push(concat$8([",", line$5]));
  24487. }
  24488. res.push(_printed[_i]);
  24489. }
  24490. return group$6(indent$5(fill$3(res)));
  24491. }
  24492. var isSCSSMapItem = isSCSSMapItemNode(path$$1);
  24493. return group$6(concat$8([node.open ? path$$1.call(print, "open") : "", indent$5(concat$8([softline$3, join$6(concat$8([",", line$5]), path$$1.map(function (childPath) {
  24494. var node = childPath.getValue();
  24495. var printed = print(childPath); // Key/Value pair in open paren already indented
  24496. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
  24497. printed.contents.contents.parts[1] = group$6(printed.contents.contents.parts[1]);
  24498. return group$6(dedent$3(printed));
  24499. }
  24500. return printed;
  24501. }, "groups"))])), ifBreak$2(isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path$$1.call(print, "close") : ""]), {
  24502. shouldBreak: isSCSSMapItem
  24503. });
  24504. }
  24505. case "value-func":
  24506. {
  24507. return concat$8([node.value, insideAtRuleNode(path$$1, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", path$$1.call(print, "group")]);
  24508. }
  24509. case "value-paren":
  24510. {
  24511. return node.value;
  24512. }
  24513. case "value-number":
  24514. {
  24515. return concat$8([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
  24516. }
  24517. case "value-operator":
  24518. {
  24519. return node.value;
  24520. }
  24521. case "value-word":
  24522. {
  24523. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  24524. return node.value.toLowerCase();
  24525. }
  24526. return node.value;
  24527. }
  24528. case "value-colon":
  24529. {
  24530. return concat$8([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  24531. insideValueFunctionNode(path$$1, "url") ? "" : line$5]);
  24532. }
  24533. case "value-comma":
  24534. {
  24535. return concat$8([node.value, " "]);
  24536. }
  24537. case "value-string":
  24538. {
  24539. return printString$2(node.raws.quote + node.value + node.raws.quote, options);
  24540. }
  24541. case "value-atword":
  24542. {
  24543. return concat$8(["@", node.value]);
  24544. }
  24545. case "value-unicode-range":
  24546. {
  24547. return node.value;
  24548. }
  24549. case "value-unknown":
  24550. {
  24551. return node.value;
  24552. }
  24553. default:
  24554. /* istanbul ignore next */
  24555. throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
  24556. }
  24557. }
  24558. function printNodeSequence(path$$1, options, print) {
  24559. var node = path$$1.getValue();
  24560. var parts = [];
  24561. var i = 0;
  24562. path$$1.map(function (pathChild) {
  24563. var prevNode = node.nodes[i - 1];
  24564. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  24565. var childNode = pathChild.getValue();
  24566. parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
  24567. } else {
  24568. parts.push(pathChild.call(print));
  24569. }
  24570. if (i !== node.nodes.length - 1) {
  24571. if (node.nodes[i + 1].type === "css-comment" && !hasNewline$3(options.originalText, options.locStart(node.nodes[i + 1]), {
  24572. backwards: true
  24573. }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
  24574. parts.push(" ");
  24575. } else {
  24576. parts.push(hardline$6);
  24577. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
  24578. parts.push(hardline$6);
  24579. }
  24580. }
  24581. }
  24582. i++;
  24583. }, "nodes");
  24584. return concat$8(parts);
  24585. }
  24586. var STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
  24587. var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
  24588. var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
  24589. var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
  24590. var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX.source + `|` + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
  24591. function adjustStrings(value, options) {
  24592. return value.replace(STRING_REGEX, function (match) {
  24593. return printString$2(match, options);
  24594. });
  24595. }
  24596. function quoteAttributeValue(value, options) {
  24597. var quote = options.singleQuote ? "'" : '"';
  24598. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  24599. }
  24600. function adjustNumbers(value) {
  24601. return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) {
  24602. return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase(unit || "") : match;
  24603. });
  24604. }
  24605. function printCssNumber(rawNumber) {
  24606. return printNumber$2(rawNumber) // Remove trailing `.0`.
  24607. .replace(/\.0(?=$|e)/, "");
  24608. }
  24609. var printerPostcss = {
  24610. print: genericPrint$2,
  24611. embed: embed_1$2,
  24612. insertPragma: insertPragma$2,
  24613. hasPrettierIgnore: hasIgnoreComment$2,
  24614. massageAstNode: clean_1$2
  24615. };
  24616. var options$7 = {
  24617. singleQuote: commonOptions.singleQuote
  24618. };
  24619. var name$7 = "CSS";
  24620. var type$6 = "markup";
  24621. var tmScope$6 = "source.css";
  24622. var aceMode$6 = "css";
  24623. var codemirrorMode$6 = "css";
  24624. var codemirrorMimeType$6 = "text/css";
  24625. var color$2 = "#563d7c";
  24626. var extensions$6 = [".css"];
  24627. var languageId$6 = 50;
  24628. var css$2 = {
  24629. name: name$7,
  24630. type: type$6,
  24631. tmScope: tmScope$6,
  24632. aceMode: aceMode$6,
  24633. codemirrorMode: codemirrorMode$6,
  24634. codemirrorMimeType: codemirrorMimeType$6,
  24635. color: color$2,
  24636. extensions: extensions$6,
  24637. languageId: languageId$6
  24638. };
  24639. var css$3 = Object.freeze({
  24640. name: name$7,
  24641. type: type$6,
  24642. tmScope: tmScope$6,
  24643. aceMode: aceMode$6,
  24644. codemirrorMode: codemirrorMode$6,
  24645. codemirrorMimeType: codemirrorMimeType$6,
  24646. color: color$2,
  24647. extensions: extensions$6,
  24648. languageId: languageId$6,
  24649. default: css$2
  24650. });
  24651. var name$8 = "PostCSS";
  24652. var type$7 = "markup";
  24653. var tmScope$7 = "source.postcss";
  24654. var group$7 = "CSS";
  24655. var extensions$7 = [".pcss"];
  24656. var aceMode$7 = "text";
  24657. var languageId$7 = 262764437;
  24658. var postcss = {
  24659. name: name$8,
  24660. type: type$7,
  24661. tmScope: tmScope$7,
  24662. group: group$7,
  24663. extensions: extensions$7,
  24664. aceMode: aceMode$7,
  24665. languageId: languageId$7
  24666. };
  24667. var postcss$1 = Object.freeze({
  24668. name: name$8,
  24669. type: type$7,
  24670. tmScope: tmScope$7,
  24671. group: group$7,
  24672. extensions: extensions$7,
  24673. aceMode: aceMode$7,
  24674. languageId: languageId$7,
  24675. default: postcss
  24676. });
  24677. var name$9 = "Less";
  24678. var type$8 = "markup";
  24679. var group$8 = "CSS";
  24680. var extensions$8 = [".less"];
  24681. var tmScope$8 = "source.css.less";
  24682. var aceMode$8 = "less";
  24683. var codemirrorMode$7 = "css";
  24684. var codemirrorMimeType$7 = "text/css";
  24685. var languageId$8 = 198;
  24686. var less = {
  24687. name: name$9,
  24688. type: type$8,
  24689. group: group$8,
  24690. extensions: extensions$8,
  24691. tmScope: tmScope$8,
  24692. aceMode: aceMode$8,
  24693. codemirrorMode: codemirrorMode$7,
  24694. codemirrorMimeType: codemirrorMimeType$7,
  24695. languageId: languageId$8
  24696. };
  24697. var less$1 = Object.freeze({
  24698. name: name$9,
  24699. type: type$8,
  24700. group: group$8,
  24701. extensions: extensions$8,
  24702. tmScope: tmScope$8,
  24703. aceMode: aceMode$8,
  24704. codemirrorMode: codemirrorMode$7,
  24705. codemirrorMimeType: codemirrorMimeType$7,
  24706. languageId: languageId$8,
  24707. default: less
  24708. });
  24709. var name$10 = "SCSS";
  24710. var type$9 = "markup";
  24711. var tmScope$9 = "source.scss";
  24712. var group$9 = "CSS";
  24713. var aceMode$9 = "scss";
  24714. var codemirrorMode$8 = "css";
  24715. var codemirrorMimeType$8 = "text/x-scss";
  24716. var extensions$9 = [".scss"];
  24717. var languageId$9 = 329;
  24718. var scss = {
  24719. name: name$10,
  24720. type: type$9,
  24721. tmScope: tmScope$9,
  24722. group: group$9,
  24723. aceMode: aceMode$9,
  24724. codemirrorMode: codemirrorMode$8,
  24725. codemirrorMimeType: codemirrorMimeType$8,
  24726. extensions: extensions$9,
  24727. languageId: languageId$9
  24728. };
  24729. var scss$1 = Object.freeze({
  24730. name: name$10,
  24731. type: type$9,
  24732. tmScope: tmScope$9,
  24733. group: group$9,
  24734. aceMode: aceMode$9,
  24735. codemirrorMode: codemirrorMode$8,
  24736. codemirrorMimeType: codemirrorMimeType$8,
  24737. extensions: extensions$9,
  24738. languageId: languageId$9,
  24739. default: scss
  24740. });
  24741. var require$$0$23 = ( css$3 && css$2 ) || css$3;
  24742. var require$$1$11 = ( postcss$1 && postcss ) || postcss$1;
  24743. var require$$2$11 = ( less$1 && less ) || less$1;
  24744. var require$$3$4 = ( scss$1 && scss ) || scss$1;
  24745. var languages$1 = [createLanguage(require$$0$23, {
  24746. override: {
  24747. since: "1.4.0",
  24748. parsers: ["css"],
  24749. vscodeLanguageIds: ["css"]
  24750. }
  24751. }), createLanguage(require$$1$11, {
  24752. override: {
  24753. since: "1.4.0",
  24754. parsers: ["css"],
  24755. vscodeLanguageIds: ["postcss"]
  24756. },
  24757. extend: {
  24758. extensions: [".postcss"]
  24759. }
  24760. }), createLanguage(require$$2$11, {
  24761. override: {
  24762. since: "1.4.0",
  24763. parsers: ["less"],
  24764. vscodeLanguageIds: ["less"]
  24765. }
  24766. }), createLanguage(require$$3$4, {
  24767. override: {
  24768. since: "1.4.0",
  24769. parsers: ["scss"],
  24770. vscodeLanguageIds: ["scss"]
  24771. }
  24772. })];
  24773. var printers$1 = {
  24774. postcss: printerPostcss
  24775. };
  24776. var languageCss = {
  24777. languages: languages$1,
  24778. options: options$7,
  24779. printers: printers$1
  24780. };
  24781. var _require$$0$builders$4 = doc.builders;
  24782. var concat$10 = _require$$0$builders$4.concat;
  24783. var join$7 = _require$$0$builders$4.join;
  24784. var softline$4 = _require$$0$builders$4.softline;
  24785. var hardline$8 = _require$$0$builders$4.hardline;
  24786. var line$6 = _require$$0$builders$4.line;
  24787. var group$10 = _require$$0$builders$4.group;
  24788. var indent$6 = _require$$0$builders$4.indent;
  24789. var ifBreak$3 = _require$$0$builders$4.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
  24790. var voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
  24791. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  24792. function print(path$$1, options, print) {
  24793. var n = path$$1.getValue();
  24794. /* istanbul ignore if*/
  24795. if (!n) {
  24796. return "";
  24797. }
  24798. switch (n.type) {
  24799. case "Program":
  24800. {
  24801. return group$10(join$7(softline$4, path$$1.map(print, "body").filter(function (text) {
  24802. return text !== "";
  24803. })));
  24804. }
  24805. case "ElementNode":
  24806. {
  24807. var tagFirstChar = n.tag[0];
  24808. var isLocal = n.tag.indexOf(".") !== -1;
  24809. var isGlimmerComponent = tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
  24810. var hasChildren = n.children.length > 0;
  24811. var isVoid = isGlimmerComponent && !hasChildren || voidTags.indexOf(n.tag) !== -1;
  24812. var closeTagForNoBreak = isVoid ? concat$10([" />", softline$4]) : ">";
  24813. var closeTagForBreak = isVoid ? "/>" : ">";
  24814. var _getParams = function _getParams(path$$1, print) {
  24815. return indent$6(concat$10([n.attributes.length ? line$6 : "", join$7(line$6, path$$1.map(print, "attributes")), n.modifiers.length ? line$6 : "", join$7(line$6, path$$1.map(print, "modifiers")), n.comments.length ? line$6 : "", join$7(line$6, path$$1.map(print, "comments"))]));
  24816. };
  24817. return concat$10([group$10(concat$10(["<", n.tag, _getParams(path$$1, print), n.blockParams.length ? ` as |${n.blockParams.join(" ")}|` : "", ifBreak$3(softline$4, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), group$10(concat$10([indent$6(join$7(softline$4, [""].concat(path$$1.map(print, "children")))), ifBreak$3(hasChildren ? hardline$8 : "", ""), !isVoid ? concat$10(["</", n.tag, ">"]) : ""]))]);
  24818. }
  24819. case "BlockStatement":
  24820. {
  24821. var pp = path$$1.getParentNode(1);
  24822. var isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
  24823. var hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
  24824. var indentElse = hasElseIf ? function (a) {
  24825. return a;
  24826. } : indent$6;
  24827. if (n.inverse) {
  24828. return concat$10([isElseIf ? concat$10(["{{else ", printPathParams(path$$1, print), "}}"]) : printOpenBlock(path$$1, print), indent$6(concat$10([hardline$8, path$$1.call(print, "program")])), n.inverse && !hasElseIf ? concat$10([hardline$8, "{{else}}"]) : "", n.inverse ? indentElse(concat$10([hardline$8, path$$1.call(print, "inverse")])) : "", isElseIf ? "" : concat$10([hardline$8, printCloseBlock(path$$1, print)])]);
  24829. } else if (isElseIf) {
  24830. return concat$10([concat$10(["{{else ", printPathParams(path$$1, print), "}}"]), indent$6(concat$10([hardline$8, path$$1.call(print, "program")]))]);
  24831. }
  24832. /**
  24833. * I want this boolean to be: if params are going to cause a break,
  24834. * not that it has params.
  24835. */
  24836. var hasParams = n.params.length > 0 || n.hash.pairs.length > 0;
  24837. var _hasChildren = n.program.body.length > 0;
  24838. return concat$10([printOpenBlock(path$$1, print), group$10(concat$10([indent$6(concat$10([softline$4, path$$1.call(print, "program")])), hasParams && _hasChildren ? hardline$8 : softline$4, printCloseBlock(path$$1, print)]))]);
  24839. }
  24840. case "ElementModifierStatement":
  24841. case "MustacheStatement":
  24842. {
  24843. var _pp = path$$1.getParentNode(1);
  24844. var isConcat = _pp && _pp.type === "ConcatStatement";
  24845. return group$10(concat$10([n.escaped === false ? "{{{" : "{{", printPathParams(path$$1, print), isConcat ? "" : softline$4, n.escaped === false ? "}}}" : "}}"]));
  24846. }
  24847. case "SubExpression":
  24848. {
  24849. var params = getParams(path$$1, print);
  24850. var printedParams = params.length > 0 ? indent$6(concat$10([line$6, group$10(join$7(line$6, params))])) : "";
  24851. return group$10(concat$10(["(", printPath(path$$1, print), printedParams, softline$4, ")"]));
  24852. }
  24853. case "AttrNode":
  24854. {
  24855. var isText = n.value.type === "TextNode";
  24856. if (isText && n.value.loc.start.column === n.value.loc.end.column) {
  24857. return concat$10([n.name]);
  24858. }
  24859. var quote = isText ? '"' : "";
  24860. return concat$10([n.name, "=", quote, path$$1.call(print, "value"), quote]);
  24861. }
  24862. case "ConcatStatement":
  24863. {
  24864. return concat$10(['"', group$10(indent$6(join$7(softline$4, path$$1.map(function (partPath) {
  24865. return print(partPath);
  24866. }, "parts").filter(function (a) {
  24867. return a !== "";
  24868. })))), '"']);
  24869. }
  24870. case "Hash":
  24871. {
  24872. return concat$10([join$7(line$6, path$$1.map(print, "pairs"))]);
  24873. }
  24874. case "HashPair":
  24875. {
  24876. return concat$10([n.key, "=", path$$1.call(print, "value")]);
  24877. }
  24878. case "TextNode":
  24879. {
  24880. var leadingSpace = "";
  24881. var trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present, when next to mustache statement.
  24882. var inAttrNode = path$$1.stack.indexOf("attributes") >= 0;
  24883. if (inAttrNode) {
  24884. var parentNode = path$$1.getParentNode(0);
  24885. var _isConcat = parentNode.type === "ConcatStatement";
  24886. if (_isConcat) {
  24887. var parts = parentNode.parts;
  24888. var partIndex = parts.indexOf(n);
  24889. if (partIndex > 0) {
  24890. var partType = parts[partIndex - 1].type;
  24891. var isMustache = partType === "MustacheStatement";
  24892. if (isMustache) {
  24893. leadingSpace = " ";
  24894. }
  24895. }
  24896. if (partIndex < parts.length - 1) {
  24897. var _partType = parts[partIndex + 1].type;
  24898. var _isMustache = _partType === "MustacheStatement";
  24899. if (_isMustache) {
  24900. trailingSpace = " ";
  24901. }
  24902. }
  24903. }
  24904. }
  24905. return n.chars.replace(/^\s+/, leadingSpace).replace(/\s+$/, trailingSpace);
  24906. }
  24907. case "MustacheCommentStatement":
  24908. {
  24909. var dashes = n.value.indexOf("}}") > -1 ? "--" : "";
  24910. return concat$10(["{{!", dashes, n.value, dashes, "}}"]);
  24911. }
  24912. case "PathExpression":
  24913. {
  24914. return n.original;
  24915. }
  24916. case "BooleanLiteral":
  24917. {
  24918. return String(n.value);
  24919. }
  24920. case "CommentStatement":
  24921. {
  24922. return concat$10(["<!--", n.value, "-->"]);
  24923. }
  24924. case "StringLiteral":
  24925. {
  24926. return printStringLiteral(n.value, options);
  24927. }
  24928. case "NumberLiteral":
  24929. {
  24930. return String(n.value);
  24931. }
  24932. case "UndefinedLiteral":
  24933. {
  24934. return "undefined";
  24935. }
  24936. case "NullLiteral":
  24937. {
  24938. return "null";
  24939. }
  24940. /* istanbul ignore next */
  24941. default:
  24942. throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
  24943. }
  24944. }
  24945. /**
  24946. * Prints a string literal with the correct surrounding quotes based on
  24947. * `options.singleQuote` and the number of escaped quotes contained in
  24948. * the string literal. This function is the glimmer equivalent of `printString`
  24949. * in `common/util`, but has differences because of the way escaped characters
  24950. * are treated in hbs string literals.
  24951. * @param {string} stringLiteral - the string literal value
  24952. * @param {object} options - the prettier options object
  24953. */
  24954. function printStringLiteral(stringLiteral, options) {
  24955. var double = {
  24956. quote: '"',
  24957. regex: /"/g
  24958. };
  24959. var single = {
  24960. quote: "'",
  24961. regex: /'/g
  24962. };
  24963. var preferred = options.singleQuote ? single : double;
  24964. var alternate = preferred === single ? double : single;
  24965. var shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
  24966. // enclosing the string, we might want to enclose with the alternate quote
  24967. // instead, to minimize the number of escaped quotes.
  24968. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
  24969. var numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
  24970. var numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
  24971. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  24972. }
  24973. var enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
  24974. var escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, `\\${enclosingQuote.quote}`);
  24975. return `${enclosingQuote.quote}${escapedStringLiteral}${enclosingQuote.quote}`;
  24976. }
  24977. function printPath(path$$1, print) {
  24978. return path$$1.call(print, "path");
  24979. }
  24980. function getParams(path$$1, print) {
  24981. var node = path$$1.getValue();
  24982. var parts = [];
  24983. if (node.params.length > 0) {
  24984. parts = parts.concat(path$$1.map(print, "params"));
  24985. }
  24986. if (node.hash && node.hash.pairs.length > 0) {
  24987. parts.push(path$$1.call(print, "hash"));
  24988. }
  24989. return parts;
  24990. }
  24991. function printPathParams(path$$1, print) {
  24992. var parts = [];
  24993. parts.push(printPath(path$$1, print));
  24994. parts = parts.concat(getParams(path$$1, print));
  24995. return indent$6(group$10(join$7(line$6, parts)));
  24996. }
  24997. function printBlockParams(path$$1) {
  24998. var block = path$$1.getValue();
  24999. if (!block.program || !block.program.blockParams.length) {
  25000. return "";
  25001. }
  25002. return concat$10([" as |", block.program.blockParams.join(" "), "|"]);
  25003. }
  25004. function printOpenBlock(path$$1, print) {
  25005. return group$10(concat$10(["{{#", printPathParams(path$$1, print), printBlockParams(path$$1), softline$4, "}}"]));
  25006. }
  25007. function printCloseBlock(path$$1, print) {
  25008. return concat$10(["{{/", path$$1.call(print, "path"), "}}"]);
  25009. }
  25010. function clean$5(ast, newObj) {
  25011. delete newObj.loc; // (Glimmer/HTML) ignore TextNode whitespace
  25012. if (ast.type === "TextNode") {
  25013. if (ast.chars.replace(/\s+/, "") === "") {
  25014. return null;
  25015. }
  25016. newObj.chars = ast.chars.replace(/^\s+/, "").replace(/\s+$/, "");
  25017. }
  25018. }
  25019. var printerGlimmer = {
  25020. print,
  25021. massageAstNode: clean$5
  25022. };
  25023. var name$11 = "Handlebars";
  25024. var type$10 = "markup";
  25025. var group$11 = "HTML";
  25026. var aliases$3 = ["hbs", "htmlbars"];
  25027. var extensions$10 = [".handlebars", ".hbs"];
  25028. var tmScope$10 = "text.html.handlebars";
  25029. var aceMode$10 = "handlebars";
  25030. var languageId$10 = 155;
  25031. var handlebars = {
  25032. name: name$11,
  25033. type: type$10,
  25034. group: group$11,
  25035. aliases: aliases$3,
  25036. extensions: extensions$10,
  25037. tmScope: tmScope$10,
  25038. aceMode: aceMode$10,
  25039. languageId: languageId$10
  25040. };
  25041. var handlebars$1 = Object.freeze({
  25042. name: name$11,
  25043. type: type$10,
  25044. group: group$11,
  25045. aliases: aliases$3,
  25046. extensions: extensions$10,
  25047. tmScope: tmScope$10,
  25048. aceMode: aceMode$10,
  25049. languageId: languageId$10,
  25050. default: handlebars
  25051. });
  25052. var require$$0$24 = ( handlebars$1 && handlebars ) || handlebars$1;
  25053. var languages$2 = [createLanguage(require$$0$24, {
  25054. override: {
  25055. since: null,
  25056. // unreleased
  25057. parsers: ["glimmer"],
  25058. vscodeLanguageIds: ["handlebars"]
  25059. }
  25060. })];
  25061. var printers$2 = {
  25062. glimmer: printerGlimmer
  25063. };
  25064. var languageHandlebars = {
  25065. languages: languages$2,
  25066. printers: printers$2
  25067. };
  25068. function hasPragma$2(text) {
  25069. return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
  25070. }
  25071. function insertPragma$5(text) {
  25072. return "# @format\n\n" + text;
  25073. }
  25074. var pragma$4 = {
  25075. hasPragma: hasPragma$2,
  25076. insertPragma: insertPragma$5
  25077. };
  25078. var _require$$0$builders$5 = doc.builders;
  25079. var concat$11 = _require$$0$builders$5.concat;
  25080. var join$8 = _require$$0$builders$5.join;
  25081. var hardline$9 = _require$$0$builders$5.hardline;
  25082. var line$7 = _require$$0$builders$5.line;
  25083. var softline$5 = _require$$0$builders$5.softline;
  25084. var group$12 = _require$$0$builders$5.group;
  25085. var indent$7 = _require$$0$builders$5.indent;
  25086. var ifBreak$4 = _require$$0$builders$5.ifBreak;
  25087. var hasIgnoreComment$3 = util$1.hasIgnoreComment;
  25088. var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
  25089. var insertPragma$4 = pragma$4.insertPragma;
  25090. function genericPrint$3(path$$1, options, print) {
  25091. var n = path$$1.getValue();
  25092. if (!n) {
  25093. return "";
  25094. }
  25095. if (typeof n === "string") {
  25096. return n;
  25097. }
  25098. switch (n.kind) {
  25099. case "Document":
  25100. {
  25101. var parts = [];
  25102. path$$1.map(function (pathChild, index) {
  25103. parts.push(concat$11([pathChild.call(print)]));
  25104. if (index !== n.definitions.length - 1) {
  25105. parts.push(hardline$9);
  25106. if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
  25107. parts.push(hardline$9);
  25108. }
  25109. }
  25110. }, "definitions");
  25111. return concat$11([concat$11(parts), hardline$9]);
  25112. }
  25113. case "OperationDefinition":
  25114. {
  25115. var hasOperation = options.originalText[options.locStart(n)] !== "{";
  25116. var hasName = !!n.name;
  25117. return concat$11([hasOperation ? n.operation : "", hasOperation && hasName ? concat$11([" ", path$$1.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", printDirectives(path$$1, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path$$1.call(print, "selectionSet")]);
  25118. }
  25119. case "FragmentDefinition":
  25120. {
  25121. return concat$11(["fragment ", path$$1.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
  25122. }
  25123. case "SelectionSet":
  25124. {
  25125. return concat$11(["{", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (selectionsPath) {
  25126. return printSequence(selectionsPath, options, print);
  25127. }, "selections"))])), hardline$9, "}"]);
  25128. }
  25129. case "Field":
  25130. {
  25131. return group$12(concat$11([n.alias ? concat$11([path$$1.call(print, "alias"), ": "]) : "", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  25132. return printSequence(argsPath, options, print);
  25133. }, "arguments"))])), softline$5, ")"])) : "", printDirectives(path$$1, print, n), n.selectionSet ? " " : "", path$$1.call(print, "selectionSet")]));
  25134. }
  25135. case "Name":
  25136. {
  25137. return n.value;
  25138. }
  25139. case "StringValue":
  25140. {
  25141. if (n.block) {
  25142. return concat$11(['"""', hardline$9, join$8(hardline$9, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$9, '"""']);
  25143. }
  25144. return concat$11(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
  25145. }
  25146. case "IntValue":
  25147. case "FloatValue":
  25148. case "EnumValue":
  25149. {
  25150. return n.value;
  25151. }
  25152. case "BooleanValue":
  25153. {
  25154. return n.value ? "true" : "false";
  25155. }
  25156. case "NullValue":
  25157. {
  25158. return "null";
  25159. }
  25160. case "Variable":
  25161. {
  25162. return concat$11(["$", path$$1.call(print, "name")]);
  25163. }
  25164. case "ListValue":
  25165. {
  25166. return group$12(concat$11(["[", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "values"))])), softline$5, "]"]));
  25167. }
  25168. case "ObjectValue":
  25169. {
  25170. return group$12(concat$11(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "fields"))])), softline$5, ifBreak$4("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
  25171. }
  25172. case "ObjectField":
  25173. case "Argument":
  25174. {
  25175. return concat$11([path$$1.call(print, "name"), ": ", path$$1.call(print, "value")]);
  25176. }
  25177. case "Directive":
  25178. {
  25179. return concat$11(["@", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  25180. return printSequence(argsPath, options, print);
  25181. }, "arguments"))])), softline$5, ")"])) : ""]);
  25182. }
  25183. case "NamedType":
  25184. {
  25185. return path$$1.call(print, "name");
  25186. }
  25187. case "VariableDefinition":
  25188. {
  25189. return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : "", printDirectives(path$$1, print, n)]);
  25190. }
  25191. case "TypeExtensionDefinition":
  25192. {
  25193. return concat$11(["extend ", path$$1.call(print, "definition")]);
  25194. }
  25195. case "ObjectTypeExtension":
  25196. case "ObjectTypeDefinition":
  25197. {
  25198. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path$$1.call(print, "name"), n.interfaces.length > 0 ? concat$11([" implements ", join$8(determineInterfaceSeparator(options.originalText.substr(options.locStart(n), options.locEnd(n))), path$$1.map(print, "interfaces"))]) : "", printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  25199. return printSequence(fieldsPath, options, print);
  25200. }, "fields"))])), hardline$9, "}"]) : ""]);
  25201. }
  25202. case "FieldDefinition":
  25203. {
  25204. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  25205. return printSequence(argsPath, options, print);
  25206. }, "arguments"))])), softline$5, ")"])) : "", ": ", path$$1.call(print, "type"), printDirectives(path$$1, print, n)]);
  25207. }
  25208. case "DirectiveDefinition":
  25209. {
  25210. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", "directive ", "@", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  25211. return printSequence(argsPath, options, print);
  25212. }, "arguments"))])), softline$5, ")"])) : "", concat$11([" on ", join$8(" | ", path$$1.map(print, "locations"))])]);
  25213. }
  25214. case "EnumTypeExtension":
  25215. case "EnumTypeDefinition":
  25216. {
  25217. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.values.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (valuesPath) {
  25218. return printSequence(valuesPath, options, print);
  25219. }, "values"))])), hardline$9, "}"]) : ""]);
  25220. }
  25221. case "EnumValueDefinition":
  25222. {
  25223. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25224. }
  25225. case "InputValueDefinition":
  25226. {
  25227. return concat$11([path$$1.call(print, "description"), n.description ? n.description.block ? hardline$9 : line$7 : "", path$$1.call(print, "name"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : "", printDirectives(path$$1, print, n)]);
  25228. }
  25229. case "InputObjectTypeExtension":
  25230. case "InputObjectTypeDefinition":
  25231. {
  25232. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  25233. return printSequence(fieldsPath, options, print);
  25234. }, "fields"))])), hardline$9, "}"]) : ""]);
  25235. }
  25236. case "SchemaDefinition":
  25237. {
  25238. return concat$11(["schema", printDirectives(path$$1, print, n), " {", n.operationTypes.length > 0 ? indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (opsPath) {
  25239. return printSequence(opsPath, options, print);
  25240. }, "operationTypes"))])) : "", hardline$9, "}"]);
  25241. }
  25242. case "OperationTypeDefinition":
  25243. {
  25244. return concat$11([path$$1.call(print, "operation"), ": ", path$$1.call(print, "type")]);
  25245. }
  25246. case "InterfaceTypeExtension":
  25247. case "InterfaceTypeDefinition":
  25248. {
  25249. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  25250. return printSequence(fieldsPath, options, print);
  25251. }, "fields"))])), hardline$9, "}"]) : ""]);
  25252. }
  25253. case "FragmentSpread":
  25254. {
  25255. return concat$11(["...", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25256. }
  25257. case "InlineFragment":
  25258. {
  25259. return concat$11(["...", n.typeCondition ? concat$11([" on ", path$$1.call(print, "typeCondition")]) : "", printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
  25260. }
  25261. case "UnionTypeExtension":
  25262. case "UnionTypeDefinition":
  25263. {
  25264. return group$12(concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", group$12(concat$11([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.types.length > 0 ? concat$11([" =", ifBreak$4("", " "), indent$7(concat$11([ifBreak$4(concat$11([line$7, " "])), join$8(concat$11([line$7, "| "]), path$$1.map(print, "types"))]))]) : ""]))]));
  25265. }
  25266. case "ScalarTypeExtension":
  25267. case "ScalarTypeDefinition":
  25268. {
  25269. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25270. }
  25271. case "NonNullType":
  25272. {
  25273. return concat$11([path$$1.call(print, "type"), "!"]);
  25274. }
  25275. case "ListType":
  25276. {
  25277. return concat$11(["[", path$$1.call(print, "type"), "]"]);
  25278. }
  25279. default:
  25280. /* istanbul ignore next */
  25281. throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
  25282. }
  25283. }
  25284. function printDirectives(path$$1, print, n) {
  25285. if (n.directives.length === 0) {
  25286. return "";
  25287. }
  25288. return concat$11([" ", group$12(indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", " "), softline$5]), path$$1.map(print, "directives"))])))]);
  25289. }
  25290. function printSequence(sequencePath, options, print) {
  25291. var count = sequencePath.getValue().length;
  25292. return sequencePath.map(function (path$$1, i) {
  25293. var printed = print(path$$1);
  25294. if (isNextLineEmpty$4(options.originalText, path$$1.getValue(), options) && i < count - 1) {
  25295. return concat$11([printed, hardline$9]);
  25296. }
  25297. return printed;
  25298. });
  25299. }
  25300. function canAttachComment$1(node) {
  25301. return node.kind && node.kind !== "Comment";
  25302. }
  25303. function printComment$2(commentPath) {
  25304. var comment = commentPath.getValue();
  25305. if (comment.kind === "Comment") {
  25306. return "#" + comment.value.trimRight();
  25307. }
  25308. throw new Error("Not a comment: " + JSON.stringify(comment));
  25309. }
  25310. function determineInterfaceSeparator(originalSource) {
  25311. var start = originalSource.indexOf("implements");
  25312. if (start === -1) {
  25313. throw new Error("Must implement interfaces: " + originalSource);
  25314. }
  25315. var end = originalSource.indexOf("{");
  25316. if (end === -1) {
  25317. end = originalSource.length;
  25318. }
  25319. return originalSource.substr(start, end).includes("&") ? " & " : ", ";
  25320. }
  25321. function clean$6(node, newNode
  25322. /*, parent*/
  25323. ) {
  25324. delete newNode.loc;
  25325. delete newNode.comments;
  25326. }
  25327. var printerGraphql = {
  25328. print: genericPrint$3,
  25329. massageAstNode: clean$6,
  25330. hasPrettierIgnore: hasIgnoreComment$3,
  25331. insertPragma: insertPragma$4,
  25332. printComment: printComment$2,
  25333. canAttachComment: canAttachComment$1
  25334. };
  25335. var options$10 = {
  25336. bracketSpacing: commonOptions.bracketSpacing
  25337. };
  25338. var name$12 = "GraphQL";
  25339. var type$11 = "data";
  25340. var extensions$11 = [".graphql", ".gql"];
  25341. var tmScope$11 = "source.graphql";
  25342. var aceMode$11 = "text";
  25343. var languageId$11 = 139;
  25344. var graphql = {
  25345. name: name$12,
  25346. type: type$11,
  25347. extensions: extensions$11,
  25348. tmScope: tmScope$11,
  25349. aceMode: aceMode$11,
  25350. languageId: languageId$11
  25351. };
  25352. var graphql$1 = Object.freeze({
  25353. name: name$12,
  25354. type: type$11,
  25355. extensions: extensions$11,
  25356. tmScope: tmScope$11,
  25357. aceMode: aceMode$11,
  25358. languageId: languageId$11,
  25359. default: graphql
  25360. });
  25361. var require$$0$25 = ( graphql$1 && graphql ) || graphql$1;
  25362. var languages$3 = [createLanguage(require$$0$25, {
  25363. override: {
  25364. since: "1.5.0",
  25365. parsers: ["graphql"],
  25366. vscodeLanguageIds: ["graphql"]
  25367. }
  25368. })];
  25369. var printers$3 = {
  25370. graphql: printerGraphql
  25371. };
  25372. var languageGraphql = {
  25373. languages: languages$3,
  25374. options: options$10,
  25375. printers: printers$3
  25376. };
  25377. var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\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]|\\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]","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]","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\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\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-\\u2e49\\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]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
  25378. var cjkPattern = json$6.cjkPattern;
  25379. var kPattern = json$6.kPattern;
  25380. var punctuationPattern$1 = json$6.punctuationPattern;
  25381. var getLast$4 = util$1.getLast;
  25382. var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  25383. var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
  25384. var kRegex = new RegExp(kPattern);
  25385. var punctuationRegex = new RegExp(punctuationPattern$1);
  25386. /**
  25387. * split text into whitespaces and words
  25388. * @param {string} text
  25389. * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
  25390. */
  25391. function splitText$1(text, options) {
  25392. var KIND_NON_CJK = "non-cjk";
  25393. var KIND_CJ_LETTER = "cj-letter";
  25394. var KIND_K_LETTER = "k-letter";
  25395. var KIND_CJK_PUNCTUATION = "cjk-punctuation";
  25396. var nodes = [];
  25397. (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) {
  25398. // whitespace
  25399. if (index % 2 === 1) {
  25400. nodes.push({
  25401. type: "whitespace",
  25402. value: /\n/.test(token) ? "\n" : " "
  25403. });
  25404. return;
  25405. } // word separated by whitespace
  25406. if ((index === 0 || index === tokens.length - 1) && token === "") {
  25407. return;
  25408. }
  25409. token.split(new RegExp(`(${cjkPattern})`)).forEach(function (innerToken, innerIndex, innerTokens) {
  25410. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  25411. return;
  25412. } // non-CJK word
  25413. if (innerIndex % 2 === 0) {
  25414. if (innerToken !== "") {
  25415. appendNode({
  25416. type: "word",
  25417. value: innerToken,
  25418. kind: KIND_NON_CJK,
  25419. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  25420. hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
  25421. });
  25422. }
  25423. return;
  25424. } // CJK character
  25425. appendNode(punctuationRegex.test(innerToken) ? {
  25426. type: "word",
  25427. value: innerToken,
  25428. kind: KIND_CJK_PUNCTUATION,
  25429. hasLeadingPunctuation: true,
  25430. hasTrailingPunctuation: true
  25431. } : {
  25432. type: "word",
  25433. value: innerToken,
  25434. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  25435. hasLeadingPunctuation: false,
  25436. hasTrailingPunctuation: false
  25437. });
  25438. });
  25439. });
  25440. return nodes;
  25441. function appendNode(node) {
  25442. var lastNode = getLast$4(nodes);
  25443. if (lastNode && lastNode.type === "word") {
  25444. 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) {
  25445. nodes.push({
  25446. type: "whitespace",
  25447. value: " "
  25448. });
  25449. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  25450. ![lastNode.value, node.value].some(function (value) {
  25451. return /\u3000/.test(value);
  25452. })) {
  25453. nodes.push({
  25454. type: "whitespace",
  25455. value: ""
  25456. });
  25457. }
  25458. }
  25459. nodes.push(node);
  25460. function isBetween(kind1, kind2) {
  25461. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  25462. }
  25463. }
  25464. }
  25465. function getOrderedListItemInfo$1(orderListItem, originalText) {
  25466. var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/),
  25467. _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4),
  25468. numberText = _originalText$slice$m2[1],
  25469. marker = _originalText$slice$m2[2],
  25470. leadingSpaces = _originalText$slice$m2[3];
  25471. return {
  25472. numberText,
  25473. marker,
  25474. leadingSpaces
  25475. };
  25476. } // workaround for https://github.com/remarkjs/remark/issues/351
  25477. // leading and trailing newlines are stripped by remark
  25478. function getFencedCodeBlockValue$2(node, originalText) {
  25479. var text = originalText.slice(node.position.start.offset, node.position.end.offset);
  25480. var leadingSpaceCount = text.match(/^\s*/)[0].length;
  25481. var replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
  25482. var lineContents = text.split("\n");
  25483. var markerStyle = text[leadingSpaceCount]; // ` or ~
  25484. var marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
  25485. // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
  25486. var hasEndMarker = new RegExp(`^\\s{0,3}${marker}`).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
  25487. return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) {
  25488. return x.slice(getIndent(i + 1)).replace(replaceRegex, "");
  25489. }).join("\n");
  25490. function getIndent(lineIndex) {
  25491. return node.position.indent[lineIndex - 1] - 1;
  25492. }
  25493. }
  25494. function mapAst(ast, handler) {
  25495. return function preorder(node, index, parentStack) {
  25496. parentStack = parentStack || [];
  25497. var newNode = Object.assign({}, handler(node, index, parentStack));
  25498. if (newNode.children) {
  25499. newNode.children = newNode.children.map(function (child, index) {
  25500. return preorder(child, index, [newNode].concat(parentStack));
  25501. });
  25502. }
  25503. return newNode;
  25504. }(ast, null, null);
  25505. }
  25506. var utils$8 = {
  25507. mapAst,
  25508. splitText: splitText$1,
  25509. punctuationPattern: punctuationPattern$1,
  25510. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  25511. getOrderedListItemInfo: getOrderedListItemInfo$1,
  25512. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  25513. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
  25514. };
  25515. var _require$$0$builders$7 = doc.builders;
  25516. var hardline$11 = _require$$0$builders$7.hardline;
  25517. var literalline$5 = _require$$0$builders$7.literalline;
  25518. var concat$13 = _require$$0$builders$7.concat;
  25519. var markAsRoot$3 = _require$$0$builders$7.markAsRoot;
  25520. var mapDoc$6 = doc.utils.mapDoc;
  25521. var getFencedCodeBlockValue$1 = utils$8.getFencedCodeBlockValue;
  25522. function embed$4(path$$1, print, textToDoc, options) {
  25523. var node = path$$1.getValue();
  25524. if (node.type === "code" && node.lang !== null) {
  25525. // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
  25526. var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
  25527. var lang = langMatch ? langMatch[0] : "";
  25528. var parser = getParserName(lang);
  25529. if (parser) {
  25530. var styleUnit = options.__inJsTemplate ? "~" : "`";
  25531. var style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
  25532. var doc$$2 = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
  25533. parser
  25534. });
  25535. return markAsRoot$3(concat$13([style, node.lang, hardline$11, replaceNewlinesWithLiterallines(doc$$2), style]));
  25536. }
  25537. }
  25538. if (node.type === "yaml") {
  25539. return markAsRoot$3(concat$13(["---", hardline$11, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  25540. parser: "yaml"
  25541. })) : "", "---"]));
  25542. } // MDX
  25543. switch (node.type) {
  25544. case "importExport":
  25545. return textToDoc(node.value, {
  25546. parser: "babel"
  25547. });
  25548. case "jsx":
  25549. return textToDoc(node.value, {
  25550. parser: "__js_expression"
  25551. });
  25552. }
  25553. return null;
  25554. function getParserName(lang) {
  25555. var supportInfo = support.getSupportInfo(null, {
  25556. plugins: options.plugins
  25557. });
  25558. var language = supportInfo.languages.find(function (language) {
  25559. return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) {
  25560. return ext.substring(1) === lang;
  25561. });
  25562. });
  25563. if (language) {
  25564. return language.parsers[0];
  25565. }
  25566. return null;
  25567. }
  25568. function replaceNewlinesWithLiterallines(doc$$2) {
  25569. return mapDoc$6(doc$$2, function (currentDoc) {
  25570. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$13(currentDoc.split(/(\n)/g).map(function (v, i) {
  25571. return i % 2 === 0 ? v : literalline$5;
  25572. })) : currentDoc;
  25573. });
  25574. }
  25575. }
  25576. var embed_1$4 = embed$4;
  25577. var pragma$6 = createCommonjsModule(function (module) {
  25578. "use strict";
  25579. var pragmas = ["format", "prettier"];
  25580. function startWithPragma(text) {
  25581. var pragma = `@(${pragmas.join("|")})`;
  25582. var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
  25583. var matched = text.match(regex);
  25584. return matched && matched.index === 0;
  25585. }
  25586. module.exports = {
  25587. startWithPragma,
  25588. hasPragma: function hasPragma(text) {
  25589. return startWithPragma(frontMatter(text).content.trimLeft());
  25590. },
  25591. insertPragma: function insertPragma(text) {
  25592. var extracted = frontMatter(text);
  25593. var pragma = `<!-- @${pragmas[0]} -->`;
  25594. return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
  25595. }
  25596. };
  25597. });
  25598. var getOrderedListItemInfo$2 = utils$8.getOrderedListItemInfo;
  25599. var mapAst$1 = utils$8.mapAst;
  25600. var splitText$2 = utils$8.splitText; // 0x0 ~ 0x10ffff
  25601. var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
  25602. function preprocess$2(ast, options) {
  25603. ast = restoreUnescapedCharacter(ast, options);
  25604. ast = mergeContinuousTexts(ast);
  25605. ast = transformInlineCode(ast);
  25606. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  25607. ast = markAlignedList(ast, options);
  25608. ast = splitTextIntoSentences(ast, options);
  25609. ast = transformImportExport(ast);
  25610. ast = mergeContinuousImportExport(ast);
  25611. return ast;
  25612. }
  25613. function transformImportExport(ast) {
  25614. return mapAst$1(ast, function (node) {
  25615. if (node.type !== "import" && node.type !== "export") {
  25616. return node;
  25617. }
  25618. return Object.assign({}, node, {
  25619. type: "importExport"
  25620. });
  25621. });
  25622. }
  25623. function transformInlineCode(ast) {
  25624. return mapAst$1(ast, function (node) {
  25625. if (node.type !== "inlineCode") {
  25626. return node;
  25627. }
  25628. return Object.assign({}, node, {
  25629. value: node.value.replace(/\s+/g, " ")
  25630. });
  25631. });
  25632. }
  25633. function restoreUnescapedCharacter(ast, options) {
  25634. return mapAst$1(ast, function (node) {
  25635. return node.type !== "text" ? node : Object.assign({}, node, {
  25636. value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
  25637. isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
  25638. });
  25639. });
  25640. }
  25641. function mergeContinuousImportExport(ast) {
  25642. return mergeChildren(ast, function (prevNode, node) {
  25643. return prevNode.type === "importExport" && node.type === "importExport";
  25644. }, function (prevNode, node) {
  25645. return {
  25646. type: "importExport",
  25647. value: prevNode.value + "\n\n" + node.value,
  25648. position: {
  25649. start: prevNode.position.start,
  25650. end: node.position.end
  25651. }
  25652. };
  25653. });
  25654. }
  25655. function mergeChildren(ast, shouldMerge, mergeNode) {
  25656. return mapAst$1(ast, function (node) {
  25657. if (!node.children) {
  25658. return node;
  25659. }
  25660. var children = node.children.reduce(function (current, child) {
  25661. var lastChild = current[current.length - 1];
  25662. if (lastChild && shouldMerge(lastChild, child)) {
  25663. current.splice(-1, 1, mergeNode(lastChild, child));
  25664. } else {
  25665. current.push(child);
  25666. }
  25667. return current;
  25668. }, []);
  25669. return Object.assign({}, node, {
  25670. children
  25671. });
  25672. });
  25673. }
  25674. function mergeContinuousTexts(ast) {
  25675. return mergeChildren(ast, function (prevNode, node) {
  25676. return prevNode.type === "text" && node.type === "text";
  25677. }, function (prevNode, node) {
  25678. return {
  25679. type: "text",
  25680. value: prevNode.value + node.value,
  25681. position: {
  25682. start: prevNode.position.start,
  25683. end: node.position.end
  25684. }
  25685. };
  25686. });
  25687. }
  25688. function splitTextIntoSentences(ast, options) {
  25689. return mapAst$1(ast, function (node, index, _ref) {
  25690. var _ref2 = _slicedToArray(_ref, 1),
  25691. parentNode = _ref2[0];
  25692. if (node.type !== "text") {
  25693. return node;
  25694. }
  25695. var value = node.value;
  25696. if (parentNode.type === "paragraph") {
  25697. if (index === 0) {
  25698. value = value.trimLeft();
  25699. }
  25700. if (index === parentNode.children.length - 1) {
  25701. value = value.trimRight();
  25702. }
  25703. }
  25704. return {
  25705. type: "sentence",
  25706. position: node.position,
  25707. children: splitText$2(value, options)
  25708. };
  25709. });
  25710. }
  25711. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  25712. return mapAst$1(ast, function (node, index, parentStack) {
  25713. if (node.type === "code") {
  25714. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  25715. var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  25716. node.isIndented = isIndented;
  25717. if (isIndented) {
  25718. for (var i = 0; i < parentStack.length; i++) {
  25719. var parent = parentStack[i]; // no need to check checked items
  25720. if (parent.hasIndentedCodeblock) {
  25721. break;
  25722. }
  25723. if (parent.type === "list") {
  25724. parent.hasIndentedCodeblock = true;
  25725. }
  25726. }
  25727. }
  25728. }
  25729. return node;
  25730. });
  25731. }
  25732. function markAlignedList(ast, options) {
  25733. return mapAst$1(ast, function (node, index, parentStack) {
  25734. if (node.type === "list" && node.children.length !== 0) {
  25735. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  25736. for (var i = 0; i < parentStack.length; i++) {
  25737. var parent = parentStack[i];
  25738. if (parent.type === "list" && !parent.isAligned) {
  25739. node.isAligned = false;
  25740. return node;
  25741. }
  25742. }
  25743. node.isAligned = isAligned(node);
  25744. }
  25745. return node;
  25746. });
  25747. function getListItemStart(listItem) {
  25748. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  25749. }
  25750. function isAligned(list) {
  25751. if (!list.ordered) {
  25752. /**
  25753. * - 123
  25754. * - 123
  25755. */
  25756. return true;
  25757. }
  25758. var _list$children = _slicedToArray(list.children, 2),
  25759. firstItem = _list$children[0],
  25760. secondItem = _list$children[1];
  25761. var firstInfo = getOrderedListItemInfo$2(firstItem, options.originalText);
  25762. if (firstInfo.leadingSpaces.length > 1) {
  25763. /**
  25764. * 1. 123
  25765. *
  25766. * 1. 123
  25767. * 1. 123
  25768. */
  25769. return true;
  25770. }
  25771. var firstStart = getListItemStart(firstItem);
  25772. if (firstStart === -1) {
  25773. /**
  25774. * 1.
  25775. *
  25776. * 1.
  25777. * 1.
  25778. */
  25779. return false;
  25780. }
  25781. if (list.children.length === 1) {
  25782. /**
  25783. * aligned:
  25784. *
  25785. * 11. 123
  25786. *
  25787. * not aligned:
  25788. *
  25789. * 1. 123
  25790. */
  25791. return firstStart % options.tabWidth === 0;
  25792. }
  25793. var secondStart = getListItemStart(secondItem);
  25794. if (firstStart !== secondStart) {
  25795. /**
  25796. * 11. 123
  25797. * 1. 123
  25798. *
  25799. * 1. 123
  25800. * 11. 123
  25801. */
  25802. return false;
  25803. }
  25804. if (firstStart % options.tabWidth === 0) {
  25805. /**
  25806. * 11. 123
  25807. * 12. 123
  25808. */
  25809. return true;
  25810. }
  25811. /**
  25812. * aligned:
  25813. *
  25814. * 11. 123
  25815. * 1. 123
  25816. *
  25817. * not aligned:
  25818. *
  25819. * 1. 123
  25820. * 2. 123
  25821. */
  25822. var secondInfo = getOrderedListItemInfo$2(secondItem, options.originalText);
  25823. return secondInfo.leadingSpaces.length > 1;
  25824. }
  25825. }
  25826. var preprocess_1$2 = preprocess$2;
  25827. var _require$$0$builders$6 = doc.builders;
  25828. var breakParent$3 = _require$$0$builders$6.breakParent;
  25829. var concat$12 = _require$$0$builders$6.concat;
  25830. var join$9 = _require$$0$builders$6.join;
  25831. var line$8 = _require$$0$builders$6.line;
  25832. var literalline$4 = _require$$0$builders$6.literalline;
  25833. var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
  25834. var hardline$10 = _require$$0$builders$6.hardline;
  25835. var softline$6 = _require$$0$builders$6.softline;
  25836. var ifBreak$5 = _require$$0$builders$6.ifBreak;
  25837. var fill$4 = _require$$0$builders$6.fill;
  25838. var align$2 = _require$$0$builders$6.align;
  25839. var indent$8 = _require$$0$builders$6.indent;
  25840. var group$13 = _require$$0$builders$6.group;
  25841. var mapDoc$5 = doc.utils.mapDoc;
  25842. var printDocToString$3 = doc.printer.printDocToString;
  25843. var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
  25844. var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
  25845. var splitText = utils$8.splitText;
  25846. var punctuationPattern = utils$8.punctuationPattern;
  25847. var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
  25848. var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
  25849. var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
  25850. var TRAILING_HARDLINE_NODES = ["importExport"];
  25851. var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
  25852. var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
  25853. function genericPrint$4(path$$1, options, print) {
  25854. var node = path$$1.getValue();
  25855. if (shouldRemainTheSameContent(path$$1)) {
  25856. return concat$12(splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
  25857. return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path$$1, node.value, options);
  25858. }));
  25859. }
  25860. switch (node.type) {
  25861. case "root":
  25862. if (node.children.length === 0) {
  25863. return "";
  25864. }
  25865. return concat$12([normalizeDoc(printRoot(path$$1, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$10 : ""]);
  25866. case "paragraph":
  25867. return printChildren(path$$1, options, print, {
  25868. postprocessor: fill$4
  25869. });
  25870. case "sentence":
  25871. return printChildren(path$$1, options, print);
  25872. case "word":
  25873. return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
  25874. .replace(new RegExp([`(^|${punctuationPattern})(_+)`, `(_+)(${punctuationPattern}|$)`].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
  25875. return (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_");
  25876. });
  25877. // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  25878. case "whitespace":
  25879. {
  25880. var parentNode = path$$1.getParentNode();
  25881. var index = parentNode.children.indexOf(node);
  25882. var nextNode = parentNode.children[index + 1];
  25883. var proseWrap = // leading char that may cause different syntax
  25884. nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
  25885. return printLine(path$$1, node.value, {
  25886. proseWrap
  25887. });
  25888. }
  25889. case "emphasis":
  25890. {
  25891. var _parentNode = path$$1.getParentNode();
  25892. var _index = _parentNode.children.indexOf(node);
  25893. var prevNode = _parentNode.children[_index - 1];
  25894. var _nextNode = _parentNode.children[_index + 1];
  25895. var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
  25896. prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util$1.getLast(prevNode.children).type === "word" && !util$1.getLast(prevNode.children).hasTrailingPunctuation || _nextNode && _nextNode.type === "sentence" && _nextNode.children.length > 0 && _nextNode.children[0].type === "word" && !_nextNode.children[0].hasLeadingPunctuation;
  25897. var style = hasPrevOrNextWord || getAncestorNode$2(path$$1, "emphasis") ? "*" : "_";
  25898. return concat$12([style, printChildren(path$$1, options, print), style]);
  25899. }
  25900. case "strong":
  25901. return concat$12(["**", printChildren(path$$1, options, print), "**"]);
  25902. case "delete":
  25903. return concat$12(["~~", printChildren(path$$1, options, print), "~~"]);
  25904. case "inlineCode":
  25905. {
  25906. var backtickCount = util$1.getMinNotPresentContinuousCount(node.value, "`");
  25907. var _style = "`".repeat(backtickCount || 1);
  25908. var gap = backtickCount ? " " : "";
  25909. return concat$12([_style, gap, node.value, gap, _style]);
  25910. }
  25911. case "link":
  25912. switch (options.originalText[node.position.start.offset]) {
  25913. case "<":
  25914. {
  25915. var mailto = "mailto:";
  25916. var url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  25917. 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;
  25918. return concat$12(["<", url, ">"]);
  25919. }
  25920. case "[":
  25921. return concat$12(["[", printChildren(path$$1, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  25922. default:
  25923. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  25924. }
  25925. case "image":
  25926. return concat$12(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  25927. case "blockquote":
  25928. return concat$12(["> ", align$2("> ", printChildren(path$$1, options, print))]);
  25929. case "heading":
  25930. return concat$12(["#".repeat(node.depth) + " ", printChildren(path$$1, options, print)]);
  25931. case "code":
  25932. {
  25933. if (node.isIndented) {
  25934. // indented code block
  25935. var alignment = " ".repeat(4);
  25936. return align$2(alignment, concat$12([alignment, concat$12(replaceEndOfLineWith$1(node.value, hardline$10))]));
  25937. } // fenced code block
  25938. var styleUnit = options.__inJsTemplate ? "~" : "`";
  25939. var _style2 = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
  25940. return concat$12([_style2, node.lang || "", hardline$10, concat$12(replaceEndOfLineWith$1(getFencedCodeBlockValue(node, options.originalText), hardline$10)), hardline$10, _style2]);
  25941. }
  25942. case "yaml":
  25943. case "toml":
  25944. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  25945. case "html":
  25946. {
  25947. var _parentNode2 = path$$1.getParentNode();
  25948. var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
  25949. var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
  25950. return concat$12(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$10 : markAsRoot$2(literalline$4)));
  25951. }
  25952. case "list":
  25953. {
  25954. var nthSiblingIndex = getNthListSiblingIndex(node, path$$1.getParentNode());
  25955. var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo(node.children[1], options.originalText).numberText === 1;
  25956. return printChildren(path$$1, options, print, {
  25957. processor: function processor(childPath, index) {
  25958. var prefix = getPrefix();
  25959. return concat$12([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
  25960. function getPrefix() {
  25961. var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  25962. return node.isAligned ||
  25963. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  25964. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  25965. }
  25966. }
  25967. });
  25968. }
  25969. case "thematicBreak":
  25970. {
  25971. var counter = getAncestorCounter$1(path$$1, "list");
  25972. if (counter === -1) {
  25973. return "---";
  25974. }
  25975. var _nthSiblingIndex = getNthListSiblingIndex(path$$1.getParentNode(counter), path$$1.getParentNode(counter + 1));
  25976. return _nthSiblingIndex % 2 === 0 ? "***" : "---";
  25977. }
  25978. case "linkReference":
  25979. return concat$12(["[", printChildren(path$$1, options, print), "]", node.referenceType === "full" ? concat$12(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
  25980. case "imageReference":
  25981. switch (node.referenceType) {
  25982. case "full":
  25983. return concat$12(["![", node.alt || "", "][", node.identifier, "]"]);
  25984. default:
  25985. return concat$12(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
  25986. }
  25987. case "definition":
  25988. {
  25989. var lineOrSpace = options.proseWrap === "always" ? line$8 : " ";
  25990. return group$13(concat$12([concat$12(["[", node.identifier, "]:"]), indent$8(concat$12([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$12([lineOrSpace, printTitle(node.title, options, false)])]))]));
  25991. }
  25992. case "footnote":
  25993. return concat$12(["[^", printChildren(path$$1, options, print), "]"]);
  25994. case "footnoteReference":
  25995. return concat$12(["[^", node.identifier, "]"]);
  25996. case "footnoteDefinition":
  25997. {
  25998. var _nextNode2 = path$$1.getParentNode().children[path$$1.getName() + 1];
  25999. var 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);
  26000. return concat$12(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren(path$$1, options, print) : group$13(concat$12([align$2(" ".repeat(options.tabWidth), printChildren(path$$1, options, print, {
  26001. processor: function processor(childPath, index) {
  26002. return index === 0 ? group$13(concat$12([softline$6, softline$6, childPath.call(print)])) : childPath.call(print);
  26003. }
  26004. })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$6 : ""]))]);
  26005. }
  26006. case "table":
  26007. return printTable(path$$1, options, print);
  26008. case "tableCell":
  26009. return printChildren(path$$1, options, print);
  26010. case "break":
  26011. return /\s/.test(options.originalText[node.position.start.offset]) ? concat$12([" ", markAsRoot$2(literalline$4)]) : concat$12(["\\", hardline$10]);
  26012. case "liquidNode":
  26013. return concat$12(replaceEndOfLineWith$1(node.value, hardline$10));
  26014. // MDX
  26015. case "importExport":
  26016. case "jsx":
  26017. return node.value;
  26018. // fallback to the original text if multiparser failed
  26019. case "math":
  26020. return concat$12(["$$", hardline$10, node.value ? concat$12([concat$12(replaceEndOfLineWith$1(node.value, hardline$10)), hardline$10]) : "", "$$"]);
  26021. case "inlineMath":
  26022. {
  26023. // remark-math trims content but we don't want to remove whitespaces
  26024. // since it's very possible that it's recognized as math accidentally
  26025. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  26026. }
  26027. case "tableRow": // handled in "table"
  26028. case "listItem": // handled in "list"
  26029. default:
  26030. throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
  26031. }
  26032. }
  26033. function printListItem(path$$1, options, print, listPrefix) {
  26034. var node = path$$1.getValue();
  26035. var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  26036. return concat$12([prefix, printChildren(path$$1, options, print, {
  26037. processor: function processor(childPath, index) {
  26038. if (index === 0 && childPath.getValue().type !== "list") {
  26039. return align$2(" ".repeat(prefix.length), childPath.call(print));
  26040. }
  26041. var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  26042. );
  26043. return concat$12([alignment, align$2(alignment, childPath.call(print))]);
  26044. }
  26045. })]);
  26046. }
  26047. function alignListPrefix(prefix, options) {
  26048. var additionalSpaces = getAdditionalSpaces();
  26049. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  26050. );
  26051. function getAdditionalSpaces() {
  26052. var restSpaces = prefix.length % options.tabWidth;
  26053. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  26054. }
  26055. }
  26056. function getNthListSiblingIndex(node, parentNode) {
  26057. return getNthSiblingIndex(node, parentNode, function (siblingNode) {
  26058. return siblingNode.ordered === node.ordered;
  26059. });
  26060. }
  26061. function getNthSiblingIndex(node, parentNode, condition) {
  26062. condition = condition || function () {
  26063. return true;
  26064. };
  26065. var index = -1;
  26066. var _iteratorNormalCompletion = true;
  26067. var _didIteratorError = false;
  26068. var _iteratorError = undefined;
  26069. try {
  26070. for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26071. var childNode = _step.value;
  26072. if (childNode.type === node.type && condition(childNode)) {
  26073. index++;
  26074. } else {
  26075. index = -1;
  26076. }
  26077. if (childNode === node) {
  26078. return index;
  26079. }
  26080. }
  26081. } catch (err) {
  26082. _didIteratorError = true;
  26083. _iteratorError = err;
  26084. } finally {
  26085. try {
  26086. if (!_iteratorNormalCompletion && _iterator.return != null) {
  26087. _iterator.return();
  26088. }
  26089. } finally {
  26090. if (_didIteratorError) {
  26091. throw _iteratorError;
  26092. }
  26093. }
  26094. }
  26095. }
  26096. function getAncestorCounter$1(path$$1, typeOrTypes) {
  26097. var types = [].concat(typeOrTypes);
  26098. var counter = -1;
  26099. var ancestorNode;
  26100. while (ancestorNode = path$$1.getParentNode(++counter)) {
  26101. if (types.indexOf(ancestorNode.type) !== -1) {
  26102. return counter;
  26103. }
  26104. }
  26105. return -1;
  26106. }
  26107. function getAncestorNode$2(path$$1, typeOrTypes) {
  26108. var counter = getAncestorCounter$1(path$$1, typeOrTypes);
  26109. return counter === -1 ? null : path$$1.getParentNode(counter);
  26110. }
  26111. function printLine(path$$1, value, options) {
  26112. if (options.proseWrap === "preserve" && value === "\n") {
  26113. return hardline$10;
  26114. }
  26115. var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path$$1, SINGLE_LINE_NODE_TYPES);
  26116. return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$6 : "";
  26117. }
  26118. function printTable(path$$1, options, print) {
  26119. var hardlineWithoutBreakParent = hardline$10.parts[0];
  26120. var node = path$$1.getValue();
  26121. var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
  26122. path$$1.map(function (rowPath) {
  26123. var rowContents = [];
  26124. rowPath.map(function (cellPath) {
  26125. rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
  26126. }, "children");
  26127. contents.push(rowContents);
  26128. }, "children"); // Get the width of each column
  26129. var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
  26130. return currentWidths.map(function (width, columnIndex) {
  26131. return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
  26132. });
  26133. }, contents[0].map(function () {
  26134. return 3;
  26135. }) // minimum width = 3 (---, :--, :-:, --:)
  26136. );
  26137. var alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
  26138. return printRow(rowContents);
  26139. }))]);
  26140. if (options.proseWrap !== "never") {
  26141. return concat$12([breakParent$3, alignedTable]);
  26142. } // Only if the --prose-wrap never is set and it exceeds the print width.
  26143. var compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
  26144. /* isCompact */
  26145. true), printSeparator(
  26146. /* isCompact */
  26147. true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
  26148. return printRow(rowContents,
  26149. /* isCompact */
  26150. true);
  26151. }))]);
  26152. return concat$12([breakParent$3, group$13(ifBreak$5(compactTable, alignedTable))]);
  26153. function printSeparator(isCompact) {
  26154. return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
  26155. var spaces = isCompact ? 3 : width;
  26156. switch (node.align[index]) {
  26157. case "left":
  26158. return ":" + "-".repeat(spaces - 1);
  26159. case "right":
  26160. return "-".repeat(spaces - 1) + ":";
  26161. case "center":
  26162. return ":" + "-".repeat(spaces - 2) + ":";
  26163. default:
  26164. return "-".repeat(spaces);
  26165. }
  26166. })), " |"]);
  26167. }
  26168. function printRow(rowContents, isCompact) {
  26169. return concat$12(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
  26170. switch (node.align[columnIndex]) {
  26171. case "right":
  26172. return alignRight(rowContent, columnMaxWidths[columnIndex]);
  26173. case "center":
  26174. return alignCenter(rowContent, columnMaxWidths[columnIndex]);
  26175. default:
  26176. return alignLeft(rowContent, columnMaxWidths[columnIndex]);
  26177. }
  26178. })), " |"]);
  26179. }
  26180. function alignLeft(text, width) {
  26181. var spaces = width - util$1.getStringWidth(text);
  26182. return concat$12([text, " ".repeat(spaces)]);
  26183. }
  26184. function alignRight(text, width) {
  26185. var spaces = width - util$1.getStringWidth(text);
  26186. return concat$12([" ".repeat(spaces), text]);
  26187. }
  26188. function alignCenter(text, width) {
  26189. var spaces = width - util$1.getStringWidth(text);
  26190. var left = Math.floor(spaces / 2);
  26191. var right = spaces - left;
  26192. return concat$12([" ".repeat(left), text, " ".repeat(right)]);
  26193. }
  26194. }
  26195. function printRoot(path$$1, options, print) {
  26196. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  26197. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  26198. var ignoreRanges = [];
  26199. /** @type {IgnorePosition | null} */
  26200. var ignoreStart = null;
  26201. var children = path$$1.getValue().children;
  26202. children.forEach(function (childNode, index) {
  26203. switch (isPrettierIgnore(childNode)) {
  26204. case "start":
  26205. if (ignoreStart === null) {
  26206. ignoreStart = {
  26207. index,
  26208. offset: childNode.position.end.offset
  26209. };
  26210. }
  26211. break;
  26212. case "end":
  26213. if (ignoreStart !== null) {
  26214. ignoreRanges.push({
  26215. start: ignoreStart,
  26216. end: {
  26217. index,
  26218. offset: childNode.position.start.offset
  26219. }
  26220. });
  26221. ignoreStart = null;
  26222. }
  26223. break;
  26224. default:
  26225. // do nothing
  26226. break;
  26227. }
  26228. });
  26229. return printChildren(path$$1, options, print, {
  26230. processor: function processor(childPath, index) {
  26231. if (ignoreRanges.length !== 0) {
  26232. var ignoreRange = ignoreRanges[0];
  26233. if (index === ignoreRange.start.index) {
  26234. return concat$12([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
  26235. }
  26236. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  26237. return false;
  26238. }
  26239. if (index === ignoreRange.end.index) {
  26240. ignoreRanges.shift();
  26241. return false;
  26242. }
  26243. }
  26244. return childPath.call(print);
  26245. }
  26246. });
  26247. }
  26248. function printChildren(path$$1, options, print, events$$1) {
  26249. events$$1 = events$$1 || {};
  26250. var postprocessor = events$$1.postprocessor || concat$12;
  26251. var processor = events$$1.processor || function (childPath) {
  26252. return childPath.call(print);
  26253. };
  26254. var node = path$$1.getValue();
  26255. var parts = [];
  26256. var lastChildNode;
  26257. path$$1.map(function (childPath, index) {
  26258. var childNode = childPath.getValue();
  26259. var result = processor(childPath, index);
  26260. if (result !== false) {
  26261. var data = {
  26262. parts,
  26263. prevNode: lastChildNode,
  26264. parentNode: node,
  26265. options
  26266. };
  26267. if (!shouldNotPrePrintHardline(childNode, data)) {
  26268. parts.push(hardline$10);
  26269. if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) {
  26270. if (shouldPrePrintTripleHardline(childNode, data)) {
  26271. parts.push(hardline$10);
  26272. }
  26273. } else {
  26274. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  26275. parts.push(hardline$10);
  26276. }
  26277. if (shouldPrePrintTripleHardline(childNode, data)) {
  26278. parts.push(hardline$10);
  26279. }
  26280. }
  26281. }
  26282. parts.push(result);
  26283. lastChildNode = childNode;
  26284. }
  26285. }, "children");
  26286. return postprocessor(parts);
  26287. }
  26288. function getLastDescendantNode(node) {
  26289. var current = node;
  26290. while (current.children && current.children.length !== 0) {
  26291. current = current.children[current.children.length - 1];
  26292. }
  26293. return current;
  26294. }
  26295. /** @return {false | 'next' | 'start' | 'end'} */
  26296. function isPrettierIgnore(node) {
  26297. if (node.type !== "html") {
  26298. return false;
  26299. }
  26300. var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  26301. return match === null ? false : match[1] ? match[1] : "next";
  26302. }
  26303. function shouldNotPrePrintHardline(node, data) {
  26304. var isFirstNode = data.parts.length === 0;
  26305. var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
  26306. var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
  26307. return isFirstNode || isInlineNode || isInlineHTML;
  26308. }
  26309. function shouldPrePrintDoubleHardline(node, data) {
  26310. var isSequence = (data.prevNode && data.prevNode.type) === node.type;
  26311. var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
  26312. var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  26313. var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  26314. var isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
  26315. var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  26316. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
  26317. }
  26318. function shouldPrePrintTripleHardline(node, data) {
  26319. var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  26320. var isIndentedCode = node.type === "code" && node.isIndented;
  26321. return isPrevNodeList && isIndentedCode;
  26322. }
  26323. function shouldRemainTheSameContent(path$$1) {
  26324. var ancestorNode = getAncestorNode$2(path$$1, ["linkReference", "imageReference"]);
  26325. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  26326. }
  26327. function normalizeDoc(doc$$2) {
  26328. return mapDoc$5(doc$$2, function (currentDoc) {
  26329. if (!currentDoc.parts) {
  26330. return currentDoc;
  26331. }
  26332. if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
  26333. return currentDoc.parts[0];
  26334. }
  26335. var parts = [];
  26336. currentDoc.parts.forEach(function (part) {
  26337. if (part.type === "concat") {
  26338. parts.push.apply(parts, part.parts);
  26339. } else if (part !== "") {
  26340. parts.push(part);
  26341. }
  26342. });
  26343. return Object.assign({}, currentDoc, {
  26344. parts: normalizeParts(parts)
  26345. });
  26346. });
  26347. }
  26348. function printUrl(url, dangerousCharOrChars) {
  26349. var dangerousChars = [" "].concat(dangerousCharOrChars || []);
  26350. return new RegExp(dangerousChars.map(function (x) {
  26351. return `\\${x}`;
  26352. }).join("|")).test(url) ? `<${url}>` : url;
  26353. }
  26354. function printTitle(title, options, printSpace) {
  26355. if (printSpace == null) {
  26356. printSpace = true;
  26357. }
  26358. if (!title) {
  26359. return "";
  26360. }
  26361. if (printSpace) {
  26362. return " " + printTitle(title, options, false);
  26363. }
  26364. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  26365. return `(${title})`; // avoid escaped quotes
  26366. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  26367. var singleCount = title.split("'").length - 1;
  26368. var doubleCount = title.split('"').length - 1;
  26369. var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  26370. title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
  26371. return `${quote}${title}${quote}`;
  26372. }
  26373. function normalizeParts(parts) {
  26374. return parts.reduce(function (current, part) {
  26375. var lastPart = util$1.getLast(current);
  26376. if (typeof lastPart === "string" && typeof part === "string") {
  26377. current.splice(-1, 1, lastPart + part);
  26378. } else {
  26379. current.push(part);
  26380. }
  26381. return current;
  26382. }, []);
  26383. }
  26384. function clamp(value, min, max) {
  26385. return value < min ? min : value > max ? max : value;
  26386. }
  26387. function clean$7(ast, newObj, parent) {
  26388. delete newObj.position;
  26389. delete newObj.raw; // front-matter
  26390. // for codeblock
  26391. if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  26392. delete newObj.value;
  26393. }
  26394. if (ast.type === "list") {
  26395. delete newObj.isAligned;
  26396. } // texts can be splitted or merged
  26397. if (ast.type === "text") {
  26398. return null;
  26399. }
  26400. if (ast.type === "inlineCode") {
  26401. newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
  26402. } // for insert pragma
  26403. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$6.startWithPragma(ast.value)) {
  26404. return null;
  26405. }
  26406. }
  26407. function hasPrettierIgnore$1(path$$1) {
  26408. var index = +path$$1.getName();
  26409. if (index === 0) {
  26410. return false;
  26411. }
  26412. var prevNode = path$$1.getParentNode().children[index - 1];
  26413. return isPrettierIgnore(prevNode) === "next";
  26414. }
  26415. var printerMarkdown = {
  26416. preprocess: preprocess_1$2,
  26417. print: genericPrint$4,
  26418. embed: embed_1$4,
  26419. massageAstNode: clean$7,
  26420. hasPrettierIgnore: hasPrettierIgnore$1,
  26421. insertPragma: pragma$6.insertPragma
  26422. };
  26423. var options$13 = {
  26424. proseWrap: commonOptions.proseWrap,
  26425. singleQuote: commonOptions.singleQuote
  26426. };
  26427. var name$13 = "Markdown";
  26428. var type$12 = "prose";
  26429. var aliases$4 = ["pandoc"];
  26430. var aceMode$12 = "markdown";
  26431. var codemirrorMode$9 = "gfm";
  26432. var codemirrorMimeType$9 = "text/x-gfm";
  26433. var wrap = true;
  26434. var extensions$12 = [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ronn", ".workbook"];
  26435. var tmScope$12 = "source.gfm";
  26436. var languageId$12 = 222;
  26437. var markdown = {
  26438. name: name$13,
  26439. type: type$12,
  26440. aliases: aliases$4,
  26441. aceMode: aceMode$12,
  26442. codemirrorMode: codemirrorMode$9,
  26443. codemirrorMimeType: codemirrorMimeType$9,
  26444. wrap: wrap,
  26445. extensions: extensions$12,
  26446. tmScope: tmScope$12,
  26447. languageId: languageId$12
  26448. };
  26449. var markdown$1 = Object.freeze({
  26450. name: name$13,
  26451. type: type$12,
  26452. aliases: aliases$4,
  26453. aceMode: aceMode$12,
  26454. codemirrorMode: codemirrorMode$9,
  26455. codemirrorMimeType: codemirrorMimeType$9,
  26456. wrap: wrap,
  26457. extensions: extensions$12,
  26458. tmScope: tmScope$12,
  26459. languageId: languageId$12,
  26460. default: markdown
  26461. });
  26462. var require$$0$28 = ( markdown$1 && markdown ) || markdown$1;
  26463. var languages$4 = [createLanguage(require$$0$28, {
  26464. override: {
  26465. since: "1.8.0",
  26466. parsers: ["remark"],
  26467. vscodeLanguageIds: ["markdown"]
  26468. },
  26469. extend: {
  26470. filenames: ["README"]
  26471. }
  26472. }), createLanguage({
  26473. name: "MDX",
  26474. extensions: [".mdx"]
  26475. }, // TODO: use linguist data
  26476. {
  26477. override: {
  26478. since: "1.15.0",
  26479. parsers: ["mdx"],
  26480. vscodeLanguageIds: ["mdx"]
  26481. }
  26482. })];
  26483. var printers$4 = {
  26484. mdast: printerMarkdown
  26485. };
  26486. var languageMarkdown = {
  26487. languages: languages$4,
  26488. options: options$13,
  26489. printers: printers$4
  26490. };
  26491. var clean$8 = function clean(ast, newNode) {
  26492. delete newNode.sourceSpan;
  26493. delete newNode.startSourceSpan;
  26494. delete newNode.endSourceSpan;
  26495. delete newNode.nameSpan;
  26496. delete newNode.valueSpan;
  26497. if (ast.type === "text" || ast.type === "comment") {
  26498. return null;
  26499. } // may be formatted by multiparser
  26500. if (ast.type === "yaml" || ast.type === "toml") {
  26501. return null;
  26502. }
  26503. if (ast.type === "attribute") {
  26504. delete newNode.value;
  26505. }
  26506. if (ast.type === "docType") {
  26507. delete newNode.value;
  26508. }
  26509. };
  26510. var a = ["accesskey", "charset", "coords", "download", "href", "hreflang", "name", "ping", "referrerpolicy", "rel", "rev", "shape", "tabindex", "target", "type"];
  26511. var abbr = ["title"];
  26512. var applet = ["align", "alt", "archive", "code", "codebase", "height", "hspace", "name", "object", "vspace", "width"];
  26513. var area = ["accesskey", "alt", "coords", "download", "href", "hreflang", "nohref", "ping", "referrerpolicy", "rel", "shape", "tabindex", "target", "type"];
  26514. var audio = ["autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src"];
  26515. var base$2 = ["href", "target"];
  26516. var basefont = ["color", "face", "size"];
  26517. var bdo = ["dir"];
  26518. var blockquote = ["cite"];
  26519. var body = ["alink", "background", "bgcolor", "link", "text", "vlink"];
  26520. var br = ["clear"];
  26521. var button = ["accesskey", "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "tabindex", "type", "value"];
  26522. var canvas = ["height", "width"];
  26523. var caption = ["align"];
  26524. var col = ["align", "char", "charoff", "span", "valign", "width"];
  26525. var colgroup = ["align", "char", "charoff", "span", "valign", "width"];
  26526. var data$1 = ["value"];
  26527. var del = ["cite", "datetime"];
  26528. var details = ["open"];
  26529. var dfn = ["title"];
  26530. var dialog = ["open"];
  26531. var dir = ["compact"];
  26532. var div = ["align"];
  26533. var dl = ["compact"];
  26534. var embed$7 = ["height", "src", "type", "width"];
  26535. var fieldset = ["disabled", "form", "name"];
  26536. var font = ["color", "face", "size"];
  26537. var form = ["accept", "accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"];
  26538. var frame = ["frameborder", "longdesc", "marginheight", "marginwidth", "name", "noresize", "scrolling", "src"];
  26539. var frameset = ["cols", "rows"];
  26540. var h1 = ["align"];
  26541. var h2 = ["align"];
  26542. var h3 = ["align"];
  26543. var h4 = ["align"];
  26544. var h5 = ["align"];
  26545. var h6 = ["align"];
  26546. var head = ["profile"];
  26547. var hr = ["align", "noshade", "size", "width"];
  26548. var html = ["manifest", "version"];
  26549. var iframe = ["align", "allowfullscreen", "allowpaymentrequest", "allowusermedia", "frameborder", "height", "longdesc", "marginheight", "marginwidth", "name", "referrerpolicy", "sandbox", "scrolling", "src", "srcdoc", "width"];
  26550. var img = ["align", "alt", "border", "crossorigin", "decoding", "height", "hspace", "ismap", "longdesc", "name", "referrerpolicy", "sizes", "src", "srcset", "usemap", "vspace", "width"];
  26551. var input = ["accept", "accesskey", "align", "alt", "autocomplete", "autofocus", "checked", "dirname", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "ismap", "list", "max", "maxlength", "min", "minlength", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "tabindex", "title", "type", "usemap", "value", "width"];
  26552. var ins = ["cite", "datetime"];
  26553. var isindex = ["prompt"];
  26554. var label = ["accesskey", "for", "form"];
  26555. var legend = ["accesskey", "align"];
  26556. var li = ["type", "value"];
  26557. var link$1 = ["as", "charset", "color", "crossorigin", "href", "hreflang", "integrity", "media", "nonce", "referrerpolicy", "rel", "rev", "sizes", "target", "title", "type"];
  26558. var map = ["name"];
  26559. var menu = ["compact"];
  26560. var meta = ["charset", "content", "http-equiv", "name", "scheme"];
  26561. var meter = ["high", "low", "max", "min", "optimum", "value"];
  26562. var object = ["align", "archive", "border", "classid", "codebase", "codetype", "data", "declare", "form", "height", "hspace", "name", "standby", "tabindex", "type", "typemustmatch", "usemap", "vspace", "width"];
  26563. var ol = ["compact", "reversed", "start", "type"];
  26564. var optgroup = ["disabled", "label"];
  26565. var option = ["disabled", "label", "selected", "value"];
  26566. var output = ["for", "form", "name"];
  26567. var p = ["align"];
  26568. var param = ["name", "type", "value", "valuetype"];
  26569. var pre = ["width"];
  26570. var progress = ["max", "value"];
  26571. var q = ["cite"];
  26572. var script = ["async", "charset", "crossorigin", "defer", "integrity", "language", "nomodule", "nonce", "referrerpolicy", "src", "type"];
  26573. var select = ["autocomplete", "autofocus", "disabled", "form", "multiple", "name", "required", "size", "tabindex"];
  26574. var slot = ["name"];
  26575. var source = ["media", "sizes", "src", "srcset", "type"];
  26576. var style = ["media", "nonce", "title", "type"];
  26577. var table = ["align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", "width"];
  26578. var tbody = ["align", "char", "charoff", "valign"];
  26579. var td = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  26580. var textarea = ["accesskey", "autocomplete", "autofocus", "cols", "dirname", "disabled", "form", "maxlength", "minlength", "name", "placeholder", "readonly", "required", "rows", "tabindex", "wrap"];
  26581. var tfoot = ["align", "char", "charoff", "valign"];
  26582. var th = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  26583. var thead = ["align", "char", "charoff", "valign"];
  26584. var time = ["datetime"];
  26585. var tr = ["align", "bgcolor", "char", "charoff", "valign"];
  26586. var track = ["default", "kind", "label", "src", "srclang"];
  26587. var ul = ["compact", "type"];
  26588. var video = ["autoplay", "controls", "crossorigin", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "width"];
  26589. var index$13 = {
  26590. a: a,
  26591. abbr: abbr,
  26592. applet: applet,
  26593. area: area,
  26594. audio: audio,
  26595. base: base$2,
  26596. basefont: basefont,
  26597. bdo: bdo,
  26598. blockquote: blockquote,
  26599. body: body,
  26600. br: br,
  26601. button: button,
  26602. canvas: canvas,
  26603. caption: caption,
  26604. col: col,
  26605. colgroup: colgroup,
  26606. data: data$1,
  26607. del: del,
  26608. details: details,
  26609. dfn: dfn,
  26610. dialog: dialog,
  26611. dir: dir,
  26612. div: div,
  26613. dl: dl,
  26614. embed: embed$7,
  26615. fieldset: fieldset,
  26616. font: font,
  26617. form: form,
  26618. frame: frame,
  26619. frameset: frameset,
  26620. h1: h1,
  26621. h2: h2,
  26622. h3: h3,
  26623. h4: h4,
  26624. h5: h5,
  26625. h6: h6,
  26626. head: head,
  26627. hr: hr,
  26628. html: html,
  26629. iframe: iframe,
  26630. img: img,
  26631. input: input,
  26632. ins: ins,
  26633. isindex: isindex,
  26634. label: label,
  26635. legend: legend,
  26636. li: li,
  26637. link: link$1,
  26638. map: map,
  26639. menu: menu,
  26640. meta: meta,
  26641. meter: meter,
  26642. object: object,
  26643. ol: ol,
  26644. optgroup: optgroup,
  26645. option: option,
  26646. output: output,
  26647. p: p,
  26648. param: param,
  26649. pre: pre,
  26650. progress: progress,
  26651. q: q,
  26652. script: script,
  26653. select: select,
  26654. slot: slot,
  26655. source: source,
  26656. style: style,
  26657. table: table,
  26658. tbody: tbody,
  26659. td: td,
  26660. textarea: textarea,
  26661. tfoot: tfoot,
  26662. th: th,
  26663. thead: thead,
  26664. time: time,
  26665. tr: tr,
  26666. track: track,
  26667. ul: ul,
  26668. video: video,
  26669. "*": ["accesskey", "autocapitalize", "class", "contenteditable", "dir", "draggable", "hidden", "id", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "slot", "spellcheck", "style", "tabindex", "title", "translate"]
  26670. };
  26671. var htmlElementAttributes = Object.freeze({
  26672. a: a,
  26673. abbr: abbr,
  26674. applet: applet,
  26675. area: area,
  26676. audio: audio,
  26677. base: base$2,
  26678. basefont: basefont,
  26679. bdo: bdo,
  26680. blockquote: blockquote,
  26681. body: body,
  26682. br: br,
  26683. button: button,
  26684. canvas: canvas,
  26685. caption: caption,
  26686. col: col,
  26687. colgroup: colgroup,
  26688. data: data$1,
  26689. del: del,
  26690. details: details,
  26691. dfn: dfn,
  26692. dialog: dialog,
  26693. dir: dir,
  26694. div: div,
  26695. dl: dl,
  26696. embed: embed$7,
  26697. fieldset: fieldset,
  26698. font: font,
  26699. form: form,
  26700. frame: frame,
  26701. frameset: frameset,
  26702. h1: h1,
  26703. h2: h2,
  26704. h3: h3,
  26705. h4: h4,
  26706. h5: h5,
  26707. h6: h6,
  26708. head: head,
  26709. hr: hr,
  26710. html: html,
  26711. iframe: iframe,
  26712. img: img,
  26713. input: input,
  26714. ins: ins,
  26715. isindex: isindex,
  26716. label: label,
  26717. legend: legend,
  26718. li: li,
  26719. link: link$1,
  26720. map: map,
  26721. menu: menu,
  26722. meta: meta,
  26723. meter: meter,
  26724. object: object,
  26725. ol: ol,
  26726. optgroup: optgroup,
  26727. option: option,
  26728. output: output,
  26729. p: p,
  26730. param: param,
  26731. pre: pre,
  26732. progress: progress,
  26733. q: q,
  26734. script: script,
  26735. select: select,
  26736. slot: slot,
  26737. source: source,
  26738. style: style,
  26739. table: table,
  26740. tbody: tbody,
  26741. td: td,
  26742. textarea: textarea,
  26743. tfoot: tfoot,
  26744. th: th,
  26745. thead: thead,
  26746. time: time,
  26747. tr: tr,
  26748. track: track,
  26749. ul: ul,
  26750. video: video,
  26751. default: index$13
  26752. });
  26753. var json$9 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none","datalist":"none","head":"none","link":"none","meta":"none","noembed":"none","noframes":"none","param":"none","rp":"none","script":"none","source":"block","style":"none","template":"inline","track":"block","title":"none","html":"block","body":"block","address":"block","blockquote":"block","center":"block","div":"block","figure":"block","figcaption":"block","footer":"block","form":"block","header":"block","hr":"block","legend":"block","listing":"block","main":"block","p":"block","plaintext":"block","pre":"block","xmp":"block","slot":"contents","ruby":"ruby","rt":"ruby-text","article":"block","aside":"block","h1":"block","h2":"block","h3":"block","h4":"block","h5":"block","h6":"block","hgroup":"block","nav":"block","section":"block","dir":"block","dd":"block","dl":"block","dt":"block","ol":"block","ul":"block","li":"list-item","table":"table","caption":"table-caption","colgroup":"table-column-group","col":"table-column","thead":"table-header-group","tbody":"table-row-group","tfoot":"table-footer-group","tr":"table-row","td":"table-cell","th":"table-cell","fieldset":"block","button":"inline-block","video":"inline-block","audio":"inline-block"},"CSS_DISPLAY_DEFAULT":"inline","CSS_WHITE_SPACE_TAGS":{"listing":"pre","plaintext":"pre","pre":"pre","xmp":"pre","nobr":"nowrap","table":"initial","textarea":"pre-wrap"},"CSS_WHITE_SPACE_DEFAULT":"normal"};
  26754. var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
  26755. var CSS_DISPLAY_TAGS = json$9.CSS_DISPLAY_TAGS;
  26756. var CSS_DISPLAY_DEFAULT = json$9.CSS_DISPLAY_DEFAULT;
  26757. var CSS_WHITE_SPACE_TAGS = json$9.CSS_WHITE_SPACE_TAGS;
  26758. var CSS_WHITE_SPACE_DEFAULT = json$9.CSS_WHITE_SPACE_DEFAULT;
  26759. var HTML_TAGS = arrayToMap(htmlTagNames$1);
  26760. var HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
  26761. function arrayToMap(array) {
  26762. var map = Object.create(null);
  26763. var _iteratorNormalCompletion = true;
  26764. var _didIteratorError = false;
  26765. var _iteratorError = undefined;
  26766. try {
  26767. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26768. var value = _step.value;
  26769. map[value] = true;
  26770. }
  26771. } catch (err) {
  26772. _didIteratorError = true;
  26773. _iteratorError = err;
  26774. } finally {
  26775. try {
  26776. if (!_iteratorNormalCompletion && _iterator.return != null) {
  26777. _iterator.return();
  26778. }
  26779. } finally {
  26780. if (_didIteratorError) {
  26781. throw _iteratorError;
  26782. }
  26783. }
  26784. }
  26785. return map;
  26786. }
  26787. function mapObject(object, fn) {
  26788. var newObject = Object.create(null);
  26789. var _arr = Object.keys(object);
  26790. for (var _i = 0; _i < _arr.length; _i++) {
  26791. var key = _arr[_i];
  26792. newObject[key] = fn(object[key], key);
  26793. }
  26794. return newObject;
  26795. }
  26796. function shouldPreserveContent$1(node, options) {
  26797. if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
  26798. return true;
  26799. } // unterminated node in ie conditional comment
  26800. // e.g. <!--[if lt IE 9]><html><![endif]-->
  26801. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  26802. return true;
  26803. } // incomplete html in ie conditional comment
  26804. // e.g. <!--[if lt IE 9]></div><![endif]-->
  26805. if (node.type === "ieConditionalComment" && !node.complete) {
  26806. return true;
  26807. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  26808. // custom blocks can be written in other languages so we should preserve them to not break the code
  26809. if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && ["template", "style", "script", // vue parser can be used for vue dom template as well, so we should still format top-level <html>
  26810. "html"].indexOf(node.fullName) === -1) {
  26811. return true;
  26812. } // TODO: handle non-text children in <pre>
  26813. if (isPreLikeNode(node) && node.children.some(function (child) {
  26814. return child.type !== "text" && child.type !== "interpolation";
  26815. })) {
  26816. return true;
  26817. }
  26818. return false;
  26819. }
  26820. function hasPrettierIgnore$3(node) {
  26821. if (node.type === "attribute" || isTextLikeNode$1(node)) {
  26822. return false;
  26823. }
  26824. if (!node.parent) {
  26825. return false;
  26826. }
  26827. if (typeof node.index !== "number" || node.index === 0) {
  26828. return false;
  26829. }
  26830. var prevNode = node.parent.children[node.index - 1];
  26831. return isPrettierIgnore$1(prevNode);
  26832. }
  26833. function isPrettierIgnore$1(node) {
  26834. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  26835. }
  26836. function getPrettierIgnoreAttributeCommentData$1(value) {
  26837. var match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/);
  26838. if (!match) {
  26839. return false;
  26840. }
  26841. if (!match[1]) {
  26842. return true;
  26843. }
  26844. return match[1].split(/\s+/);
  26845. }
  26846. /** there's no opening/closing tag or it's considered not breakable */
  26847. function isTextLikeNode$1(node) {
  26848. return node.type === "text" || node.type === "comment";
  26849. }
  26850. function isScriptLikeTag$1(node) {
  26851. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style");
  26852. }
  26853. function isFrontMatterNode(node) {
  26854. return node.type === "yaml" || node.type === "toml";
  26855. }
  26856. function canHaveInterpolation(node) {
  26857. return node.children && !isScriptLikeTag$1(node);
  26858. }
  26859. function isWhitespaceSensitiveNode(node) {
  26860. return isScriptLikeTag$1(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
  26861. }
  26862. function isIndentationSensitiveNode(node) {
  26863. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  26864. }
  26865. function isLeadingSpaceSensitiveNode(node) {
  26866. var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  26867. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  26868. return node.type === "interpolation";
  26869. }
  26870. return isLeadingSpaceSensitive;
  26871. function _isLeadingSpaceSensitiveNode() {
  26872. if (isFrontMatterNode(node)) {
  26873. return false;
  26874. }
  26875. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  26876. return true;
  26877. }
  26878. if (!node.parent || node.parent.cssDisplay === "none") {
  26879. return false;
  26880. }
  26881. if (isPreLikeNode(node.parent)) {
  26882. return true;
  26883. }
  26884. if (!node.prev && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  26885. return false;
  26886. }
  26887. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  26888. return false;
  26889. }
  26890. return true;
  26891. }
  26892. }
  26893. function isTrailingSpaceSensitiveNode(node) {
  26894. if (isFrontMatterNode(node)) {
  26895. return false;
  26896. }
  26897. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  26898. return true;
  26899. }
  26900. if (!node.parent || node.parent.cssDisplay === "none") {
  26901. return false;
  26902. }
  26903. if (isPreLikeNode(node.parent)) {
  26904. return true;
  26905. }
  26906. if (!node.next && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  26907. return false;
  26908. }
  26909. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  26910. return false;
  26911. }
  26912. return true;
  26913. }
  26914. function isDanglingSpaceSensitiveNode(node) {
  26915. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
  26916. }
  26917. function forceNextEmptyLine$1(node) {
  26918. return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  26919. }
  26920. /** firstChild leadingSpaces and lastChild trailingSpaces */
  26921. function forceBreakContent$1(node) {
  26922. return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
  26923. return hasNonTextChild(child);
  26924. })) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  26925. }
  26926. /** spaces between children */
  26927. function forceBreakChildren$1(node) {
  26928. return node.type === "element" && node.children.length !== 0 && (["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
  26929. }
  26930. function preferHardlineAsLeadingSpaces$1(node) {
  26931. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  26932. }
  26933. function preferHardlineAsTrailingSpaces(node) {
  26934. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  26935. }
  26936. function hasSurroundingLineBreak(node) {
  26937. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  26938. }
  26939. function hasLeadingLineBreak(node) {
  26940. 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);
  26941. }
  26942. function hasTrailingLineBreak(node) {
  26943. return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
  26944. }
  26945. function preferHardlineAsSurroundingSpaces(node) {
  26946. switch (node.type) {
  26947. case "ieConditionalComment":
  26948. case "comment":
  26949. case "directive":
  26950. return true;
  26951. case "element":
  26952. return ["script", "select"].indexOf(node.name) !== -1;
  26953. }
  26954. return false;
  26955. }
  26956. function getLastDescendant$1(node) {
  26957. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  26958. }
  26959. function hasNonTextChild(node) {
  26960. return node.children && node.children.some(function (child) {
  26961. return child.type !== "text";
  26962. });
  26963. }
  26964. function inferScriptParser$1(node) {
  26965. if (node.name === "script" && !node.attrMap.src) {
  26966. if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript") {
  26967. return "babel";
  26968. }
  26969. if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
  26970. return "typescript";
  26971. }
  26972. if (node.attrMap.type === "text/markdown") {
  26973. return "markdown";
  26974. }
  26975. if (node.attrMap.type === "application/ld+json") {
  26976. return "json";
  26977. }
  26978. }
  26979. if (node.name === "style") {
  26980. if (!node.attrMap.lang || node.attrMap.lang === "postcss") {
  26981. return "css";
  26982. }
  26983. if (node.attrMap.lang === "scss") {
  26984. return "scss";
  26985. }
  26986. if (node.attrMap.lang === "less") {
  26987. return "less";
  26988. }
  26989. }
  26990. return null;
  26991. }
  26992. function isBlockLikeCssDisplay(cssDisplay) {
  26993. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  26994. }
  26995. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  26996. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  26997. }
  26998. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  26999. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  27000. }
  27001. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  27002. return !isBlockLikeCssDisplay(cssDisplay);
  27003. }
  27004. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  27005. return !isBlockLikeCssDisplay(cssDisplay);
  27006. }
  27007. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  27008. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  27009. }
  27010. function isPreLikeNode(node) {
  27011. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  27012. }
  27013. function countParents$1(path$$1) {
  27014. var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  27015. return true;
  27016. };
  27017. var counter = 0;
  27018. for (var i = path$$1.stack.length - 1; i >= 0; i--) {
  27019. var value = path$$1.stack[i];
  27020. if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
  27021. counter++;
  27022. }
  27023. }
  27024. return counter;
  27025. }
  27026. function hasParent(node, fn) {
  27027. var current = node;
  27028. while (current) {
  27029. if (fn(current)) {
  27030. return true;
  27031. }
  27032. current = current.parent;
  27033. }
  27034. return false;
  27035. }
  27036. function getNodeCssStyleDisplay(node, options) {
  27037. if (node.prev && node.prev.type === "comment") {
  27038. // <!-- display: block -->
  27039. var match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  27040. if (match) {
  27041. return match[1];
  27042. }
  27043. }
  27044. var isInSvgForeignObject = false;
  27045. if (node.type === "element" && node.namespace === "svg") {
  27046. if (hasParent(node, function (parent) {
  27047. return parent.fullName === "svg:foreignObject";
  27048. })) {
  27049. isInSvgForeignObject = true;
  27050. } else {
  27051. return node.name === "svg" ? "inline-block" : "block";
  27052. }
  27053. }
  27054. switch (options.htmlWhitespaceSensitivity) {
  27055. case "strict":
  27056. return "inline";
  27057. case "ignore":
  27058. return "block";
  27059. default:
  27060. return node.type === "element" && (!node.namespace || isInSvgForeignObject) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  27061. }
  27062. }
  27063. function getNodeCssStyleWhiteSpace(node) {
  27064. return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  27065. }
  27066. function getMinIndentation(text) {
  27067. var minIndentation = Infinity;
  27068. var _iteratorNormalCompletion2 = true;
  27069. var _didIteratorError2 = false;
  27070. var _iteratorError2 = undefined;
  27071. try {
  27072. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  27073. var lineText = _step2.value;
  27074. if (lineText.length === 0) {
  27075. continue;
  27076. }
  27077. if (/\S/.test(lineText[0])) {
  27078. return 0;
  27079. }
  27080. var indentation = lineText.match(/^\s*/)[0].length;
  27081. if (lineText.length === indentation) {
  27082. continue;
  27083. }
  27084. if (indentation < minIndentation) {
  27085. minIndentation = indentation;
  27086. }
  27087. }
  27088. } catch (err) {
  27089. _didIteratorError2 = true;
  27090. _iteratorError2 = err;
  27091. } finally {
  27092. try {
  27093. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  27094. _iterator2.return();
  27095. }
  27096. } finally {
  27097. if (_didIteratorError2) {
  27098. throw _iteratorError2;
  27099. }
  27100. }
  27101. }
  27102. return minIndentation === Infinity ? 0 : minIndentation;
  27103. }
  27104. function dedentString$1(text) {
  27105. var minIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getMinIndentation(text);
  27106. return minIndent === 0 ? text : text.split("\n").map(function (lineText) {
  27107. return lineText.slice(minIndent);
  27108. }).join("\n");
  27109. }
  27110. function normalizeParts$2(parts) {
  27111. var newParts = [];
  27112. var restParts = parts.slice();
  27113. while (restParts.length !== 0) {
  27114. var part = restParts.shift();
  27115. if (!part) {
  27116. continue;
  27117. }
  27118. if (part.type === "concat") {
  27119. Array.prototype.unshift.apply(restParts, part.parts);
  27120. continue;
  27121. }
  27122. if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
  27123. newParts.push(newParts.pop() + part);
  27124. continue;
  27125. }
  27126. newParts.push(part);
  27127. }
  27128. return newParts;
  27129. }
  27130. function identity$2(x) {
  27131. return x;
  27132. }
  27133. function shouldNotPrintClosingTag$1(node, options) {
  27134. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
  27135. }
  27136. function countChars$1(text, char) {
  27137. var counter = 0;
  27138. for (var i = 0; i < text.length; i++) {
  27139. if (text[i] === char) {
  27140. counter++;
  27141. }
  27142. }
  27143. return counter;
  27144. }
  27145. function unescapeQuoteEntities$1(text) {
  27146. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  27147. }
  27148. var utils$10 = {
  27149. HTML_ELEMENT_ATTRIBUTES,
  27150. HTML_TAGS,
  27151. canHaveInterpolation,
  27152. countChars: countChars$1,
  27153. countParents: countParents$1,
  27154. dedentString: dedentString$1,
  27155. forceBreakChildren: forceBreakChildren$1,
  27156. forceBreakContent: forceBreakContent$1,
  27157. forceNextEmptyLine: forceNextEmptyLine$1,
  27158. getLastDescendant: getLastDescendant$1,
  27159. getNodeCssStyleDisplay,
  27160. getNodeCssStyleWhiteSpace,
  27161. getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData$1,
  27162. hasPrettierIgnore: hasPrettierIgnore$3,
  27163. identity: identity$2,
  27164. inferScriptParser: inferScriptParser$1,
  27165. isDanglingSpaceSensitiveNode,
  27166. isFrontMatterNode,
  27167. isIndentationSensitiveNode,
  27168. isLeadingSpaceSensitiveNode,
  27169. isPreLikeNode,
  27170. isScriptLikeTag: isScriptLikeTag$1,
  27171. isTextLikeNode: isTextLikeNode$1,
  27172. isTrailingSpaceSensitiveNode,
  27173. isWhitespaceSensitiveNode,
  27174. normalizeParts: normalizeParts$2,
  27175. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  27176. preferHardlineAsTrailingSpaces,
  27177. shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
  27178. shouldPreserveContent: shouldPreserveContent$1,
  27179. unescapeQuoteEntities: unescapeQuoteEntities$1
  27180. };
  27181. var canHaveInterpolation$1 = utils$10.canHaveInterpolation;
  27182. var getNodeCssStyleDisplay$1 = utils$10.getNodeCssStyleDisplay;
  27183. var isDanglingSpaceSensitiveNode$1 = utils$10.isDanglingSpaceSensitiveNode;
  27184. var isIndentationSensitiveNode$1 = utils$10.isIndentationSensitiveNode;
  27185. var isLeadingSpaceSensitiveNode$1 = utils$10.isLeadingSpaceSensitiveNode;
  27186. var isTrailingSpaceSensitiveNode$1 = utils$10.isTrailingSpaceSensitiveNode;
  27187. var isWhitespaceSensitiveNode$1 = utils$10.isWhitespaceSensitiveNode;
  27188. var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  27189. function preprocess$4(ast, options) {
  27190. for (var _i = 0; _i < PREPROCESS_PIPELINE.length; _i++) {
  27191. var fn = PREPROCESS_PIPELINE[_i];
  27192. ast = fn(ast, options);
  27193. }
  27194. return ast;
  27195. }
  27196. function removeIgnorableFirstLf(ast
  27197. /*, options */
  27198. ) {
  27199. return ast.map(function (node) {
  27200. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  27201. var text = node.children[0];
  27202. return node.clone({
  27203. children: text.value.length === 1 ? node.children.slice(1) : [].concat(text.clone({
  27204. value: text.value.slice(1)
  27205. }), node.children.slice(1))
  27206. });
  27207. }
  27208. return node;
  27209. });
  27210. }
  27211. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  27212. /*, options */
  27213. ) {
  27214. /**
  27215. * <!--[if ...]><!--><target><!--<![endif]-->
  27216. */
  27217. var isTarget = function isTarget(node) {
  27218. return 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;
  27219. };
  27220. return ast.map(function (node) {
  27221. if (node.children) {
  27222. var isTargetResults = node.children.map(isTarget);
  27223. if (isTargetResults.some(Boolean)) {
  27224. var newChildren = [];
  27225. for (var i = 0; i < node.children.length; i++) {
  27226. var child = node.children[i];
  27227. if (isTargetResults[i + 1]) {
  27228. // ieConditionalStartComment
  27229. continue;
  27230. }
  27231. if (isTargetResults[i]) {
  27232. var ieConditionalStartComment = child.prev;
  27233. var ieConditionalEndComment = child.firstChild;
  27234. var ParseSourceSpan = child.sourceSpan.constructor;
  27235. var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  27236. var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  27237. newChildren.push(child.clone({
  27238. condition: ieConditionalStartComment.condition,
  27239. sourceSpan,
  27240. startSourceSpan,
  27241. children: child.children.slice(1)
  27242. }));
  27243. continue;
  27244. }
  27245. newChildren.push(child);
  27246. }
  27247. return node.clone({
  27248. children: newChildren
  27249. });
  27250. }
  27251. }
  27252. return node;
  27253. });
  27254. }
  27255. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  27256. return ast.map(function (node) {
  27257. if (node.children) {
  27258. var shouldMergeResults = node.children.map(shouldMerge);
  27259. if (shouldMergeResults.some(Boolean)) {
  27260. var newChildren = [];
  27261. for (var i = 0; i < node.children.length; i++) {
  27262. var child = node.children[i];
  27263. if (child.type !== "text" && !shouldMergeResults[i]) {
  27264. newChildren.push(child);
  27265. continue;
  27266. }
  27267. var newChild = child.type === "text" ? child : child.clone({
  27268. type: "text",
  27269. value: getValue(child)
  27270. });
  27271. if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") {
  27272. newChildren.push(newChild);
  27273. continue;
  27274. }
  27275. var lastChild = newChildren.pop();
  27276. var ParseSourceSpan = lastChild.sourceSpan.constructor;
  27277. newChildren.push(lastChild.clone({
  27278. value: lastChild.value + newChild.value,
  27279. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  27280. }));
  27281. }
  27282. return node.clone({
  27283. children: newChildren
  27284. });
  27285. }
  27286. }
  27287. return node;
  27288. });
  27289. }
  27290. function mergeCdataIntoText(ast
  27291. /*, options */
  27292. ) {
  27293. return mergeNodeIntoText(ast, function (node) {
  27294. return node.type === "cdata";
  27295. }, function (node) {
  27296. return `<![CDATA[${node.value}]]>`;
  27297. });
  27298. }
  27299. function mergeSimpleElementIntoText(ast
  27300. /*, options */
  27301. ) {
  27302. var isSimpleElement = function isSimpleElement(node) {
  27303. return node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && // \xA0: non-breaking whitespace
  27304. !/[^\S\xA0]/.test(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";
  27305. };
  27306. return ast.map(function (node) {
  27307. if (node.children) {
  27308. var isSimpleElementResults = node.children.map(isSimpleElement);
  27309. if (isSimpleElementResults.some(Boolean)) {
  27310. var newChildren = [];
  27311. for (var i = 0; i < node.children.length; i++) {
  27312. var child = node.children[i];
  27313. if (isSimpleElementResults[i]) {
  27314. var lastChild = newChildren.pop();
  27315. var nextChild = node.children[++i];
  27316. var ParseSourceSpan = node.sourceSpan.constructor;
  27317. var isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive,
  27318. hasTrailingSpaces = nextChild.hasTrailingSpaces;
  27319. newChildren.push(lastChild.clone({
  27320. value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
  27321. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  27322. isTrailingSpaceSensitive,
  27323. hasTrailingSpaces
  27324. }));
  27325. } else {
  27326. newChildren.push(child);
  27327. }
  27328. }
  27329. return node.clone({
  27330. children: newChildren
  27331. });
  27332. }
  27333. }
  27334. return node;
  27335. });
  27336. }
  27337. function extractInterpolation(ast, options) {
  27338. if (options.parser === "html") {
  27339. return ast;
  27340. }
  27341. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  27342. return ast.map(function (node) {
  27343. if (!canHaveInterpolation$1(node)) {
  27344. return node;
  27345. }
  27346. var newChildren = [];
  27347. var _iteratorNormalCompletion = true;
  27348. var _didIteratorError = false;
  27349. var _iteratorError = undefined;
  27350. try {
  27351. for (var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27352. var child = _step.value;
  27353. if (child.type !== "text") {
  27354. newChildren.push(child);
  27355. continue;
  27356. }
  27357. var ParseSourceSpan = child.sourceSpan.constructor;
  27358. var startSourceSpan = child.sourceSpan.start;
  27359. var endSourceSpan = null;
  27360. var components = child.value.split(interpolationRegex);
  27361. for (var i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  27362. var value = components[i];
  27363. if (i % 2 === 0) {
  27364. endSourceSpan = startSourceSpan.moveBy(value.length);
  27365. if (value.length !== 0) {
  27366. newChildren.push({
  27367. type: "text",
  27368. value,
  27369. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  27370. });
  27371. }
  27372. continue;
  27373. }
  27374. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  27375. newChildren.push({
  27376. type: "interpolation",
  27377. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  27378. children: value.length === 0 ? [] : [{
  27379. type: "text",
  27380. value,
  27381. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  27382. }]
  27383. });
  27384. }
  27385. }
  27386. } catch (err) {
  27387. _didIteratorError = true;
  27388. _iteratorError = err;
  27389. } finally {
  27390. try {
  27391. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27392. _iterator.return();
  27393. }
  27394. } finally {
  27395. if (_didIteratorError) {
  27396. throw _iteratorError;
  27397. }
  27398. }
  27399. }
  27400. return node.clone({
  27401. children: newChildren
  27402. });
  27403. });
  27404. }
  27405. /**
  27406. * - add `hasLeadingSpaces` field
  27407. * - add `hasTrailingSpaces` field
  27408. * - add `hasDanglingSpaces` field for parent nodes
  27409. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  27410. * - remove insensitive whitespaces
  27411. */
  27412. function extractWhitespaces(ast
  27413. /*, options*/
  27414. ) {
  27415. var TYPE_WHITESPACE = "whitespace";
  27416. return ast.map(function (node) {
  27417. if (!node.children) {
  27418. return node;
  27419. }
  27420. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) {
  27421. return node.clone({
  27422. children: [],
  27423. hasDanglingSpaces: node.children.length !== 0
  27424. });
  27425. }
  27426. var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
  27427. var isIndentationSensitive = isIndentationSensitiveNode$1(node);
  27428. return node.clone({
  27429. isWhitespaceSensitive,
  27430. isIndentationSensitive,
  27431. children: node.children // extract whitespace nodes
  27432. .reduce(function (newChildren, child) {
  27433. if (child.type !== "text" || isWhitespaceSensitive) {
  27434. return newChildren.concat(child);
  27435. }
  27436. var localChildren = [];
  27437. var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/),
  27438. _child$value$match2 = _slicedToArray(_child$value$match, 4),
  27439. leadingSpaces = _child$value$match2[1],
  27440. text = _child$value$match2[2],
  27441. trailingSpaces = _child$value$match2[3];
  27442. if (leadingSpaces) {
  27443. localChildren.push({
  27444. type: TYPE_WHITESPACE
  27445. });
  27446. }
  27447. var ParseSourceSpan = child.sourceSpan.constructor;
  27448. if (text) {
  27449. localChildren.push({
  27450. type: "text",
  27451. value: text,
  27452. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length))
  27453. });
  27454. }
  27455. if (trailingSpaces) {
  27456. localChildren.push({
  27457. type: TYPE_WHITESPACE
  27458. });
  27459. }
  27460. return newChildren.concat(localChildren);
  27461. }, []) // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes
  27462. .reduce(function (newChildren, child, i, children) {
  27463. if (child.type === TYPE_WHITESPACE) {
  27464. return newChildren;
  27465. }
  27466. var hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
  27467. var hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE;
  27468. return newChildren.concat(Object.assign({}, child, {
  27469. hasLeadingSpaces,
  27470. hasTrailingSpaces
  27471. }));
  27472. }, [])
  27473. });
  27474. });
  27475. }
  27476. function addIsSelfClosing(ast
  27477. /*, options */
  27478. ) {
  27479. return ast.map(function (node) {
  27480. return Object.assign(node, {
  27481. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  27482. node.startSourceSpan === node.endSourceSpan)
  27483. });
  27484. });
  27485. }
  27486. function addHasHtmComponentClosingTag(ast, options) {
  27487. return ast.map(function (node) {
  27488. return node.type !== "element" ? node : Object.assign(node, {
  27489. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  27490. });
  27491. });
  27492. }
  27493. function addCssDisplay(ast, options) {
  27494. return ast.map(function (node) {
  27495. return Object.assign(node, {
  27496. cssDisplay: getNodeCssStyleDisplay$1(node, options)
  27497. });
  27498. });
  27499. }
  27500. /**
  27501. * - add `isLeadingSpaceSensitive` field
  27502. * - add `isTrailingSpaceSensitive` field
  27503. * - add `isDanglingSpaceSensitive` field for parent nodes
  27504. */
  27505. function addIsSpaceSensitive(ast
  27506. /*, options */
  27507. ) {
  27508. return ast.map(function (node) {
  27509. if (!node.children) {
  27510. return node;
  27511. }
  27512. if (node.children.length === 0) {
  27513. return node.clone({
  27514. isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
  27515. });
  27516. }
  27517. return node.clone({
  27518. children: node.children.map(function (child) {
  27519. return Object.assign({}, child, {
  27520. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child),
  27521. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child)
  27522. });
  27523. }).map(function (child, index, children) {
  27524. return Object.assign({}, child, {
  27525. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  27526. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  27527. });
  27528. })
  27529. });
  27530. });
  27531. }
  27532. var preprocess_1$4 = preprocess$4;
  27533. function hasPragma$3(text) {
  27534. return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
  27535. }
  27536. function insertPragma$7(text) {
  27537. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  27538. }
  27539. var pragma$9 = {
  27540. hasPragma: hasPragma$3,
  27541. insertPragma: insertPragma$7
  27542. };
  27543. var _require$$0$builders$8 = doc.builders;
  27544. var concat$15 = _require$$0$builders$8.concat;
  27545. var group$15 = _require$$0$builders$8.group;
  27546. /**
  27547. * v-for="... in ..."
  27548. * v-for="... of ..."
  27549. * v-for="(..., ...) in ..."
  27550. * v-for="(..., ...) of ..."
  27551. */
  27552. function printVueFor$1(value, textToDoc) {
  27553. var _parseVueFor = parseVueFor(value),
  27554. left = _parseVueFor.left,
  27555. operator = _parseVueFor.operator,
  27556. right = _parseVueFor.right;
  27557. return concat$15([group$15(textToDoc(`function _(${left}) {}`, {
  27558. parser: "babel",
  27559. __isVueForBindingLeft: true
  27560. })), " ", operator, " ", textToDoc(right, {
  27561. parser: "__js_expression"
  27562. })]);
  27563. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  27564. function parseVueFor(value) {
  27565. var forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
  27566. var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
  27567. var stripParensRE = /^\(|\)$/g;
  27568. var inMatch = value.match(forAliasRE);
  27569. if (!inMatch) {
  27570. return;
  27571. }
  27572. var res = {};
  27573. res.for = inMatch[3].trim();
  27574. var alias = inMatch[1].trim().replace(stripParensRE, "");
  27575. var iteratorMatch = alias.match(forIteratorRE);
  27576. if (iteratorMatch) {
  27577. res.alias = alias.replace(forIteratorRE, "");
  27578. res.iterator1 = iteratorMatch[1].trim();
  27579. if (iteratorMatch[2]) {
  27580. res.iterator2 = iteratorMatch[2].trim();
  27581. }
  27582. } else {
  27583. res.alias = alias;
  27584. }
  27585. return {
  27586. left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
  27587. operator: inMatch[2],
  27588. right: res.for
  27589. };
  27590. }
  27591. function printVueSlotScope$1(value, textToDoc) {
  27592. return textToDoc(`function _(${value}) {}`, {
  27593. parser: "babel",
  27594. __isVueSlotScope: true
  27595. });
  27596. }
  27597. function isVueEventBindingExpression$3(eventBindingValue) {
  27598. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  27599. // arrow function or anonymous function
  27600. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  27601. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
  27602. var value = eventBindingValue.trim();
  27603. return fnExpRE.test(value) || simplePathRE.test(value);
  27604. }
  27605. var syntaxVue = {
  27606. isVueEventBindingExpression: isVueEventBindingExpression$3,
  27607. printVueFor: printVueFor$1,
  27608. printVueSlotScope: printVueSlotScope$1
  27609. };
  27610. var parseSrcset = createCommonjsModule(function (module) {
  27611. /**
  27612. * Srcset Parser
  27613. *
  27614. * By Alex Bell | MIT License
  27615. *
  27616. * JS Parser for the string value that appears in markup <img srcset="here">
  27617. *
  27618. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  27619. *
  27620. * Based super duper closely on the reference algorithm at:
  27621. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  27622. *
  27623. * Most comments are copied in directly from the spec
  27624. * (except for comments in parens).
  27625. */
  27626. (function (root, factory) {
  27627. if (typeof undefined === 'function' && undefined.amd) {
  27628. // AMD. Register as an anonymous module.
  27629. undefined([], factory);
  27630. } else if ('object' === 'object' && module.exports) {
  27631. // Node. Does not work with strict CommonJS, but
  27632. // only CommonJS-like environments that support module.exports,
  27633. // like Node.
  27634. module.exports = factory();
  27635. } else {
  27636. // Browser globals (root is window)
  27637. root.parseSrcset = factory();
  27638. }
  27639. })(this, function () {
  27640. // 1. Let input be the value passed to this algorithm.
  27641. return function (input, options) {
  27642. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  27643. // Manual is faster than RegEx
  27644. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  27645. // http://jsperf.com/whitespace-character/5
  27646. function isSpace(c) {
  27647. return c === "\u0020" || // space
  27648. c === "\u0009" || // horizontal tab
  27649. c === "\u000A" || // new line
  27650. c === "\u000C" || // form feed
  27651. c === "\u000D"; // carriage return
  27652. }
  27653. function collectCharacters(regEx) {
  27654. var chars,
  27655. match = regEx.exec(input.substring(pos));
  27656. if (match) {
  27657. chars = match[0];
  27658. pos += chars.length;
  27659. return chars;
  27660. }
  27661. }
  27662. var inputLength = input.length,
  27663. // (Don't use \s, to avoid matching non-breaking space)
  27664. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  27665. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  27666. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  27667. regexTrailingCommas = /[,]+$/,
  27668. regexNonNegativeInteger = /^\d+$/,
  27669. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  27670. // Must include at least one digit.
  27671. // According to spec tests any decimal point must be followed by a digit.
  27672. // No leading plus sign is allowed.)
  27673. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  27674. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  27675. url,
  27676. descriptors,
  27677. currentDescriptor,
  27678. state,
  27679. c,
  27680. // 2. Let position be a pointer into input, initially pointing at the start
  27681. // of the string.
  27682. pos = 0,
  27683. // 3. Let candidates be an initially empty source set.
  27684. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  27685. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  27686. // were collected, that is a parse error.
  27687. while (true) {
  27688. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  27689. if (pos >= inputLength) {
  27690. return candidates; // (we're done, this is the sole return path)
  27691. } // 6. Collect a sequence of characters that are not space characters,
  27692. // and let that be url.
  27693. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  27694. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  27695. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  27696. // more than one character, that is a parse error.
  27697. if (url.slice(-1) === ",") {
  27698. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  27699. parseDescriptors(); // Otherwise, follow these substeps:
  27700. } else {
  27701. tokenize();
  27702. } // (close else of step 8)
  27703. // 16. Return to the step labeled splitting loop.
  27704. } // (Close of big while loop.)
  27705. /**
  27706. * Tokenizes descriptor properties prior to parsing
  27707. * Returns undefined.
  27708. */
  27709. function tokenize() {
  27710. // 8.1. Descriptor tokeniser: Skip whitespace
  27711. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  27712. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  27713. state = "in descriptor";
  27714. while (true) {
  27715. // 8.4. Let c be the character at position.
  27716. c = input.charAt(pos); // Do the following depending on the value of state.
  27717. // For the purpose of this step, "EOF" is a special character representing
  27718. // that position is past the end of input.
  27719. // In descriptor
  27720. if (state === "in descriptor") {
  27721. // Do the following, depending on the value of c:
  27722. // Space character
  27723. // If current descriptor is not empty, append current descriptor to
  27724. // descriptors and let current descriptor be the empty string.
  27725. // Set state to after descriptor.
  27726. if (isSpace(c)) {
  27727. if (currentDescriptor) {
  27728. descriptors.push(currentDescriptor);
  27729. currentDescriptor = "";
  27730. state = "after descriptor";
  27731. } // U+002C COMMA (,)
  27732. // Advance position to the next character in input. If current descriptor
  27733. // is not empty, append current descriptor to descriptors. Jump to the step
  27734. // labeled descriptor parser.
  27735. } else if (c === ",") {
  27736. pos += 1;
  27737. if (currentDescriptor) {
  27738. descriptors.push(currentDescriptor);
  27739. }
  27740. parseDescriptors();
  27741. return; // U+0028 LEFT PARENTHESIS (()
  27742. // Append c to current descriptor. Set state to in parens.
  27743. } else if (c === "\u0028") {
  27744. currentDescriptor = currentDescriptor + c;
  27745. state = "in parens"; // EOF
  27746. // If current descriptor is not empty, append current descriptor to
  27747. // descriptors. Jump to the step labeled descriptor parser.
  27748. } else if (c === "") {
  27749. if (currentDescriptor) {
  27750. descriptors.push(currentDescriptor);
  27751. }
  27752. parseDescriptors();
  27753. return; // Anything else
  27754. // Append c to current descriptor.
  27755. } else {
  27756. currentDescriptor = currentDescriptor + c;
  27757. } // (end "in descriptor"
  27758. // In parens
  27759. } else if (state === "in parens") {
  27760. // U+0029 RIGHT PARENTHESIS ())
  27761. // Append c to current descriptor. Set state to in descriptor.
  27762. if (c === ")") {
  27763. currentDescriptor = currentDescriptor + c;
  27764. state = "in descriptor"; // EOF
  27765. // Append current descriptor to descriptors. Jump to the step labeled
  27766. // descriptor parser.
  27767. } else if (c === "") {
  27768. descriptors.push(currentDescriptor);
  27769. parseDescriptors();
  27770. return; // Anything else
  27771. // Append c to current descriptor.
  27772. } else {
  27773. currentDescriptor = currentDescriptor + c;
  27774. } // After descriptor
  27775. } else if (state === "after descriptor") {
  27776. // Do the following, depending on the value of c:
  27777. // Space character: Stay in this state.
  27778. if (isSpace(c)) {// EOF: Jump to the step labeled descriptor parser.
  27779. } else if (c === "") {
  27780. parseDescriptors();
  27781. return; // Anything else
  27782. // Set state to in descriptor. Set position to the previous character in input.
  27783. } else {
  27784. state = "in descriptor";
  27785. pos -= 1;
  27786. }
  27787. } // Advance position to the next character in input.
  27788. pos += 1; // Repeat this step.
  27789. } // (close while true loop)
  27790. }
  27791. /**
  27792. * Adds descriptor properties to a candidate, pushes to the candidates array
  27793. * @return undefined
  27794. */
  27795. // Declared outside of the while loop so that it's only created once.
  27796. function parseDescriptors() {
  27797. // 9. Descriptor parser: Let error be no.
  27798. var pError = false,
  27799. // 10. Let width be absent.
  27800. // 11. Let density be absent.
  27801. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  27802. w,
  27803. d,
  27804. h,
  27805. i,
  27806. candidate = {},
  27807. desc,
  27808. lastChar,
  27809. value,
  27810. intVal,
  27811. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  27812. // from the following list:
  27813. for (i = 0; i < descriptors.length; i++) {
  27814. desc = descriptors[i];
  27815. lastChar = desc[desc.length - 1];
  27816. value = desc.substring(0, desc.length - 1);
  27817. intVal = parseInt(value, 10);
  27818. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  27819. // a U+0077 LATIN SMALL LETTER W character
  27820. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  27821. // If width and density are not both absent, then let error be yes.
  27822. if (w || d) {
  27823. pError = true;
  27824. } // Apply the rules for parsing non-negative integers to the descriptor.
  27825. // If the result is zero, let error be yes.
  27826. // Otherwise, let width be the result.
  27827. if (intVal === 0) {
  27828. pError = true;
  27829. } else {
  27830. w = intVal;
  27831. } // If the descriptor consists of a valid floating-point number followed by
  27832. // a U+0078 LATIN SMALL LETTER X character
  27833. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  27834. // If width, density and future-compat-h are not all absent, then let error
  27835. // be yes.
  27836. if (w || d || h) {
  27837. pError = true;
  27838. } // Apply the rules for parsing floating-point number values to the descriptor.
  27839. // If the result is less than zero, let error be yes. Otherwise, let density
  27840. // be the result.
  27841. if (floatVal < 0) {
  27842. pError = true;
  27843. } else {
  27844. d = floatVal;
  27845. } // If the descriptor consists of a valid non-negative integer followed by
  27846. // a U+0068 LATIN SMALL LETTER H character
  27847. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  27848. // If height and density are not both absent, then let error be yes.
  27849. if (h || d) {
  27850. pError = true;
  27851. } // Apply the rules for parsing non-negative integers to the descriptor.
  27852. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  27853. // be the result.
  27854. if (intVal === 0) {
  27855. pError = true;
  27856. } else {
  27857. h = intVal;
  27858. } // Anything else, Let error be yes.
  27859. } else {
  27860. pError = true;
  27861. }
  27862. } // (close step 13 for loop)
  27863. // 15. If error is still no, then append a new image source to candidates whose
  27864. // URL is url, associated with a width width if not absent and a pixel
  27865. // density density if not absent. Otherwise, there is a parse error.
  27866. if (!pError) {
  27867. candidate.url = url;
  27868. if (w) {
  27869. candidate.w = w;
  27870. }
  27871. if (d) {
  27872. candidate.d = d;
  27873. }
  27874. if (h) {
  27875. candidate.h = h;
  27876. }
  27877. candidates.push(candidate);
  27878. } else if (logger && logger.error) {
  27879. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  27880. }
  27881. } // (close parseDescriptors fn)
  27882. };
  27883. });
  27884. });
  27885. var _require$$0$builders$9 = doc.builders;
  27886. var concat$16 = _require$$0$builders$9.concat;
  27887. var ifBreak$7 = _require$$0$builders$9.ifBreak;
  27888. var join$11 = _require$$0$builders$9.join;
  27889. var line$10 = _require$$0$builders$9.line;
  27890. function printImgSrcset$1(value) {
  27891. var srcset = parseSrcset(value, {
  27892. logger: {
  27893. error(message) {
  27894. throw new Error(message);
  27895. }
  27896. }
  27897. });
  27898. var hasW = srcset.some(function (src) {
  27899. return src.w;
  27900. });
  27901. var hasH = srcset.some(function (src) {
  27902. return src.h;
  27903. });
  27904. var hasX = srcset.some(function (src) {
  27905. return src.d;
  27906. });
  27907. if (hasW + hasH + hasX !== 1) {
  27908. throw new Error(`Mixed descriptor in srcset is not supported`);
  27909. }
  27910. var key = hasW ? "w" : hasH ? "h" : "d";
  27911. var unit = hasW ? "w" : hasH ? "h" : "x";
  27912. var getMax = function getMax(values) {
  27913. return Math.max.apply(Math, values);
  27914. };
  27915. var urls = srcset.map(function (src) {
  27916. return src.url;
  27917. });
  27918. var maxUrlLength = getMax(urls.map(function (url) {
  27919. return url.length;
  27920. }));
  27921. var descriptors = srcset.map(function (src) {
  27922. return src[key];
  27923. }).map(function (descriptor) {
  27924. return descriptor ? descriptor.toString() : "";
  27925. });
  27926. var descriptorLeftLengths = descriptors.map(function (descriptor) {
  27927. var index = descriptor.indexOf(".");
  27928. return index === -1 ? descriptor.length : index;
  27929. });
  27930. var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  27931. return join$11(concat$16([",", line$10]), urls.map(function (url, index) {
  27932. var parts = [url];
  27933. var descriptor = descriptors[index];
  27934. if (descriptor) {
  27935. var urlPadding = maxUrlLength - url.length + 1;
  27936. var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  27937. var alignment = " ".repeat(urlPadding + descriptorPadding);
  27938. parts.push(ifBreak$7(alignment, " "), descriptor + unit);
  27939. }
  27940. return concat$16(parts);
  27941. }));
  27942. }
  27943. var syntaxAttribute = {
  27944. printImgSrcset: printImgSrcset$1
  27945. };
  27946. var builders = doc.builders;
  27947. var _require$$0$utils = doc.utils;
  27948. var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
  27949. var mapDoc$7 = _require$$0$utils.mapDoc;
  27950. var breakParent$4 = builders.breakParent;
  27951. var dedentToRoot$2 = builders.dedentToRoot;
  27952. var fill$5 = builders.fill;
  27953. var group$14 = builders.group;
  27954. var hardline$12 = builders.hardline;
  27955. var ifBreak$6 = builders.ifBreak;
  27956. var indent$9 = builders.indent;
  27957. var join$10 = builders.join;
  27958. var line$9 = builders.line;
  27959. var literalline$6 = builders.literalline;
  27960. var markAsRoot$4 = builders.markAsRoot;
  27961. var softline$7 = builders.softline;
  27962. var countChars = utils$10.countChars;
  27963. var countParents = utils$10.countParents;
  27964. var dedentString = utils$10.dedentString;
  27965. var forceBreakChildren = utils$10.forceBreakChildren;
  27966. var forceBreakContent = utils$10.forceBreakContent;
  27967. var forceNextEmptyLine = utils$10.forceNextEmptyLine;
  27968. var getLastDescendant = utils$10.getLastDescendant;
  27969. var getPrettierIgnoreAttributeCommentData = utils$10.getPrettierIgnoreAttributeCommentData;
  27970. var hasPrettierIgnore$2 = utils$10.hasPrettierIgnore;
  27971. var inferScriptParser = utils$10.inferScriptParser;
  27972. var isScriptLikeTag = utils$10.isScriptLikeTag;
  27973. var isTextLikeNode = utils$10.isTextLikeNode;
  27974. var normalizeParts$1 = utils$10.normalizeParts;
  27975. var preferHardlineAsLeadingSpaces = utils$10.preferHardlineAsLeadingSpaces;
  27976. var shouldNotPrintClosingTag = utils$10.shouldNotPrintClosingTag;
  27977. var shouldPreserveContent = utils$10.shouldPreserveContent;
  27978. var unescapeQuoteEntities = utils$10.unescapeQuoteEntities;
  27979. var replaceEndOfLineWith$2 = util$1.replaceEndOfLineWith;
  27980. var insertPragma$6 = pragma$9.insertPragma;
  27981. var printVueFor = syntaxVue.printVueFor;
  27982. var printVueSlotScope = syntaxVue.printVueSlotScope;
  27983. var isVueEventBindingExpression$2 = syntaxVue.isVueEventBindingExpression;
  27984. var printImgSrcset = syntaxAttribute.printImgSrcset;
  27985. function concat$14(parts) {
  27986. var newParts = normalizeParts$1(parts);
  27987. return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
  27988. }
  27989. function embed$6(path$$1, print, textToDoc, options) {
  27990. var node = path$$1.getValue();
  27991. switch (node.type) {
  27992. case "text":
  27993. {
  27994. if (isScriptLikeTag(node.parent)) {
  27995. var parser = inferScriptParser(node.parent);
  27996. if (parser) {
  27997. var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  27998. return builders.concat([concat$14([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
  27999. parser
  28000. })), printClosingTagSuffix(node, options)])]);
  28001. }
  28002. } else if (node.parent.type === "interpolation") {
  28003. return concat$14([indent$9(concat$14([line$9, textToDoc(node.value, Object.assign({
  28004. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  28005. }, options.parser === "angular" ? {
  28006. parser: "__ng_interpolation",
  28007. trailingComma: "none"
  28008. } : options.parser === "vue" ? {
  28009. parser: "__vue_expression"
  28010. } : {
  28011. parser: "__js_expression"
  28012. }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
  28013. }
  28014. break;
  28015. }
  28016. case "attribute":
  28017. {
  28018. if (!node.value) {
  28019. break;
  28020. } // lit-html: html`<my-element obj=${obj}></my-element>`
  28021. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  28022. return concat$14([node.rawName, "=", node.value]);
  28023. } // lwc: html`<my-element data-for={value}></my-elememt>`
  28024. if (options.parser === "lwc") {
  28025. var interpolationRegex = /^\{[\s\S]*\}$/;
  28026. if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  28027. return concat$14([node.rawName, "=", node.value]);
  28028. }
  28029. }
  28030. var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
  28031. return (// strictly prefer single quote to avoid unnecessary html entity escape
  28032. textToDoc(code, Object.assign({
  28033. __isInHtmlAttribute: true
  28034. }, opts))
  28035. );
  28036. }, options);
  28037. if (embeddedAttributeValueDoc) {
  28038. return concat$14([node.rawName, '="', group$14(mapDoc$7(embeddedAttributeValueDoc, function (doc$$2) {
  28039. return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, "&quot;") : doc$$2;
  28040. })), '"']);
  28041. }
  28042. break;
  28043. }
  28044. case "yaml":
  28045. return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
  28046. parser: "yaml"
  28047. }), "---"]));
  28048. }
  28049. }
  28050. function genericPrint$5(path$$1, options, print) {
  28051. var node = path$$1.getValue();
  28052. switch (node.type) {
  28053. case "root":
  28054. // use original concat to not break stripTrailingHardline
  28055. return builders.concat([group$14(printChildren$1(path$$1, options, print)), hardline$12]);
  28056. case "element":
  28057. case "ieConditionalComment":
  28058. {
  28059. /**
  28060. * do not break:
  28061. *
  28062. * <div>{{
  28063. * ~
  28064. * interpolation
  28065. * }}</div>
  28066. * ~
  28067. *
  28068. * exception: break if the opening tag breaks
  28069. *
  28070. * <div
  28071. * long
  28072. * ~
  28073. * >{{
  28074. * interpolation
  28075. * }}</div
  28076. * ~
  28077. * >
  28078. */
  28079. var shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  28080. var attrGroupId = Symbol("element-attr-group-id");
  28081. return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
  28082. id: attrGroupId
  28083. }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$4 : "", function (childrenDoc) {
  28084. return shouldHugContent ? ifBreak$6(indent$9(childrenDoc), childrenDoc, {
  28085. groupId: attrGroupId
  28086. }) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
  28087. }(concat$14([shouldHugContent ? ifBreak$6(softline$7, "", {
  28088. groupId: attrGroupId
  28089. }) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$6(softline$7, "", {
  28090. groupId: attrGroupId
  28091. }) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$9 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n\\s{${options.tabWidth * countParents(path$$1, function (n) {
  28092. return n.parent && n.parent.type !== "root";
  28093. })}}$`).test(node.lastChild.value) ?
  28094. /**
  28095. * <div>
  28096. * <pre>
  28097. * something
  28098. * </pre>
  28099. * ~
  28100. * </div>
  28101. */
  28102. "" : softline$7])])), printClosingTag(node, options)]);
  28103. }
  28104. case "ieConditionalStartComment":
  28105. case "ieConditionalEndComment":
  28106. return concat$14([printOpeningTagStart(node), printClosingTagEnd(node)]);
  28107. case "interpolation":
  28108. return concat$14([printOpeningTagStart(node, options), concat$14(path$$1.map(print, "children")), printClosingTagEnd(node, options)]);
  28109. case "text":
  28110. {
  28111. if (node.parent.type === "interpolation") {
  28112. // replace the trailing literalline with hardline for better readability
  28113. var trailingNewlineRegex = /\n[^\S\n]*?$/;
  28114. var hasTrailingNewline = trailingNewlineRegex.test(node.value);
  28115. var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  28116. return concat$14([concat$14(replaceEndOfLineWith$2(value, literalline$6)), hasTrailingNewline ? hardline$12 : ""]);
  28117. }
  28118. return fill$5(normalizeParts$1([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
  28119. }
  28120. case "docType":
  28121. return concat$14([group$14(concat$14([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
  28122. case "comment":
  28123. {
  28124. return concat$14([printOpeningTagPrefix(node, options), concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$6)), printClosingTagSuffix(node, options)]);
  28125. }
  28126. case "attribute":
  28127. {
  28128. if (node.value === null) {
  28129. return node.rawName;
  28130. }
  28131. var _value = unescapeQuoteEntities(node.value);
  28132. var singleQuoteCount = countChars(_value, "'");
  28133. var doubleQuoteCount = countChars(_value, '"');
  28134. var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  28135. return concat$14([node.rawName, concat$14(["=", quote, concat$14(replaceEndOfLineWith$2(quote === '"' ? _value.replace(/"/g, "&quot;") : _value.replace(/'/g, "&apos;"), literalline$6)), quote])]);
  28136. }
  28137. case "yaml":
  28138. case "toml":
  28139. return concat$14(replaceEndOfLineWith$2(node.raw, literalline$6));
  28140. default:
  28141. throw new Error(`Unexpected node type ${node.type}`);
  28142. }
  28143. }
  28144. function printChildren$1(path$$1, options, print) {
  28145. var node = path$$1.getValue();
  28146. if (forceBreakChildren(node)) {
  28147. return concat$14([breakParent$4, concat$14(path$$1.map(function (childPath) {
  28148. var childNode = childPath.getValue();
  28149. var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  28150. return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
  28151. }, "children"))]);
  28152. }
  28153. var groupIds = node.children.map(function () {
  28154. return Symbol("");
  28155. });
  28156. return concat$14(path$$1.map(function (childPath, childIndex) {
  28157. var childNode = childPath.getValue();
  28158. if (isTextLikeNode(childNode)) {
  28159. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  28160. var _prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  28161. if (_prevBetweenLine) {
  28162. if (forceNextEmptyLine(childNode.prev)) {
  28163. return concat$14([hardline$12, hardline$12, printChild(childPath)]);
  28164. }
  28165. return concat$14([_prevBetweenLine, printChild(childPath)]);
  28166. }
  28167. }
  28168. return printChild(childPath);
  28169. }
  28170. var prevParts = [];
  28171. var leadingParts = [];
  28172. var trailingParts = [];
  28173. var nextParts = [];
  28174. var prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  28175. var nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  28176. if (prevBetweenLine) {
  28177. if (forceNextEmptyLine(childNode.prev)) {
  28178. prevParts.push(hardline$12, hardline$12);
  28179. } else if (prevBetweenLine === hardline$12) {
  28180. prevParts.push(hardline$12);
  28181. } else {
  28182. if (isTextLikeNode(childNode.prev)) {
  28183. leadingParts.push(prevBetweenLine);
  28184. } else {
  28185. leadingParts.push(ifBreak$6("", softline$7, {
  28186. groupId: groupIds[childIndex - 1]
  28187. }));
  28188. }
  28189. }
  28190. }
  28191. if (nextBetweenLine) {
  28192. if (forceNextEmptyLine(childNode)) {
  28193. if (isTextLikeNode(childNode.next)) {
  28194. nextParts.push(hardline$12, hardline$12);
  28195. }
  28196. } else if (nextBetweenLine === hardline$12) {
  28197. if (isTextLikeNode(childNode.next)) {
  28198. nextParts.push(hardline$12);
  28199. }
  28200. } else {
  28201. trailingParts.push(nextBetweenLine);
  28202. }
  28203. }
  28204. return concat$14([].concat(prevParts, group$14(concat$14([concat$14(leadingParts), group$14(concat$14([printChild(childPath), concat$14(trailingParts)]), {
  28205. id: groupIds[childIndex]
  28206. })])), nextParts));
  28207. }, "children"));
  28208. function printChild(childPath) {
  28209. var child = childPath.getValue();
  28210. if (hasPrettierIgnore$2(child)) {
  28211. return concat$14([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$2(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$6), printClosingTagSuffix(child, options)));
  28212. }
  28213. if (shouldPreserveContent(child, options)) {
  28214. return concat$14([].concat(printOpeningTagPrefix(child, options), group$14(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$2(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$6), printClosingTag(child, options), printClosingTagSuffix(child, options)));
  28215. }
  28216. return print(childPath);
  28217. }
  28218. function printBetweenLine(prevNode, nextNode) {
  28219. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$12 : line$9 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$12 : softline$7 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (
  28220. /**
  28221. * 123<a
  28222. * ~
  28223. * ><b>
  28224. */
  28225. nextNode.firstChild ||
  28226. /**
  28227. * 123<!--
  28228. * ~
  28229. * -->
  28230. */
  28231. nextNode.isSelfClosing ||
  28232. /**
  28233. * 123<span
  28234. * ~
  28235. * attr
  28236. */
  28237. nextNode.type === "element" && nextNode.attrs.length !== 0) ||
  28238. /**
  28239. * <img
  28240. * src="long"
  28241. * ~
  28242. * />123
  28243. */
  28244. prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
  28245. /**
  28246. * Want to write us a letter? Use our<a
  28247. * ><b><a>mailing address</a></b></a
  28248. * ~
  28249. * >.
  28250. */
  28251. needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$12 : nextNode.hasLeadingSpaces ? line$9 : softline$7;
  28252. }
  28253. }
  28254. function printOpeningTag(path$$1, options, print) {
  28255. var node = path$$1.getValue();
  28256. var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  28257. return concat$14([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
  28258. /**
  28259. * <br />
  28260. * ^
  28261. */
  28262. " " : "" : concat$14([indent$9(concat$14([forceNotToBreakAttrContent ? " " : line$9, join$10(line$9, function (ignoreAttributeData) {
  28263. var hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? function () {
  28264. return ignoreAttributeData;
  28265. } : Array.isArray(ignoreAttributeData) ? function (attr) {
  28266. return ignoreAttributeData.indexOf(attr.rawName) !== -1;
  28267. } : function () {
  28268. return false;
  28269. };
  28270. return path$$1.map(function (attrPath) {
  28271. var attr = attrPath.getValue();
  28272. return hasPrettierIgnoreAttribute(attr) ? concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$6)) : print(attrPath);
  28273. }, "attrs");
  28274. }(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
  28275. /**
  28276. * 123<a
  28277. * attr
  28278. * ~
  28279. * >456
  28280. */
  28281. node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ||
  28282. /**
  28283. * <span
  28284. * >123<meta
  28285. * ~
  28286. * /></span>
  28287. */
  28288. node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$9 : forceNotToBreakAttrContent ? "" : softline$7]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
  28289. }
  28290. function printOpeningTagStart(node, options) {
  28291. return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$14([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
  28292. }
  28293. function printOpeningTagEnd(node) {
  28294. return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
  28295. }
  28296. function printClosingTag(node, options) {
  28297. return concat$14([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
  28298. }
  28299. function printClosingTagStart(node, options) {
  28300. return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$14([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
  28301. }
  28302. function printClosingTagEnd(node, options) {
  28303. return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$14([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
  28304. }
  28305. function needsToBorrowNextOpeningTagStartMarker(node) {
  28306. /**
  28307. * 123<p
  28308. * ^^
  28309. * >
  28310. */
  28311. return node.next && !isTextLikeNode(node.next) && isTextLikeNode(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  28312. }
  28313. function needsToBorrowParentOpeningTagEndMarker(node) {
  28314. /**
  28315. * <p
  28316. * >123
  28317. * ^
  28318. *
  28319. * <p
  28320. * ><a
  28321. * ^
  28322. */
  28323. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  28324. }
  28325. function needsToBorrowPrevClosingTagEndMarker(node) {
  28326. /**
  28327. * <p></p
  28328. * >123
  28329. * ^
  28330. *
  28331. * <p></p
  28332. * ><a
  28333. * ^
  28334. */
  28335. return node.prev && !isTextLikeNode(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  28336. }
  28337. function needsToBorrowLastChildClosingTagEndMarker(node) {
  28338. /**
  28339. * <p
  28340. * ><a></a
  28341. * ></p
  28342. * ^
  28343. * >
  28344. */
  28345. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode(getLastDescendant(node.lastChild));
  28346. }
  28347. function needsToBorrowParentClosingTagStartMarker(node) {
  28348. /**
  28349. * <p>
  28350. * 123</p
  28351. * ^^^
  28352. * >
  28353. *
  28354. * 123</b
  28355. * ></a
  28356. * ^^^
  28357. * >
  28358. */
  28359. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode(getLastDescendant(node));
  28360. }
  28361. function printOpeningTagPrefix(node, options) {
  28362. return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
  28363. }
  28364. function printClosingTagPrefix(node, options) {
  28365. return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
  28366. }
  28367. function printClosingTagSuffix(node, options) {
  28368. return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
  28369. }
  28370. function printOpeningTagStartMarker(node) {
  28371. switch (node.type) {
  28372. case "ieConditionalComment":
  28373. case "ieConditionalStartComment":
  28374. return `<!--[if ${node.condition}`;
  28375. case "ieConditionalEndComment":
  28376. return `<!--<!`;
  28377. case "interpolation":
  28378. return "{{";
  28379. case "docType":
  28380. return "<!DOCTYPE";
  28381. case "element":
  28382. if (node.condition) {
  28383. return `<!--[if ${node.condition}]><!--><${node.rawName}`;
  28384. }
  28385. // fall through
  28386. default:
  28387. return `<${node.rawName}`;
  28388. }
  28389. }
  28390. function printOpeningTagEndMarker(node) {
  28391. assert(!node.isSelfClosing);
  28392. switch (node.type) {
  28393. case "ieConditionalComment":
  28394. return "]>";
  28395. case "element":
  28396. if (node.condition) {
  28397. return `><!--<![endif]-->`;
  28398. }
  28399. // fall through
  28400. default:
  28401. return `>`;
  28402. }
  28403. }
  28404. function printClosingTagStartMarker(node, options) {
  28405. assert(!node.isSelfClosing);
  28406. if (shouldNotPrintClosingTag(node, options)) {
  28407. return "";
  28408. }
  28409. switch (node.type) {
  28410. case "ieConditionalComment":
  28411. return "<!";
  28412. case "element":
  28413. if (node.hasHtmComponentClosingTag) {
  28414. return "<//";
  28415. }
  28416. // fall through
  28417. default:
  28418. return `</${node.rawName}`;
  28419. }
  28420. }
  28421. function printClosingTagEndMarker(node, options) {
  28422. if (shouldNotPrintClosingTag(node, options)) {
  28423. return "";
  28424. }
  28425. switch (node.type) {
  28426. case "ieConditionalComment":
  28427. case "ieConditionalEndComment":
  28428. return `[endif]-->`;
  28429. case "ieConditionalStartComment":
  28430. return `]><!-->`;
  28431. case "interpolation":
  28432. return "}}";
  28433. case "element":
  28434. if (node.isSelfClosing) {
  28435. return "/>";
  28436. }
  28437. // fall through
  28438. default:
  28439. return ">";
  28440. }
  28441. }
  28442. function getTextValueParts(node) {
  28443. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
  28444. return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // https://infra.spec.whatwg.org/#ascii-whitespace
  28445. join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
  28446. }
  28447. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  28448. var isKeyMatched = function isKeyMatched(patterns) {
  28449. return new RegExp(patterns.join("|")).test(node.fullName);
  28450. };
  28451. var getValue = function getValue() {
  28452. return unescapeQuoteEntities(node.value);
  28453. };
  28454. var shouldHug = false;
  28455. var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) {
  28456. var 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;
  28457. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) {
  28458. shouldHug = true;
  28459. }
  28460. };
  28461. var printHug = function printHug(doc$$2) {
  28462. return group$14(doc$$2);
  28463. };
  28464. var printExpand = function printExpand(doc$$2) {
  28465. return group$14(concat$14([indent$9(concat$14([softline$7, doc$$2])), softline$7]));
  28466. };
  28467. var printMaybeHug = function printMaybeHug(doc$$2) {
  28468. return shouldHug ? printHug(doc$$2) : printExpand(doc$$2);
  28469. };
  28470. var textToDoc = function textToDoc(code, opts) {
  28471. return originalTextToDoc(code, Object.assign({
  28472. __onHtmlBindingRoot
  28473. }, opts));
  28474. };
  28475. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  28476. return printExpand(printImgSrcset(getValue()));
  28477. }
  28478. if (options.parser === "vue") {
  28479. if (node.fullName === "v-for") {
  28480. return printVueFor(getValue(), textToDoc);
  28481. }
  28482. if (node.fullName === "slot-scope") {
  28483. return printVueSlotScope(getValue(), textToDoc);
  28484. }
  28485. /**
  28486. * @click="jsStatement"
  28487. * @click="jsExpression"
  28488. * v-on:click="jsStatement"
  28489. * v-on:click="jsExpression"
  28490. */
  28491. var vueEventBindingPatterns = ["^@", "^v-on:"];
  28492. /**
  28493. * :class="vueExpression"
  28494. * v-bind:id="vueExpression"
  28495. */
  28496. var vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  28497. /**
  28498. * v-if="jsExpression"
  28499. */
  28500. var jsExpressionBindingPatterns = ["^v-"];
  28501. if (isKeyMatched(vueEventBindingPatterns)) {
  28502. var value = getValue();
  28503. return printMaybeHug(isVueEventBindingExpression$2(value) ? textToDoc(value, {
  28504. parser: "__js_expression"
  28505. }) : stripTrailingHardline$2(textToDoc(value, {
  28506. parser: "__vue_event_binding"
  28507. })));
  28508. }
  28509. if (isKeyMatched(vueExpressionBindingPatterns)) {
  28510. return printMaybeHug(textToDoc(getValue(), {
  28511. parser: "__vue_expression"
  28512. }));
  28513. }
  28514. if (isKeyMatched(jsExpressionBindingPatterns)) {
  28515. return printMaybeHug(textToDoc(getValue(), {
  28516. parser: "__js_expression"
  28517. }));
  28518. }
  28519. }
  28520. if (options.parser === "angular") {
  28521. var ngTextToDoc = function ngTextToDoc(code, opts) {
  28522. return (// angular does not allow trailing comma
  28523. textToDoc(code, Object.assign({
  28524. trailingComma: "none"
  28525. }, opts))
  28526. );
  28527. };
  28528. /**
  28529. * *directive="angularDirective"
  28530. */
  28531. var ngDirectiveBindingPatterns = ["^\\*"];
  28532. /**
  28533. * (click)="angularStatement"
  28534. * on-click="angularStatement"
  28535. */
  28536. var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  28537. /**
  28538. * [target]="angularExpression"
  28539. * bind-target="angularExpression"
  28540. * [(target)]="angularExpression"
  28541. * bindon-target="angularExpression"
  28542. */
  28543. var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"];
  28544. if (isKeyMatched(ngStatementBindingPatterns)) {
  28545. return printMaybeHug(ngTextToDoc(getValue(), {
  28546. parser: "__ng_action"
  28547. }));
  28548. }
  28549. if (isKeyMatched(ngExpressionBindingPatterns)) {
  28550. return printMaybeHug(ngTextToDoc(getValue(), {
  28551. parser: "__ng_binding"
  28552. }));
  28553. }
  28554. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  28555. return printMaybeHug(ngTextToDoc(getValue(), {
  28556. parser: "__ng_directive"
  28557. }));
  28558. }
  28559. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  28560. var _value2 = getValue();
  28561. if (interpolationRegex.test(_value2)) {
  28562. var parts = [];
  28563. _value2.split(interpolationRegex).forEach(function (part, index) {
  28564. if (index % 2 === 0) {
  28565. parts.push(concat$14(replaceEndOfLineWith$2(part, literalline$6)));
  28566. } else {
  28567. try {
  28568. parts.push(group$14(concat$14(["{{", indent$9(concat$14([line$9, ngTextToDoc(part, {
  28569. parser: "__ng_interpolation",
  28570. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  28571. })])), line$9, "}}"])));
  28572. } catch (e) {
  28573. parts.push("{{", concat$14(replaceEndOfLineWith$2(part, literalline$6)), "}}");
  28574. }
  28575. }
  28576. });
  28577. return group$14(concat$14(parts));
  28578. }
  28579. }
  28580. return null;
  28581. }
  28582. var printerHtml = {
  28583. preprocess: preprocess_1$4,
  28584. print: genericPrint$5,
  28585. insertPragma: insertPragma$6,
  28586. massageAstNode: clean$8,
  28587. embed: embed$6
  28588. };
  28589. var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  28590. var options$16 = {
  28591. htmlWhitespaceSensitivity: {
  28592. since: "1.15.0",
  28593. category: CATEGORY_HTML,
  28594. type: "choice",
  28595. default: "css",
  28596. description: "How to handle whitespaces in HTML.",
  28597. choices: [{
  28598. value: "css",
  28599. description: "Respect the default value of CSS display property."
  28600. }, {
  28601. value: "strict",
  28602. description: "Whitespaces are considered sensitive."
  28603. }, {
  28604. value: "ignore",
  28605. description: "Whitespaces are considered insensitive."
  28606. }]
  28607. }
  28608. };
  28609. var name$14 = "HTML";
  28610. var type$13 = "markup";
  28611. var tmScope$13 = "text.html.basic";
  28612. var aceMode$13 = "html";
  28613. var codemirrorMode$10 = "htmlmixed";
  28614. var codemirrorMimeType$10 = "text/html";
  28615. var color$3 = "#e34c26";
  28616. var aliases$5 = ["xhtml"];
  28617. var extensions$13 = [".html", ".htm", ".html.hl", ".inc", ".st", ".xht", ".xhtml"];
  28618. var languageId$13 = 146;
  28619. var html$1 = {
  28620. name: name$14,
  28621. type: type$13,
  28622. tmScope: tmScope$13,
  28623. aceMode: aceMode$13,
  28624. codemirrorMode: codemirrorMode$10,
  28625. codemirrorMimeType: codemirrorMimeType$10,
  28626. color: color$3,
  28627. aliases: aliases$5,
  28628. extensions: extensions$13,
  28629. languageId: languageId$13
  28630. };
  28631. var html$2 = Object.freeze({
  28632. name: name$14,
  28633. type: type$13,
  28634. tmScope: tmScope$13,
  28635. aceMode: aceMode$13,
  28636. codemirrorMode: codemirrorMode$10,
  28637. codemirrorMimeType: codemirrorMimeType$10,
  28638. color: color$3,
  28639. aliases: aliases$5,
  28640. extensions: extensions$13,
  28641. languageId: languageId$13,
  28642. default: html$1
  28643. });
  28644. var name$15 = "Vue";
  28645. var type$14 = "markup";
  28646. var color$4 = "#2c3e50";
  28647. var extensions$14 = [".vue"];
  28648. var tmScope$14 = "text.html.vue";
  28649. var aceMode$14 = "html";
  28650. var languageId$14 = 391;
  28651. var vue = {
  28652. name: name$15,
  28653. type: type$14,
  28654. color: color$4,
  28655. extensions: extensions$14,
  28656. tmScope: tmScope$14,
  28657. aceMode: aceMode$14,
  28658. languageId: languageId$14
  28659. };
  28660. var vue$1 = Object.freeze({
  28661. name: name$15,
  28662. type: type$14,
  28663. color: color$4,
  28664. extensions: extensions$14,
  28665. tmScope: tmScope$14,
  28666. aceMode: aceMode$14,
  28667. languageId: languageId$14,
  28668. default: vue
  28669. });
  28670. var require$$0$31 = ( html$2 && html$1 ) || html$2;
  28671. var require$$1$12 = ( vue$1 && vue ) || vue$1;
  28672. var languages$5 = [createLanguage(require$$0$31, {
  28673. override: {
  28674. name: "Angular",
  28675. since: "1.15.0",
  28676. parsers: ["angular"],
  28677. vscodeLanguageIds: ["html"],
  28678. extensions: [".component.html"],
  28679. filenames: []
  28680. }
  28681. }), createLanguage(require$$0$31, {
  28682. override: {
  28683. since: "1.15.0",
  28684. parsers: ["html"],
  28685. vscodeLanguageIds: ["html"]
  28686. },
  28687. extend: {
  28688. extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  28689. ]
  28690. }
  28691. }), createLanguage(require$$0$31, {
  28692. override: {
  28693. name: "Lightning Web Components",
  28694. since: "1.17.0",
  28695. parsers: ["lwc"],
  28696. vscodeLanguageIds: ["html"],
  28697. extensions: [],
  28698. filenames: []
  28699. }
  28700. }), createLanguage(require$$1$12, {
  28701. override: {
  28702. since: "1.10.0",
  28703. parsers: ["vue"],
  28704. vscodeLanguageIds: ["vue"]
  28705. }
  28706. })];
  28707. var printers$5 = {
  28708. html: printerHtml
  28709. };
  28710. var languageHtml = {
  28711. languages: languages$5,
  28712. printers: printers$5,
  28713. options: options$16
  28714. };
  28715. function isPragma$1(text) {
  28716. return /^\s*@(prettier|format)\s*$/.test(text);
  28717. }
  28718. function hasPragma$4(text) {
  28719. return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
  28720. }
  28721. function insertPragma$9(text) {
  28722. return `# @format\n\n${text}`;
  28723. }
  28724. var pragma$11 = {
  28725. isPragma: isPragma$1,
  28726. hasPragma: hasPragma$4,
  28727. insertPragma: insertPragma$9
  28728. };
  28729. var getLast$6 = util$1.getLast;
  28730. function getAncestorCount$1(path$$1, filter) {
  28731. var counter = 0;
  28732. var pathStackLength = path$$1.stack.length - 1;
  28733. for (var i = 0; i < pathStackLength; i++) {
  28734. var value = path$$1.stack[i];
  28735. if (isNode$2(value) && filter(value)) {
  28736. counter++;
  28737. }
  28738. }
  28739. return counter;
  28740. }
  28741. /**
  28742. * @param {any} value
  28743. * @param {string[]=} types
  28744. */
  28745. function isNode$2(value, types) {
  28746. return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1);
  28747. }
  28748. function mapNode$1(node, callback, parent) {
  28749. return callback("children" in node ? Object.assign({}, node, {
  28750. children: node.children.map(function (childNode) {
  28751. return mapNode$1(childNode, callback, node);
  28752. })
  28753. }) : node, parent);
  28754. }
  28755. function defineShortcut$1(x, key, getter) {
  28756. Object.defineProperty(x, key, {
  28757. get: getter,
  28758. enumerable: false
  28759. });
  28760. }
  28761. function isNextLineEmpty$6(node, text) {
  28762. var newlineCount = 0;
  28763. var textLength = text.length;
  28764. for (var i = node.position.end.offset - 1; i < textLength; i++) {
  28765. var char = text[i];
  28766. if (char === "\n") {
  28767. newlineCount++;
  28768. }
  28769. if (newlineCount === 1 && /\S/.test(char)) {
  28770. return false;
  28771. }
  28772. if (newlineCount === 2) {
  28773. return true;
  28774. }
  28775. }
  28776. return false;
  28777. }
  28778. function isLastDescendantNode$1(path$$1) {
  28779. var node = path$$1.getValue();
  28780. switch (node.type) {
  28781. case "tag":
  28782. case "anchor":
  28783. case "comment":
  28784. return false;
  28785. }
  28786. var pathStackLength = path$$1.stack.length;
  28787. for (var i = 1; i < pathStackLength; i++) {
  28788. var item = path$$1.stack[i];
  28789. var parentItem = path$$1.stack[i - 1];
  28790. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  28791. return false;
  28792. }
  28793. }
  28794. return true;
  28795. }
  28796. function getLastDescendantNode$2(node) {
  28797. return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
  28798. }
  28799. function isPrettierIgnore$2(comment) {
  28800. return comment.value.trim() === "prettier-ignore";
  28801. }
  28802. function hasPrettierIgnore$5(path$$1) {
  28803. var node = path$$1.getValue();
  28804. if (node.type === "documentBody") {
  28805. var document = path$$1.getParentNode();
  28806. return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
  28807. }
  28808. return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
  28809. }
  28810. function isEmptyNode$1(node) {
  28811. return (!node.children || node.children.length === 0) && !hasComments(node);
  28812. }
  28813. function hasComments(node) {
  28814. return hasLeadingComments$1(node) || hasMiddleComments$1(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$1(node);
  28815. }
  28816. function hasLeadingComments$1(node) {
  28817. return node && node.leadingComments && node.leadingComments.length !== 0;
  28818. }
  28819. function hasMiddleComments$1(node) {
  28820. return node && node.middleComments && node.middleComments.length !== 0;
  28821. }
  28822. function hasIndicatorComment$1(node) {
  28823. return node && node.indicatorComment;
  28824. }
  28825. function hasTrailingComment$2(node) {
  28826. return node && node.trailingComment;
  28827. }
  28828. function hasEndComments$1(node) {
  28829. return node && node.endComments && node.endComments.length !== 0;
  28830. }
  28831. /**
  28832. * " a b c d e f " -> [" a b", "c d", "e f "]
  28833. */
  28834. function splitWithSingleSpace(text) {
  28835. var parts = [];
  28836. var lastPart = undefined;
  28837. var _iteratorNormalCompletion = true;
  28838. var _didIteratorError = false;
  28839. var _iteratorError = undefined;
  28840. try {
  28841. for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28842. var part = _step.value;
  28843. if (part !== " ") {
  28844. if (lastPart === " ") {
  28845. parts.push(part);
  28846. } else {
  28847. parts.push((parts.pop() || "") + part);
  28848. }
  28849. } else if (lastPart === undefined) {
  28850. parts.unshift("");
  28851. }
  28852. lastPart = part;
  28853. }
  28854. } catch (err) {
  28855. _didIteratorError = true;
  28856. _iteratorError = err;
  28857. } finally {
  28858. try {
  28859. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28860. _iterator.return();
  28861. }
  28862. } finally {
  28863. if (_didIteratorError) {
  28864. throw _iteratorError;
  28865. }
  28866. }
  28867. }
  28868. if (lastPart === " ") {
  28869. parts.push((parts.pop() || "") + " ");
  28870. }
  28871. if (parts[0] === "") {
  28872. parts.shift();
  28873. parts.unshift(" " + (parts.shift() || ""));
  28874. }
  28875. return parts;
  28876. }
  28877. function getFlowScalarLineContents$1(nodeType, content, options) {
  28878. var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) {
  28879. return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft();
  28880. });
  28881. if (options.proseWrap === "preserve") {
  28882. return rawLineContents.map(function (lineContent) {
  28883. return lineContent.length === 0 ? [] : [lineContent];
  28884. });
  28885. }
  28886. return rawLineContents.map(function (lineContent) {
  28887. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  28888. }).reduce(function (reduced, lineContentWords, index) {
  28889. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
  28890. nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  28891. }, []).map(function (lineContentWords) {
  28892. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  28893. });
  28894. }
  28895. function getBlockValueLineContents$1(node, _ref) {
  28896. var parentIndent = _ref.parentIndent,
  28897. isLastDescendant = _ref.isLastDescendant,
  28898. options = _ref.options;
  28899. var content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
  28900. .match(/^[^\n]*?\n([\s\S]*)$/)[1];
  28901. var leadingSpaceCount = node.indent === null ? function (match) {
  28902. return match ? match[1].length : Infinity;
  28903. }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  28904. var rawLineContents = content.split("\n").map(function (lineContent) {
  28905. return lineContent.slice(leadingSpaceCount);
  28906. });
  28907. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  28908. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  28909. return lineContent.length === 0 ? [] : [lineContent];
  28910. }));
  28911. }
  28912. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  28913. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  28914. }).reduce(function (reduced, lineContentWords, index) {
  28915. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$6(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  28916. }, []).map(function (lineContentWords) {
  28917. return lineContentWords.reduce(function (reduced, word) {
  28918. return (// disallow trailing spaces
  28919. reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
  28920. );
  28921. }, []);
  28922. }).map(function (lineContentWords) {
  28923. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  28924. }));
  28925. function removeUnnecessaryTrailingNewlines(lineContents) {
  28926. if (node.chomping === "keep") {
  28927. return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  28928. }
  28929. var trailingNewlineCount = 0;
  28930. for (var i = lineContents.length - 1; i >= 0; i--) {
  28931. if (lineContents[i].length === 0) {
  28932. trailingNewlineCount++;
  28933. } else {
  28934. break;
  28935. }
  28936. }
  28937. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  28938. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  28939. }
  28940. }
  28941. var utils$12 = {
  28942. getLast: getLast$6,
  28943. getAncestorCount: getAncestorCount$1,
  28944. isNode: isNode$2,
  28945. isEmptyNode: isEmptyNode$1,
  28946. mapNode: mapNode$1,
  28947. defineShortcut: defineShortcut$1,
  28948. isNextLineEmpty: isNextLineEmpty$6,
  28949. isLastDescendantNode: isLastDescendantNode$1,
  28950. getBlockValueLineContents: getBlockValueLineContents$1,
  28951. getFlowScalarLineContents: getFlowScalarLineContents$1,
  28952. getLastDescendantNode: getLastDescendantNode$2,
  28953. hasPrettierIgnore: hasPrettierIgnore$5,
  28954. hasLeadingComments: hasLeadingComments$1,
  28955. hasMiddleComments: hasMiddleComments$1,
  28956. hasIndicatorComment: hasIndicatorComment$1,
  28957. hasTrailingComment: hasTrailingComment$2,
  28958. hasEndComments: hasEndComments$1
  28959. };
  28960. var insertPragma$8 = pragma$11.insertPragma;
  28961. var isPragma = pragma$11.isPragma;
  28962. var getAncestorCount = utils$12.getAncestorCount;
  28963. var getBlockValueLineContents = utils$12.getBlockValueLineContents;
  28964. var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
  28965. var getLast$5 = utils$12.getLast;
  28966. var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
  28967. var hasLeadingComments = utils$12.hasLeadingComments;
  28968. var hasMiddleComments = utils$12.hasMiddleComments;
  28969. var hasIndicatorComment = utils$12.hasIndicatorComment;
  28970. var hasTrailingComment$1 = utils$12.hasTrailingComment;
  28971. var hasEndComments = utils$12.hasEndComments;
  28972. var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
  28973. var isLastDescendantNode = utils$12.isLastDescendantNode;
  28974. var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
  28975. var isNode$1 = utils$12.isNode;
  28976. var isEmptyNode = utils$12.isEmptyNode;
  28977. var defineShortcut = utils$12.defineShortcut;
  28978. var mapNode = utils$12.mapNode;
  28979. var docBuilders$3 = doc.builders;
  28980. var conditionalGroup$2 = docBuilders$3.conditionalGroup;
  28981. var breakParent$5 = docBuilders$3.breakParent;
  28982. var concat$17 = docBuilders$3.concat;
  28983. var dedent$4 = docBuilders$3.dedent;
  28984. var dedentToRoot$3 = docBuilders$3.dedentToRoot;
  28985. var fill$6 = docBuilders$3.fill;
  28986. var group$16 = docBuilders$3.group;
  28987. var hardline$13 = docBuilders$3.hardline;
  28988. var ifBreak$8 = docBuilders$3.ifBreak;
  28989. var join$12 = docBuilders$3.join;
  28990. var line$11 = docBuilders$3.line;
  28991. var lineSuffix$2 = docBuilders$3.lineSuffix;
  28992. var literalline$7 = docBuilders$3.literalline;
  28993. var markAsRoot$5 = docBuilders$3.markAsRoot;
  28994. var softline$8 = docBuilders$3.softline;
  28995. var replaceEndOfLineWith$3 = util$1.replaceEndOfLineWith;
  28996. function preprocess$6(ast) {
  28997. return mapNode(ast, defineShortcuts);
  28998. }
  28999. function defineShortcuts(node) {
  29000. switch (node.type) {
  29001. case "document":
  29002. defineShortcut(node, "head", function () {
  29003. return node.children[0];
  29004. });
  29005. defineShortcut(node, "body", function () {
  29006. return node.children[1];
  29007. });
  29008. break;
  29009. case "documentBody":
  29010. case "sequenceItem":
  29011. case "flowSequenceItem":
  29012. case "mappingKey":
  29013. case "mappingValue":
  29014. defineShortcut(node, "content", function () {
  29015. return node.children[0];
  29016. });
  29017. break;
  29018. case "mappingItem":
  29019. case "flowMappingItem":
  29020. defineShortcut(node, "key", function () {
  29021. return node.children[0];
  29022. });
  29023. defineShortcut(node, "value", function () {
  29024. return node.children[1];
  29025. });
  29026. break;
  29027. }
  29028. return node;
  29029. }
  29030. function genericPrint$6(path$$1, options, print) {
  29031. var node = path$$1.getValue();
  29032. var parentNode = path$$1.getParentNode();
  29033. var tag = !node.tag ? "" : path$$1.call(print, "tag");
  29034. var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
  29035. var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
  29036. return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$5, path$$1.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path$$1.map(print, "endComments"))])) : ""]);
  29037. }
  29038. function _print(node, parentNode, path$$1, options, print) {
  29039. switch (node.type) {
  29040. case "root":
  29041. return concat$17([join$12(hardline$13, path$$1.map(function (childPath, index) {
  29042. var document = node.children[index];
  29043. var nextDocument = node.children[index + 1];
  29044. return concat$17([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$17([hardline$13, "...", hasTrailingComment$1(document) ? concat$17([" ", path$$1.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$1(nextDocument.head) ? "" : concat$17([hardline$13, "---"])]);
  29045. }, "children")), node.children.length === 0 || function (lastDescendantNode) {
  29046. return isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
  29047. }(getLastDescendantNode$1(node)) ? "" : hardline$13]);
  29048. case "document":
  29049. {
  29050. var nextDocument = parentNode.children[path$$1.getName() + 1];
  29051. return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path$$1.call(print, "head"), concat$17(["---", hasTrailingComment$1(node.head) ? concat$17([" ", path$$1.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path$$1.call(print, "body") : ""].filter(Boolean));
  29052. }
  29053. case "documentHead":
  29054. return join$12(hardline$13, [].concat(path$$1.map(print, "children"), path$$1.map(print, "endComments")));
  29055. case "documentBody":
  29056. {
  29057. var children = join$12(hardline$13, path$$1.map(print, "children")).parts;
  29058. var endComments = join$12(hardline$13, path$$1.map(print, "endComments")).parts;
  29059. var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
  29060. return isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  29061. "" : // an extra newline for better readability
  29062. concat$17([hardline$13, hardline$13]) : hardline$13;
  29063. }(getLastDescendantNode$1(node));
  29064. return concat$17([].concat(children, separator, endComments));
  29065. }
  29066. case "directive":
  29067. return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
  29068. case "comment":
  29069. return concat$17(["#", node.value]);
  29070. case "alias":
  29071. return concat$17(["*", node.value]);
  29072. case "tag":
  29073. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  29074. case "anchor":
  29075. return concat$17(["&", node.value]);
  29076. case "plain":
  29077. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  29078. case "quoteDouble":
  29079. case "quoteSingle":
  29080. {
  29081. var singleQuote = "'";
  29082. var doubleQuote = '"';
  29083. var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  29084. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  29085. // only quoteDouble can use escape chars
  29086. // and quoteSingle do not need to escape backslashes
  29087. var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  29088. return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
  29089. } else if (raw.includes(doubleQuote)) {
  29090. return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  29091. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
  29092. }
  29093. if (raw.includes(singleQuote)) {
  29094. return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  29095. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
  29096. }
  29097. var quote = options.singleQuote ? singleQuote : doubleQuote;
  29098. return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
  29099. }
  29100. case "blockFolded":
  29101. case "blockLiteral":
  29102. {
  29103. var parentIndent = getAncestorCount(path$$1, function (ancestorNode) {
  29104. return isNode$1(ancestorNode, ["sequence", "mapping"]);
  29105. });
  29106. var isLastDescendant = isLastDescendantNode(path$$1);
  29107. return concat$17([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$17([" ", path$$1.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$17(getBlockValueLineContents(node, {
  29108. parentIndent,
  29109. isLastDescendant,
  29110. options
  29111. }).reduce(function (reduced, lineWords, index, lineContents) {
  29112. return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$13) : dedentToRoot$3(literalline$7) : "");
  29113. }, []))))]);
  29114. }
  29115. case "sequence":
  29116. return join$12(hardline$13, path$$1.map(print, "children"));
  29117. case "sequenceItem":
  29118. return concat$17(["- ", align$3(2, !node.content ? "" : path$$1.call(print, "content"))]);
  29119. case "mappingKey":
  29120. return !node.content ? "" : path$$1.call(print, "content");
  29121. case "mappingValue":
  29122. return !node.content ? "" : path$$1.call(print, "content");
  29123. case "mapping":
  29124. return join$12(hardline$13, path$$1.map(print, "children"));
  29125. case "mappingItem":
  29126. case "flowMappingItem":
  29127. {
  29128. var isEmptyMappingKey = isEmptyNode(node.key);
  29129. var isEmptyMappingValue = isEmptyNode(node.value);
  29130. if (isEmptyMappingKey && isEmptyMappingValue) {
  29131. return concat$17([": "]);
  29132. }
  29133. var key = path$$1.call(print, "key");
  29134. var value = path$$1.call(print, "value");
  29135. if (isEmptyMappingValue) {
  29136. return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$17(["? ", align$3(2, key)]);
  29137. }
  29138. if (isEmptyMappingKey) {
  29139. return concat$17([": ", align$3(2, value)]);
  29140. }
  29141. var groupId = Symbol("mappingKey");
  29142. var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
  29143. return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
  29144. return concat$17([comment, hardline$13]);
  29145. })), ": ", align$3(2, value)]) : // force singleline
  29146. isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$8("? "), group$16(align$3(2, key), {
  29147. id: groupId
  29148. })])), ifBreak$8(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
  29149. groupId
  29150. })])]);
  29151. }
  29152. case "flowMapping":
  29153. case "flowSequence":
  29154. {
  29155. var openMarker = node.type === "flowMapping" ? "{" : "[";
  29156. var closeMarker = node.type === "flowMapping" ? "}" : "]";
  29157. var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$11 : softline$8;
  29158. var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
  29159. return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
  29160. }(getLast$5(node.children));
  29161. return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
  29162. return concat$17([print(childPath), index === node.children.length - 1 ? "" : concat$17([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
  29163. }, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
  29164. }
  29165. case "flowSequenceItem":
  29166. return path$$1.call(print, "content");
  29167. // istanbul ignore next
  29168. default:
  29169. throw new Error(`Unexpected node type ${node.type}`);
  29170. }
  29171. function indent(doc$$2) {
  29172. return docBuilders$3.align(" ".repeat(options.tabWidth), doc$$2);
  29173. }
  29174. }
  29175. function align$3(n, doc$$2) {
  29176. return typeof n === "number" && n > 0 ? docBuilders$3.align(" ".repeat(n), doc$$2) : docBuilders$3.align(n, doc$$2);
  29177. }
  29178. function isInlineNode(node) {
  29179. if (!node) {
  29180. return true;
  29181. }
  29182. switch (node.type) {
  29183. case "plain":
  29184. case "quoteDouble":
  29185. case "quoteSingle":
  29186. case "alias":
  29187. case "flowMapping":
  29188. case "flowSequence":
  29189. return true;
  29190. default:
  29191. return false;
  29192. }
  29193. }
  29194. function isSingleLineNode(node) {
  29195. if (!node) {
  29196. return true;
  29197. }
  29198. switch (node.type) {
  29199. case "plain":
  29200. case "quoteDouble":
  29201. case "quoteSingle":
  29202. return node.position.start.line === node.position.end.line;
  29203. case "alias":
  29204. return true;
  29205. default:
  29206. return false;
  29207. }
  29208. }
  29209. function shouldPrintDocumentBody(document) {
  29210. return document.body.children.length !== 0 || hasEndComments(document.body);
  29211. }
  29212. function shouldPrintDocumentEndMarker(document, nextDocument) {
  29213. return (
  29214. /**
  29215. *... # trailingComment
  29216. */
  29217. hasTrailingComment$1(document) || nextDocument && (
  29218. /**
  29219. * ...
  29220. * %DIRECTIVE
  29221. * ---
  29222. */
  29223. nextDocument.head.children.length !== 0 ||
  29224. /**
  29225. * ...
  29226. * # endComment
  29227. * ---
  29228. */
  29229. hasEndComments(nextDocument.head))
  29230. );
  29231. }
  29232. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  29233. if (
  29234. /**
  29235. * ---
  29236. * preserve the first document head end marker
  29237. */
  29238. root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
  29239. /**
  29240. * %DIRECTIVE
  29241. * ---
  29242. */
  29243. document.head.children.length !== 0 ||
  29244. /**
  29245. * # end comment
  29246. * ---
  29247. */
  29248. hasEndComments(document.head) ||
  29249. /**
  29250. * --- # trailing comment
  29251. */
  29252. hasTrailingComment$1(document.head)) {
  29253. return "head";
  29254. }
  29255. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  29256. return false;
  29257. }
  29258. return nextDocument ? "root" : false;
  29259. }
  29260. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  29261. if (!node) {
  29262. return true;
  29263. }
  29264. switch (node.type) {
  29265. case "plain":
  29266. case "quoteSingle":
  29267. case "quoteDouble":
  29268. break;
  29269. case "alias":
  29270. return true;
  29271. default:
  29272. return false;
  29273. }
  29274. if (options.proseWrap === "preserve") {
  29275. return node.position.start.line === node.position.end.line;
  29276. }
  29277. if ( // backslash-newline
  29278. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  29279. return false;
  29280. }
  29281. switch (options.proseWrap) {
  29282. case "never":
  29283. return node.value.indexOf("\n") === -1;
  29284. case "always":
  29285. return !/[\n ]/.test(node.value);
  29286. // istanbul ignore next
  29287. default:
  29288. return false;
  29289. }
  29290. }
  29291. function needsSpaceInFrontOfMappingValue(node) {
  29292. return node.key.content && node.key.content.type === "alias";
  29293. }
  29294. function printNextEmptyLine(path$$1, originalText) {
  29295. var node = path$$1.getValue();
  29296. var root = path$$1.stack[0];
  29297. root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
  29298. if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
  29299. if (isNextLineEmpty$5(node, originalText)) {
  29300. root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
  29301. return softline$8;
  29302. }
  29303. }
  29304. return "";
  29305. }
  29306. function printFlowScalarContent(nodeType, content, options) {
  29307. var lineContents = getFlowScalarLineContents(nodeType, content, options);
  29308. return join$12(hardline$13, lineContents.map(function (lineContentWords) {
  29309. return fill$6(join$12(line$11, lineContentWords).parts);
  29310. }));
  29311. }
  29312. function clean$11(node, newNode
  29313. /*, parent */
  29314. ) {
  29315. if (isNode$1(newNode)) {
  29316. delete newNode.position;
  29317. switch (newNode.type) {
  29318. case "comment":
  29319. // insert pragma
  29320. if (isPragma(newNode.value)) {
  29321. return null;
  29322. }
  29323. break;
  29324. case "quoteDouble":
  29325. case "quoteSingle":
  29326. newNode.type = "quote";
  29327. break;
  29328. }
  29329. }
  29330. }
  29331. var printerYaml = {
  29332. preprocess: preprocess$6,
  29333. print: genericPrint$6,
  29334. massageAstNode: clean$11,
  29335. insertPragma: insertPragma$8
  29336. };
  29337. var options$19 = {
  29338. bracketSpacing: commonOptions.bracketSpacing,
  29339. singleQuote: commonOptions.singleQuote,
  29340. proseWrap: commonOptions.proseWrap
  29341. };
  29342. var name$16 = "YAML";
  29343. var type$15 = "data";
  29344. var tmScope$15 = "source.yaml";
  29345. var aliases$6 = ["yml"];
  29346. var extensions$15 = [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yml.mysql"];
  29347. var filenames$3 = [".clang-format", ".clang-tidy", ".gemrc", "glide.lock"];
  29348. var aceMode$15 = "yaml";
  29349. var codemirrorMode$11 = "yaml";
  29350. var codemirrorMimeType$11 = "text/x-yaml";
  29351. var languageId$15 = 407;
  29352. var yaml = {
  29353. name: name$16,
  29354. type: type$15,
  29355. tmScope: tmScope$15,
  29356. aliases: aliases$6,
  29357. extensions: extensions$15,
  29358. filenames: filenames$3,
  29359. aceMode: aceMode$15,
  29360. codemirrorMode: codemirrorMode$11,
  29361. codemirrorMimeType: codemirrorMimeType$11,
  29362. languageId: languageId$15
  29363. };
  29364. var yaml$1 = Object.freeze({
  29365. name: name$16,
  29366. type: type$15,
  29367. tmScope: tmScope$15,
  29368. aliases: aliases$6,
  29369. extensions: extensions$15,
  29370. filenames: filenames$3,
  29371. aceMode: aceMode$15,
  29372. codemirrorMode: codemirrorMode$11,
  29373. codemirrorMimeType: codemirrorMimeType$11,
  29374. languageId: languageId$15,
  29375. default: yaml
  29376. });
  29377. var require$$0$33 = ( yaml$1 && yaml ) || yaml$1;
  29378. var languages$6 = [createLanguage(require$$0$33, {
  29379. override: {
  29380. since: "1.14.0",
  29381. parsers: ["yaml"],
  29382. vscodeLanguageIds: ["yaml"]
  29383. }
  29384. })];
  29385. var languageYaml = {
  29386. languages: languages$6,
  29387. printers: {
  29388. yaml: printerYaml
  29389. },
  29390. options: options$19
  29391. };
  29392. // plugin will look for `eval("require")()` and transform to `require()` in the bundle,
  29393. // and rewrite the paths to require from the top-level.
  29394. // We need to list the parsers and getters so we can load them only when necessary.
  29395. var internalPlugins = [// JS
  29396. languageJs, {
  29397. parsers: {
  29398. // JS - Babel
  29399. get babel() {
  29400. return require("./parser-babylon").parsers.babel;
  29401. },
  29402. get "babel-flow"() {
  29403. return require("./parser-babylon").parsers["babel-flow"];
  29404. },
  29405. get babylon() {
  29406. return require("./parser-babylon").parsers.babel;
  29407. },
  29408. get json() {
  29409. return require("./parser-babylon").parsers.json;
  29410. },
  29411. get json5() {
  29412. return require("./parser-babylon").parsers.json5;
  29413. },
  29414. get "json-stringify"() {
  29415. return require("./parser-babylon").parsers["json-stringify"];
  29416. },
  29417. get __js_expression() {
  29418. return require("./parser-babylon").parsers.__js_expression;
  29419. },
  29420. get __vue_expression() {
  29421. return require("./parser-babylon").parsers.__vue_expression;
  29422. },
  29423. get __vue_event_binding() {
  29424. return require("./parser-babylon").parsers.__vue_event_binding;
  29425. },
  29426. // JS - Flow
  29427. get flow() {
  29428. return require("./parser-flow").parsers.flow;
  29429. },
  29430. // JS - TypeScript
  29431. get typescript() {
  29432. return require("./parser-typescript").parsers.typescript;
  29433. },
  29434. /**
  29435. * TODO: Remove this old alias in a major version
  29436. */
  29437. get "typescript-eslint"() {
  29438. return require("./parser-typescript").parsers.typescript;
  29439. },
  29440. // JS - Angular Action
  29441. get __ng_action() {
  29442. return require("./parser-angular").parsers.__ng_action;
  29443. },
  29444. // JS - Angular Binding
  29445. get __ng_binding() {
  29446. return require("./parser-angular").parsers.__ng_binding;
  29447. },
  29448. // JS - Angular Interpolation
  29449. get __ng_interpolation() {
  29450. return require("./parser-angular").parsers.__ng_interpolation;
  29451. },
  29452. // JS - Angular Directive
  29453. get __ng_directive() {
  29454. return require("./parser-angular").parsers.__ng_directive;
  29455. }
  29456. }
  29457. }, // CSS
  29458. languageCss, {
  29459. parsers: {
  29460. // TODO: switch these to just `postcss` and use `language` instead.
  29461. get css() {
  29462. return require("./parser-postcss").parsers.css;
  29463. },
  29464. get less() {
  29465. return require("./parser-postcss").parsers.css;
  29466. },
  29467. get scss() {
  29468. return require("./parser-postcss").parsers.css;
  29469. }
  29470. }
  29471. }, // Handlebars
  29472. languageHandlebars, {
  29473. parsers: {
  29474. get glimmer() {
  29475. return require("./parser-glimmer").parsers.glimmer;
  29476. }
  29477. }
  29478. }, // GraphQL
  29479. languageGraphql, {
  29480. parsers: {
  29481. get graphql() {
  29482. return require("./parser-graphql").parsers.graphql;
  29483. }
  29484. }
  29485. }, // Markdown
  29486. languageMarkdown, {
  29487. parsers: {
  29488. get remark() {
  29489. return require("./parser-markdown").parsers.remark;
  29490. },
  29491. // TODO: Delete this in 2.0
  29492. get markdown() {
  29493. return require("./parser-markdown").parsers.remark;
  29494. },
  29495. get mdx() {
  29496. return require("./parser-markdown").parsers.mdx;
  29497. }
  29498. }
  29499. }, languageHtml, {
  29500. parsers: {
  29501. // HTML
  29502. get html() {
  29503. return require("./parser-html").parsers.html;
  29504. },
  29505. // Vue
  29506. get vue() {
  29507. return require("./parser-html").parsers.vue;
  29508. },
  29509. // Angular
  29510. get angular() {
  29511. return require("./parser-html").parsers.angular;
  29512. },
  29513. // Lightning Web Components
  29514. get lwc() {
  29515. return require("./parser-html").parsers.lwc;
  29516. }
  29517. }
  29518. }, // YAML
  29519. languageYaml, {
  29520. parsers: {
  29521. get yaml() {
  29522. return require("./parser-yaml").parsers.yaml;
  29523. }
  29524. }
  29525. }];
  29526. var partition = function partition(array, fn) {
  29527. var a = [];
  29528. var b = [];
  29529. array.forEach(function (item) {
  29530. if (fn(item)) {
  29531. a.push(item);
  29532. } else {
  29533. b.push(item);
  29534. }
  29535. });
  29536. return [a, b];
  29537. };
  29538. var thirdParty$1 = ( thirdParty && thirdParty__default ) || thirdParty;
  29539. function loadPlugins(plugins, pluginSearchDirs) {
  29540. if (!plugins) {
  29541. plugins = [];
  29542. }
  29543. if (!pluginSearchDirs) {
  29544. pluginSearchDirs = [];
  29545. } // unless pluginSearchDirs are provided, auto-load plugins from node_modules that are parent to Prettier
  29546. if (!pluginSearchDirs.length) {
  29547. var autoLoadDir = thirdParty$1.findParentDir(__dirname, "node_modules");
  29548. if (autoLoadDir) {
  29549. pluginSearchDirs = [autoLoadDir];
  29550. }
  29551. }
  29552. var _partition = partition(plugins, function (plugin) {
  29553. return typeof plugin === "string";
  29554. }),
  29555. _partition2 = _slicedToArray(_partition, 2),
  29556. externalPluginNames = _partition2[0],
  29557. externalPluginInstances = _partition2[1];
  29558. var externalManualLoadPluginInfos = externalPluginNames.map(function (pluginName) {
  29559. var requirePath;
  29560. try {
  29561. // try local files
  29562. requirePath = resolve$1.sync(path.resolve(process.cwd(), pluginName));
  29563. } catch (e) {
  29564. // try node modules
  29565. requirePath = resolve$1.sync(pluginName, {
  29566. basedir: process.cwd()
  29567. });
  29568. }
  29569. return {
  29570. name: pluginName,
  29571. requirePath
  29572. };
  29573. });
  29574. var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
  29575. var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
  29576. var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
  29577. // isDirectory(resolvedPluginSearchDir) check might be false even though
  29578. // the node_modules actually exists.
  29579. if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
  29580. throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
  29581. }
  29582. return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
  29583. return {
  29584. name: pluginName,
  29585. requirePath: resolve$1.sync(pluginName, {
  29586. basedir: resolvedPluginSearchDir
  29587. })
  29588. };
  29589. });
  29590. }).reduce(function (a, b) {
  29591. return a.concat(b);
  29592. }, []);
  29593. var externalPlugins = lodash_uniqby(externalManualLoadPluginInfos.concat(externalAutoLoadPluginInfos), "requirePath").map(function (externalPluginInfo) {
  29594. return Object.assign({
  29595. name: externalPluginInfo.name
  29596. }, require(externalPluginInfo.requirePath));
  29597. }).concat(externalPluginInstances);
  29598. return internalPlugins.concat(externalPlugins);
  29599. }
  29600. function findPluginsInNodeModules(nodeModulesDir) {
  29601. var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
  29602. cwd: nodeModulesDir
  29603. });
  29604. return pluginPackageJsonPaths.map(path.dirname);
  29605. }
  29606. function isDirectory(dir) {
  29607. try {
  29608. return fs.statSync(dir).isDirectory();
  29609. } catch (e) {
  29610. return false;
  29611. }
  29612. }
  29613. var loadPlugins_1 = loadPlugins;
  29614. var mimicFn = function mimicFn(to, from) {
  29615. // TODO: use `Reflect.ownKeys()` when targeting Node.js 6
  29616. var _iteratorNormalCompletion = true;
  29617. var _didIteratorError = false;
  29618. var _iteratorError = undefined;
  29619. try {
  29620. for (var _iterator = Object.getOwnPropertyNames(from).concat(Object.getOwnPropertySymbols(from))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29621. var prop = _step.value;
  29622. Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
  29623. }
  29624. } catch (err) {
  29625. _didIteratorError = true;
  29626. _iteratorError = err;
  29627. } finally {
  29628. try {
  29629. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29630. _iterator.return();
  29631. }
  29632. } finally {
  29633. if (_didIteratorError) {
  29634. throw _iteratorError;
  29635. }
  29636. }
  29637. }
  29638. };
  29639. var mem = createCommonjsModule(function (module) {
  29640. 'use strict';
  29641. var cacheStore = new WeakMap();
  29642. var defaultCacheKey = function defaultCacheKey(x) {
  29643. if (arguments.length === 1 && (x === null || x === undefined || typeof x !== 'function' && typeof x !== 'object')) {
  29644. return x;
  29645. }
  29646. return JSON.stringify(arguments);
  29647. };
  29648. module.exports = function (fn, opts) {
  29649. opts = Object.assign({
  29650. cacheKey: defaultCacheKey,
  29651. cache: new Map()
  29652. }, opts);
  29653. var memoized = function memoized() {
  29654. var cache = cacheStore.get(memoized);
  29655. var key = opts.cacheKey.apply(null, arguments);
  29656. if (cache.has(key)) {
  29657. var c = cache.get(key);
  29658. if (typeof opts.maxAge !== 'number' || Date.now() < c.maxAge) {
  29659. return c.data;
  29660. }
  29661. }
  29662. var ret = fn.apply(null, arguments);
  29663. cache.set(key, {
  29664. data: ret,
  29665. maxAge: Date.now() + (opts.maxAge || 0)
  29666. });
  29667. return ret;
  29668. };
  29669. mimicFn(memoized, fn);
  29670. cacheStore.set(memoized, opts.cache);
  29671. return memoized;
  29672. };
  29673. module.exports.clear = function (fn) {
  29674. var cache = cacheStore.get(fn);
  29675. if (cache && typeof cache.clear === 'function') {
  29676. cache.clear();
  29677. }
  29678. };
  29679. });
  29680. var semver$3 = createCommonjsModule(function (module, exports) {
  29681. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  29682. /* nomin */
  29683. var debug;
  29684. /* nomin */
  29685. if (typeof process === 'object' &&
  29686. /* nomin */
  29687. process.env &&
  29688. /* nomin */
  29689. process.env.NODE_DEBUG &&
  29690. /* nomin */
  29691. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  29692. /* nomin */
  29693. debug = function debug() {
  29694. /* nomin */
  29695. var args = Array.prototype.slice.call(arguments, 0);
  29696. /* nomin */
  29697. args.unshift('SEMVER');
  29698. /* nomin */
  29699. console.log.apply(console, args);
  29700. /* nomin */
  29701. };
  29702. /* nomin */
  29703. else
  29704. /* nomin */
  29705. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  29706. // Not necessarily the package version of this code.
  29707. exports.SEMVER_SPEC_VERSION = '2.0.0';
  29708. var MAX_LENGTH = 256;
  29709. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // Max safe segment length for coercion.
  29710. var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
  29711. var re = exports.re = [];
  29712. var src = exports.src = [];
  29713. var R = 0; // The following Regular Expressions can be used for tokenizing,
  29714. // validating, and parsing SemVer version strings.
  29715. // ## Numeric Identifier
  29716. // A single `0`, or a non-zero digit followed by zero or more digits.
  29717. var NUMERICIDENTIFIER = R++;
  29718. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  29719. var NUMERICIDENTIFIERLOOSE = R++;
  29720. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  29721. // Zero or more digits, followed by a letter or hyphen, and then zero or
  29722. // more letters, digits, or hyphens.
  29723. var NONNUMERICIDENTIFIER = R++;
  29724. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  29725. // Three dot-separated numeric identifiers.
  29726. var MAINVERSION = R++;
  29727. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  29728. var MAINVERSIONLOOSE = R++;
  29729. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  29730. // A numeric identifier, or a non-numeric identifier.
  29731. var PRERELEASEIDENTIFIER = R++;
  29732. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  29733. var PRERELEASEIDENTIFIERLOOSE = R++;
  29734. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  29735. // Hyphen, followed by one or more dot-separated pre-release version
  29736. // identifiers.
  29737. var PRERELEASE = R++;
  29738. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  29739. var PRERELEASELOOSE = R++;
  29740. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  29741. // Any combination of digits, letters, or hyphens.
  29742. var BUILDIDENTIFIER = R++;
  29743. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  29744. // Plus sign, followed by one or more period-separated build metadata
  29745. // identifiers.
  29746. var BUILD = R++;
  29747. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  29748. // A main version, followed optionally by a pre-release version and
  29749. // build metadata.
  29750. // Note that the only major, minor, patch, and pre-release sections of
  29751. // the version string are capturing groups. The build metadata is not a
  29752. // capturing group, because it should not ever be used in version
  29753. // comparison.
  29754. var FULL = R++;
  29755. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  29756. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  29757. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  29758. // common in the npm registry.
  29759. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  29760. var LOOSE = R++;
  29761. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  29762. var GTLT = R++;
  29763. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  29764. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  29765. // Only the first item is strictly required.
  29766. var XRANGEIDENTIFIERLOOSE = R++;
  29767. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  29768. var XRANGEIDENTIFIER = R++;
  29769. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  29770. var XRANGEPLAIN = R++;
  29771. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  29772. var XRANGEPLAINLOOSE = R++;
  29773. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  29774. var XRANGE = R++;
  29775. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  29776. var XRANGELOOSE = R++;
  29777. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Coercion.
  29778. // Extract anything that could conceivably be a part of a valid semver
  29779. var COERCE = R++;
  29780. src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; // Tilde ranges.
  29781. // Meaning is "reasonably at or greater than"
  29782. var LONETILDE = R++;
  29783. src[LONETILDE] = '(?:~>?)';
  29784. var TILDETRIM = R++;
  29785. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  29786. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  29787. var tildeTrimReplace = '$1~';
  29788. var TILDE = R++;
  29789. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  29790. var TILDELOOSE = R++;
  29791. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  29792. // Meaning is "at least and backwards compatible with"
  29793. var LONECARET = R++;
  29794. src[LONECARET] = '(?:\\^)';
  29795. var CARETTRIM = R++;
  29796. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  29797. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  29798. var caretTrimReplace = '$1^';
  29799. var CARET = R++;
  29800. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  29801. var CARETLOOSE = R++;
  29802. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  29803. var COMPARATORLOOSE = R++;
  29804. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  29805. var COMPARATOR = R++;
  29806. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  29807. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  29808. var COMPARATORTRIM = R++;
  29809. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  29810. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  29811. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  29812. // Note that these all use the loose form, because they'll be
  29813. // checked against either the strict or loose comparator form
  29814. // later.
  29815. var HYPHENRANGE = R++;
  29816. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  29817. var HYPHENRANGELOOSE = R++;
  29818. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  29819. var STAR = R++;
  29820. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  29821. // All are flag-free, unless they were created above with a flag.
  29822. for (var i = 0; i < R; i++) {
  29823. debug(i, src[i]);
  29824. if (!re[i]) re[i] = new RegExp(src[i]);
  29825. }
  29826. exports.parse = parse;
  29827. function parse(version, options) {
  29828. if (!options || typeof options !== 'object') options = {
  29829. loose: !!options,
  29830. includePrerelease: false
  29831. };
  29832. if (version instanceof SemVer) return version;
  29833. if (typeof version !== 'string') return null;
  29834. if (version.length > MAX_LENGTH) return null;
  29835. var r = options.loose ? re[LOOSE] : re[FULL];
  29836. if (!r.test(version)) return null;
  29837. try {
  29838. return new SemVer(version, options);
  29839. } catch (er) {
  29840. return null;
  29841. }
  29842. }
  29843. exports.valid = valid;
  29844. function valid(version, options) {
  29845. var v = parse(version, options);
  29846. return v ? v.version : null;
  29847. }
  29848. exports.clean = clean;
  29849. function clean(version, options) {
  29850. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  29851. return s ? s.version : null;
  29852. }
  29853. exports.SemVer = SemVer;
  29854. function SemVer(version, options) {
  29855. if (!options || typeof options !== 'object') options = {
  29856. loose: !!options,
  29857. includePrerelease: false
  29858. };
  29859. if (version instanceof SemVer) {
  29860. if (version.loose === options.loose) return version;else version = version.version;
  29861. } else if (typeof version !== 'string') {
  29862. throw new TypeError('Invalid Version: ' + version);
  29863. }
  29864. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  29865. if (!(this instanceof SemVer)) return new SemVer(version, options);
  29866. debug('SemVer', version, options);
  29867. this.options = options;
  29868. this.loose = !!options.loose;
  29869. var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
  29870. if (!m) throw new TypeError('Invalid Version: ' + version);
  29871. this.raw = version; // these are actually numbers
  29872. this.major = +m[1];
  29873. this.minor = +m[2];
  29874. this.patch = +m[3];
  29875. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  29876. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  29877. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  29878. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  29879. if (/^[0-9]+$/.test(id)) {
  29880. var num = +id;
  29881. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  29882. }
  29883. return id;
  29884. });
  29885. this.build = m[5] ? m[5].split('.') : [];
  29886. this.format();
  29887. }
  29888. SemVer.prototype.format = function () {
  29889. this.version = this.major + '.' + this.minor + '.' + this.patch;
  29890. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  29891. return this.version;
  29892. };
  29893. SemVer.prototype.toString = function () {
  29894. return this.version;
  29895. };
  29896. SemVer.prototype.compare = function (other) {
  29897. debug('SemVer.compare', this.version, this.options, other);
  29898. if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
  29899. return this.compareMain(other) || this.comparePre(other);
  29900. };
  29901. SemVer.prototype.compareMain = function (other) {
  29902. if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
  29903. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  29904. };
  29905. SemVer.prototype.comparePre = function (other) {
  29906. if (!(other instanceof SemVer)) other = new SemVer(other, this.options); // NOT having a prerelease is > having one
  29907. if (this.prerelease.length && !other.prerelease.length) return -1;else if (!this.prerelease.length && other.prerelease.length) return 1;else if (!this.prerelease.length && !other.prerelease.length) return 0;
  29908. var i = 0;
  29909. do {
  29910. var a = this.prerelease[i];
  29911. var b = other.prerelease[i];
  29912. debug('prerelease compare', i, a, b);
  29913. if (a === undefined && b === undefined) return 0;else if (b === undefined) return 1;else if (a === undefined) return -1;else if (a === b) continue;else return compareIdentifiers(a, b);
  29914. } while (++i);
  29915. }; // preminor will bump the version up to the next minor release, and immediately
  29916. // down to pre-release. premajor and prepatch work the same way.
  29917. SemVer.prototype.inc = function (release, identifier) {
  29918. switch (release) {
  29919. case 'premajor':
  29920. this.prerelease.length = 0;
  29921. this.patch = 0;
  29922. this.minor = 0;
  29923. this.major++;
  29924. this.inc('pre', identifier);
  29925. break;
  29926. case 'preminor':
  29927. this.prerelease.length = 0;
  29928. this.patch = 0;
  29929. this.minor++;
  29930. this.inc('pre', identifier);
  29931. break;
  29932. case 'prepatch':
  29933. // If this is already a prerelease, it will bump to the next version
  29934. // drop any prereleases that might already exist, since they are not
  29935. // relevant at this point.
  29936. this.prerelease.length = 0;
  29937. this.inc('patch', identifier);
  29938. this.inc('pre', identifier);
  29939. break;
  29940. // If the input is a non-prerelease version, this acts the same as
  29941. // prepatch.
  29942. case 'prerelease':
  29943. if (this.prerelease.length === 0) this.inc('patch', identifier);
  29944. this.inc('pre', identifier);
  29945. break;
  29946. case 'major':
  29947. // If this is a pre-major version, bump up to the same major version.
  29948. // Otherwise increment major.
  29949. // 1.0.0-5 bumps to 1.0.0
  29950. // 1.1.0 bumps to 2.0.0
  29951. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  29952. this.minor = 0;
  29953. this.patch = 0;
  29954. this.prerelease = [];
  29955. break;
  29956. case 'minor':
  29957. // If this is a pre-minor version, bump up to the same minor version.
  29958. // Otherwise increment minor.
  29959. // 1.2.0-5 bumps to 1.2.0
  29960. // 1.2.1 bumps to 1.3.0
  29961. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  29962. this.patch = 0;
  29963. this.prerelease = [];
  29964. break;
  29965. case 'patch':
  29966. // If this is not a pre-release version, it will increment the patch.
  29967. // If it is a pre-release it will bump up to the same patch version.
  29968. // 1.2.0-5 patches to 1.2.0
  29969. // 1.2.0 patches to 1.2.1
  29970. if (this.prerelease.length === 0) this.patch++;
  29971. this.prerelease = [];
  29972. break;
  29973. // This probably shouldn't be used publicly.
  29974. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  29975. case 'pre':
  29976. if (this.prerelease.length === 0) this.prerelease = [0];else {
  29977. var i = this.prerelease.length;
  29978. while (--i >= 0) {
  29979. if (typeof this.prerelease[i] === 'number') {
  29980. this.prerelease[i]++;
  29981. i = -2;
  29982. }
  29983. }
  29984. if (i === -1) // didn't increment anything
  29985. this.prerelease.push(0);
  29986. }
  29987. if (identifier) {
  29988. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  29989. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  29990. if (this.prerelease[0] === identifier) {
  29991. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  29992. } else this.prerelease = [identifier, 0];
  29993. }
  29994. break;
  29995. default:
  29996. throw new Error('invalid increment argument: ' + release);
  29997. }
  29998. this.format();
  29999. this.raw = this.version;
  30000. return this;
  30001. };
  30002. exports.inc = inc;
  30003. function inc(version, release, loose, identifier) {
  30004. if (typeof loose === 'string') {
  30005. identifier = loose;
  30006. loose = undefined;
  30007. }
  30008. try {
  30009. return new SemVer(version, loose).inc(release, identifier).version;
  30010. } catch (er) {
  30011. return null;
  30012. }
  30013. }
  30014. exports.diff = diff;
  30015. function diff(version1, version2) {
  30016. if (eq(version1, version2)) {
  30017. return null;
  30018. } else {
  30019. var v1 = parse(version1);
  30020. var v2 = parse(version2);
  30021. if (v1.prerelease.length || v2.prerelease.length) {
  30022. for (var key in v1) {
  30023. if (key === 'major' || key === 'minor' || key === 'patch') {
  30024. if (v1[key] !== v2[key]) {
  30025. return 'pre' + key;
  30026. }
  30027. }
  30028. }
  30029. return 'prerelease';
  30030. }
  30031. for (var key in v1) {
  30032. if (key === 'major' || key === 'minor' || key === 'patch') {
  30033. if (v1[key] !== v2[key]) {
  30034. return key;
  30035. }
  30036. }
  30037. }
  30038. }
  30039. }
  30040. exports.compareIdentifiers = compareIdentifiers;
  30041. var numeric = /^[0-9]+$/;
  30042. function compareIdentifiers(a, b) {
  30043. var anum = numeric.test(a);
  30044. var bnum = numeric.test(b);
  30045. if (anum && bnum) {
  30046. a = +a;
  30047. b = +b;
  30048. }
  30049. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  30050. }
  30051. exports.rcompareIdentifiers = rcompareIdentifiers;
  30052. function rcompareIdentifiers(a, b) {
  30053. return compareIdentifiers(b, a);
  30054. }
  30055. exports.major = major;
  30056. function major(a, loose) {
  30057. return new SemVer(a, loose).major;
  30058. }
  30059. exports.minor = minor;
  30060. function minor(a, loose) {
  30061. return new SemVer(a, loose).minor;
  30062. }
  30063. exports.patch = patch;
  30064. function patch(a, loose) {
  30065. return new SemVer(a, loose).patch;
  30066. }
  30067. exports.compare = compare;
  30068. function compare(a, b, loose) {
  30069. return new SemVer(a, loose).compare(new SemVer(b, loose));
  30070. }
  30071. exports.compareLoose = compareLoose;
  30072. function compareLoose(a, b) {
  30073. return compare(a, b, true);
  30074. }
  30075. exports.rcompare = rcompare;
  30076. function rcompare(a, b, loose) {
  30077. return compare(b, a, loose);
  30078. }
  30079. exports.sort = sort;
  30080. function sort(list, loose) {
  30081. return list.sort(function (a, b) {
  30082. return exports.compare(a, b, loose);
  30083. });
  30084. }
  30085. exports.rsort = rsort;
  30086. function rsort(list, loose) {
  30087. return list.sort(function (a, b) {
  30088. return exports.rcompare(a, b, loose);
  30089. });
  30090. }
  30091. exports.gt = gt;
  30092. function gt(a, b, loose) {
  30093. return compare(a, b, loose) > 0;
  30094. }
  30095. exports.lt = lt;
  30096. function lt(a, b, loose) {
  30097. return compare(a, b, loose) < 0;
  30098. }
  30099. exports.eq = eq;
  30100. function eq(a, b, loose) {
  30101. return compare(a, b, loose) === 0;
  30102. }
  30103. exports.neq = neq;
  30104. function neq(a, b, loose) {
  30105. return compare(a, b, loose) !== 0;
  30106. }
  30107. exports.gte = gte;
  30108. function gte(a, b, loose) {
  30109. return compare(a, b, loose) >= 0;
  30110. }
  30111. exports.lte = lte;
  30112. function lte(a, b, loose) {
  30113. return compare(a, b, loose) <= 0;
  30114. }
  30115. exports.cmp = cmp;
  30116. function cmp(a, op, b, loose) {
  30117. var ret;
  30118. switch (op) {
  30119. case '===':
  30120. if (typeof a === 'object') a = a.version;
  30121. if (typeof b === 'object') b = b.version;
  30122. ret = a === b;
  30123. break;
  30124. case '!==':
  30125. if (typeof a === 'object') a = a.version;
  30126. if (typeof b === 'object') b = b.version;
  30127. ret = a !== b;
  30128. break;
  30129. case '':
  30130. case '=':
  30131. case '==':
  30132. ret = eq(a, b, loose);
  30133. break;
  30134. case '!=':
  30135. ret = neq(a, b, loose);
  30136. break;
  30137. case '>':
  30138. ret = gt(a, b, loose);
  30139. break;
  30140. case '>=':
  30141. ret = gte(a, b, loose);
  30142. break;
  30143. case '<':
  30144. ret = lt(a, b, loose);
  30145. break;
  30146. case '<=':
  30147. ret = lte(a, b, loose);
  30148. break;
  30149. default:
  30150. throw new TypeError('Invalid operator: ' + op);
  30151. }
  30152. return ret;
  30153. }
  30154. exports.Comparator = Comparator;
  30155. function Comparator(comp, options) {
  30156. if (!options || typeof options !== 'object') options = {
  30157. loose: !!options,
  30158. includePrerelease: false
  30159. };
  30160. if (comp instanceof Comparator) {
  30161. if (comp.loose === !!options.loose) return comp;else comp = comp.value;
  30162. }
  30163. if (!(this instanceof Comparator)) return new Comparator(comp, options);
  30164. debug('comparator', comp, options);
  30165. this.options = options;
  30166. this.loose = !!options.loose;
  30167. this.parse(comp);
  30168. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  30169. debug('comp', this);
  30170. }
  30171. var ANY = {};
  30172. Comparator.prototype.parse = function (comp) {
  30173. var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  30174. var m = comp.match(r);
  30175. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  30176. this.operator = m[1];
  30177. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  30178. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.options.loose);
  30179. };
  30180. Comparator.prototype.toString = function () {
  30181. return this.value;
  30182. };
  30183. Comparator.prototype.test = function (version) {
  30184. debug('Comparator.test', version, this.options.loose);
  30185. if (this.semver === ANY) return true;
  30186. if (typeof version === 'string') version = new SemVer(version, this.options);
  30187. return cmp(version, this.operator, this.semver, this.options);
  30188. };
  30189. Comparator.prototype.intersects = function (comp, options) {
  30190. if (!(comp instanceof Comparator)) {
  30191. throw new TypeError('a Comparator is required');
  30192. }
  30193. if (!options || typeof options !== 'object') options = {
  30194. loose: !!options,
  30195. includePrerelease: false
  30196. };
  30197. var rangeTmp;
  30198. if (this.operator === '') {
  30199. rangeTmp = new Range(comp.value, options);
  30200. return satisfies(this.value, rangeTmp, options);
  30201. } else if (comp.operator === '') {
  30202. rangeTmp = new Range(this.value, options);
  30203. return satisfies(comp.semver, rangeTmp, options);
  30204. }
  30205. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  30206. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  30207. var sameSemVer = this.semver.version === comp.semver.version;
  30208. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  30209. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  30210. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  30211. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  30212. };
  30213. exports.Range = Range;
  30214. function Range(range, options) {
  30215. if (!options || typeof options !== 'object') options = {
  30216. loose: !!options,
  30217. includePrerelease: false
  30218. };
  30219. if (range instanceof Range) {
  30220. if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
  30221. return range;
  30222. } else {
  30223. return new Range(range.raw, options);
  30224. }
  30225. }
  30226. if (range instanceof Comparator) {
  30227. return new Range(range.value, options);
  30228. }
  30229. if (!(this instanceof Range)) return new Range(range, options);
  30230. this.options = options;
  30231. this.loose = !!options.loose;
  30232. this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
  30233. this.raw = range;
  30234. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  30235. return this.parseRange(range.trim());
  30236. }, this).filter(function (c) {
  30237. // throw out any that are not relevant for whatever reason
  30238. return c.length;
  30239. });
  30240. if (!this.set.length) {
  30241. throw new TypeError('Invalid SemVer Range: ' + range);
  30242. }
  30243. this.format();
  30244. }
  30245. Range.prototype.format = function () {
  30246. this.range = this.set.map(function (comps) {
  30247. return comps.join(' ').trim();
  30248. }).join('||').trim();
  30249. return this.range;
  30250. };
  30251. Range.prototype.toString = function () {
  30252. return this.range;
  30253. };
  30254. Range.prototype.parseRange = function (range) {
  30255. var loose = this.options.loose;
  30256. range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  30257. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  30258. range = range.replace(hr, hyphenReplace);
  30259. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  30260. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  30261. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  30262. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  30263. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  30264. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  30265. // ready to be split into comparators.
  30266. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  30267. var set = range.split(' ').map(function (comp) {
  30268. return parseComparator(comp, this.options);
  30269. }, this).join(' ').split(/\s+/);
  30270. if (this.options.loose) {
  30271. // in loose mode, throw out any that are not valid comparators
  30272. set = set.filter(function (comp) {
  30273. return !!comp.match(compRe);
  30274. });
  30275. }
  30276. set = set.map(function (comp) {
  30277. return new Comparator(comp, this.options);
  30278. }, this);
  30279. return set;
  30280. };
  30281. Range.prototype.intersects = function (range, options) {
  30282. if (!(range instanceof Range)) {
  30283. throw new TypeError('a Range is required');
  30284. }
  30285. return this.set.some(function (thisComparators) {
  30286. return thisComparators.every(function (thisComparator) {
  30287. return range.set.some(function (rangeComparators) {
  30288. return rangeComparators.every(function (rangeComparator) {
  30289. return thisComparator.intersects(rangeComparator, options);
  30290. });
  30291. });
  30292. });
  30293. });
  30294. }; // Mostly just for testing and legacy API reasons
  30295. exports.toComparators = toComparators;
  30296. function toComparators(range, options) {
  30297. return new Range(range, options).set.map(function (comp) {
  30298. return comp.map(function (c) {
  30299. return c.value;
  30300. }).join(' ').trim().split(' ');
  30301. });
  30302. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  30303. // already replaced the hyphen ranges
  30304. // turn into a set of JUST comparators.
  30305. function parseComparator(comp, options) {
  30306. debug('comp', comp, options);
  30307. comp = replaceCarets(comp, options);
  30308. debug('caret', comp);
  30309. comp = replaceTildes(comp, options);
  30310. debug('tildes', comp);
  30311. comp = replaceXRanges(comp, options);
  30312. debug('xrange', comp);
  30313. comp = replaceStars(comp, options);
  30314. debug('stars', comp);
  30315. return comp;
  30316. }
  30317. function isX(id) {
  30318. return !id || id.toLowerCase() === 'x' || id === '*';
  30319. } // ~, ~> --> * (any, kinda silly)
  30320. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  30321. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  30322. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  30323. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  30324. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  30325. function replaceTildes(comp, options) {
  30326. return comp.trim().split(/\s+/).map(function (comp) {
  30327. return replaceTilde(comp, options);
  30328. }).join(' ');
  30329. }
  30330. function replaceTilde(comp, options) {
  30331. if (!options || typeof options !== 'object') options = {
  30332. loose: !!options,
  30333. includePrerelease: false
  30334. };
  30335. var r = options.loose ? re[TILDELOOSE] : re[TILDE];
  30336. return comp.replace(r, function (_, M, m, p, pr) {
  30337. debug('tilde', comp, _, M, m, p, pr);
  30338. var ret;
  30339. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) // ~1.2 == >=1.2.0 <1.3.0
  30340. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  30341. debug('replaceTilde pr', pr);
  30342. if (pr.charAt(0) !== '-') pr = '-' + pr;
  30343. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  30344. } else // ~1.2.3 == >=1.2.3 <1.3.0
  30345. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  30346. debug('tilde return', ret);
  30347. return ret;
  30348. });
  30349. } // ^ --> * (any, kinda silly)
  30350. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  30351. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  30352. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  30353. // ^1.2.3 --> >=1.2.3 <2.0.0
  30354. // ^1.2.0 --> >=1.2.0 <2.0.0
  30355. function replaceCarets(comp, options) {
  30356. return comp.trim().split(/\s+/).map(function (comp) {
  30357. return replaceCaret(comp, options);
  30358. }).join(' ');
  30359. }
  30360. function replaceCaret(comp, options) {
  30361. debug('caret', comp, options);
  30362. if (!options || typeof options !== 'object') options = {
  30363. loose: !!options,
  30364. includePrerelease: false
  30365. };
  30366. var r = options.loose ? re[CARETLOOSE] : re[CARET];
  30367. return comp.replace(r, function (_, M, m, p, pr) {
  30368. debug('caret', comp, _, M, m, p, pr);
  30369. var ret;
  30370. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  30371. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  30372. } else if (pr) {
  30373. debug('replaceCaret pr', pr);
  30374. if (pr.charAt(0) !== '-') pr = '-' + pr;
  30375. if (M === '0') {
  30376. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  30377. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  30378. } else {
  30379. debug('no pr');
  30380. if (M === '0') {
  30381. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  30382. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  30383. }
  30384. debug('caret return', ret);
  30385. return ret;
  30386. });
  30387. }
  30388. function replaceXRanges(comp, options) {
  30389. debug('replaceXRanges', comp, options);
  30390. return comp.split(/\s+/).map(function (comp) {
  30391. return replaceXRange(comp, options);
  30392. }).join(' ');
  30393. }
  30394. function replaceXRange(comp, options) {
  30395. comp = comp.trim();
  30396. if (!options || typeof options !== 'object') options = {
  30397. loose: !!options,
  30398. includePrerelease: false
  30399. };
  30400. var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
  30401. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  30402. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  30403. var xM = isX(M);
  30404. var xm = xM || isX(m);
  30405. var xp = xm || isX(p);
  30406. var anyX = xp;
  30407. if (gtlt === '=' && anyX) gtlt = '';
  30408. if (xM) {
  30409. if (gtlt === '>' || gtlt === '<') {
  30410. // nothing is allowed
  30411. ret = '<0.0.0';
  30412. } else {
  30413. // nothing is forbidden
  30414. ret = '*';
  30415. }
  30416. } else if (gtlt && anyX) {
  30417. // replace X with 0
  30418. if (xm) m = 0;
  30419. if (xp) p = 0;
  30420. if (gtlt === '>') {
  30421. // >1 => >=2.0.0
  30422. // >1.2 => >=1.3.0
  30423. // >1.2.3 => >= 1.2.4
  30424. gtlt = '>=';
  30425. if (xm) {
  30426. M = +M + 1;
  30427. m = 0;
  30428. p = 0;
  30429. } else if (xp) {
  30430. m = +m + 1;
  30431. p = 0;
  30432. }
  30433. } else if (gtlt === '<=') {
  30434. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  30435. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  30436. gtlt = '<';
  30437. if (xm) M = +M + 1;else m = +m + 1;
  30438. }
  30439. ret = gtlt + M + '.' + m + '.' + p;
  30440. } else if (xm) {
  30441. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  30442. } else if (xp) {
  30443. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  30444. }
  30445. debug('xRange return', ret);
  30446. return ret;
  30447. });
  30448. } // Because * is AND-ed with everything else in the comparator,
  30449. // and '' means "any version", just remove the *s entirely.
  30450. function replaceStars(comp, options) {
  30451. debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
  30452. return comp.trim().replace(re[STAR], '');
  30453. } // This function is passed to string.replace(re[HYPHENRANGE])
  30454. // M, m, patch, prerelease, build
  30455. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  30456. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  30457. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  30458. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  30459. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  30460. if (isX(tM)) to = '';else if (isX(tm)) to = '<' + (+tM + 1) + '.0.0';else if (isX(tp)) to = '<' + tM + '.' + (+tm + 1) + '.0';else if (tpr) to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;else to = '<=' + to;
  30461. return (from + ' ' + to).trim();
  30462. } // if ANY of the sets match ALL of its comparators, then pass
  30463. Range.prototype.test = function (version) {
  30464. if (!version) return false;
  30465. if (typeof version === 'string') version = new SemVer(version, this.options);
  30466. for (var i = 0; i < this.set.length; i++) {
  30467. if (testSet(this.set[i], version, this.options)) return true;
  30468. }
  30469. return false;
  30470. };
  30471. function testSet(set, version, options) {
  30472. for (var i = 0; i < set.length; i++) {
  30473. if (!set[i].test(version)) return false;
  30474. }
  30475. if (!options) options = {};
  30476. if (version.prerelease.length && !options.includePrerelease) {
  30477. // Find the set of versions that are allowed to have prereleases
  30478. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  30479. // That should allow `1.2.3-pr.2` to pass.
  30480. // However, `1.2.4-alpha.notready` should NOT be allowed,
  30481. // even though it's within the range set by the comparators.
  30482. for (var i = 0; i < set.length; i++) {
  30483. debug(set[i].semver);
  30484. if (set[i].semver === ANY) continue;
  30485. if (set[i].semver.prerelease.length > 0) {
  30486. var allowed = set[i].semver;
  30487. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  30488. }
  30489. } // Version has a -pre, but it's not one of the ones we like.
  30490. return false;
  30491. }
  30492. return true;
  30493. }
  30494. exports.satisfies = satisfies;
  30495. function satisfies(version, range, options) {
  30496. try {
  30497. range = new Range(range, options);
  30498. } catch (er) {
  30499. return false;
  30500. }
  30501. return range.test(version);
  30502. }
  30503. exports.maxSatisfying = maxSatisfying;
  30504. function maxSatisfying(versions, range, options) {
  30505. var max = null;
  30506. var maxSV = null;
  30507. try {
  30508. var rangeObj = new Range(range, options);
  30509. } catch (er) {
  30510. return null;
  30511. }
  30512. versions.forEach(function (v) {
  30513. if (rangeObj.test(v)) {
  30514. // satisfies(v, range, options)
  30515. if (!max || maxSV.compare(v) === -1) {
  30516. // compare(max, v, true)
  30517. max = v;
  30518. maxSV = new SemVer(max, options);
  30519. }
  30520. }
  30521. });
  30522. return max;
  30523. }
  30524. exports.minSatisfying = minSatisfying;
  30525. function minSatisfying(versions, range, options) {
  30526. var min = null;
  30527. var minSV = null;
  30528. try {
  30529. var rangeObj = new Range(range, options);
  30530. } catch (er) {
  30531. return null;
  30532. }
  30533. versions.forEach(function (v) {
  30534. if (rangeObj.test(v)) {
  30535. // satisfies(v, range, options)
  30536. if (!min || minSV.compare(v) === 1) {
  30537. // compare(min, v, true)
  30538. min = v;
  30539. minSV = new SemVer(min, options);
  30540. }
  30541. }
  30542. });
  30543. return min;
  30544. }
  30545. exports.validRange = validRange;
  30546. function validRange(range, options) {
  30547. try {
  30548. // Return '*' instead of '' so that truthiness works.
  30549. // This will throw if it's invalid anyway
  30550. return new Range(range, options).range || '*';
  30551. } catch (er) {
  30552. return null;
  30553. }
  30554. } // Determine if version is less than all the versions possible in the range
  30555. exports.ltr = ltr;
  30556. function ltr(version, range, options) {
  30557. return outside(version, range, '<', options);
  30558. } // Determine if version is greater than all the versions possible in the range.
  30559. exports.gtr = gtr;
  30560. function gtr(version, range, options) {
  30561. return outside(version, range, '>', options);
  30562. }
  30563. exports.outside = outside;
  30564. function outside(version, range, hilo, options) {
  30565. version = new SemVer(version, options);
  30566. range = new Range(range, options);
  30567. var gtfn, ltefn, ltfn, comp, ecomp;
  30568. switch (hilo) {
  30569. case '>':
  30570. gtfn = gt;
  30571. ltefn = lte;
  30572. ltfn = lt;
  30573. comp = '>';
  30574. ecomp = '>=';
  30575. break;
  30576. case '<':
  30577. gtfn = lt;
  30578. ltefn = gte;
  30579. ltfn = gt;
  30580. comp = '<';
  30581. ecomp = '<=';
  30582. break;
  30583. default:
  30584. throw new TypeError('Must provide a hilo val of "<" or ">"');
  30585. } // If it satisifes the range it is not outside
  30586. if (satisfies(version, range, options)) {
  30587. return false;
  30588. } // From now on, variable terms are as if we're in "gtr" mode.
  30589. // but note that everything is flipped for the "ltr" function.
  30590. for (var i = 0; i < range.set.length; ++i) {
  30591. var comparators = range.set[i];
  30592. var high = null;
  30593. var low = null;
  30594. comparators.forEach(function (comparator) {
  30595. if (comparator.semver === ANY) {
  30596. comparator = new Comparator('>=0.0.0');
  30597. }
  30598. high = high || comparator;
  30599. low = low || comparator;
  30600. if (gtfn(comparator.semver, high.semver, options)) {
  30601. high = comparator;
  30602. } else if (ltfn(comparator.semver, low.semver, options)) {
  30603. low = comparator;
  30604. }
  30605. }); // If the edge version comparator has a operator then our version
  30606. // isn't outside it
  30607. if (high.operator === comp || high.operator === ecomp) {
  30608. return false;
  30609. } // If the lowest version comparator has an operator and our version
  30610. // is less than it then it isn't higher than the range
  30611. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  30612. return false;
  30613. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  30614. return false;
  30615. }
  30616. }
  30617. return true;
  30618. }
  30619. exports.prerelease = prerelease;
  30620. function prerelease(version, options) {
  30621. var parsed = parse(version, options);
  30622. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  30623. }
  30624. exports.intersects = intersects;
  30625. function intersects(r1, r2, options) {
  30626. r1 = new Range(r1, options);
  30627. r2 = new Range(r2, options);
  30628. return r1.intersects(r2);
  30629. }
  30630. exports.coerce = coerce;
  30631. function coerce(version) {
  30632. if (version instanceof SemVer) return version;
  30633. if (typeof version !== 'string') return null;
  30634. var match = version.match(re[COERCE]);
  30635. if (match == null) return null;
  30636. return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
  30637. }
  30638. });
  30639. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  30640. var pseudomap = PseudoMap;
  30641. function PseudoMap(set) {
  30642. if (!(this instanceof PseudoMap)) // whyyyyyyy
  30643. throw new TypeError("Constructor PseudoMap requires 'new'");
  30644. this.clear();
  30645. if (set) {
  30646. if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
  30647. this.set(key, value);
  30648. }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
  30649. this.set(kv[0], kv[1]);
  30650. }, this);else throw new TypeError('invalid argument');
  30651. }
  30652. }
  30653. PseudoMap.prototype.forEach = function (fn, thisp) {
  30654. thisp = thisp || this;
  30655. Object.keys(this._data).forEach(function (k) {
  30656. if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
  30657. }, this);
  30658. };
  30659. PseudoMap.prototype.has = function (k) {
  30660. return !!find(this._data, k);
  30661. };
  30662. PseudoMap.prototype.get = function (k) {
  30663. var res = find(this._data, k);
  30664. return res && res.value;
  30665. };
  30666. PseudoMap.prototype.set = function (k, v) {
  30667. set$1(this._data, k, v);
  30668. };
  30669. PseudoMap.prototype.delete = function (k) {
  30670. var res = find(this._data, k);
  30671. if (res) {
  30672. delete this._data[res._index];
  30673. this._data.size--;
  30674. }
  30675. };
  30676. PseudoMap.prototype.clear = function () {
  30677. var data = Object.create(null);
  30678. data.size = 0;
  30679. Object.defineProperty(this, '_data', {
  30680. value: data,
  30681. enumerable: false,
  30682. configurable: true,
  30683. writable: false
  30684. });
  30685. };
  30686. Object.defineProperty(PseudoMap.prototype, 'size', {
  30687. get: function get() {
  30688. return this._data.size;
  30689. },
  30690. set: function set(n) {},
  30691. enumerable: true,
  30692. configurable: true
  30693. });
  30694. PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
  30695. throw new Error('iterators are not implemented in this version');
  30696. }; // Either identical, or both NaN
  30697. function same(a, b) {
  30698. return a === b || a !== a && b !== b;
  30699. }
  30700. function Entry$1(k, v, i) {
  30701. this.key = k;
  30702. this.value = v;
  30703. this._index = i;
  30704. }
  30705. function find(data, k) {
  30706. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$1.call(data, key); key = s + i++) {
  30707. if (same(data[key].key, k)) return data[key];
  30708. }
  30709. }
  30710. function set$1(data, k, v) {
  30711. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$1.call(data, key); key = s + i++) {
  30712. if (same(data[key].key, k)) {
  30713. data[key].value = v;
  30714. return;
  30715. }
  30716. }
  30717. data.size++;
  30718. data[key] = new Entry$1(k, v, key);
  30719. }
  30720. var map$1 = createCommonjsModule(function (module) {
  30721. if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
  30722. if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
  30723. module.exports = Map;
  30724. } else {
  30725. module.exports = pseudomap;
  30726. }
  30727. });
  30728. var yallist = Yallist;
  30729. Yallist.Node = Node;
  30730. Yallist.create = Yallist;
  30731. function Yallist(list) {
  30732. var self = this;
  30733. if (!(self instanceof Yallist)) {
  30734. self = new Yallist();
  30735. }
  30736. self.tail = null;
  30737. self.head = null;
  30738. self.length = 0;
  30739. if (list && typeof list.forEach === 'function') {
  30740. list.forEach(function (item) {
  30741. self.push(item);
  30742. });
  30743. } else if (arguments.length > 0) {
  30744. for (var i = 0, l = arguments.length; i < l; i++) {
  30745. self.push(arguments[i]);
  30746. }
  30747. }
  30748. return self;
  30749. }
  30750. Yallist.prototype.removeNode = function (node) {
  30751. if (node.list !== this) {
  30752. throw new Error('removing node which does not belong to this list');
  30753. }
  30754. var next = node.next;
  30755. var prev = node.prev;
  30756. if (next) {
  30757. next.prev = prev;
  30758. }
  30759. if (prev) {
  30760. prev.next = next;
  30761. }
  30762. if (node === this.head) {
  30763. this.head = next;
  30764. }
  30765. if (node === this.tail) {
  30766. this.tail = prev;
  30767. }
  30768. node.list.length--;
  30769. node.next = null;
  30770. node.prev = null;
  30771. node.list = null;
  30772. };
  30773. Yallist.prototype.unshiftNode = function (node) {
  30774. if (node === this.head) {
  30775. return;
  30776. }
  30777. if (node.list) {
  30778. node.list.removeNode(node);
  30779. }
  30780. var head = this.head;
  30781. node.list = this;
  30782. node.next = head;
  30783. if (head) {
  30784. head.prev = node;
  30785. }
  30786. this.head = node;
  30787. if (!this.tail) {
  30788. this.tail = node;
  30789. }
  30790. this.length++;
  30791. };
  30792. Yallist.prototype.pushNode = function (node) {
  30793. if (node === this.tail) {
  30794. return;
  30795. }
  30796. if (node.list) {
  30797. node.list.removeNode(node);
  30798. }
  30799. var tail = this.tail;
  30800. node.list = this;
  30801. node.prev = tail;
  30802. if (tail) {
  30803. tail.next = node;
  30804. }
  30805. this.tail = node;
  30806. if (!this.head) {
  30807. this.head = node;
  30808. }
  30809. this.length++;
  30810. };
  30811. Yallist.prototype.push = function () {
  30812. for (var i = 0, l = arguments.length; i < l; i++) {
  30813. push(this, arguments[i]);
  30814. }
  30815. return this.length;
  30816. };
  30817. Yallist.prototype.unshift = function () {
  30818. for (var i = 0, l = arguments.length; i < l; i++) {
  30819. unshift(this, arguments[i]);
  30820. }
  30821. return this.length;
  30822. };
  30823. Yallist.prototype.pop = function () {
  30824. if (!this.tail) {
  30825. return undefined;
  30826. }
  30827. var res = this.tail.value;
  30828. this.tail = this.tail.prev;
  30829. if (this.tail) {
  30830. this.tail.next = null;
  30831. } else {
  30832. this.head = null;
  30833. }
  30834. this.length--;
  30835. return res;
  30836. };
  30837. Yallist.prototype.shift = function () {
  30838. if (!this.head) {
  30839. return undefined;
  30840. }
  30841. var res = this.head.value;
  30842. this.head = this.head.next;
  30843. if (this.head) {
  30844. this.head.prev = null;
  30845. } else {
  30846. this.tail = null;
  30847. }
  30848. this.length--;
  30849. return res;
  30850. };
  30851. Yallist.prototype.forEach = function (fn, thisp) {
  30852. thisp = thisp || this;
  30853. for (var walker = this.head, i = 0; walker !== null; i++) {
  30854. fn.call(thisp, walker.value, i, this);
  30855. walker = walker.next;
  30856. }
  30857. };
  30858. Yallist.prototype.forEachReverse = function (fn, thisp) {
  30859. thisp = thisp || this;
  30860. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  30861. fn.call(thisp, walker.value, i, this);
  30862. walker = walker.prev;
  30863. }
  30864. };
  30865. Yallist.prototype.get = function (n) {
  30866. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  30867. // abort out of the list early if we hit a cycle
  30868. walker = walker.next;
  30869. }
  30870. if (i === n && walker !== null) {
  30871. return walker.value;
  30872. }
  30873. };
  30874. Yallist.prototype.getReverse = function (n) {
  30875. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  30876. // abort out of the list early if we hit a cycle
  30877. walker = walker.prev;
  30878. }
  30879. if (i === n && walker !== null) {
  30880. return walker.value;
  30881. }
  30882. };
  30883. Yallist.prototype.map = function (fn, thisp) {
  30884. thisp = thisp || this;
  30885. var res = new Yallist();
  30886. for (var walker = this.head; walker !== null;) {
  30887. res.push(fn.call(thisp, walker.value, this));
  30888. walker = walker.next;
  30889. }
  30890. return res;
  30891. };
  30892. Yallist.prototype.mapReverse = function (fn, thisp) {
  30893. thisp = thisp || this;
  30894. var res = new Yallist();
  30895. for (var walker = this.tail; walker !== null;) {
  30896. res.push(fn.call(thisp, walker.value, this));
  30897. walker = walker.prev;
  30898. }
  30899. return res;
  30900. };
  30901. Yallist.prototype.reduce = function (fn, initial) {
  30902. var acc;
  30903. var walker = this.head;
  30904. if (arguments.length > 1) {
  30905. acc = initial;
  30906. } else if (this.head) {
  30907. walker = this.head.next;
  30908. acc = this.head.value;
  30909. } else {
  30910. throw new TypeError('Reduce of empty list with no initial value');
  30911. }
  30912. for (var i = 0; walker !== null; i++) {
  30913. acc = fn(acc, walker.value, i);
  30914. walker = walker.next;
  30915. }
  30916. return acc;
  30917. };
  30918. Yallist.prototype.reduceReverse = function (fn, initial) {
  30919. var acc;
  30920. var walker = this.tail;
  30921. if (arguments.length > 1) {
  30922. acc = initial;
  30923. } else if (this.tail) {
  30924. walker = this.tail.prev;
  30925. acc = this.tail.value;
  30926. } else {
  30927. throw new TypeError('Reduce of empty list with no initial value');
  30928. }
  30929. for (var i = this.length - 1; walker !== null; i--) {
  30930. acc = fn(acc, walker.value, i);
  30931. walker = walker.prev;
  30932. }
  30933. return acc;
  30934. };
  30935. Yallist.prototype.toArray = function () {
  30936. var arr = new Array(this.length);
  30937. for (var i = 0, walker = this.head; walker !== null; i++) {
  30938. arr[i] = walker.value;
  30939. walker = walker.next;
  30940. }
  30941. return arr;
  30942. };
  30943. Yallist.prototype.toArrayReverse = function () {
  30944. var arr = new Array(this.length);
  30945. for (var i = 0, walker = this.tail; walker !== null; i++) {
  30946. arr[i] = walker.value;
  30947. walker = walker.prev;
  30948. }
  30949. return arr;
  30950. };
  30951. Yallist.prototype.slice = function (from, to) {
  30952. to = to || this.length;
  30953. if (to < 0) {
  30954. to += this.length;
  30955. }
  30956. from = from || 0;
  30957. if (from < 0) {
  30958. from += this.length;
  30959. }
  30960. var ret = new Yallist();
  30961. if (to < from || to < 0) {
  30962. return ret;
  30963. }
  30964. if (from < 0) {
  30965. from = 0;
  30966. }
  30967. if (to > this.length) {
  30968. to = this.length;
  30969. }
  30970. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  30971. walker = walker.next;
  30972. }
  30973. for (; walker !== null && i < to; i++, walker = walker.next) {
  30974. ret.push(walker.value);
  30975. }
  30976. return ret;
  30977. };
  30978. Yallist.prototype.sliceReverse = function (from, to) {
  30979. to = to || this.length;
  30980. if (to < 0) {
  30981. to += this.length;
  30982. }
  30983. from = from || 0;
  30984. if (from < 0) {
  30985. from += this.length;
  30986. }
  30987. var ret = new Yallist();
  30988. if (to < from || to < 0) {
  30989. return ret;
  30990. }
  30991. if (from < 0) {
  30992. from = 0;
  30993. }
  30994. if (to > this.length) {
  30995. to = this.length;
  30996. }
  30997. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  30998. walker = walker.prev;
  30999. }
  31000. for (; walker !== null && i > from; i--, walker = walker.prev) {
  31001. ret.push(walker.value);
  31002. }
  31003. return ret;
  31004. };
  31005. Yallist.prototype.reverse = function () {
  31006. var head = this.head;
  31007. var tail = this.tail;
  31008. for (var walker = head; walker !== null; walker = walker.prev) {
  31009. var p = walker.prev;
  31010. walker.prev = walker.next;
  31011. walker.next = p;
  31012. }
  31013. this.head = tail;
  31014. this.tail = head;
  31015. return this;
  31016. };
  31017. function push(self, item) {
  31018. self.tail = new Node(item, self.tail, null, self);
  31019. if (!self.head) {
  31020. self.head = self.tail;
  31021. }
  31022. self.length++;
  31023. }
  31024. function unshift(self, item) {
  31025. self.head = new Node(item, null, self.head, self);
  31026. if (!self.tail) {
  31027. self.tail = self.head;
  31028. }
  31029. self.length++;
  31030. }
  31031. function Node(value, prev, next, list) {
  31032. if (!(this instanceof Node)) {
  31033. return new Node(value, prev, next, list);
  31034. }
  31035. this.list = list;
  31036. this.value = value;
  31037. if (prev) {
  31038. prev.next = this;
  31039. this.prev = prev;
  31040. } else {
  31041. this.prev = null;
  31042. }
  31043. if (next) {
  31044. next.prev = this;
  31045. this.next = next;
  31046. } else {
  31047. this.next = null;
  31048. }
  31049. }
  31050. var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
  31051. // or a fakey-fake PseudoMap in older versions.
  31052. // A linked list to keep track of recently-used-ness
  31053. // use symbols if possible, otherwise just _props
  31054. var hasSymbol = typeof Symbol === 'function';
  31055. var makeSymbol;
  31056. if (hasSymbol) {
  31057. makeSymbol = function makeSymbol(key) {
  31058. return Symbol(key);
  31059. };
  31060. } else {
  31061. makeSymbol = function makeSymbol(key) {
  31062. return '_' + key;
  31063. };
  31064. }
  31065. var MAX = makeSymbol('max');
  31066. var LENGTH = makeSymbol('length');
  31067. var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
  31068. var ALLOW_STALE = makeSymbol('allowStale');
  31069. var MAX_AGE = makeSymbol('maxAge');
  31070. var DISPOSE = makeSymbol('dispose');
  31071. var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
  31072. var LRU_LIST = makeSymbol('lruList');
  31073. var CACHE = makeSymbol('cache');
  31074. function naiveLength() {
  31075. return 1;
  31076. } // lruList is a yallist where the head is the youngest
  31077. // item, and the tail is the oldest. the list contains the Hit
  31078. // objects as the entries.
  31079. // Each Hit object has a reference to its Yallist.Node. This
  31080. // never changes.
  31081. //
  31082. // cache is a Map (or PseudoMap) that matches the keys to
  31083. // the Yallist.Node object.
  31084. function LRUCache(options) {
  31085. if (!(this instanceof LRUCache)) {
  31086. return new LRUCache(options);
  31087. }
  31088. if (typeof options === 'number') {
  31089. options = {
  31090. max: options
  31091. };
  31092. }
  31093. if (!options) {
  31094. options = {};
  31095. }
  31096. var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
  31097. if (!max || !(typeof max === 'number') || max <= 0) {
  31098. this[MAX] = Infinity;
  31099. }
  31100. var lc = options.length || naiveLength;
  31101. if (typeof lc !== 'function') {
  31102. lc = naiveLength;
  31103. }
  31104. this[LENGTH_CALCULATOR] = lc;
  31105. this[ALLOW_STALE] = options.stale || false;
  31106. this[MAX_AGE] = options.maxAge || 0;
  31107. this[DISPOSE] = options.dispose;
  31108. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  31109. this.reset();
  31110. } // resize the cache when the max changes.
  31111. Object.defineProperty(LRUCache.prototype, 'max', {
  31112. set: function set(mL) {
  31113. if (!mL || !(typeof mL === 'number') || mL <= 0) {
  31114. mL = Infinity;
  31115. }
  31116. this[MAX] = mL;
  31117. trim$2(this);
  31118. },
  31119. get: function get() {
  31120. return this[MAX];
  31121. },
  31122. enumerable: true
  31123. });
  31124. Object.defineProperty(LRUCache.prototype, 'allowStale', {
  31125. set: function set(allowStale) {
  31126. this[ALLOW_STALE] = !!allowStale;
  31127. },
  31128. get: function get() {
  31129. return this[ALLOW_STALE];
  31130. },
  31131. enumerable: true
  31132. });
  31133. Object.defineProperty(LRUCache.prototype, 'maxAge', {
  31134. set: function set(mA) {
  31135. if (!mA || !(typeof mA === 'number') || mA < 0) {
  31136. mA = 0;
  31137. }
  31138. this[MAX_AGE] = mA;
  31139. trim$2(this);
  31140. },
  31141. get: function get() {
  31142. return this[MAX_AGE];
  31143. },
  31144. enumerable: true
  31145. }); // resize the cache when the lengthCalculator changes.
  31146. Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
  31147. set: function set(lC) {
  31148. if (typeof lC !== 'function') {
  31149. lC = naiveLength;
  31150. }
  31151. if (lC !== this[LENGTH_CALCULATOR]) {
  31152. this[LENGTH_CALCULATOR] = lC;
  31153. this[LENGTH] = 0;
  31154. this[LRU_LIST].forEach(function (hit) {
  31155. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  31156. this[LENGTH] += hit.length;
  31157. }, this);
  31158. }
  31159. trim$2(this);
  31160. },
  31161. get: function get() {
  31162. return this[LENGTH_CALCULATOR];
  31163. },
  31164. enumerable: true
  31165. });
  31166. Object.defineProperty(LRUCache.prototype, 'length', {
  31167. get: function get() {
  31168. return this[LENGTH];
  31169. },
  31170. enumerable: true
  31171. });
  31172. Object.defineProperty(LRUCache.prototype, 'itemCount', {
  31173. get: function get() {
  31174. return this[LRU_LIST].length;
  31175. },
  31176. enumerable: true
  31177. });
  31178. LRUCache.prototype.rforEach = function (fn, thisp) {
  31179. thisp = thisp || this;
  31180. for (var walker = this[LRU_LIST].tail; walker !== null;) {
  31181. var prev = walker.prev;
  31182. forEachStep(this, fn, walker, thisp);
  31183. walker = prev;
  31184. }
  31185. };
  31186. function forEachStep(self, fn, node, thisp) {
  31187. var hit = node.value;
  31188. if (isStale(self, hit)) {
  31189. del$1(self, node);
  31190. if (!self[ALLOW_STALE]) {
  31191. hit = undefined;
  31192. }
  31193. }
  31194. if (hit) {
  31195. fn.call(thisp, hit.value, hit.key, self);
  31196. }
  31197. }
  31198. LRUCache.prototype.forEach = function (fn, thisp) {
  31199. thisp = thisp || this;
  31200. for (var walker = this[LRU_LIST].head; walker !== null;) {
  31201. var next = walker.next;
  31202. forEachStep(this, fn, walker, thisp);
  31203. walker = next;
  31204. }
  31205. };
  31206. LRUCache.prototype.keys = function () {
  31207. return this[LRU_LIST].toArray().map(function (k) {
  31208. return k.key;
  31209. }, this);
  31210. };
  31211. LRUCache.prototype.values = function () {
  31212. return this[LRU_LIST].toArray().map(function (k) {
  31213. return k.value;
  31214. }, this);
  31215. };
  31216. LRUCache.prototype.reset = function () {
  31217. if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
  31218. this[LRU_LIST].forEach(function (hit) {
  31219. this[DISPOSE](hit.key, hit.value);
  31220. }, this);
  31221. }
  31222. this[CACHE] = new map$1(); // hash of items by key
  31223. this[LRU_LIST] = new yallist(); // list of items in order of use recency
  31224. this[LENGTH] = 0; // length of items in the list
  31225. };
  31226. LRUCache.prototype.dump = function () {
  31227. return this[LRU_LIST].map(function (hit) {
  31228. if (!isStale(this, hit)) {
  31229. return {
  31230. k: hit.key,
  31231. v: hit.value,
  31232. e: hit.now + (hit.maxAge || 0)
  31233. };
  31234. }
  31235. }, this).toArray().filter(function (h) {
  31236. return h;
  31237. });
  31238. };
  31239. LRUCache.prototype.dumpLru = function () {
  31240. return this[LRU_LIST];
  31241. };
  31242. LRUCache.prototype.inspect = function (n, opts) {
  31243. var str = 'LRUCache {';
  31244. var extras = false;
  31245. var as = this[ALLOW_STALE];
  31246. if (as) {
  31247. str += '\n allowStale: true';
  31248. extras = true;
  31249. }
  31250. var max = this[MAX];
  31251. if (max && max !== Infinity) {
  31252. if (extras) {
  31253. str += ',';
  31254. }
  31255. str += '\n max: ' + util.inspect(max, opts);
  31256. extras = true;
  31257. }
  31258. var maxAge = this[MAX_AGE];
  31259. if (maxAge) {
  31260. if (extras) {
  31261. str += ',';
  31262. }
  31263. str += '\n maxAge: ' + util.inspect(maxAge, opts);
  31264. extras = true;
  31265. }
  31266. var lc = this[LENGTH_CALCULATOR];
  31267. if (lc && lc !== naiveLength) {
  31268. if (extras) {
  31269. str += ',';
  31270. }
  31271. str += '\n length: ' + util.inspect(this[LENGTH], opts);
  31272. extras = true;
  31273. }
  31274. var didFirst = false;
  31275. this[LRU_LIST].forEach(function (item) {
  31276. if (didFirst) {
  31277. str += ',\n ';
  31278. } else {
  31279. if (extras) {
  31280. str += ',\n';
  31281. }
  31282. didFirst = true;
  31283. str += '\n ';
  31284. }
  31285. var key = util.inspect(item.key).split('\n').join('\n ');
  31286. var val = {
  31287. value: item.value
  31288. };
  31289. if (item.maxAge !== maxAge) {
  31290. val.maxAge = item.maxAge;
  31291. }
  31292. if (lc !== naiveLength) {
  31293. val.length = item.length;
  31294. }
  31295. if (isStale(this, item)) {
  31296. val.stale = true;
  31297. }
  31298. val = util.inspect(val, opts).split('\n').join('\n ');
  31299. str += key + ' => ' + val;
  31300. });
  31301. if (didFirst || extras) {
  31302. str += '\n';
  31303. }
  31304. str += '}';
  31305. return str;
  31306. };
  31307. LRUCache.prototype.set = function (key, value, maxAge) {
  31308. maxAge = maxAge || this[MAX_AGE];
  31309. var now = maxAge ? Date.now() : 0;
  31310. var len = this[LENGTH_CALCULATOR](value, key);
  31311. if (this[CACHE].has(key)) {
  31312. if (len > this[MAX]) {
  31313. del$1(this, this[CACHE].get(key));
  31314. return false;
  31315. }
  31316. var node = this[CACHE].get(key);
  31317. var item = node.value; // dispose of the old one before overwriting
  31318. // split out into 2 ifs for better coverage tracking
  31319. if (this[DISPOSE]) {
  31320. if (!this[NO_DISPOSE_ON_SET]) {
  31321. this[DISPOSE](key, item.value);
  31322. }
  31323. }
  31324. item.now = now;
  31325. item.maxAge = maxAge;
  31326. item.value = value;
  31327. this[LENGTH] += len - item.length;
  31328. item.length = len;
  31329. this.get(key);
  31330. trim$2(this);
  31331. return true;
  31332. }
  31333. var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
  31334. if (hit.length > this[MAX]) {
  31335. if (this[DISPOSE]) {
  31336. this[DISPOSE](key, value);
  31337. }
  31338. return false;
  31339. }
  31340. this[LENGTH] += hit.length;
  31341. this[LRU_LIST].unshift(hit);
  31342. this[CACHE].set(key, this[LRU_LIST].head);
  31343. trim$2(this);
  31344. return true;
  31345. };
  31346. LRUCache.prototype.has = function (key) {
  31347. if (!this[CACHE].has(key)) return false;
  31348. var hit = this[CACHE].get(key).value;
  31349. if (isStale(this, hit)) {
  31350. return false;
  31351. }
  31352. return true;
  31353. };
  31354. LRUCache.prototype.get = function (key) {
  31355. return get(this, key, true);
  31356. };
  31357. LRUCache.prototype.peek = function (key) {
  31358. return get(this, key, false);
  31359. };
  31360. LRUCache.prototype.pop = function () {
  31361. var node = this[LRU_LIST].tail;
  31362. if (!node) return null;
  31363. del$1(this, node);
  31364. return node.value;
  31365. };
  31366. LRUCache.prototype.del = function (key) {
  31367. del$1(this, this[CACHE].get(key));
  31368. };
  31369. LRUCache.prototype.load = function (arr) {
  31370. // reset the cache
  31371. this.reset();
  31372. var now = Date.now(); // A previous serialized cache has the most recent items first
  31373. for (var l = arr.length - 1; l >= 0; l--) {
  31374. var hit = arr[l];
  31375. var expiresAt = hit.e || 0;
  31376. if (expiresAt === 0) {
  31377. // the item was created without expiration in a non aged cache
  31378. this.set(hit.k, hit.v);
  31379. } else {
  31380. var maxAge = expiresAt - now; // dont add already expired items
  31381. if (maxAge > 0) {
  31382. this.set(hit.k, hit.v, maxAge);
  31383. }
  31384. }
  31385. }
  31386. };
  31387. LRUCache.prototype.prune = function () {
  31388. var self = this;
  31389. this[CACHE].forEach(function (value, key) {
  31390. get(self, key, false);
  31391. });
  31392. };
  31393. function get(self, key, doUse) {
  31394. var node = self[CACHE].get(key);
  31395. if (node) {
  31396. var hit = node.value;
  31397. if (isStale(self, hit)) {
  31398. del$1(self, node);
  31399. if (!self[ALLOW_STALE]) hit = undefined;
  31400. } else {
  31401. if (doUse) {
  31402. self[LRU_LIST].unshiftNode(node);
  31403. }
  31404. }
  31405. if (hit) hit = hit.value;
  31406. }
  31407. return hit;
  31408. }
  31409. function isStale(self, hit) {
  31410. if (!hit || !hit.maxAge && !self[MAX_AGE]) {
  31411. return false;
  31412. }
  31413. var stale = false;
  31414. var diff = Date.now() - hit.now;
  31415. if (hit.maxAge) {
  31416. stale = diff > hit.maxAge;
  31417. } else {
  31418. stale = self[MAX_AGE] && diff > self[MAX_AGE];
  31419. }
  31420. return stale;
  31421. }
  31422. function trim$2(self) {
  31423. if (self[LENGTH] > self[MAX]) {
  31424. for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
  31425. // We know that we're about to delete this one, and also
  31426. // what the next least recently used key will be, so just
  31427. // go ahead and set it now.
  31428. var prev = walker.prev;
  31429. del$1(self, walker);
  31430. walker = prev;
  31431. }
  31432. }
  31433. }
  31434. function del$1(self, node) {
  31435. if (node) {
  31436. var hit = node.value;
  31437. if (self[DISPOSE]) {
  31438. self[DISPOSE](hit.key, hit.value);
  31439. }
  31440. self[LENGTH] -= hit.length;
  31441. self[CACHE].delete(hit.key);
  31442. self[LRU_LIST].removeNode(node);
  31443. }
  31444. } // classy, since V8 prefers predictable objects.
  31445. function Entry(key, value, length, now, maxAge) {
  31446. this.key = key;
  31447. this.value = value;
  31448. this.length = length;
  31449. this.now = now;
  31450. this.maxAge = maxAge || 0;
  31451. }
  31452. var sigmund_1 = sigmund;
  31453. function sigmund(subject, maxSessions) {
  31454. maxSessions = maxSessions || 10;
  31455. var notes = [];
  31456. var analysis = '';
  31457. var RE = RegExp;
  31458. function psychoAnalyze(subject, session) {
  31459. if (session > maxSessions) return;
  31460. if (typeof subject === 'function' || typeof subject === 'undefined') {
  31461. return;
  31462. }
  31463. if (typeof subject !== 'object' || !subject || subject instanceof RE) {
  31464. analysis += subject;
  31465. return;
  31466. }
  31467. if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
  31468. notes.push(subject);
  31469. analysis += '{';
  31470. Object.keys(subject).forEach(function (issue, _, __) {
  31471. // pseudo-private values. skip those.
  31472. if (issue.charAt(0) === '_') return;
  31473. var to = typeof subject[issue];
  31474. if (to === 'function' || to === 'undefined') return;
  31475. analysis += issue;
  31476. psychoAnalyze(subject[issue], session + 1);
  31477. });
  31478. }
  31479. psychoAnalyze(subject, 0);
  31480. return analysis;
  31481. } // vim: set softtabstop=4 shiftwidth=4:
  31482. var fnmatch = createCommonjsModule(function (module, exports) {
  31483. // Based on minimatch.js by isaacs <https://npmjs.org/package/minimatch>
  31484. var platform = typeof process === "object" ? process.platform : "win32";
  31485. if (module) module.exports = minimatch;else exports.minimatch = minimatch;
  31486. minimatch.Minimatch = Minimatch;
  31487. var cache = minimatch.cache = new lruCache({
  31488. max: 100
  31489. }),
  31490. GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  31491. var qmark = "[^/]" // * => any number of characters
  31492. ,
  31493. star = qmark + "*?" // ** when dots are allowed. Anything goes, except .. and .
  31494. // not (^ or / followed by one or two dots followed by $ or /),
  31495. // followed by anything, any number of times.
  31496. ,
  31497. twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" // not a ^ or / followed by a dot,
  31498. // followed by anything, any number of times.
  31499. ,
  31500. twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" // characters that need to be escaped in RegExp.
  31501. ,
  31502. reSpecials = charSet("().*{}+?[]^$\\!"); // "abc" -> { a:true, b:true, c:true }
  31503. function charSet(s) {
  31504. return s.split("").reduce(function (set, c) {
  31505. set[c] = true;
  31506. return set;
  31507. }, {});
  31508. } // normalizes slashes.
  31509. var slashSplit = /\/+/;
  31510. minimatch.monkeyPatch = monkeyPatch;
  31511. function monkeyPatch() {
  31512. var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
  31513. var orig = desc.value;
  31514. desc.value = function (p) {
  31515. if (p instanceof Minimatch) return p.match(this);
  31516. return orig.call(this, p);
  31517. };
  31518. Object.defineProperty(String.prototype, desc);
  31519. }
  31520. minimatch.filter = filter;
  31521. function filter(pattern, options) {
  31522. options = options || {};
  31523. return function (p, i, list) {
  31524. return minimatch(p, pattern, options);
  31525. };
  31526. }
  31527. function ext(a, b) {
  31528. a = a || {};
  31529. b = b || {};
  31530. var t = {};
  31531. Object.keys(b).forEach(function (k) {
  31532. t[k] = b[k];
  31533. });
  31534. Object.keys(a).forEach(function (k) {
  31535. t[k] = a[k];
  31536. });
  31537. return t;
  31538. }
  31539. minimatch.defaults = function (def) {
  31540. if (!def || !Object.keys(def).length) return minimatch;
  31541. var orig = minimatch;
  31542. var m = function minimatch(p, pattern, options) {
  31543. return orig.minimatch(p, pattern, ext(def, options));
  31544. };
  31545. m.Minimatch = function Minimatch(pattern, options) {
  31546. return new orig.Minimatch(pattern, ext(def, options));
  31547. };
  31548. return m;
  31549. };
  31550. Minimatch.defaults = function (def) {
  31551. if (!def || !Object.keys(def).length) return Minimatch;
  31552. return minimatch.defaults(def).Minimatch;
  31553. };
  31554. function minimatch(p, pattern, options) {
  31555. if (typeof pattern !== "string") {
  31556. throw new TypeError("glob pattern string required");
  31557. }
  31558. if (!options) options = {}; // shortcut: comments match nothing.
  31559. if (!options.nocomment && pattern.charAt(0) === "#") {
  31560. return false;
  31561. } // "" only matches ""
  31562. if (pattern.trim() === "") return p === "";
  31563. return new Minimatch(pattern, options).match(p);
  31564. }
  31565. function Minimatch(pattern, options) {
  31566. if (!(this instanceof Minimatch)) {
  31567. return new Minimatch(pattern, options, cache);
  31568. }
  31569. if (typeof pattern !== "string") {
  31570. throw new TypeError("glob pattern string required");
  31571. }
  31572. if (!options) options = {}; // windows: need to use /, not \
  31573. // On other platforms, \ is a valid (albeit bad) filename char.
  31574. if (platform === "win32") {
  31575. pattern = pattern.split("\\").join("/");
  31576. } // lru storage.
  31577. // these things aren't particularly big, but walking down the string
  31578. // and turning it into a regexp can get pretty costly.
  31579. var cacheKey = pattern + "\n" + sigmund_1(options);
  31580. var cached = minimatch.cache.get(cacheKey);
  31581. if (cached) return cached;
  31582. minimatch.cache.set(cacheKey, this);
  31583. this.options = options;
  31584. this.set = [];
  31585. this.pattern = pattern;
  31586. this.regexp = null;
  31587. this.negate = false;
  31588. this.comment = false;
  31589. this.empty = false; // make the set of regexps etc.
  31590. this.make();
  31591. }
  31592. Minimatch.prototype.make = make;
  31593. function make() {
  31594. // don't do it more than once.
  31595. if (this._made) return;
  31596. var pattern = this.pattern;
  31597. var options = this.options; // empty patterns and comments match nothing.
  31598. if (!options.nocomment && pattern.charAt(0) === "#") {
  31599. this.comment = true;
  31600. return;
  31601. }
  31602. if (!pattern) {
  31603. this.empty = true;
  31604. return;
  31605. } // step 1: figure out negation, etc.
  31606. this.parseNegate(); // step 2: expand braces
  31607. var set = this.globSet = this.braceExpand();
  31608. 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
  31609. // matching patterns.
  31610. // These will be regexps, except in the case of "**", which is
  31611. // set to the GLOBSTAR object for globstar behavior,
  31612. // and will not contain any / characters
  31613. set = this.globParts = set.map(function (s) {
  31614. return s.split(slashSplit);
  31615. });
  31616. if (options.debug) console.error(this.pattern, set); // glob --> regexps
  31617. set = set.map(function (s, si, set) {
  31618. return s.map(this.parse, this);
  31619. }, this);
  31620. if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
  31621. set = set.filter(function (s) {
  31622. return -1 === s.indexOf(false);
  31623. });
  31624. if (options.debug) console.error(this.pattern, set);
  31625. this.set = set;
  31626. }
  31627. Minimatch.prototype.parseNegate = parseNegate;
  31628. function parseNegate() {
  31629. var pattern = this.pattern,
  31630. negate = false,
  31631. options = this.options,
  31632. negateOffset = 0;
  31633. if (options.nonegate) return;
  31634. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
  31635. negate = !negate;
  31636. negateOffset++;
  31637. }
  31638. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  31639. this.negate = negate;
  31640. } // Brace expansion:
  31641. // a{b,c}d -> abd acd
  31642. // a{b,}c -> abc ac
  31643. // a{0..3}d -> a0d a1d a2d a3d
  31644. // a{b,c{d,e}f}g -> abg acdfg acefg
  31645. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  31646. //
  31647. // Invalid sets are not expanded.
  31648. // a{2..}b -> a{2..}b
  31649. // a{b}c -> a{b}c
  31650. minimatch.braceExpand = function (pattern, options) {
  31651. return new Minimatch(pattern, options).braceExpand();
  31652. };
  31653. Minimatch.prototype.braceExpand = braceExpand;
  31654. function braceExpand(pattern, options) {
  31655. options = options || this.options;
  31656. pattern = typeof pattern === "undefined" ? this.pattern : pattern;
  31657. if (typeof pattern === "undefined") {
  31658. throw new Error("undefined pattern");
  31659. }
  31660. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  31661. // shortcut. no need to expand.
  31662. return [pattern];
  31663. }
  31664. var escaping = false; // examples and comments refer to this crazy pattern:
  31665. // a{b,c{d,e},{f,g}h}x{y,z}
  31666. // expected:
  31667. // abxy
  31668. // abxz
  31669. // acdxy
  31670. // acdxz
  31671. // acexy
  31672. // acexz
  31673. // afhxy
  31674. // afhxz
  31675. // aghxy
  31676. // aghxz
  31677. // everything before the first \{ is just a prefix.
  31678. // So, we pluck that off, and work with the rest,
  31679. // and then prepend it to everything we find.
  31680. if (pattern.charAt(0) !== "{") {
  31681. // console.error(pattern)
  31682. var prefix = null;
  31683. for (var i = 0, l = pattern.length; i < l; i++) {
  31684. var c = pattern.charAt(i); // console.error(i, c)
  31685. if (c === "\\") {
  31686. escaping = !escaping;
  31687. } else if (c === "{" && !escaping) {
  31688. prefix = pattern.substr(0, i);
  31689. break;
  31690. }
  31691. } // actually no sets, all { were escaped.
  31692. if (prefix === null) {
  31693. // console.error("no sets")
  31694. return [pattern];
  31695. }
  31696. var tail = braceExpand(pattern.substr(i), options);
  31697. return tail.map(function (t) {
  31698. return prefix + t;
  31699. });
  31700. } // now we have something like:
  31701. // {b,c{d,e},{f,g}h}x{y,z}
  31702. // walk through the set, expanding each part, until
  31703. // the set ends. then, we'll expand the suffix.
  31704. // If the set only has a single member, then'll put the {} back
  31705. // first, handle numeric sets, since they're easier
  31706. var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
  31707. if (numset) {
  31708. // console.error("numset", numset[1], numset[2])
  31709. var suf = braceExpand(pattern.substr(numset[0].length), options),
  31710. start = +numset[1],
  31711. end = +numset[2],
  31712. inc = start > end ? -1 : 1,
  31713. set = [];
  31714. for (var i = start; i != end + inc; i += inc) {
  31715. // append all the suffixes
  31716. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  31717. set.push(i + suf[ii]);
  31718. }
  31719. }
  31720. return set;
  31721. } // ok, walk through the set
  31722. // We hope, somewhat optimistically, that there
  31723. // will be a } at the end.
  31724. // If the closing brace isn't found, then the pattern is
  31725. // interpreted as braceExpand("\\" + pattern) so that
  31726. // the leading \{ will be interpreted literally.
  31727. var i = 1 // skip the \{
  31728. ,
  31729. depth = 1,
  31730. set = [],
  31731. member = "",
  31732. sawEnd = false,
  31733. escaping = false;
  31734. function addMember() {
  31735. set.push(member);
  31736. member = "";
  31737. } // console.error("Entering for")
  31738. FOR: for (i = 1, l = pattern.length; i < l; i++) {
  31739. var c = pattern.charAt(i); // console.error("", i, c)
  31740. if (escaping) {
  31741. escaping = false;
  31742. member += "\\" + c;
  31743. } else {
  31744. switch (c) {
  31745. case "\\":
  31746. escaping = true;
  31747. continue;
  31748. case "{":
  31749. depth++;
  31750. member += "{";
  31751. continue;
  31752. case "}":
  31753. depth--; // if this closes the actual set, then we're done
  31754. if (depth === 0) {
  31755. addMember(); // pluck off the close-brace
  31756. i++;
  31757. break FOR;
  31758. } else {
  31759. member += c;
  31760. continue;
  31761. }
  31762. case ",":
  31763. if (depth === 1) {
  31764. addMember();
  31765. } else {
  31766. member += c;
  31767. }
  31768. continue;
  31769. default:
  31770. member += c;
  31771. continue;
  31772. } // switch
  31773. } // else
  31774. } // for
  31775. // now we've either finished the set, and the suffix is
  31776. // pattern.substr(i), or we have *not* closed the set,
  31777. // and need to escape the leading brace
  31778. if (depth !== 0) {
  31779. // console.error("didn't close", pattern)
  31780. return braceExpand("\\" + pattern, options);
  31781. } // x{y,z} -> ["xy", "xz"]
  31782. // console.error("set", set)
  31783. // console.error("suffix", pattern.substr(i))
  31784. var suf = braceExpand(pattern.substr(i), options); // ["b", "c{d,e}","{f,g}h"] ->
  31785. // [["b"], ["cd", "ce"], ["fh", "gh"]]
  31786. var addBraces = set.length === 1; // console.error("set pre-expanded", set)
  31787. set = set.map(function (p) {
  31788. return braceExpand(p, options);
  31789. }); // console.error("set expanded", set)
  31790. // [["b"], ["cd", "ce"], ["fh", "gh"]] ->
  31791. // ["b", "cd", "ce", "fh", "gh"]
  31792. set = set.reduce(function (l, r) {
  31793. return l.concat(r);
  31794. });
  31795. if (addBraces) {
  31796. set = set.map(function (s) {
  31797. return "{" + s + "}";
  31798. });
  31799. } // now attach the suffixes.
  31800. var ret = [];
  31801. for (var i = 0, l = set.length; i < l; i++) {
  31802. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  31803. ret.push(set[i] + suf[ii]);
  31804. }
  31805. }
  31806. return ret;
  31807. } // parse a component of the expanded set.
  31808. // At this point, no pattern may contain "/" in it
  31809. // so we're going to return a 2d array, where each entry is the full
  31810. // pattern, split on '/', and then turned into a regular expression.
  31811. // A regexp is made at the end which joins each array with an
  31812. // escaped /, and another full one which joins each regexp with |.
  31813. //
  31814. // Following the lead of Bash 4.1, note that "**" only has special meaning
  31815. // when it is the *only* thing in a path portion. Otherwise, any series
  31816. // of * is equivalent to a single *. Globstar behavior is enabled by
  31817. // default, and can be disabled by setting options.noglobstar.
  31818. Minimatch.prototype.parse = parse;
  31819. var SUBPARSE = {};
  31820. function parse(pattern, isSub) {
  31821. var options = this.options; // shortcuts
  31822. if (!options.noglobstar && pattern === "**") return GLOBSTAR;
  31823. if (pattern === "") return "";
  31824. var re = "",
  31825. hasMagic = !!options.nocase,
  31826. escaping = false // ? => one single character
  31827. ,
  31828. patternListStack = [],
  31829. plType,
  31830. stateChar,
  31831. inClass = false,
  31832. reClassStart = -1,
  31833. classStart = -1 // . and .. never match anything that doesn't start with .,
  31834. // even when options.dot is set.
  31835. ,
  31836. patternStart = pattern.charAt(0) === "." ? "" // anything
  31837. // not (start or / followed by . or .. followed by / or end)
  31838. : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
  31839. function clearStateChar() {
  31840. if (stateChar) {
  31841. // we had some state-tracking character
  31842. // that wasn't consumed by this pass.
  31843. switch (stateChar) {
  31844. case "*":
  31845. re += star;
  31846. hasMagic = true;
  31847. break;
  31848. case "?":
  31849. re += qmark;
  31850. hasMagic = true;
  31851. break;
  31852. default:
  31853. re += "\\" + stateChar;
  31854. break;
  31855. }
  31856. stateChar = false;
  31857. }
  31858. }
  31859. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  31860. if (options.debug) {
  31861. console.error("%s\t%s %s %j", pattern, i, re, c);
  31862. } // skip over any that are escaped.
  31863. if (escaping && reSpecials[c]) {
  31864. re += "\\" + c;
  31865. escaping = false;
  31866. continue;
  31867. }
  31868. SWITCH: switch (c) {
  31869. case "/":
  31870. // completely not allowed, even escaped.
  31871. // Should already be path-split by now.
  31872. return false;
  31873. case "\\":
  31874. clearStateChar();
  31875. escaping = true;
  31876. continue;
  31877. // the various stateChar values
  31878. // for the "extglob" stuff.
  31879. case "?":
  31880. case "*":
  31881. case "+":
  31882. case "@":
  31883. case "!":
  31884. if (options.debug) {
  31885. console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
  31886. } // all of those are literals inside a class, except that
  31887. // the glob [!a] means [^a] in regexp
  31888. if (inClass) {
  31889. if (c === "!" && i === classStart + 1) c = "^";
  31890. re += c;
  31891. continue;
  31892. } // if we already have a stateChar, then it means
  31893. // that there was something like ** or +? in there.
  31894. // Handle the stateChar, then proceed with this one.
  31895. clearStateChar();
  31896. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  31897. // just clear the statechar *now*, rather than even diving into
  31898. // the patternList stuff.
  31899. if (options.noext) clearStateChar();
  31900. continue;
  31901. case "(":
  31902. if (inClass) {
  31903. re += "(";
  31904. continue;
  31905. }
  31906. if (!stateChar) {
  31907. re += "\\(";
  31908. continue;
  31909. }
  31910. plType = stateChar;
  31911. patternListStack.push({
  31912. type: plType,
  31913. start: i - 1,
  31914. reStart: re.length
  31915. }); // negation is (?:(?!js)[^/]*)
  31916. re += stateChar === "!" ? "(?:(?!" : "(?:";
  31917. stateChar = false;
  31918. continue;
  31919. case ")":
  31920. if (inClass || !patternListStack.length) {
  31921. re += "\\)";
  31922. continue;
  31923. }
  31924. hasMagic = true;
  31925. re += ")";
  31926. plType = patternListStack.pop().type; // negation is (?:(?!js)[^/]*)
  31927. // The others are (?:<pattern>)<type>
  31928. switch (plType) {
  31929. case "!":
  31930. re += "[^/]*?)";
  31931. break;
  31932. case "?":
  31933. case "+":
  31934. case "*":
  31935. re += plType;
  31936. case "@":
  31937. break;
  31938. // the default anyway
  31939. }
  31940. continue;
  31941. case "|":
  31942. if (inClass || !patternListStack.length || escaping) {
  31943. re += "\\|";
  31944. escaping = false;
  31945. continue;
  31946. }
  31947. re += "|";
  31948. continue;
  31949. // these are mostly the same in regexp and glob
  31950. case "[":
  31951. // swallow any state-tracking char before the [
  31952. clearStateChar();
  31953. if (inClass) {
  31954. re += "\\" + c;
  31955. continue;
  31956. }
  31957. inClass = true;
  31958. classStart = i;
  31959. reClassStart = re.length;
  31960. re += c;
  31961. continue;
  31962. case "]":
  31963. // a right bracket shall lose its special
  31964. // meaning and represent itself in
  31965. // a bracket expression if it occurs
  31966. // first in the list. -- POSIX.2 2.8.3.2
  31967. if (i === classStart + 1 || !inClass) {
  31968. re += "\\" + c;
  31969. escaping = false;
  31970. continue;
  31971. } // finish up the class.
  31972. hasMagic = true;
  31973. inClass = false;
  31974. re += c;
  31975. continue;
  31976. default:
  31977. // swallow any state char that wasn't consumed
  31978. clearStateChar();
  31979. if (escaping) {
  31980. // no need
  31981. escaping = false;
  31982. } else if (reSpecials[c] && !(c === "^" && inClass)) {
  31983. re += "\\";
  31984. }
  31985. re += c;
  31986. } // switch
  31987. } // for
  31988. // handle the case where we left a class open.
  31989. // "[abc" is valid, equivalent to "\[abc"
  31990. if (inClass) {
  31991. // split where the last [ was, and escape it
  31992. // this is a huge pita. We now have to re-walk
  31993. // the contents of the would-be class to re-translate
  31994. // any characters that were passed through as-is
  31995. var cs = pattern.substr(classStart + 1),
  31996. sp = this.parse(cs, SUBPARSE);
  31997. re = re.substr(0, reClassStart) + "\\[" + sp[0];
  31998. hasMagic = hasMagic || sp[1];
  31999. } // handle the case where we had a +( thing at the *end*
  32000. // of the pattern.
  32001. // each pattern list stack adds 3 chars, and we need to go through
  32002. // and escape any | chars that were passed through as-is for the regexp.
  32003. // Go through and escape them, taking care not to double-escape any
  32004. // | chars that were already escaped.
  32005. var pl;
  32006. while (pl = patternListStack.pop()) {
  32007. var tail = re.slice(pl.reStart + 3); // maybe some even number of \, then maybe 1 \, followed by a |
  32008. tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
  32009. if (!$2) {
  32010. // the | isn't already escaped, so escape it.
  32011. $2 = "\\";
  32012. } // need to escape all those slashes *again*, without escaping the
  32013. // one that we need for escaping the | character. As it works out,
  32014. // escaping an even number of slashes can be done by simply repeating
  32015. // it exactly after itself. That's why this trick works.
  32016. //
  32017. // I am sorry that you have to see this.
  32018. return $1 + $1 + $2 + "|";
  32019. }); // console.error("tail=%j\n %s", tail, tail)
  32020. var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
  32021. hasMagic = true;
  32022. re = re.slice(0, pl.reStart) + t + "\\(" + tail;
  32023. } // handle trailing things that only matter at the very end.
  32024. clearStateChar();
  32025. if (escaping) {
  32026. // trailing \\
  32027. re += "\\\\";
  32028. } // only need to apply the nodot start if the re starts with
  32029. // something that could conceivably capture a dot
  32030. var addPatternStart = false;
  32031. switch (re.charAt(0)) {
  32032. case ".":
  32033. case "[":
  32034. case "(":
  32035. addPatternStart = true;
  32036. } // if the re is not "" at this point, then we need to make sure
  32037. // it doesn't match against an empty path part.
  32038. // Otherwise a/* will match a/, which it should not.
  32039. if (re !== "" && hasMagic) re = "(?=.)" + re;
  32040. if (addPatternStart) re = patternStart + re; // parsing just a piece of a larger pattern.
  32041. if (isSub === SUBPARSE) {
  32042. return [re, hasMagic];
  32043. } // skip the regexp for non-magical patterns
  32044. // unescape anything in it, though, so that it'll be
  32045. // an exact match against a file etc.
  32046. if (!hasMagic) {
  32047. return globUnescape(pattern);
  32048. }
  32049. var flags = options.nocase ? "i" : "",
  32050. regExp = new RegExp("^" + re + "$", flags);
  32051. regExp._glob = pattern;
  32052. regExp._src = re;
  32053. return regExp;
  32054. }
  32055. minimatch.makeRe = function (pattern, options) {
  32056. return new Minimatch(pattern, options || {}).makeRe();
  32057. };
  32058. Minimatch.prototype.makeRe = makeRe;
  32059. function makeRe() {
  32060. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  32061. // pattern strings, or "**".
  32062. //
  32063. // It's better to use .match(). This function shouldn't
  32064. // be used, really, but it's pretty convenient sometimes,
  32065. // when you just want to work with a regex.
  32066. var set = this.set;
  32067. if (!set.length) return this.regexp = false;
  32068. var options = this.options;
  32069. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
  32070. flags = options.nocase ? "i" : "";
  32071. var re = set.map(function (pattern) {
  32072. return pattern.map(function (p) {
  32073. return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
  32074. }).join("\\\/");
  32075. }).join("|"); // must match entire pattern
  32076. // ending in a * or ** will make it less strict.
  32077. re = "^(?:" + re + ")$"; // can match anything, as long as it's not this.
  32078. if (this.negate) re = "^(?!" + re + ").*$";
  32079. try {
  32080. return this.regexp = new RegExp(re, flags);
  32081. } catch (ex) {
  32082. return this.regexp = false;
  32083. }
  32084. }
  32085. minimatch.match = function (list, pattern, options) {
  32086. var mm = new Minimatch(pattern, options);
  32087. list = list.filter(function (f) {
  32088. return mm.match(f);
  32089. });
  32090. if (options.nonull && !list.length) {
  32091. list.push(pattern);
  32092. }
  32093. return list;
  32094. };
  32095. Minimatch.prototype.match = match;
  32096. function match(f, partial) {
  32097. // console.error("match", f, this.pattern)
  32098. // short-circuit in the case of busted things.
  32099. // comments, etc.
  32100. if (this.comment) return false;
  32101. if (this.empty) return f === "";
  32102. if (f === "/" && partial) return true;
  32103. var options = this.options; // windows: need to use /, not \
  32104. // On other platforms, \ is a valid (albeit bad) filename char.
  32105. if (platform === "win32") {
  32106. f = f.split("\\").join("/");
  32107. } // treat the test path as a set of pathparts.
  32108. f = f.split(slashSplit);
  32109. if (options.debug) {
  32110. console.error(this.pattern, "split", f);
  32111. } // just ONE of the pattern sets in this.set needs to match
  32112. // in order for it to be valid. If negating, then just one
  32113. // match means that we have failed.
  32114. // Either way, return on the first hit.
  32115. var set = this.set; // console.error(this.pattern, "set", set)
  32116. for (var i = 0, l = set.length; i < l; i++) {
  32117. var pattern = set[i];
  32118. var hit = this.matchOne(f, pattern, partial);
  32119. if (hit) {
  32120. if (options.flipNegate) return true;
  32121. return !this.negate;
  32122. }
  32123. } // didn't get any hits. this is success if it's a negative
  32124. // pattern, failure otherwise.
  32125. if (options.flipNegate) return false;
  32126. return this.negate;
  32127. } // set partial to true to test if, for example,
  32128. // "/a/b" matches the start of "/*/b/*/d"
  32129. // Partial means, if you run out of file before you run
  32130. // out of pattern, then that's fine, as long as all
  32131. // the parts match.
  32132. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  32133. var options = this.options;
  32134. if (options.debug) {
  32135. console.error("matchOne", {
  32136. "this": this,
  32137. file: file,
  32138. pattern: pattern
  32139. });
  32140. }
  32141. if (options.matchBase && pattern.length === 1) {
  32142. file = path.basename(file.join("/")).split("/");
  32143. }
  32144. if (options.debug) {
  32145. console.error("matchOne", file.length, pattern.length);
  32146. }
  32147. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  32148. if (options.debug) {
  32149. console.error("matchOne loop");
  32150. }
  32151. var p = pattern[pi],
  32152. f = file[fi];
  32153. if (options.debug) {
  32154. console.error(pattern, p, f);
  32155. } // should be impossible.
  32156. // some invalid regexp stuff in the set.
  32157. if (p === false) return false;
  32158. if (p === GLOBSTAR) {
  32159. if (options.debug) console.error('GLOBSTAR', [pattern, p, f]); // "**"
  32160. // a/**/b/**/c would match the following:
  32161. // a/b/x/y/z/c
  32162. // a/x/y/z/b/c
  32163. // a/b/x/b/x/c
  32164. // a/b/c
  32165. // To do this, take the rest of the pattern after
  32166. // the **, and see if it would match the file remainder.
  32167. // If so, return success.
  32168. // If not, the ** "swallows" a segment, and try again.
  32169. // This is recursively awful.
  32170. //
  32171. // a/**/b/**/c matching a/b/x/y/z/c
  32172. // - a matches a
  32173. // - doublestar
  32174. // - matchOne(b/x/y/z/c, b/**/c)
  32175. // - b matches b
  32176. // - doublestar
  32177. // - matchOne(x/y/z/c, c) -> no
  32178. // - matchOne(y/z/c, c) -> no
  32179. // - matchOne(z/c, c) -> no
  32180. // - matchOne(c, c) yes, hit
  32181. var fr = fi,
  32182. pr = pi + 1;
  32183. if (pr === pl) {
  32184. if (options.debug) console.error('** at the end'); // a ** at the end will just swallow the rest.
  32185. // We have found a match.
  32186. // however, it will not swallow /.x, unless
  32187. // options.dot is set.
  32188. // . and .. are *never* matched by **, for explosively
  32189. // exponential reasons.
  32190. for (; fi < fl; fi++) {
  32191. if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
  32192. }
  32193. return true;
  32194. } // ok, let's see if we can swallow whatever we can.
  32195. WHILE: while (fr < fl) {
  32196. var swallowee = file[fr];
  32197. if (options.debug) {
  32198. console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
  32199. } // XXX remove this slice. Just pass the start index.
  32200. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  32201. if (options.debug) console.error('globstar found match!', fr, fl, swallowee); // found a match.
  32202. return true;
  32203. } else {
  32204. // can't swallow "." or ".." ever.
  32205. // can only swallow ".foo" when explicitly asked.
  32206. if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
  32207. if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
  32208. break WHILE;
  32209. } // ** swallows a segment, and continue.
  32210. if (options.debug) console.error('globstar swallow a segment, and continue');
  32211. fr++;
  32212. }
  32213. } // no match was found.
  32214. // However, in partial mode, we can't say this is necessarily over.
  32215. // If there's more *pattern* left, then
  32216. if (partial) {
  32217. // ran out of file
  32218. // console.error("\n>>> no match, partial?", file, fr, pattern, pr)
  32219. if (fr === fl) return true;
  32220. }
  32221. return false;
  32222. } // something other than **
  32223. // non-magic patterns just have to match exactly
  32224. // patterns with magic have been turned into regexps.
  32225. var hit;
  32226. if (typeof p === "string") {
  32227. if (options.nocase) {
  32228. hit = f.toLowerCase() === p.toLowerCase();
  32229. } else {
  32230. hit = f === p;
  32231. }
  32232. if (options.debug) {
  32233. console.error("string match", p, f, hit);
  32234. }
  32235. } else {
  32236. hit = f.match(p);
  32237. if (options.debug) {
  32238. console.error("pattern match", p, f, hit);
  32239. }
  32240. }
  32241. if (!hit) return false;
  32242. } // Note: ending in / means that we'll get a final ""
  32243. // at the end of the pattern. This can only match a
  32244. // corresponding "" at the end of the file.
  32245. // If the file ends in /, then it can only match a
  32246. // a pattern that ends in /, unless the pattern just
  32247. // doesn't have any more for it. But, a/b/ should *not*
  32248. // match "a/b/*", even though "" matches against the
  32249. // [^/]*? pattern, except in partial mode, where it might
  32250. // simply not be reached yet.
  32251. // However, a/b/ should still satisfy a/*
  32252. // now either we fell off the end of the pattern, or we're done.
  32253. if (fi === fl && pi === pl) {
  32254. // ran out of pattern and filename at the same time.
  32255. // an exact hit!
  32256. return true;
  32257. } else if (fi === fl) {
  32258. // ran out of file, but still had pattern left.
  32259. // this is ok if we're doing the match as part of
  32260. // a glob fs traversal.
  32261. return partial;
  32262. } else if (pi === pl) {
  32263. // ran out of pattern, still have file left.
  32264. // this is only acceptable if we're on the very last
  32265. // empty segment of a file with a trailing slash.
  32266. // a/* should match a/b/
  32267. var emptyFileEnd = fi === fl - 1 && file[fi] === "";
  32268. return emptyFileEnd;
  32269. } // should be unreachable.
  32270. throw new Error("wtf?");
  32271. }; // replace stuff like \* with *
  32272. function globUnescape(s) {
  32273. return s.replace(/\\(.)/g, "$1");
  32274. }
  32275. function regExpEscape(s) {
  32276. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  32277. }
  32278. });
  32279. var ini = createCommonjsModule(function (module, exports) {
  32280. "use strict"; // Based on iniparser by shockie <https://npmjs.org/package/iniparser>
  32281. var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
  32282. return new (P || (P = Promise))(function (resolve, reject) {
  32283. function fulfilled(value) {
  32284. try {
  32285. step(generator.next(value));
  32286. } catch (e) {
  32287. reject(e);
  32288. }
  32289. }
  32290. function rejected(value) {
  32291. try {
  32292. step(generator["throw"](value));
  32293. } catch (e) {
  32294. reject(e);
  32295. }
  32296. }
  32297. function step(result) {
  32298. result.done ? resolve(result.value) : new P(function (resolve) {
  32299. resolve(result.value);
  32300. }).then(fulfilled, rejected);
  32301. }
  32302. step((generator = generator.apply(thisArg, _arguments || [])).next());
  32303. });
  32304. };
  32305. var __generator = this && this.__generator || function (thisArg, body) {
  32306. var _ = {
  32307. label: 0,
  32308. sent: function sent() {
  32309. if (t[0] & 1) throw t[1];
  32310. return t[1];
  32311. },
  32312. trys: [],
  32313. ops: []
  32314. },
  32315. f,
  32316. y,
  32317. t,
  32318. g;
  32319. return g = {
  32320. next: verb(0),
  32321. "throw": verb(1),
  32322. "return": verb(2)
  32323. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  32324. return this;
  32325. }), g;
  32326. function verb(n) {
  32327. return function (v) {
  32328. return step([n, v]);
  32329. };
  32330. }
  32331. function step(op) {
  32332. if (f) throw new TypeError("Generator is already executing.");
  32333. while (_) {
  32334. try {
  32335. 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;
  32336. if (y = 0, t) op = [op[0] & 2, t.value];
  32337. switch (op[0]) {
  32338. case 0:
  32339. case 1:
  32340. t = op;
  32341. break;
  32342. case 4:
  32343. _.label++;
  32344. return {
  32345. value: op[1],
  32346. done: false
  32347. };
  32348. case 5:
  32349. _.label++;
  32350. y = op[1];
  32351. op = [0];
  32352. continue;
  32353. case 7:
  32354. op = _.ops.pop();
  32355. _.trys.pop();
  32356. continue;
  32357. default:
  32358. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  32359. _ = 0;
  32360. continue;
  32361. }
  32362. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  32363. _.label = op[1];
  32364. break;
  32365. }
  32366. if (op[0] === 6 && _.label < t[1]) {
  32367. _.label = t[1];
  32368. t = op;
  32369. break;
  32370. }
  32371. if (t && _.label < t[2]) {
  32372. _.label = t[2];
  32373. _.ops.push(op);
  32374. break;
  32375. }
  32376. if (t[2]) _.ops.pop();
  32377. _.trys.pop();
  32378. continue;
  32379. }
  32380. op = body.call(thisArg, _);
  32381. } catch (e) {
  32382. op = [6, e];
  32383. y = 0;
  32384. } finally {
  32385. f = t = 0;
  32386. }
  32387. }
  32388. if (op[0] & 5) throw op[1];
  32389. return {
  32390. value: op[0] ? op[1] : void 0,
  32391. done: true
  32392. };
  32393. }
  32394. };
  32395. var __importStar = this && this.__importStar || function (mod) {
  32396. if (mod && mod.__esModule) return mod;
  32397. var result = {};
  32398. if (mod != null) for (var k in mod) {
  32399. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  32400. }
  32401. result["default"] = mod;
  32402. return result;
  32403. };
  32404. Object.defineProperty(exports, "__esModule", {
  32405. value: true
  32406. });
  32407. var fs$$2 = __importStar(fs);
  32408. /**
  32409. * define the possible values:
  32410. * section: [section]
  32411. * param: key=value
  32412. * comment: ;this is a comment
  32413. */
  32414. var regex = {
  32415. section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
  32416. param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
  32417. comment: /^\s*[#;].*$/
  32418. };
  32419. /**
  32420. * Parses an .ini file
  32421. * @param file The location of the .ini file
  32422. */
  32423. function parse(file) {
  32424. return __awaiter(this, void 0, void 0, function () {
  32425. return __generator(this, function (_a) {
  32426. return [2
  32427. /*return*/
  32428. , new Promise(function (resolve, reject) {
  32429. fs$$2.readFile(file, 'utf8', function (err, data) {
  32430. if (err) {
  32431. reject(err);
  32432. return;
  32433. }
  32434. resolve(parseString(data));
  32435. });
  32436. })];
  32437. });
  32438. });
  32439. }
  32440. exports.parse = parse;
  32441. function parseSync(file) {
  32442. return parseString(fs$$2.readFileSync(file, 'utf8'));
  32443. }
  32444. exports.parseSync = parseSync;
  32445. function parseString(data) {
  32446. var sectionBody = {};
  32447. var sectionName = null;
  32448. var value = [[sectionName, sectionBody]];
  32449. var lines = data.split(/\r\n|\r|\n/);
  32450. lines.forEach(function (line) {
  32451. var match;
  32452. if (regex.comment.test(line)) {
  32453. return;
  32454. }
  32455. if (regex.param.test(line)) {
  32456. match = line.match(regex.param);
  32457. sectionBody[match[1]] = match[2];
  32458. } else if (regex.section.test(line)) {
  32459. match = line.match(regex.section);
  32460. sectionName = match[1];
  32461. sectionBody = {};
  32462. value.push([sectionName, sectionBody]);
  32463. }
  32464. });
  32465. return value;
  32466. }
  32467. exports.parseString = parseString;
  32468. });
  32469. unwrapExports(ini);
  32470. var name$17 = "editorconfig";
  32471. var version$3 = "0.15.2";
  32472. var description$1 = "EditorConfig File Locator and Interpreter for Node.js";
  32473. var keywords = ["editorconfig", "core"];
  32474. var main$1 = "src/index.js";
  32475. var contributors = ["Hong Xu (topbug.net)", "Jed Mao (https://github.com/jedmao/)", "Trey Hunner (http://treyhunner.com)"];
  32476. var directories = {
  32477. "bin": "./bin",
  32478. "lib": "./lib"
  32479. };
  32480. var scripts$1 = {
  32481. "clean": "rimraf dist",
  32482. "prebuild": "npm run clean",
  32483. "build": "tsc",
  32484. "pretest": "npm run lint && npm run build && npm run copy && cmake .",
  32485. "test": "ctest .",
  32486. "pretest:ci": "npm run pretest",
  32487. "test:ci": "ctest -VV --output-on-failure .",
  32488. "lint": "npm run eclint && npm run tslint",
  32489. "eclint": "eclint check --indent_size ignore \"src/**\"",
  32490. "tslint": "tslint --project tsconfig.json --exclude package.json",
  32491. "copy": "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
  32492. "prepub": "npm run lint && npm run build && npm run copy",
  32493. "pub": "npm publish ./dist"
  32494. };
  32495. var repository$1 = {
  32496. "type": "git",
  32497. "url": "git://github.com/editorconfig/editorconfig-core-js.git"
  32498. };
  32499. var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
  32500. var author$1 = "EditorConfig Team";
  32501. var license$1 = "MIT";
  32502. var dependencies$1 = {
  32503. "@types/node": "^10.11.7",
  32504. "@types/semver": "^5.5.0",
  32505. "commander": "^2.19.0",
  32506. "lru-cache": "^4.1.3",
  32507. "semver": "^5.6.0",
  32508. "sigmund": "^1.0.1"
  32509. };
  32510. var devDependencies$1 = {
  32511. "@types/mocha": "^5.2.5",
  32512. "cpy-cli": "^2.0.0",
  32513. "eclint": "^2.8.0",
  32514. "mocha": "^5.2.0",
  32515. "rimraf": "^2.6.2",
  32516. "should": "^13.2.3",
  32517. "tslint": "^5.11.0",
  32518. "typescript": "^3.1.3"
  32519. };
  32520. var _package$2 = {
  32521. name: name$17,
  32522. version: version$3,
  32523. description: description$1,
  32524. keywords: keywords,
  32525. main: main$1,
  32526. contributors: contributors,
  32527. directories: directories,
  32528. scripts: scripts$1,
  32529. repository: repository$1,
  32530. bugs: bugs,
  32531. author: author$1,
  32532. license: license$1,
  32533. dependencies: dependencies$1,
  32534. devDependencies: devDependencies$1
  32535. };
  32536. var _package$3 = Object.freeze({
  32537. name: name$17,
  32538. version: version$3,
  32539. description: description$1,
  32540. keywords: keywords,
  32541. main: main$1,
  32542. contributors: contributors,
  32543. directories: directories,
  32544. scripts: scripts$1,
  32545. repository: repository$1,
  32546. bugs: bugs,
  32547. author: author$1,
  32548. license: license$1,
  32549. dependencies: dependencies$1,
  32550. devDependencies: devDependencies$1,
  32551. default: _package$2
  32552. });
  32553. var require$$4$6 = ( _package$3 && _package$2 ) || _package$3;
  32554. var src$2 = createCommonjsModule(function (module, exports) {
  32555. "use strict";
  32556. var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
  32557. return new (P || (P = Promise))(function (resolve, reject) {
  32558. function fulfilled(value) {
  32559. try {
  32560. step(generator.next(value));
  32561. } catch (e) {
  32562. reject(e);
  32563. }
  32564. }
  32565. function rejected(value) {
  32566. try {
  32567. step(generator["throw"](value));
  32568. } catch (e) {
  32569. reject(e);
  32570. }
  32571. }
  32572. function step(result) {
  32573. result.done ? resolve(result.value) : new P(function (resolve) {
  32574. resolve(result.value);
  32575. }).then(fulfilled, rejected);
  32576. }
  32577. step((generator = generator.apply(thisArg, _arguments || [])).next());
  32578. });
  32579. };
  32580. var __generator = this && this.__generator || function (thisArg, body) {
  32581. var _ = {
  32582. label: 0,
  32583. sent: function sent() {
  32584. if (t[0] & 1) throw t[1];
  32585. return t[1];
  32586. },
  32587. trys: [],
  32588. ops: []
  32589. },
  32590. f,
  32591. y,
  32592. t,
  32593. g;
  32594. return g = {
  32595. next: verb(0),
  32596. "throw": verb(1),
  32597. "return": verb(2)
  32598. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  32599. return this;
  32600. }), g;
  32601. function verb(n) {
  32602. return function (v) {
  32603. return step([n, v]);
  32604. };
  32605. }
  32606. function step(op) {
  32607. if (f) throw new TypeError("Generator is already executing.");
  32608. while (_) {
  32609. try {
  32610. 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;
  32611. if (y = 0, t) op = [op[0] & 2, t.value];
  32612. switch (op[0]) {
  32613. case 0:
  32614. case 1:
  32615. t = op;
  32616. break;
  32617. case 4:
  32618. _.label++;
  32619. return {
  32620. value: op[1],
  32621. done: false
  32622. };
  32623. case 5:
  32624. _.label++;
  32625. y = op[1];
  32626. op = [0];
  32627. continue;
  32628. case 7:
  32629. op = _.ops.pop();
  32630. _.trys.pop();
  32631. continue;
  32632. default:
  32633. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  32634. _ = 0;
  32635. continue;
  32636. }
  32637. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  32638. _.label = op[1];
  32639. break;
  32640. }
  32641. if (op[0] === 6 && _.label < t[1]) {
  32642. _.label = t[1];
  32643. t = op;
  32644. break;
  32645. }
  32646. if (t && _.label < t[2]) {
  32647. _.label = t[2];
  32648. _.ops.push(op);
  32649. break;
  32650. }
  32651. if (t[2]) _.ops.pop();
  32652. _.trys.pop();
  32653. continue;
  32654. }
  32655. op = body.call(thisArg, _);
  32656. } catch (e) {
  32657. op = [6, e];
  32658. y = 0;
  32659. } finally {
  32660. f = t = 0;
  32661. }
  32662. }
  32663. if (op[0] & 5) throw op[1];
  32664. return {
  32665. value: op[0] ? op[1] : void 0,
  32666. done: true
  32667. };
  32668. }
  32669. };
  32670. var __importStar = this && this.__importStar || function (mod) {
  32671. if (mod && mod.__esModule) return mod;
  32672. var result = {};
  32673. if (mod != null) for (var k in mod) {
  32674. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  32675. }
  32676. result["default"] = mod;
  32677. return result;
  32678. };
  32679. var __importDefault = this && this.__importDefault || function (mod) {
  32680. return mod && mod.__esModule ? mod : {
  32681. "default": mod
  32682. };
  32683. };
  32684. Object.defineProperty(exports, "__esModule", {
  32685. value: true
  32686. });
  32687. var fs$$2 = __importStar(fs);
  32688. var path$$2 = __importStar(path);
  32689. var semver = __importStar(semver$3);
  32690. var fnmatch_1 = __importDefault(fnmatch);
  32691. exports.parseString = ini.parseString;
  32692. var package_json_1 = __importDefault(require$$4$6);
  32693. var knownProps = {
  32694. end_of_line: true,
  32695. indent_style: true,
  32696. indent_size: true,
  32697. insert_final_newline: true,
  32698. trim_trailing_whitespace: true,
  32699. charset: true
  32700. };
  32701. function fnmatch$$1(filepath, glob) {
  32702. var matchOptions = {
  32703. matchBase: true,
  32704. dot: true,
  32705. noext: true
  32706. };
  32707. glob = glob.replace(/\*\*/g, '{*,**/**/**}');
  32708. return fnmatch_1.default(filepath, glob, matchOptions);
  32709. }
  32710. function getConfigFileNames(filepath, options) {
  32711. var paths = [];
  32712. do {
  32713. filepath = path$$2.dirname(filepath);
  32714. paths.push(path$$2.join(filepath, options.config));
  32715. } while (filepath !== options.root);
  32716. return paths;
  32717. }
  32718. function processMatches(matches, version) {
  32719. // Set indent_size to 'tab' if indent_size is unspecified and
  32720. // indent_style is set to 'tab'.
  32721. if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
  32722. matches.indent_size = 'tab';
  32723. } // Set tab_width to indent_size if indent_size is specified and
  32724. // tab_width is unspecified
  32725. if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
  32726. matches.tab_width = matches.indent_size;
  32727. } // Set indent_size to tab_width if indent_size is 'tab'
  32728. if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
  32729. matches.indent_size = matches.tab_width;
  32730. }
  32731. return matches;
  32732. }
  32733. function processOptions(options, filepath) {
  32734. if (options === void 0) {
  32735. options = {};
  32736. }
  32737. return {
  32738. config: options.config || '.editorconfig',
  32739. version: options.version || package_json_1.default.version,
  32740. root: path$$2.resolve(options.root || path$$2.parse(filepath).root)
  32741. };
  32742. }
  32743. function buildFullGlob(pathPrefix, glob) {
  32744. switch (glob.indexOf('/')) {
  32745. case -1:
  32746. glob = '**/' + glob;
  32747. break;
  32748. case 0:
  32749. glob = glob.substring(1);
  32750. break;
  32751. default:
  32752. break;
  32753. }
  32754. return path$$2.join(pathPrefix, glob);
  32755. }
  32756. function extendProps(props, options) {
  32757. if (props === void 0) {
  32758. props = {};
  32759. }
  32760. if (options === void 0) {
  32761. options = {};
  32762. }
  32763. for (var key in options) {
  32764. if (options.hasOwnProperty(key)) {
  32765. var value = options[key];
  32766. var key2 = key.toLowerCase();
  32767. var value2 = value;
  32768. if (knownProps[key2]) {
  32769. value2 = value.toLowerCase();
  32770. }
  32771. try {
  32772. value2 = JSON.parse(value);
  32773. } catch (e) {}
  32774. if (typeof value === 'undefined' || value === null) {
  32775. // null and undefined are values specific to JSON (no special meaning
  32776. // in editorconfig) & should just be returned as regular strings.
  32777. value2 = String(value);
  32778. }
  32779. props[key2] = value2;
  32780. }
  32781. }
  32782. return props;
  32783. }
  32784. function parseFromConfigs(configs, filepath, options) {
  32785. return processMatches(configs.reverse().reduce(function (matches, file) {
  32786. var pathPrefix = path$$2.dirname(file.name);
  32787. file.contents.forEach(function (section) {
  32788. var glob = section[0];
  32789. var options2 = section[1];
  32790. if (!glob) {
  32791. return;
  32792. }
  32793. var fullGlob = buildFullGlob(pathPrefix, glob);
  32794. if (!fnmatch$$1(filepath, fullGlob)) {
  32795. return;
  32796. }
  32797. matches = extendProps(matches, options2);
  32798. });
  32799. return matches;
  32800. }, {}), options.version);
  32801. }
  32802. function getConfigsForFiles(files) {
  32803. var configs = [];
  32804. for (var i in files) {
  32805. if (files.hasOwnProperty(i)) {
  32806. var file = files[i];
  32807. var contents = ini.parseString(file.contents);
  32808. configs.push({
  32809. name: file.name,
  32810. contents: contents
  32811. });
  32812. if ((contents[0][1].root || '').toLowerCase() === 'true') {
  32813. break;
  32814. }
  32815. }
  32816. }
  32817. return configs;
  32818. }
  32819. function readConfigFiles(filepaths) {
  32820. return __awaiter(this, void 0, void 0, function () {
  32821. return __generator(this, function (_a) {
  32822. return [2
  32823. /*return*/
  32824. , Promise.all(filepaths.map(function (name) {
  32825. return new Promise(function (resolve) {
  32826. fs$$2.readFile(name, 'utf8', function (err, data) {
  32827. resolve({
  32828. name: name,
  32829. contents: err ? '' : data
  32830. });
  32831. });
  32832. });
  32833. }))];
  32834. });
  32835. });
  32836. }
  32837. function readConfigFilesSync(filepaths) {
  32838. var files = [];
  32839. var file;
  32840. filepaths.forEach(function (filepath) {
  32841. try {
  32842. file = fs$$2.readFileSync(filepath, 'utf8');
  32843. } catch (e) {
  32844. file = '';
  32845. }
  32846. files.push({
  32847. name: filepath,
  32848. contents: file
  32849. });
  32850. });
  32851. return files;
  32852. }
  32853. function opts(filepath, options) {
  32854. if (options === void 0) {
  32855. options = {};
  32856. }
  32857. var resolvedFilePath = path$$2.resolve(filepath);
  32858. return [resolvedFilePath, processOptions(options, resolvedFilePath)];
  32859. }
  32860. function parseFromFiles(filepath, files, options) {
  32861. if (options === void 0) {
  32862. options = {};
  32863. }
  32864. return __awaiter(this, void 0, void 0, function () {
  32865. var _a, resolvedFilePath, processedOptions;
  32866. return __generator(this, function (_b) {
  32867. _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
  32868. return [2
  32869. /*return*/
  32870. , files.then(getConfigsForFiles).then(function (configs) {
  32871. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  32872. })];
  32873. });
  32874. });
  32875. }
  32876. exports.parseFromFiles = parseFromFiles;
  32877. function parseFromFilesSync(filepath, files, options) {
  32878. if (options === void 0) {
  32879. options = {};
  32880. }
  32881. var _a = opts(filepath, options),
  32882. resolvedFilePath = _a[0],
  32883. processedOptions = _a[1];
  32884. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  32885. }
  32886. exports.parseFromFilesSync = parseFromFilesSync;
  32887. function parse(_filepath, _options) {
  32888. if (_options === void 0) {
  32889. _options = {};
  32890. }
  32891. return __awaiter(this, void 0, void 0, function () {
  32892. var _a, resolvedFilePath, processedOptions, filepaths;
  32893. return __generator(this, function (_b) {
  32894. _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
  32895. filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  32896. return [2
  32897. /*return*/
  32898. , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
  32899. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  32900. })];
  32901. });
  32902. });
  32903. }
  32904. exports.parse = parse;
  32905. function parseSync(_filepath, _options) {
  32906. if (_options === void 0) {
  32907. _options = {};
  32908. }
  32909. var _a = opts(_filepath, _options),
  32910. resolvedFilePath = _a[0],
  32911. processedOptions = _a[1];
  32912. var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  32913. var files = readConfigFilesSync(filepaths);
  32914. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  32915. }
  32916. exports.parseSync = parseSync;
  32917. });
  32918. unwrapExports(src$2);
  32919. var editorconfigToPrettier = editorConfigToPrettier;
  32920. function removeUnset(editorConfig) {
  32921. var result = {};
  32922. var keys = Object.keys(editorConfig);
  32923. for (var i = 0; i < keys.length; i++) {
  32924. var key = keys[i];
  32925. if (editorConfig[key] === "unset") {
  32926. continue;
  32927. }
  32928. result[key] = editorConfig[key];
  32929. }
  32930. return result;
  32931. }
  32932. function editorConfigToPrettier(editorConfig) {
  32933. if (!editorConfig) {
  32934. return null;
  32935. }
  32936. editorConfig = removeUnset(editorConfig);
  32937. if (Object.keys(editorConfig).length === 0) {
  32938. return null;
  32939. }
  32940. var result = {};
  32941. if (editorConfig.indent_style) {
  32942. result.useTabs = editorConfig.indent_style === "tab";
  32943. }
  32944. if (editorConfig.indent_size === "tab") {
  32945. result.useTabs = true;
  32946. }
  32947. if (result.useTabs && editorConfig.tab_width) {
  32948. result.tabWidth = editorConfig.tab_width;
  32949. } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
  32950. result.tabWidth = editorConfig.indent_size;
  32951. } else if (editorConfig.tab_width !== undefined) {
  32952. result.tabWidth = editorConfig.tab_width;
  32953. }
  32954. if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
  32955. result.printWidth = editorConfig.max_line_length;
  32956. }
  32957. if (editorConfig.quote_type === "single") {
  32958. result.singleQuote = true;
  32959. } else if (editorConfig.quote_type === "double") {
  32960. result.singleQuote = false;
  32961. }
  32962. if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
  32963. result.endOfLine = editorConfig.end_of_line;
  32964. }
  32965. return result;
  32966. }
  32967. function markerExists(files, markers) {
  32968. return markers.some(function (marker) {
  32969. return files.some(function (file) {
  32970. return file === marker;
  32971. });
  32972. });
  32973. }
  32974. function traverseFolder(directory, levels, markers) {
  32975. var files = fs.readdirSync(directory);
  32976. if (levels === 0) {
  32977. return null;
  32978. } else if (markerExists(files, markers)) {
  32979. return directory;
  32980. } else {
  32981. return traverseFolder(path.resolve(directory, '..'), levels - 1, markers);
  32982. }
  32983. }
  32984. var findProjectRoot = function findRoot(dir, opts) {
  32985. if (!dir) throw new Error("Directory not defined");
  32986. opts = opts || {};
  32987. var levels = opts.maxDepth || findRoot.MAX_DEPTH;
  32988. var markers = opts.markers || findRoot.MARKERS;
  32989. return traverseFolder(dir, levels, markers);
  32990. };
  32991. var MAX_DEPTH = 9;
  32992. var MARKERS = ['.git', '.hg'];
  32993. findProjectRoot.MAX_DEPTH = MAX_DEPTH;
  32994. findProjectRoot.MARKERS = MARKERS;
  32995. var resolveConfigEditorconfig = createCommonjsModule(function (module) {
  32996. "use strict";
  32997. var maybeParse = function maybeParse(filePath, config, parse) {
  32998. var root = findProjectRoot(path.dirname(path.resolve(filePath)));
  32999. return filePath && parse(filePath, {
  33000. root
  33001. });
  33002. };
  33003. var editorconfigAsyncNoCache = function editorconfigAsyncNoCache(filePath, config) {
  33004. return Promise.resolve(maybeParse(filePath, config, src$2.parse)).then(editorconfigToPrettier);
  33005. };
  33006. var editorconfigAsyncWithCache = mem(editorconfigAsyncNoCache);
  33007. var editorconfigSyncNoCache = function editorconfigSyncNoCache(filePath, config) {
  33008. return editorconfigToPrettier(maybeParse(filePath, config, src$2.parseSync));
  33009. };
  33010. var editorconfigSyncWithCache = mem(editorconfigSyncNoCache);
  33011. function getLoadFunction(opts) {
  33012. if (!opts.editorconfig) {
  33013. return function () {
  33014. return null;
  33015. };
  33016. }
  33017. if (opts.sync) {
  33018. return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
  33019. }
  33020. return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
  33021. }
  33022. function clearCache() {
  33023. mem.clear(editorconfigSyncWithCache);
  33024. mem.clear(editorconfigAsyncWithCache);
  33025. }
  33026. module.exports = {
  33027. getLoadFunction,
  33028. clearCache
  33029. };
  33030. });
  33031. var ParserEND = 0x110000;
  33032. var ParserError =
  33033. /*#__PURE__*/
  33034. function (_Error) {
  33035. _inherits(ParserError, _Error);
  33036. /* istanbul ignore next */
  33037. function ParserError(msg, filename, linenumber) {
  33038. var _this;
  33039. _classCallCheck(this, ParserError);
  33040. _this = _possibleConstructorReturn(this, _getPrototypeOf(ParserError).call(this, '[ParserError] ' + msg, filename, linenumber));
  33041. _this.name = 'ParserError';
  33042. _this.code = 'ParserError';
  33043. if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_assertThisInitialized(_this)), ParserError);
  33044. return _this;
  33045. }
  33046. return ParserError;
  33047. }(_wrapNativeSuper(Error));
  33048. var State = function State(parser) {
  33049. _classCallCheck(this, State);
  33050. this.parser = parser;
  33051. this.buf = '';
  33052. this.returned = null;
  33053. this.result = null;
  33054. this.resultTable = null;
  33055. this.resultArr = null;
  33056. };
  33057. var Parser =
  33058. /*#__PURE__*/
  33059. function () {
  33060. function Parser() {
  33061. _classCallCheck(this, Parser);
  33062. this.pos = 0;
  33063. this.col = 0;
  33064. this.line = 0;
  33065. this.obj = {};
  33066. this.ctx = this.obj;
  33067. this.stack = [];
  33068. this._buf = '';
  33069. this.char = null;
  33070. this.ii = 0;
  33071. this.state = new State(this.parseStart);
  33072. }
  33073. _createClass(Parser, [{
  33074. key: "parse",
  33075. value: function parse(str) {
  33076. /* istanbul ignore next */
  33077. if (str.length === 0 || str.length == null) return;
  33078. this._buf = String(str);
  33079. this.ii = -1;
  33080. this.char = -1;
  33081. var getNext;
  33082. while (getNext === false || this.nextChar()) {
  33083. getNext = this.runOne();
  33084. }
  33085. this._buf = null;
  33086. }
  33087. }, {
  33088. key: "nextChar",
  33089. value: function nextChar() {
  33090. if (this.char === 0x0A) {
  33091. ++this.line;
  33092. this.col = -1;
  33093. }
  33094. ++this.ii;
  33095. this.char = this._buf.codePointAt(this.ii);
  33096. ++this.pos;
  33097. ++this.col;
  33098. return this.haveBuffer();
  33099. }
  33100. }, {
  33101. key: "haveBuffer",
  33102. value: function haveBuffer() {
  33103. return this.ii < this._buf.length;
  33104. }
  33105. }, {
  33106. key: "runOne",
  33107. value: function runOne() {
  33108. return this.state.parser.call(this, this.state.returned);
  33109. }
  33110. }, {
  33111. key: "finish",
  33112. value: function finish() {
  33113. this.char = ParserEND;
  33114. var last;
  33115. do {
  33116. last = this.state.parser;
  33117. this.runOne();
  33118. } while (this.state.parser !== last);
  33119. this.ctx = null;
  33120. this.state = null;
  33121. this._buf = null;
  33122. return this.obj;
  33123. }
  33124. }, {
  33125. key: "next",
  33126. value: function next(fn) {
  33127. /* istanbul ignore next */
  33128. if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
  33129. this.state.parser = fn;
  33130. }
  33131. }, {
  33132. key: "goto",
  33133. value: function goto(fn) {
  33134. this.next(fn);
  33135. return this.runOne();
  33136. }
  33137. }, {
  33138. key: "call",
  33139. value: function call(fn, returnWith) {
  33140. if (returnWith) this.next(returnWith);
  33141. this.stack.push(this.state);
  33142. this.state = new State(fn);
  33143. }
  33144. }, {
  33145. key: "callNow",
  33146. value: function callNow(fn, returnWith) {
  33147. this.call(fn, returnWith);
  33148. return this.runOne();
  33149. }
  33150. }, {
  33151. key: "return",
  33152. value: function _return(value) {
  33153. /* istanbul ignore next */
  33154. if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'));
  33155. if (value === undefined) value = this.state.buf;
  33156. this.state = this.stack.pop();
  33157. this.state.returned = value;
  33158. }
  33159. }, {
  33160. key: "returnNow",
  33161. value: function returnNow(value) {
  33162. this.return(value);
  33163. return this.runOne();
  33164. }
  33165. }, {
  33166. key: "consume",
  33167. value: function consume() {
  33168. /* istanbul ignore next */
  33169. if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
  33170. this.state.buf += this._buf[this.ii];
  33171. }
  33172. }, {
  33173. key: "error",
  33174. value: function error(err) {
  33175. err.line = this.line;
  33176. err.col = this.col;
  33177. err.pos = this.pos;
  33178. return err;
  33179. }
  33180. /* istanbul ignore next */
  33181. }, {
  33182. key: "parseStart",
  33183. value: function parseStart() {
  33184. throw new ParserError('Must declare a parseStart method');
  33185. }
  33186. }]);
  33187. return Parser;
  33188. }();
  33189. Parser.END = ParserEND;
  33190. Parser.Error = ParserError;
  33191. var parser$2 = Parser;
  33192. var createDatetime = createCommonjsModule(function (module) {
  33193. 'use strict';
  33194. module.exports = function (value) {
  33195. var date = new Date(value);
  33196. /* istanbul ignore if */
  33197. if (isNaN(date)) {
  33198. throw new TypeError('Invalid Datetime');
  33199. } else {
  33200. return date;
  33201. }
  33202. };
  33203. });
  33204. var formatNum = createCommonjsModule(function (module) {
  33205. 'use strict';
  33206. module.exports = function (d, num) {
  33207. num = String(num);
  33208. while (num.length < d) {
  33209. num = '0' + num;
  33210. }
  33211. return num;
  33212. };
  33213. });
  33214. var createDatetimeFloat = createCommonjsModule(function (module) {
  33215. 'use strict';
  33216. var FloatingDateTime =
  33217. /*#__PURE__*/
  33218. function (_Date) {
  33219. _inherits(FloatingDateTime, _Date);
  33220. function FloatingDateTime(value) {
  33221. var _this;
  33222. _classCallCheck(this, FloatingDateTime);
  33223. _this = _possibleConstructorReturn(this, _getPrototypeOf(FloatingDateTime).call(this, value + 'Z'));
  33224. _this.isFloating = true;
  33225. return _this;
  33226. }
  33227. _createClass(FloatingDateTime, [{
  33228. key: "toISOString",
  33229. value: function toISOString() {
  33230. var date = `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  33231. var time = `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  33232. return `${date}T${time}`;
  33233. }
  33234. }]);
  33235. return FloatingDateTime;
  33236. }(_wrapNativeSuper(Date));
  33237. module.exports = function (value) {
  33238. var date = new FloatingDateTime(value);
  33239. /* istanbul ignore if */
  33240. if (isNaN(date)) {
  33241. throw new TypeError('Invalid Datetime');
  33242. } else {
  33243. return date;
  33244. }
  33245. };
  33246. });
  33247. var createDate = createCommonjsModule(function (module) {
  33248. 'use strict';
  33249. var DateTime = global.Date;
  33250. var Date =
  33251. /*#__PURE__*/
  33252. function (_DateTime) {
  33253. _inherits(Date, _DateTime);
  33254. function Date(value) {
  33255. var _this;
  33256. _classCallCheck(this, Date);
  33257. _this = _possibleConstructorReturn(this, _getPrototypeOf(Date).call(this, value));
  33258. _this.isDate = true;
  33259. return _this;
  33260. }
  33261. _createClass(Date, [{
  33262. key: "toISOString",
  33263. value: function toISOString() {
  33264. return `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  33265. }
  33266. }]);
  33267. return Date;
  33268. }(DateTime);
  33269. module.exports = function (value) {
  33270. var date = new Date(value);
  33271. /* istanbul ignore if */
  33272. if (isNaN(date)) {
  33273. throw new TypeError('Invalid Datetime');
  33274. } else {
  33275. return date;
  33276. }
  33277. };
  33278. });
  33279. var createTime = createCommonjsModule(function (module) {
  33280. 'use strict';
  33281. var Time =
  33282. /*#__PURE__*/
  33283. function (_Date) {
  33284. _inherits(Time, _Date);
  33285. function Time(value) {
  33286. var _this;
  33287. _classCallCheck(this, Time);
  33288. _this = _possibleConstructorReturn(this, _getPrototypeOf(Time).call(this, `0000-01-01T${value}Z`));
  33289. _this.isTime = true;
  33290. return _this;
  33291. }
  33292. _createClass(Time, [{
  33293. key: "toISOString",
  33294. value: function toISOString() {
  33295. return `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  33296. }
  33297. }]);
  33298. return Time;
  33299. }(_wrapNativeSuper(Date));
  33300. module.exports = function (value) {
  33301. var date = new Time(value);
  33302. /* istanbul ignore if */
  33303. if (isNaN(date)) {
  33304. throw new TypeError('Invalid Datetime');
  33305. } else {
  33306. return date;
  33307. }
  33308. };
  33309. });
  33310. var tomlParser = createCommonjsModule(function (module) {
  33311. 'use strict';
  33312. /* eslint-disable no-new-wrappers, no-eval, camelcase, operator-linebreak */
  33313. module.exports = makeParserClass(parser$2);
  33314. module.exports.makeParserClass = makeParserClass;
  33315. var TomlError =
  33316. /*#__PURE__*/
  33317. function (_Error) {
  33318. _inherits(TomlError, _Error);
  33319. function TomlError(msg) {
  33320. var _this;
  33321. _classCallCheck(this, TomlError);
  33322. _this = _possibleConstructorReturn(this, _getPrototypeOf(TomlError).call(this, msg));
  33323. _this.name = 'TomlError';
  33324. /* istanbul ignore next */
  33325. if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_assertThisInitialized(_this)), TomlError);
  33326. _this.fromTOML = true;
  33327. _this.wrapped = null;
  33328. return _this;
  33329. }
  33330. return TomlError;
  33331. }(_wrapNativeSuper(Error));
  33332. TomlError.wrap = function (err) {
  33333. var terr = new TomlError(err.message);
  33334. terr.code = err.code;
  33335. terr.wrapped = err;
  33336. return terr;
  33337. };
  33338. module.exports.TomlError = TomlError;
  33339. var CTRL_I = 0x09;
  33340. var CTRL_J = 0x0A;
  33341. var CTRL_M = 0x0D;
  33342. var CTRL_CHAR_BOUNDARY = 0x1F; // the last non-character in the latin1 region of unicode, except DEL
  33343. var CHAR_SP = 0x20;
  33344. var CHAR_QUOT = 0x22;
  33345. var CHAR_NUM = 0x23;
  33346. var CHAR_APOS = 0x27;
  33347. var CHAR_PLUS = 0x2B;
  33348. var CHAR_COMMA = 0x2C;
  33349. var CHAR_HYPHEN = 0x2D;
  33350. var CHAR_PERIOD = 0x2E;
  33351. var CHAR_0 = 0x30;
  33352. var CHAR_1 = 0x31;
  33353. var CHAR_7 = 0x37;
  33354. var CHAR_9 = 0x39;
  33355. var CHAR_COLON = 0x3A;
  33356. var CHAR_EQUALS = 0x3D;
  33357. var CHAR_A = 0x41;
  33358. var CHAR_E = 0x45;
  33359. var CHAR_F = 0x46;
  33360. var CHAR_T = 0x54;
  33361. var CHAR_U = 0x55;
  33362. var CHAR_Z = 0x5A;
  33363. var CHAR_LOWBAR = 0x5F;
  33364. var CHAR_a = 0x61;
  33365. var CHAR_b = 0x62;
  33366. var CHAR_e = 0x65;
  33367. var CHAR_f = 0x66;
  33368. var CHAR_i = 0x69;
  33369. var CHAR_l = 0x6C;
  33370. var CHAR_n = 0x6E;
  33371. var CHAR_o = 0x6F;
  33372. var CHAR_r = 0x72;
  33373. var CHAR_s = 0x73;
  33374. var CHAR_t = 0x74;
  33375. var CHAR_u = 0x75;
  33376. var CHAR_x = 0x78;
  33377. var CHAR_z = 0x7A;
  33378. var CHAR_LCUB = 0x7B;
  33379. var CHAR_RCUB = 0x7D;
  33380. var CHAR_LSQB = 0x5B;
  33381. var CHAR_BSOL = 0x5C;
  33382. var CHAR_RSQB = 0x5D;
  33383. var CHAR_DEL = 0x7F;
  33384. var SURROGATE_FIRST = 0xD800;
  33385. var SURROGATE_LAST = 0xDFFF;
  33386. var escapes = {
  33387. [CHAR_b]: '\u0008',
  33388. [CHAR_t]: '\u0009',
  33389. [CHAR_n]: '\u000A',
  33390. [CHAR_f]: '\u000C',
  33391. [CHAR_r]: '\u000D',
  33392. [CHAR_QUOT]: '\u0022',
  33393. [CHAR_BSOL]: '\u005C'
  33394. };
  33395. function isDigit(cp) {
  33396. return cp >= CHAR_0 && cp <= CHAR_9;
  33397. }
  33398. function isHexit(cp) {
  33399. return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
  33400. }
  33401. function isBit(cp) {
  33402. return cp === CHAR_1 || cp === CHAR_0;
  33403. }
  33404. function isOctit(cp) {
  33405. return cp >= CHAR_0 && cp <= CHAR_7;
  33406. }
  33407. function isAlphaNumQuoteHyphen(cp) {
  33408. 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;
  33409. }
  33410. function isAlphaNumHyphen(cp) {
  33411. 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;
  33412. }
  33413. var _type = Symbol('type');
  33414. var _declared = Symbol('declared');
  33415. var hasOwnProperty = Object.prototype.hasOwnProperty;
  33416. var defineProperty = Object.defineProperty;
  33417. var descriptor = {
  33418. configurable: true,
  33419. enumerable: true,
  33420. writable: true,
  33421. value: undefined
  33422. };
  33423. function hasKey(obj, key) {
  33424. if (hasOwnProperty.call(obj, key)) return true;
  33425. if (key === '__proto__') defineProperty(obj, '__proto__', descriptor);
  33426. return false;
  33427. }
  33428. var INLINE_TABLE = Symbol('inline-table');
  33429. function InlineTable() {
  33430. return Object.defineProperties({}, {
  33431. [_type]: {
  33432. value: INLINE_TABLE
  33433. }
  33434. });
  33435. }
  33436. function isInlineTable(obj) {
  33437. if (obj === null || typeof obj !== 'object') return false;
  33438. return obj[_type] === INLINE_TABLE;
  33439. }
  33440. var TABLE = Symbol('table');
  33441. function Table() {
  33442. return Object.defineProperties({}, {
  33443. [_type]: {
  33444. value: TABLE
  33445. },
  33446. [_declared]: {
  33447. value: false,
  33448. writable: true
  33449. }
  33450. });
  33451. }
  33452. function isTable(obj) {
  33453. if (obj === null || typeof obj !== 'object') return false;
  33454. return obj[_type] === TABLE;
  33455. }
  33456. var _contentType = Symbol('content-type');
  33457. var INLINE_LIST = Symbol('inline-list');
  33458. function InlineList(type) {
  33459. return Object.defineProperties([], {
  33460. [_type]: {
  33461. value: INLINE_LIST
  33462. },
  33463. [_contentType]: {
  33464. value: type
  33465. }
  33466. });
  33467. }
  33468. function isInlineList(obj) {
  33469. if (obj === null || typeof obj !== 'object') return false;
  33470. return obj[_type] === INLINE_LIST;
  33471. }
  33472. var LIST = Symbol('list');
  33473. function List() {
  33474. return Object.defineProperties([], {
  33475. [_type]: {
  33476. value: LIST
  33477. }
  33478. });
  33479. }
  33480. function isList(obj) {
  33481. if (obj === null || typeof obj !== 'object') return false;
  33482. return obj[_type] === LIST;
  33483. } // in an eval, to let bundlers not slurp in a util proxy
  33484. var _custom;
  33485. try {
  33486. var utilInspect = util.inspect;
  33487. _custom = utilInspect.custom;
  33488. } catch (_) {}
  33489. /* eval require not available in transpiled bundle */
  33490. /* istanbul ignore next */
  33491. var _inspect = _custom || 'inspect';
  33492. var BoxedBigInt =
  33493. /*#__PURE__*/
  33494. function () {
  33495. function BoxedBigInt(value) {
  33496. _classCallCheck(this, BoxedBigInt);
  33497. try {
  33498. this.value = global.BigInt.asIntN(64, value);
  33499. } catch (_) {
  33500. /* istanbul ignore next */
  33501. this.value = null;
  33502. }
  33503. Object.defineProperty(this, _type, {
  33504. value: INTEGER
  33505. });
  33506. }
  33507. _createClass(BoxedBigInt, [{
  33508. key: "isNaN",
  33509. value: function isNaN() {
  33510. return this.value === null;
  33511. }
  33512. /* istanbul ignore next */
  33513. }, {
  33514. key: "toString",
  33515. value: function toString() {
  33516. return String(this.value);
  33517. }
  33518. /* istanbul ignore next */
  33519. }, {
  33520. key: _inspect,
  33521. value: function value() {
  33522. return `[BigInt: ${this.toString()}]}`;
  33523. }
  33524. }, {
  33525. key: "valueOf",
  33526. value: function valueOf() {
  33527. return this.value;
  33528. }
  33529. }]);
  33530. return BoxedBigInt;
  33531. }();
  33532. var INTEGER = Symbol('integer');
  33533. function Integer(_value) {
  33534. var num = Number(_value); // -0 is a float thing, not an int thing
  33535. if (Object.is(num, -0)) num = 0;
  33536. /* istanbul ignore else */
  33537. if (global.BigInt && !Number.isSafeInteger(num)) {
  33538. return new BoxedBigInt(_value);
  33539. } else {
  33540. /* istanbul ignore next */
  33541. return Object.defineProperties(new Number(num), {
  33542. isNaN: {
  33543. value: function value() {
  33544. return isNaN(this);
  33545. }
  33546. },
  33547. [_type]: {
  33548. value: INTEGER
  33549. },
  33550. [_inspect]: {
  33551. value: function value() {
  33552. return `[Integer: ${_value}]`;
  33553. }
  33554. }
  33555. });
  33556. }
  33557. }
  33558. function isInteger(obj) {
  33559. if (obj === null || typeof obj !== 'object') return false;
  33560. return obj[_type] === INTEGER;
  33561. }
  33562. var FLOAT = Symbol('float');
  33563. function Float(_value2) {
  33564. /* istanbul ignore next */
  33565. return Object.defineProperties(new Number(_value2), {
  33566. [_type]: {
  33567. value: FLOAT
  33568. },
  33569. [_inspect]: {
  33570. value: function value() {
  33571. return `[Float: ${_value2}]`;
  33572. }
  33573. }
  33574. });
  33575. }
  33576. function isFloat(obj) {
  33577. if (obj === null || typeof obj !== 'object') return false;
  33578. return obj[_type] === FLOAT;
  33579. }
  33580. function tomlType(value) {
  33581. var type = typeof value;
  33582. if (type === 'object') {
  33583. /* istanbul ignore if */
  33584. if (value === null) return 'null';
  33585. if (value instanceof Date) return 'datetime';
  33586. /* istanbul ignore else */
  33587. if (_type in value) {
  33588. switch (value[_type]) {
  33589. case INLINE_TABLE:
  33590. return 'inline-table';
  33591. case INLINE_LIST:
  33592. return 'inline-list';
  33593. /* istanbul ignore next */
  33594. case TABLE:
  33595. return 'table';
  33596. /* istanbul ignore next */
  33597. case LIST:
  33598. return 'list';
  33599. case FLOAT:
  33600. return 'float';
  33601. case INTEGER:
  33602. return 'integer';
  33603. }
  33604. }
  33605. }
  33606. return type;
  33607. }
  33608. function makeParserClass(Parser) {
  33609. var TOMLParser =
  33610. /*#__PURE__*/
  33611. function (_Parser) {
  33612. _inherits(TOMLParser, _Parser);
  33613. function TOMLParser() {
  33614. var _this2;
  33615. _classCallCheck(this, TOMLParser);
  33616. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(TOMLParser).call(this));
  33617. _this2.ctx = _this2.obj = Table();
  33618. return _this2;
  33619. }
  33620. /* MATCH HELPER */
  33621. _createClass(TOMLParser, [{
  33622. key: "atEndOfWord",
  33623. value: function atEndOfWord() {
  33624. return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
  33625. }
  33626. }, {
  33627. key: "atEndOfLine",
  33628. value: function atEndOfLine() {
  33629. return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
  33630. }
  33631. }, {
  33632. key: "parseStart",
  33633. value: function parseStart() {
  33634. if (this.char === Parser.END) {
  33635. return null;
  33636. } else if (this.char === CHAR_LSQB) {
  33637. return this.call(this.parseTableOrList);
  33638. } else if (this.char === CHAR_NUM) {
  33639. return this.call(this.parseComment);
  33640. } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  33641. return null;
  33642. } else if (isAlphaNumQuoteHyphen(this.char)) {
  33643. return this.callNow(this.parseAssignStatement);
  33644. } else {
  33645. throw this.error(new TomlError(`Unknown character "${this.char}"`));
  33646. }
  33647. } // HELPER, this strips any whitespace and comments to the end of the line
  33648. // then RETURNS. Last state in a production.
  33649. }, {
  33650. key: "parseWhitespaceToEOL",
  33651. value: function parseWhitespaceToEOL() {
  33652. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  33653. return null;
  33654. } else if (this.char === CHAR_NUM) {
  33655. return this.goto(this.parseComment);
  33656. } else if (this.char === Parser.END || this.char === CTRL_J) {
  33657. return this.return();
  33658. } else {
  33659. throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
  33660. }
  33661. }
  33662. /* ASSIGNMENT: key = value */
  33663. }, {
  33664. key: "parseAssignStatement",
  33665. value: function parseAssignStatement() {
  33666. return this.callNow(this.parseAssign, this.recordAssignStatement);
  33667. }
  33668. }, {
  33669. key: "recordAssignStatement",
  33670. value: function recordAssignStatement(kv) {
  33671. var target = this.ctx;
  33672. var finalKey = kv.key.pop();
  33673. var _iteratorNormalCompletion = true;
  33674. var _didIteratorError = false;
  33675. var _iteratorError = undefined;
  33676. try {
  33677. for (var _iterator = kv.key[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  33678. var kw = _step.value;
  33679. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  33680. throw this.error(new TomlError("Can't redefine existing key"));
  33681. }
  33682. target = target[kw] = target[kw] || Table();
  33683. }
  33684. } catch (err) {
  33685. _didIteratorError = true;
  33686. _iteratorError = err;
  33687. } finally {
  33688. try {
  33689. if (!_iteratorNormalCompletion && _iterator.return != null) {
  33690. _iterator.return();
  33691. }
  33692. } finally {
  33693. if (_didIteratorError) {
  33694. throw _iteratorError;
  33695. }
  33696. }
  33697. }
  33698. if (hasKey(target, finalKey)) {
  33699. throw this.error(new TomlError("Can't redefine existing key"));
  33700. } // unbox our numbers
  33701. if (isInteger(kv.value) || isFloat(kv.value)) {
  33702. target[finalKey] = kv.value.valueOf();
  33703. } else {
  33704. target[finalKey] = kv.value;
  33705. }
  33706. return this.goto(this.parseWhitespaceToEOL);
  33707. }
  33708. /* ASSSIGNMENT expression, key = value possibly inside an inline table */
  33709. }, {
  33710. key: "parseAssign",
  33711. value: function parseAssign() {
  33712. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  33713. }
  33714. }, {
  33715. key: "recordAssignKeyword",
  33716. value: function recordAssignKeyword(key) {
  33717. if (this.state.resultTable) {
  33718. this.state.resultTable.push(key);
  33719. } else {
  33720. this.state.resultTable = [key];
  33721. }
  33722. return this.goto(this.parseAssignKeywordPreDot);
  33723. }
  33724. }, {
  33725. key: "parseAssignKeywordPreDot",
  33726. value: function parseAssignKeywordPreDot() {
  33727. if (this.char === CHAR_PERIOD) {
  33728. return this.next(this.parseAssignKeywordPostDot);
  33729. } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  33730. return this.goto(this.parseAssignEqual);
  33731. }
  33732. }
  33733. }, {
  33734. key: "parseAssignKeywordPostDot",
  33735. value: function parseAssignKeywordPostDot() {
  33736. if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  33737. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  33738. }
  33739. }
  33740. }, {
  33741. key: "parseAssignEqual",
  33742. value: function parseAssignEqual() {
  33743. if (this.char === CHAR_EQUALS) {
  33744. return this.next(this.parseAssignPreValue);
  33745. } else {
  33746. throw this.error(new TomlError('Invalid character, expected "="'));
  33747. }
  33748. }
  33749. }, {
  33750. key: "parseAssignPreValue",
  33751. value: function parseAssignPreValue() {
  33752. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33753. return null;
  33754. } else {
  33755. return this.callNow(this.parseValue, this.recordAssignValue);
  33756. }
  33757. }
  33758. }, {
  33759. key: "recordAssignValue",
  33760. value: function recordAssignValue(value) {
  33761. return this.returnNow({
  33762. key: this.state.resultTable,
  33763. value: value
  33764. });
  33765. }
  33766. /* COMMENTS: #...eol */
  33767. }, {
  33768. key: "parseComment",
  33769. value: function parseComment() {
  33770. do {
  33771. if (this.char === Parser.END || this.char === CTRL_J) {
  33772. return this.return();
  33773. }
  33774. } while (this.nextChar());
  33775. }
  33776. /* TABLES AND LISTS, [foo] and [[foo]] */
  33777. }, {
  33778. key: "parseTableOrList",
  33779. value: function parseTableOrList() {
  33780. if (this.char === CHAR_LSQB) {
  33781. this.next(this.parseList);
  33782. } else {
  33783. return this.goto(this.parseTable);
  33784. }
  33785. }
  33786. /* TABLE [foo.bar.baz] */
  33787. }, {
  33788. key: "parseTable",
  33789. value: function parseTable() {
  33790. this.ctx = this.obj;
  33791. return this.goto(this.parseTableNext);
  33792. }
  33793. }, {
  33794. key: "parseTableNext",
  33795. value: function parseTableNext() {
  33796. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33797. return null;
  33798. } else {
  33799. return this.callNow(this.parseKeyword, this.parseTableMore);
  33800. }
  33801. }
  33802. }, {
  33803. key: "parseTableMore",
  33804. value: function parseTableMore(keyword) {
  33805. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33806. return null;
  33807. } else if (this.char === CHAR_RSQB) {
  33808. if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
  33809. throw this.error(new TomlError("Can't redefine existing key"));
  33810. } else {
  33811. this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
  33812. this.ctx[_declared] = true;
  33813. }
  33814. return this.next(this.parseWhitespaceToEOL);
  33815. } else if (this.char === CHAR_PERIOD) {
  33816. if (!hasKey(this.ctx, keyword)) {
  33817. this.ctx = this.ctx[keyword] = Table();
  33818. } else if (isTable(this.ctx[keyword])) {
  33819. this.ctx = this.ctx[keyword];
  33820. } else if (isList(this.ctx[keyword])) {
  33821. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  33822. } else {
  33823. throw this.error(new TomlError("Can't redefine existing key"));
  33824. }
  33825. return this.next(this.parseTableNext);
  33826. } else {
  33827. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33828. }
  33829. }
  33830. /* LIST [[a.b.c]] */
  33831. }, {
  33832. key: "parseList",
  33833. value: function parseList() {
  33834. this.ctx = this.obj;
  33835. return this.goto(this.parseListNext);
  33836. }
  33837. }, {
  33838. key: "parseListNext",
  33839. value: function parseListNext() {
  33840. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33841. return null;
  33842. } else {
  33843. return this.callNow(this.parseKeyword, this.parseListMore);
  33844. }
  33845. }
  33846. }, {
  33847. key: "parseListMore",
  33848. value: function parseListMore(keyword) {
  33849. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33850. return null;
  33851. } else if (this.char === CHAR_RSQB) {
  33852. if (!hasKey(this.ctx, keyword)) {
  33853. this.ctx[keyword] = List();
  33854. }
  33855. if (isInlineList(this.ctx[keyword])) {
  33856. throw this.error(new TomlError("Can't extend an inline array"));
  33857. } else if (isList(this.ctx[keyword])) {
  33858. var next = Table();
  33859. this.ctx[keyword].push(next);
  33860. this.ctx = next;
  33861. } else {
  33862. throw this.error(new TomlError("Can't redefine an existing key"));
  33863. }
  33864. return this.next(this.parseListEnd);
  33865. } else if (this.char === CHAR_PERIOD) {
  33866. if (!hasKey(this.ctx, keyword)) {
  33867. this.ctx = this.ctx[keyword] = Table();
  33868. } else if (isInlineList(this.ctx[keyword])) {
  33869. throw this.error(new TomlError("Can't extend an inline array"));
  33870. } else if (isInlineTable(this.ctx[keyword])) {
  33871. throw this.error(new TomlError("Can't extend an inline table"));
  33872. } else if (isList(this.ctx[keyword])) {
  33873. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  33874. } else if (isTable(this.ctx[keyword])) {
  33875. this.ctx = this.ctx[keyword];
  33876. } else {
  33877. throw this.error(new TomlError("Can't redefine an existing key"));
  33878. }
  33879. return this.next(this.parseListNext);
  33880. } else {
  33881. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33882. }
  33883. }
  33884. }, {
  33885. key: "parseListEnd",
  33886. value: function parseListEnd(keyword) {
  33887. if (this.char === CHAR_RSQB) {
  33888. return this.next(this.parseWhitespaceToEOL);
  33889. } else {
  33890. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33891. }
  33892. }
  33893. /* VALUE string, number, boolean, inline list, inline object */
  33894. }, {
  33895. key: "parseValue",
  33896. value: function parseValue() {
  33897. if (this.char === Parser.END) {
  33898. throw this.error(new TomlError('Key without value'));
  33899. } else if (this.char === CHAR_QUOT) {
  33900. return this.next(this.parseDoubleString);
  33901. }
  33902. if (this.char === CHAR_APOS) {
  33903. return this.next(this.parseSingleString);
  33904. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  33905. return this.goto(this.parseNumberSign);
  33906. } else if (this.char === CHAR_i) {
  33907. return this.next(this.parseInf);
  33908. } else if (this.char === CHAR_n) {
  33909. return this.next(this.parseNan);
  33910. } else if (isDigit(this.char)) {
  33911. return this.goto(this.parseNumberOrDateTime);
  33912. } else if (this.char === CHAR_t || this.char === CHAR_f) {
  33913. return this.goto(this.parseBoolean);
  33914. } else if (this.char === CHAR_LSQB) {
  33915. return this.call(this.parseInlineList, this.recordValue);
  33916. } else if (this.char === CHAR_LCUB) {
  33917. return this.call(this.parseInlineTable, this.recordValue);
  33918. } else {
  33919. throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
  33920. }
  33921. }
  33922. }, {
  33923. key: "recordValue",
  33924. value: function recordValue(value) {
  33925. return this.returnNow(value);
  33926. }
  33927. }, {
  33928. key: "parseInf",
  33929. value: function parseInf() {
  33930. if (this.char === CHAR_n) {
  33931. return this.next(this.parseInf2);
  33932. } else {
  33933. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  33934. }
  33935. }
  33936. }, {
  33937. key: "parseInf2",
  33938. value: function parseInf2() {
  33939. if (this.char === CHAR_f) {
  33940. if (this.state.buf === '-') {
  33941. return this.return(-Infinity);
  33942. } else {
  33943. return this.return(Infinity);
  33944. }
  33945. } else {
  33946. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  33947. }
  33948. }
  33949. }, {
  33950. key: "parseNan",
  33951. value: function parseNan() {
  33952. if (this.char === CHAR_a) {
  33953. return this.next(this.parseNan2);
  33954. } else {
  33955. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  33956. }
  33957. }
  33958. }, {
  33959. key: "parseNan2",
  33960. value: function parseNan2() {
  33961. if (this.char === CHAR_n) {
  33962. return this.return(NaN);
  33963. } else {
  33964. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  33965. }
  33966. }
  33967. /* KEYS, barewords or basic, literal, or dotted */
  33968. }, {
  33969. key: "parseKeyword",
  33970. value: function parseKeyword() {
  33971. if (this.char === CHAR_QUOT) {
  33972. return this.next(this.parseBasicString);
  33973. } else if (this.char === CHAR_APOS) {
  33974. return this.next(this.parseLiteralString);
  33975. } else {
  33976. return this.goto(this.parseBareKey);
  33977. }
  33978. }
  33979. /* KEYS: barewords */
  33980. }, {
  33981. key: "parseBareKey",
  33982. value: function parseBareKey() {
  33983. do {
  33984. if (this.char === Parser.END) {
  33985. throw this.error(new TomlError('Key ended without value'));
  33986. } else if (isAlphaNumHyphen(this.char)) {
  33987. this.consume();
  33988. } else if (this.state.buf.length === 0) {
  33989. throw this.error(new TomlError('Empty bare keys are not allowed'));
  33990. } else {
  33991. return this.returnNow();
  33992. }
  33993. } while (this.nextChar());
  33994. }
  33995. /* STRINGS, single quoted (literal) */
  33996. }, {
  33997. key: "parseSingleString",
  33998. value: function parseSingleString() {
  33999. if (this.char === CHAR_APOS) {
  34000. return this.next(this.parseLiteralMultiStringMaybe);
  34001. } else {
  34002. return this.goto(this.parseLiteralString);
  34003. }
  34004. }
  34005. }, {
  34006. key: "parseLiteralString",
  34007. value: function parseLiteralString() {
  34008. do {
  34009. if (this.char === CHAR_APOS) {
  34010. return this.return();
  34011. } else if (this.atEndOfLine()) {
  34012. throw this.error(new TomlError('Unterminated string'));
  34013. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  34014. throw this.errorControlCharInString();
  34015. } else {
  34016. this.consume();
  34017. }
  34018. } while (this.nextChar());
  34019. }
  34020. }, {
  34021. key: "parseLiteralMultiStringMaybe",
  34022. value: function parseLiteralMultiStringMaybe() {
  34023. if (this.char === CHAR_APOS) {
  34024. return this.next(this.parseLiteralMultiString);
  34025. } else {
  34026. return this.returnNow();
  34027. }
  34028. }
  34029. }, {
  34030. key: "parseLiteralMultiString",
  34031. value: function parseLiteralMultiString() {
  34032. if (this.char === CTRL_M) {
  34033. return null;
  34034. } else if (this.char === CTRL_J) {
  34035. return this.next(this.parseLiteralMultiStringContent);
  34036. } else {
  34037. return this.goto(this.parseLiteralMultiStringContent);
  34038. }
  34039. }
  34040. }, {
  34041. key: "parseLiteralMultiStringContent",
  34042. value: function parseLiteralMultiStringContent() {
  34043. do {
  34044. if (this.char === CHAR_APOS) {
  34045. return this.next(this.parseLiteralMultiEnd);
  34046. } else if (this.char === Parser.END) {
  34047. throw this.error(new TomlError('Unterminated multi-line string'));
  34048. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  34049. throw this.errorControlCharInString();
  34050. } else {
  34051. this.consume();
  34052. }
  34053. } while (this.nextChar());
  34054. }
  34055. }, {
  34056. key: "parseLiteralMultiEnd",
  34057. value: function parseLiteralMultiEnd() {
  34058. if (this.char === CHAR_APOS) {
  34059. return this.next(this.parseLiteralMultiEnd2);
  34060. } else {
  34061. this.state.buf += "'";
  34062. return this.goto(this.parseLiteralMultiStringContent);
  34063. }
  34064. }
  34065. }, {
  34066. key: "parseLiteralMultiEnd2",
  34067. value: function parseLiteralMultiEnd2() {
  34068. if (this.char === CHAR_APOS) {
  34069. return this.return();
  34070. } else {
  34071. this.state.buf += "''";
  34072. return this.goto(this.parseLiteralMultiStringContent);
  34073. }
  34074. }
  34075. /* STRINGS double quoted */
  34076. }, {
  34077. key: "parseDoubleString",
  34078. value: function parseDoubleString() {
  34079. if (this.char === CHAR_QUOT) {
  34080. return this.next(this.parseMultiStringMaybe);
  34081. } else {
  34082. return this.goto(this.parseBasicString);
  34083. }
  34084. }
  34085. }, {
  34086. key: "parseBasicString",
  34087. value: function parseBasicString() {
  34088. do {
  34089. if (this.char === CHAR_BSOL) {
  34090. return this.call(this.parseEscape, this.recordEscapeReplacement);
  34091. } else if (this.char === CHAR_QUOT) {
  34092. return this.return();
  34093. } else if (this.atEndOfLine()) {
  34094. throw this.error(new TomlError('Unterminated string'));
  34095. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  34096. throw this.errorControlCharInString();
  34097. } else {
  34098. this.consume();
  34099. }
  34100. } while (this.nextChar());
  34101. }
  34102. }, {
  34103. key: "recordEscapeReplacement",
  34104. value: function recordEscapeReplacement(replacement) {
  34105. this.state.buf += replacement;
  34106. return this.goto(this.parseBasicString);
  34107. }
  34108. }, {
  34109. key: "parseMultiStringMaybe",
  34110. value: function parseMultiStringMaybe() {
  34111. if (this.char === CHAR_QUOT) {
  34112. return this.next(this.parseMultiString);
  34113. } else {
  34114. return this.returnNow();
  34115. }
  34116. }
  34117. }, {
  34118. key: "parseMultiString",
  34119. value: function parseMultiString() {
  34120. if (this.char === CTRL_M) {
  34121. return null;
  34122. } else if (this.char === CTRL_J) {
  34123. return this.next(this.parseMultiStringContent);
  34124. } else {
  34125. return this.goto(this.parseMultiStringContent);
  34126. }
  34127. }
  34128. }, {
  34129. key: "parseMultiStringContent",
  34130. value: function parseMultiStringContent() {
  34131. do {
  34132. if (this.char === CHAR_BSOL) {
  34133. return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
  34134. } else if (this.char === CHAR_QUOT) {
  34135. return this.next(this.parseMultiEnd);
  34136. } else if (this.char === Parser.END) {
  34137. throw this.error(new TomlError('Unterminated multi-line string'));
  34138. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  34139. throw this.errorControlCharInString();
  34140. } else {
  34141. this.consume();
  34142. }
  34143. } while (this.nextChar());
  34144. }
  34145. }, {
  34146. key: "errorControlCharInString",
  34147. value: function errorControlCharInString() {
  34148. var displayCode = '\\u00';
  34149. if (this.char < 16) {
  34150. displayCode += '0';
  34151. }
  34152. displayCode += this.char.toString(16);
  34153. return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
  34154. }
  34155. }, {
  34156. key: "recordMultiEscapeReplacement",
  34157. value: function recordMultiEscapeReplacement(replacement) {
  34158. this.state.buf += replacement;
  34159. return this.goto(this.parseMultiStringContent);
  34160. }
  34161. }, {
  34162. key: "parseMultiEnd",
  34163. value: function parseMultiEnd() {
  34164. if (this.char === CHAR_QUOT) {
  34165. return this.next(this.parseMultiEnd2);
  34166. } else {
  34167. this.state.buf += '"';
  34168. return this.goto(this.parseMultiStringContent);
  34169. }
  34170. }
  34171. }, {
  34172. key: "parseMultiEnd2",
  34173. value: function parseMultiEnd2() {
  34174. if (this.char === CHAR_QUOT) {
  34175. return this.return();
  34176. } else {
  34177. this.state.buf += '""';
  34178. return this.goto(this.parseMultiStringContent);
  34179. }
  34180. }
  34181. }, {
  34182. key: "parseMultiEscape",
  34183. value: function parseMultiEscape() {
  34184. if (this.char === CTRL_M || this.char === CTRL_J) {
  34185. return this.next(this.parseMultiTrim);
  34186. } else if (this.char === CHAR_SP || this.char === CTRL_I) {
  34187. return this.next(this.parsePreMultiTrim);
  34188. } else {
  34189. return this.goto(this.parseEscape);
  34190. }
  34191. }
  34192. }, {
  34193. key: "parsePreMultiTrim",
  34194. value: function parsePreMultiTrim() {
  34195. if (this.char === CHAR_SP || this.char === CTRL_I) {
  34196. return null;
  34197. } else if (this.char === CTRL_M || this.char === CTRL_J) {
  34198. return this.next(this.parseMultiTrim);
  34199. } else {
  34200. throw this.error(new TomlError("Can't escape whitespace"));
  34201. }
  34202. }
  34203. }, {
  34204. key: "parseMultiTrim",
  34205. value: function parseMultiTrim() {
  34206. // explicitly whitespace here, END should follow the same path as chars
  34207. if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  34208. return null;
  34209. } else {
  34210. return this.returnNow();
  34211. }
  34212. }
  34213. }, {
  34214. key: "parseEscape",
  34215. value: function parseEscape() {
  34216. if (this.char in escapes) {
  34217. return this.return(escapes[this.char]);
  34218. } else if (this.char === CHAR_u) {
  34219. return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
  34220. } else if (this.char === CHAR_U) {
  34221. return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
  34222. } else {
  34223. throw this.error(new TomlError('Unknown escape character: ' + this.char));
  34224. }
  34225. }
  34226. }, {
  34227. key: "parseUnicodeReturn",
  34228. value: function parseUnicodeReturn(char) {
  34229. try {
  34230. var codePoint = parseInt(char, 16);
  34231. if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
  34232. throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
  34233. }
  34234. return this.returnNow(String.fromCodePoint(codePoint));
  34235. } catch (err) {
  34236. throw this.error(TomlError.wrap(err));
  34237. }
  34238. }
  34239. }, {
  34240. key: "parseSmallUnicode",
  34241. value: function parseSmallUnicode() {
  34242. if (!isHexit(this.char)) {
  34243. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  34244. } else {
  34245. this.consume();
  34246. if (this.state.buf.length >= 4) return this.return();
  34247. }
  34248. }
  34249. }, {
  34250. key: "parseLargeUnicode",
  34251. value: function parseLargeUnicode() {
  34252. if (!isHexit(this.char)) {
  34253. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  34254. } else {
  34255. this.consume();
  34256. if (this.state.buf.length >= 8) return this.return();
  34257. }
  34258. }
  34259. /* NUMBERS */
  34260. }, {
  34261. key: "parseNumberSign",
  34262. value: function parseNumberSign() {
  34263. this.consume();
  34264. return this.next(this.parseMaybeSignedInfOrNan);
  34265. }
  34266. }, {
  34267. key: "parseMaybeSignedInfOrNan",
  34268. value: function parseMaybeSignedInfOrNan() {
  34269. if (this.char === CHAR_i) {
  34270. return this.next(this.parseInf);
  34271. } else if (this.char === CHAR_n) {
  34272. return this.next(this.parseNan);
  34273. } else {
  34274. return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
  34275. }
  34276. }
  34277. }, {
  34278. key: "parseNumberIntegerStart",
  34279. value: function parseNumberIntegerStart() {
  34280. if (this.char === CHAR_0) {
  34281. this.consume();
  34282. return this.next(this.parseNumberIntegerExponentOrDecimal);
  34283. } else {
  34284. return this.goto(this.parseNumberInteger);
  34285. }
  34286. }
  34287. }, {
  34288. key: "parseNumberIntegerExponentOrDecimal",
  34289. value: function parseNumberIntegerExponentOrDecimal() {
  34290. if (this.char === CHAR_PERIOD) {
  34291. this.consume();
  34292. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34293. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34294. this.consume();
  34295. return this.next(this.parseNumberExponentSign);
  34296. } else {
  34297. return this.returnNow(Integer(this.state.buf));
  34298. }
  34299. }
  34300. }, {
  34301. key: "parseNumberInteger",
  34302. value: function parseNumberInteger() {
  34303. if (isDigit(this.char)) {
  34304. this.consume();
  34305. } else if (this.char === CHAR_LOWBAR) {
  34306. return this.call(this.parseNoUnder);
  34307. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34308. this.consume();
  34309. return this.next(this.parseNumberExponentSign);
  34310. } else if (this.char === CHAR_PERIOD) {
  34311. this.consume();
  34312. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34313. } else {
  34314. var result = Integer(this.state.buf);
  34315. /* istanbul ignore if */
  34316. if (result.isNaN()) {
  34317. throw this.error(new TomlError('Invalid number'));
  34318. } else {
  34319. return this.returnNow(result);
  34320. }
  34321. }
  34322. }
  34323. }, {
  34324. key: "parseNoUnder",
  34325. value: function parseNoUnder() {
  34326. if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
  34327. throw this.error(new TomlError('Unexpected character, expected digit'));
  34328. } else if (this.atEndOfWord()) {
  34329. throw this.error(new TomlError('Incomplete number'));
  34330. }
  34331. return this.returnNow();
  34332. }
  34333. }, {
  34334. key: "parseNumberFloat",
  34335. value: function parseNumberFloat() {
  34336. if (this.char === CHAR_LOWBAR) {
  34337. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34338. } else if (isDigit(this.char)) {
  34339. this.consume();
  34340. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34341. this.consume();
  34342. return this.next(this.parseNumberExponentSign);
  34343. } else {
  34344. return this.returnNow(Float(this.state.buf));
  34345. }
  34346. }
  34347. }, {
  34348. key: "parseNumberExponentSign",
  34349. value: function parseNumberExponentSign() {
  34350. if (isDigit(this.char)) {
  34351. return this.goto(this.parseNumberExponent);
  34352. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34353. this.consume();
  34354. this.call(this.parseNoUnder, this.parseNumberExponent);
  34355. } else {
  34356. throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
  34357. }
  34358. }
  34359. }, {
  34360. key: "parseNumberExponent",
  34361. value: function parseNumberExponent() {
  34362. if (isDigit(this.char)) {
  34363. this.consume();
  34364. } else if (this.char === CHAR_LOWBAR) {
  34365. return this.call(this.parseNoUnder);
  34366. } else {
  34367. return this.returnNow(Float(this.state.buf));
  34368. }
  34369. }
  34370. /* NUMBERS or DATETIMES */
  34371. }, {
  34372. key: "parseNumberOrDateTime",
  34373. value: function parseNumberOrDateTime() {
  34374. if (this.char === CHAR_0) {
  34375. this.consume();
  34376. return this.next(this.parseNumberBaseOrDateTime);
  34377. } else {
  34378. return this.goto(this.parseNumberOrDateTimeOnly);
  34379. }
  34380. }
  34381. }, {
  34382. key: "parseNumberOrDateTimeOnly",
  34383. value: function parseNumberOrDateTimeOnly() {
  34384. // note, if two zeros are in a row then it MUST be a date
  34385. if (this.char === CHAR_LOWBAR) {
  34386. return this.call(this.parseNoUnder, this.parseNumberInteger);
  34387. } else if (isDigit(this.char)) {
  34388. this.consume();
  34389. if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
  34390. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34391. this.consume();
  34392. return this.next(this.parseNumberExponentSign);
  34393. } else if (this.char === CHAR_PERIOD) {
  34394. this.consume();
  34395. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34396. } else if (this.char === CHAR_HYPHEN) {
  34397. return this.goto(this.parseDateTime);
  34398. } else if (this.char === CHAR_COLON) {
  34399. return this.goto(this.parseOnlyTimeHour);
  34400. } else {
  34401. return this.returnNow(Integer(this.state.buf));
  34402. }
  34403. }
  34404. }, {
  34405. key: "parseDateTimeOnly",
  34406. value: function parseDateTimeOnly() {
  34407. if (this.state.buf.length < 4) {
  34408. if (isDigit(this.char)) {
  34409. return this.consume();
  34410. } else if (this.char === CHAR_COLON) {
  34411. return this.goto(this.parseOnlyTimeHour);
  34412. } else {
  34413. throw this.error(new TomlError('Expected digit while parsing year part of a date'));
  34414. }
  34415. } else {
  34416. if (this.char === CHAR_HYPHEN) {
  34417. return this.goto(this.parseDateTime);
  34418. } else {
  34419. throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
  34420. }
  34421. }
  34422. }
  34423. }, {
  34424. key: "parseNumberBaseOrDateTime",
  34425. value: function parseNumberBaseOrDateTime() {
  34426. if (this.char === CHAR_b) {
  34427. this.consume();
  34428. return this.call(this.parseNoUnder, this.parseIntegerBin);
  34429. } else if (this.char === CHAR_o) {
  34430. this.consume();
  34431. return this.call(this.parseNoUnder, this.parseIntegerOct);
  34432. } else if (this.char === CHAR_x) {
  34433. this.consume();
  34434. return this.call(this.parseNoUnder, this.parseIntegerHex);
  34435. } else if (this.char === CHAR_PERIOD) {
  34436. return this.goto(this.parseNumberInteger);
  34437. } else if (isDigit(this.char)) {
  34438. return this.goto(this.parseDateTimeOnly);
  34439. } else {
  34440. return this.returnNow(Integer(this.state.buf));
  34441. }
  34442. }
  34443. }, {
  34444. key: "parseIntegerHex",
  34445. value: function parseIntegerHex() {
  34446. if (isHexit(this.char)) {
  34447. this.consume();
  34448. } else if (this.char === CHAR_LOWBAR) {
  34449. return this.call(this.parseNoUnder);
  34450. } else {
  34451. var result = Integer(this.state.buf);
  34452. /* istanbul ignore if */
  34453. if (result.isNaN()) {
  34454. throw this.error(new TomlError('Invalid number'));
  34455. } else {
  34456. return this.returnNow(result);
  34457. }
  34458. }
  34459. }
  34460. }, {
  34461. key: "parseIntegerOct",
  34462. value: function parseIntegerOct() {
  34463. if (isOctit(this.char)) {
  34464. this.consume();
  34465. } else if (this.char === CHAR_LOWBAR) {
  34466. return this.call(this.parseNoUnder);
  34467. } else {
  34468. var result = Integer(this.state.buf);
  34469. /* istanbul ignore if */
  34470. if (result.isNaN()) {
  34471. throw this.error(new TomlError('Invalid number'));
  34472. } else {
  34473. return this.returnNow(result);
  34474. }
  34475. }
  34476. }
  34477. }, {
  34478. key: "parseIntegerBin",
  34479. value: function parseIntegerBin() {
  34480. if (isBit(this.char)) {
  34481. this.consume();
  34482. } else if (this.char === CHAR_LOWBAR) {
  34483. return this.call(this.parseNoUnder);
  34484. } else {
  34485. var result = Integer(this.state.buf);
  34486. /* istanbul ignore if */
  34487. if (result.isNaN()) {
  34488. throw this.error(new TomlError('Invalid number'));
  34489. } else {
  34490. return this.returnNow(result);
  34491. }
  34492. }
  34493. }
  34494. /* DATETIME */
  34495. }, {
  34496. key: "parseDateTime",
  34497. value: function parseDateTime() {
  34498. // we enter here having just consumed the year and about to consume the hyphen
  34499. if (this.state.buf.length < 4) {
  34500. throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
  34501. }
  34502. this.state.result = this.state.buf;
  34503. this.state.buf = '';
  34504. return this.next(this.parseDateMonth);
  34505. }
  34506. }, {
  34507. key: "parseDateMonth",
  34508. value: function parseDateMonth() {
  34509. if (this.char === CHAR_HYPHEN) {
  34510. if (this.state.buf.length < 2) {
  34511. throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
  34512. }
  34513. this.state.result += '-' + this.state.buf;
  34514. this.state.buf = '';
  34515. return this.next(this.parseDateDay);
  34516. } else if (isDigit(this.char)) {
  34517. this.consume();
  34518. } else {
  34519. throw this.error(new TomlError('Incomplete datetime'));
  34520. }
  34521. }
  34522. }, {
  34523. key: "parseDateDay",
  34524. value: function parseDateDay() {
  34525. if (this.char === CHAR_T || this.char === CHAR_SP) {
  34526. if (this.state.buf.length < 2) {
  34527. throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
  34528. }
  34529. this.state.result += '-' + this.state.buf;
  34530. this.state.buf = '';
  34531. return this.next(this.parseStartTimeHour);
  34532. } else if (this.atEndOfWord()) {
  34533. return this.return(createDate(this.state.result + '-' + this.state.buf));
  34534. } else if (isDigit(this.char)) {
  34535. this.consume();
  34536. } else {
  34537. throw this.error(new TomlError('Incomplete datetime'));
  34538. }
  34539. }
  34540. }, {
  34541. key: "parseStartTimeHour",
  34542. value: function parseStartTimeHour() {
  34543. if (this.atEndOfWord()) {
  34544. return this.returnNow(createDate(this.state.result));
  34545. } else {
  34546. return this.goto(this.parseTimeHour);
  34547. }
  34548. }
  34549. }, {
  34550. key: "parseTimeHour",
  34551. value: function parseTimeHour() {
  34552. if (this.char === CHAR_COLON) {
  34553. if (this.state.buf.length < 2) {
  34554. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  34555. }
  34556. this.state.result += 'T' + this.state.buf;
  34557. this.state.buf = '';
  34558. return this.next(this.parseTimeMin);
  34559. } else if (isDigit(this.char)) {
  34560. this.consume();
  34561. } else {
  34562. throw this.error(new TomlError('Incomplete datetime'));
  34563. }
  34564. }
  34565. }, {
  34566. key: "parseTimeMin",
  34567. value: function parseTimeMin() {
  34568. if (this.state.buf.length < 2 && isDigit(this.char)) {
  34569. this.consume();
  34570. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  34571. this.state.result += ':' + this.state.buf;
  34572. this.state.buf = '';
  34573. return this.next(this.parseTimeSec);
  34574. } else {
  34575. throw this.error(new TomlError('Incomplete datetime'));
  34576. }
  34577. }
  34578. }, {
  34579. key: "parseTimeSec",
  34580. value: function parseTimeSec() {
  34581. if (isDigit(this.char)) {
  34582. this.consume();
  34583. if (this.state.buf.length === 2) {
  34584. this.state.result += ':' + this.state.buf;
  34585. this.state.buf = '';
  34586. return this.next(this.parseTimeZoneOrFraction);
  34587. }
  34588. } else {
  34589. throw this.error(new TomlError('Incomplete datetime'));
  34590. }
  34591. }
  34592. }, {
  34593. key: "parseOnlyTimeHour",
  34594. value: function parseOnlyTimeHour() {
  34595. /* istanbul ignore else */
  34596. if (this.char === CHAR_COLON) {
  34597. if (this.state.buf.length < 2) {
  34598. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  34599. }
  34600. this.state.result = this.state.buf;
  34601. this.state.buf = '';
  34602. return this.next(this.parseOnlyTimeMin);
  34603. } else {
  34604. throw this.error(new TomlError('Incomplete time'));
  34605. }
  34606. }
  34607. }, {
  34608. key: "parseOnlyTimeMin",
  34609. value: function parseOnlyTimeMin() {
  34610. if (this.state.buf.length < 2 && isDigit(this.char)) {
  34611. this.consume();
  34612. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  34613. this.state.result += ':' + this.state.buf;
  34614. this.state.buf = '';
  34615. return this.next(this.parseOnlyTimeSec);
  34616. } else {
  34617. throw this.error(new TomlError('Incomplete time'));
  34618. }
  34619. }
  34620. }, {
  34621. key: "parseOnlyTimeSec",
  34622. value: function parseOnlyTimeSec() {
  34623. if (isDigit(this.char)) {
  34624. this.consume();
  34625. if (this.state.buf.length === 2) {
  34626. return this.next(this.parseOnlyTimeFractionMaybe);
  34627. }
  34628. } else {
  34629. throw this.error(new TomlError('Incomplete time'));
  34630. }
  34631. }
  34632. }, {
  34633. key: "parseOnlyTimeFractionMaybe",
  34634. value: function parseOnlyTimeFractionMaybe() {
  34635. this.state.result += ':' + this.state.buf;
  34636. if (this.char === CHAR_PERIOD) {
  34637. this.state.buf = '';
  34638. this.next(this.parseOnlyTimeFraction);
  34639. } else {
  34640. return this.return(createTime(this.state.result));
  34641. }
  34642. }
  34643. }, {
  34644. key: "parseOnlyTimeFraction",
  34645. value: function parseOnlyTimeFraction() {
  34646. if (isDigit(this.char)) {
  34647. this.consume();
  34648. } else if (this.atEndOfWord()) {
  34649. if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
  34650. return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
  34651. } else {
  34652. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34653. }
  34654. }
  34655. }, {
  34656. key: "parseTimeZoneOrFraction",
  34657. value: function parseTimeZoneOrFraction() {
  34658. if (this.char === CHAR_PERIOD) {
  34659. this.consume();
  34660. this.next(this.parseDateTimeFraction);
  34661. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34662. this.consume();
  34663. this.next(this.parseTimeZoneHour);
  34664. } else if (this.char === CHAR_Z) {
  34665. this.consume();
  34666. return this.return(createDatetime(this.state.result + this.state.buf));
  34667. } else if (this.atEndOfWord()) {
  34668. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  34669. } else {
  34670. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34671. }
  34672. }
  34673. }, {
  34674. key: "parseDateTimeFraction",
  34675. value: function parseDateTimeFraction() {
  34676. if (isDigit(this.char)) {
  34677. this.consume();
  34678. } else if (this.state.buf.length === 1) {
  34679. throw this.error(new TomlError('Expected digit in milliseconds'));
  34680. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34681. this.consume();
  34682. this.next(this.parseTimeZoneHour);
  34683. } else if (this.char === CHAR_Z) {
  34684. this.consume();
  34685. return this.return(createDatetime(this.state.result + this.state.buf));
  34686. } else if (this.atEndOfWord()) {
  34687. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  34688. } else {
  34689. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34690. }
  34691. }
  34692. }, {
  34693. key: "parseTimeZoneHour",
  34694. value: function parseTimeZoneHour() {
  34695. if (isDigit(this.char)) {
  34696. this.consume(); // FIXME: No more regexps
  34697. if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
  34698. } else {
  34699. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  34700. }
  34701. }
  34702. }, {
  34703. key: "parseTimeZoneSep",
  34704. value: function parseTimeZoneSep() {
  34705. if (this.char === CHAR_COLON) {
  34706. this.consume();
  34707. this.next(this.parseTimeZoneMin);
  34708. } else {
  34709. throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
  34710. }
  34711. }
  34712. }, {
  34713. key: "parseTimeZoneMin",
  34714. value: function parseTimeZoneMin() {
  34715. if (isDigit(this.char)) {
  34716. this.consume();
  34717. if (/\d\d$/.test(this.state.buf)) return this.return(createDatetime(this.state.result + this.state.buf));
  34718. } else {
  34719. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  34720. }
  34721. }
  34722. /* BOOLEAN */
  34723. }, {
  34724. key: "parseBoolean",
  34725. value: function parseBoolean() {
  34726. /* istanbul ignore else */
  34727. if (this.char === CHAR_t) {
  34728. this.consume();
  34729. return this.next(this.parseTrue_r);
  34730. } else if (this.char === CHAR_f) {
  34731. this.consume();
  34732. return this.next(this.parseFalse_a);
  34733. }
  34734. }
  34735. }, {
  34736. key: "parseTrue_r",
  34737. value: function parseTrue_r() {
  34738. if (this.char === CHAR_r) {
  34739. this.consume();
  34740. return this.next(this.parseTrue_u);
  34741. } else {
  34742. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34743. }
  34744. }
  34745. }, {
  34746. key: "parseTrue_u",
  34747. value: function parseTrue_u() {
  34748. if (this.char === CHAR_u) {
  34749. this.consume();
  34750. return this.next(this.parseTrue_e);
  34751. } else {
  34752. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34753. }
  34754. }
  34755. }, {
  34756. key: "parseTrue_e",
  34757. value: function parseTrue_e() {
  34758. if (this.char === CHAR_e) {
  34759. return this.return(true);
  34760. } else {
  34761. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34762. }
  34763. }
  34764. }, {
  34765. key: "parseFalse_a",
  34766. value: function parseFalse_a() {
  34767. if (this.char === CHAR_a) {
  34768. this.consume();
  34769. return this.next(this.parseFalse_l);
  34770. } else {
  34771. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34772. }
  34773. }
  34774. }, {
  34775. key: "parseFalse_l",
  34776. value: function parseFalse_l() {
  34777. if (this.char === CHAR_l) {
  34778. this.consume();
  34779. return this.next(this.parseFalse_s);
  34780. } else {
  34781. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34782. }
  34783. }
  34784. }, {
  34785. key: "parseFalse_s",
  34786. value: function parseFalse_s() {
  34787. if (this.char === CHAR_s) {
  34788. this.consume();
  34789. return this.next(this.parseFalse_e);
  34790. } else {
  34791. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34792. }
  34793. }
  34794. }, {
  34795. key: "parseFalse_e",
  34796. value: function parseFalse_e() {
  34797. if (this.char === CHAR_e) {
  34798. return this.return(false);
  34799. } else {
  34800. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34801. }
  34802. }
  34803. /* INLINE LISTS */
  34804. }, {
  34805. key: "parseInlineList",
  34806. value: function parseInlineList() {
  34807. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  34808. return null;
  34809. } else if (this.char === Parser.END) {
  34810. throw this.error(new TomlError('Unterminated inline array'));
  34811. } else if (this.char === CHAR_NUM) {
  34812. return this.call(this.parseComment);
  34813. } else if (this.char === CHAR_RSQB) {
  34814. return this.return(this.state.resultArr || InlineList());
  34815. } else {
  34816. return this.callNow(this.parseValue, this.recordInlineListValue);
  34817. }
  34818. }
  34819. }, {
  34820. key: "recordInlineListValue",
  34821. value: function recordInlineListValue(value) {
  34822. if (this.state.resultArr) {
  34823. var listType = this.state.resultArr[_contentType];
  34824. var valueType = tomlType(value);
  34825. if (listType !== valueType) {
  34826. throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
  34827. }
  34828. } else {
  34829. this.state.resultArr = InlineList(tomlType(value));
  34830. }
  34831. if (isFloat(value) || isInteger(value)) {
  34832. // unbox now that we've verified they're ok
  34833. this.state.resultArr.push(value.valueOf());
  34834. } else {
  34835. this.state.resultArr.push(value);
  34836. }
  34837. return this.goto(this.parseInlineListNext);
  34838. }
  34839. }, {
  34840. key: "parseInlineListNext",
  34841. value: function parseInlineListNext() {
  34842. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  34843. return null;
  34844. } else if (this.char === CHAR_NUM) {
  34845. return this.call(this.parseComment);
  34846. } else if (this.char === CHAR_COMMA) {
  34847. return this.next(this.parseInlineList);
  34848. } else if (this.char === CHAR_RSQB) {
  34849. return this.goto(this.parseInlineList);
  34850. } else {
  34851. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  34852. }
  34853. }
  34854. /* INLINE TABLE */
  34855. }, {
  34856. key: "parseInlineTable",
  34857. value: function parseInlineTable() {
  34858. if (this.char === CHAR_SP || this.char === CTRL_I) {
  34859. return null;
  34860. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  34861. throw this.error(new TomlError('Unterminated inline array'));
  34862. } else if (this.char === CHAR_RCUB) {
  34863. return this.return(this.state.resultTable || InlineTable());
  34864. } else {
  34865. if (!this.state.resultTable) this.state.resultTable = InlineTable();
  34866. return this.callNow(this.parseAssign, this.recordInlineTableValue);
  34867. }
  34868. }
  34869. }, {
  34870. key: "recordInlineTableValue",
  34871. value: function recordInlineTableValue(kv) {
  34872. var target = this.state.resultTable;
  34873. var finalKey = kv.key.pop();
  34874. var _iteratorNormalCompletion2 = true;
  34875. var _didIteratorError2 = false;
  34876. var _iteratorError2 = undefined;
  34877. try {
  34878. for (var _iterator2 = kv.key[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  34879. var kw = _step2.value;
  34880. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  34881. throw this.error(new TomlError("Can't redefine existing key"));
  34882. }
  34883. target = target[kw] = target[kw] || Table();
  34884. }
  34885. } catch (err) {
  34886. _didIteratorError2 = true;
  34887. _iteratorError2 = err;
  34888. } finally {
  34889. try {
  34890. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  34891. _iterator2.return();
  34892. }
  34893. } finally {
  34894. if (_didIteratorError2) {
  34895. throw _iteratorError2;
  34896. }
  34897. }
  34898. }
  34899. if (hasKey(target, finalKey)) {
  34900. throw this.error(new TomlError("Can't redefine existing key"));
  34901. }
  34902. if (isInteger(kv.value) || isFloat(kv.value)) {
  34903. target[finalKey] = kv.value.valueOf();
  34904. } else {
  34905. target[finalKey] = kv.value;
  34906. }
  34907. return this.goto(this.parseInlineTableNext);
  34908. }
  34909. }, {
  34910. key: "parseInlineTableNext",
  34911. value: function parseInlineTableNext() {
  34912. if (this.char === CHAR_SP || this.char === CTRL_I) {
  34913. return null;
  34914. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  34915. throw this.error(new TomlError('Unterminated inline array'));
  34916. } else if (this.char === CHAR_COMMA) {
  34917. return this.next(this.parseInlineTable);
  34918. } else if (this.char === CHAR_RCUB) {
  34919. return this.goto(this.parseInlineTable);
  34920. } else {
  34921. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  34922. }
  34923. }
  34924. }]);
  34925. return TOMLParser;
  34926. }(Parser);
  34927. return TOMLParser;
  34928. }
  34929. });
  34930. var parsePrettyError = prettyError;
  34931. function prettyError(err, buf) {
  34932. /* istanbul ignore if */
  34933. if (err.pos == null || err.line == null) return err;
  34934. var msg = err.message;
  34935. msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
  34936. /* istanbul ignore else */
  34937. if (buf && buf.split) {
  34938. var lines = buf.split(/\n/);
  34939. var lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
  34940. var linePadding = ' ';
  34941. while (linePadding.length < lineNumWidth) {
  34942. linePadding += ' ';
  34943. }
  34944. for (var ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
  34945. var lineNum = String(ii + 1);
  34946. if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
  34947. if (err.line === ii) {
  34948. msg += lineNum + '> ' + lines[ii] + '\n';
  34949. msg += linePadding + ' ';
  34950. for (var hh = 0; hh < err.col; ++hh) {
  34951. msg += ' ';
  34952. }
  34953. msg += '^\n';
  34954. } else {
  34955. msg += lineNum + ': ' + lines[ii] + '\n';
  34956. }
  34957. }
  34958. }
  34959. err.message = msg + '\n';
  34960. return err;
  34961. }
  34962. var parseString_1 = parseString;
  34963. function parseString(str) {
  34964. if (global.Buffer && global.Buffer.isBuffer(str)) {
  34965. str = str.toString('utf8');
  34966. }
  34967. var parser = new tomlParser();
  34968. try {
  34969. parser.parse(str);
  34970. return parser.finish();
  34971. } catch (err) {
  34972. throw parsePrettyError(err, str);
  34973. }
  34974. }
  34975. var loadToml = function loadToml(filePath, content) {
  34976. try {
  34977. return parseString_1(content);
  34978. } catch (error) {
  34979. error.message = `TOML Error in ${filePath}:\n${error.message}`;
  34980. throw error;
  34981. }
  34982. };
  34983. var resolveConfig_1 = createCommonjsModule(function (module) {
  34984. "use strict";
  34985. var getExplorerMemoized = mem(function (opts) {
  34986. var explorer = thirdParty$1.cosmiconfig("prettier", {
  34987. cache: opts.cache,
  34988. transform: function transform(result) {
  34989. if (result && result.config) {
  34990. if (typeof result.config === "string") {
  34991. var modulePath = resolve$1.sync(result.config, {
  34992. basedir: path.dirname(result.filepath)
  34993. });
  34994. result.config = require(modulePath);
  34995. }
  34996. if (typeof result.config !== "object") {
  34997. throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
  34998. }
  34999. delete result.config.$schema;
  35000. }
  35001. return result;
  35002. },
  35003. searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.js", "prettier.config.js", ".prettierrc.toml"],
  35004. loaders: {
  35005. ".toml": loadToml
  35006. }
  35007. });
  35008. var _load = opts.sync ? explorer.loadSync : explorer.load;
  35009. var search = opts.sync ? explorer.searchSync : explorer.search;
  35010. return {
  35011. // cosmiconfig v4 interface
  35012. load: function load(searchPath, configPath) {
  35013. return configPath ? _load(configPath) : search(searchPath);
  35014. }
  35015. };
  35016. });
  35017. /** @param {{ cache: boolean, sync: boolean }} opts */
  35018. function getLoadFunction(opts) {
  35019. // Normalize opts before passing to a memoized function
  35020. opts = Object.assign({
  35021. sync: false,
  35022. cache: false
  35023. }, opts);
  35024. return getExplorerMemoized(opts).load;
  35025. }
  35026. function _resolveConfig(filePath, opts, sync) {
  35027. opts = Object.assign({
  35028. useCache: true
  35029. }, opts);
  35030. var loadOpts = {
  35031. cache: !!opts.useCache,
  35032. sync: !!sync,
  35033. editorconfig: !!opts.editorconfig
  35034. };
  35035. var load = getLoadFunction(loadOpts);
  35036. var loadEditorConfig = resolveConfigEditorconfig.getLoadFunction(loadOpts);
  35037. var arr = [load, loadEditorConfig].map(function (l) {
  35038. return l(filePath, opts.config);
  35039. });
  35040. var unwrapAndMerge = function unwrapAndMerge(arr) {
  35041. var result = arr[0];
  35042. var editorConfigured = arr[1];
  35043. var merged = Object.assign({}, editorConfigured, mergeOverrides(Object.assign({}, result), filePath));
  35044. ["plugins", "pluginSearchDirs"].forEach(function (optionName) {
  35045. if (Array.isArray(merged[optionName])) {
  35046. merged[optionName] = merged[optionName].map(function (value) {
  35047. return typeof value === "string" && value.startsWith(".") // relative path
  35048. ? path.resolve(path.dirname(result.filepath), value) : value;
  35049. });
  35050. }
  35051. });
  35052. if (!result && !editorConfigured) {
  35053. return null;
  35054. }
  35055. return merged;
  35056. };
  35057. if (loadOpts.sync) {
  35058. return unwrapAndMerge(arr);
  35059. }
  35060. return Promise.all(arr).then(unwrapAndMerge);
  35061. }
  35062. var resolveConfig = function resolveConfig(filePath, opts) {
  35063. return _resolveConfig(filePath, opts, false);
  35064. };
  35065. resolveConfig.sync = function (filePath, opts) {
  35066. return _resolveConfig(filePath, opts, true);
  35067. };
  35068. function clearCache() {
  35069. mem.clear(getExplorerMemoized);
  35070. resolveConfigEditorconfig.clearCache();
  35071. }
  35072. function resolveConfigFile(filePath) {
  35073. var load = getLoadFunction({
  35074. sync: false
  35075. });
  35076. return load(filePath).then(function (result) {
  35077. return result ? result.filepath : null;
  35078. });
  35079. }
  35080. resolveConfigFile.sync = function (filePath) {
  35081. var load = getLoadFunction({
  35082. sync: true
  35083. });
  35084. var result = load(filePath);
  35085. return result ? result.filepath : null;
  35086. };
  35087. function mergeOverrides(configResult, filePath) {
  35088. var options = Object.assign({}, configResult.config);
  35089. if (filePath && options.overrides) {
  35090. var relativeFilePath = path.relative(path.dirname(configResult.filepath), filePath);
  35091. var _iteratorNormalCompletion = true;
  35092. var _didIteratorError = false;
  35093. var _iteratorError = undefined;
  35094. try {
  35095. for (var _iterator = options.overrides[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  35096. var override = _step.value;
  35097. if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
  35098. Object.assign(options, override.options);
  35099. }
  35100. }
  35101. } catch (err) {
  35102. _didIteratorError = true;
  35103. _iteratorError = err;
  35104. } finally {
  35105. try {
  35106. if (!_iteratorNormalCompletion && _iterator.return != null) {
  35107. _iterator.return();
  35108. }
  35109. } finally {
  35110. if (_didIteratorError) {
  35111. throw _iteratorError;
  35112. }
  35113. }
  35114. }
  35115. }
  35116. delete options.overrides;
  35117. return options;
  35118. } // Based on eslint: https://github.com/eslint/eslint/blob/master/lib/config/config-ops.js
  35119. function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
  35120. var patternList = [].concat(patterns);
  35121. var excludedPatternList = [].concat(excludedPatterns || []);
  35122. var opts = {
  35123. matchBase: true,
  35124. dot: true
  35125. };
  35126. return patternList.some(function (pattern) {
  35127. return minimatch_1(filePath, pattern, opts);
  35128. }) && !excludedPatternList.some(function (excludedPattern) {
  35129. return minimatch_1(filePath, excludedPattern, opts);
  35130. });
  35131. }
  35132. module.exports = {
  35133. resolveConfig,
  35134. resolveConfigFile,
  35135. clearCache
  35136. };
  35137. });
  35138. var version = require$$0.version;
  35139. var getSupportInfo = support.getSupportInfo; // Luckily `opts` is always the 2nd argument
  35140. function _withPlugins(fn) {
  35141. return function () {
  35142. var args = Array.from(arguments);
  35143. var opts = args[1] || {};
  35144. args[1] = Object.assign({}, opts, {
  35145. plugins: loadPlugins_1(opts.plugins, opts.pluginSearchDirs)
  35146. });
  35147. return fn.apply(null, args);
  35148. };
  35149. }
  35150. function withPlugins(fn) {
  35151. var resultingFn = _withPlugins(fn);
  35152. if (fn.sync) {
  35153. resultingFn.sync = _withPlugins(fn.sync);
  35154. }
  35155. return resultingFn;
  35156. }
  35157. var formatWithCursor = withPlugins(core.formatWithCursor);
  35158. var src = {
  35159. formatWithCursor,
  35160. format(text, opts) {
  35161. return formatWithCursor(text, opts).formatted;
  35162. },
  35163. check: function check(text, opts) {
  35164. var formatted = formatWithCursor(text, opts).formatted;
  35165. return formatted === text;
  35166. },
  35167. doc,
  35168. resolveConfig: resolveConfig_1.resolveConfig,
  35169. resolveConfigFile: resolveConfig_1.resolveConfigFile,
  35170. clearConfigCache: resolveConfig_1.clearCache,
  35171. getFileInfo: withPlugins(getFileInfo_1),
  35172. getSupportInfo: withPlugins(getSupportInfo),
  35173. version,
  35174. util: utilShared,
  35175. /* istanbul ignore next */
  35176. __debug: {
  35177. parse: withPlugins(core.parse),
  35178. formatAST: withPlugins(core.formatAST),
  35179. formatDoc: withPlugins(core.formatDoc),
  35180. printToDoc: withPlugins(core.printToDoc),
  35181. printDocToString: withPlugins(core.printDocToString)
  35182. }
  35183. };
  35184. var prettier = src;
  35185. module.exports = prettier;