index.js 1.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027
  1. 'use strict';
  2. var require$$0$6 = require('fs');
  3. var require$$0$8 = require('path');
  4. var require$$0$7 = require('os');
  5. var require$$1$3 = require('tty');
  6. var require$$0$9 = require('assert');
  7. var require$$0$a = require('util');
  8. var require$$0$b = require('stream');
  9. var require$$0$c = require('events');
  10. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  11. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
  12. var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
  13. var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
  14. var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
  15. var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
  16. var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
  17. var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$b);
  18. var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$c);
  19. function getDefaultExportFromNamespaceIfPresent (n) {
  20. return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
  21. }
  22. var require$$0$5 = require("./package.json");
  23. var lib$6 = {};
  24. var base$1 = {};
  25. /*istanbul ignore start*/
  26. (function (exports) {
  27. Object.defineProperty(exports, "__esModule", {
  28. value: true
  29. });
  30. exports["default"] = Diff;
  31. /*istanbul ignore end*/
  32. function Diff() {}
  33. Diff.prototype = {
  34. /*istanbul ignore start*/
  35. /*istanbul ignore end*/
  36. diff: function diff(oldString, newString) {
  37. /*istanbul ignore start*/
  38. var
  39. /*istanbul ignore end*/
  40. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  41. var callback = options.callback;
  42. if (typeof options === 'function') {
  43. callback = options;
  44. options = {};
  45. }
  46. this.options = options;
  47. var self = this;
  48. function done(value) {
  49. if (callback) {
  50. setTimeout(function () {
  51. callback(undefined, value);
  52. }, 0);
  53. return true;
  54. } else {
  55. return value;
  56. }
  57. } // Allow subclasses to massage the input prior to running
  58. oldString = this.castInput(oldString);
  59. newString = this.castInput(newString);
  60. oldString = this.removeEmpty(this.tokenize(oldString));
  61. newString = this.removeEmpty(this.tokenize(newString));
  62. var newLen = newString.length,
  63. oldLen = oldString.length;
  64. var editLength = 1;
  65. var maxEditLength = newLen + oldLen;
  66. var bestPath = [{
  67. newPos: -1,
  68. components: []
  69. }]; // Seed editLength = 0, i.e. the content starts with the same values
  70. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  71. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  72. // Identity per the equality and tokenizer
  73. return done([{
  74. value: this.join(newString),
  75. count: newString.length
  76. }]);
  77. } // Main worker method. checks all permutations of a given edit length for acceptance.
  78. function execEditLength() {
  79. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  80. var basePath =
  81. /*istanbul ignore start*/
  82. void 0
  83. /*istanbul ignore end*/
  84. ;
  85. var addPath = bestPath[diagonalPath - 1],
  86. removePath = bestPath[diagonalPath + 1],
  87. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  88. if (addPath) {
  89. // No one else is going to attempt to use this value, clear it
  90. bestPath[diagonalPath - 1] = undefined;
  91. }
  92. var canAdd = addPath && addPath.newPos + 1 < newLen,
  93. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  94. if (!canAdd && !canRemove) {
  95. // If this path is a terminal then prune
  96. bestPath[diagonalPath] = undefined;
  97. continue;
  98. } // Select the diagonal that we want to branch from. We select the prior
  99. // path whose position in the new string is the farthest from the origin
  100. // and does not pass the bounds of the diff graph
  101. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  102. basePath = clonePath(removePath);
  103. self.pushComponent(basePath.components, undefined, true);
  104. } else {
  105. basePath = addPath; // No need to clone, we've pulled it from the list
  106. basePath.newPos++;
  107. self.pushComponent(basePath.components, true, undefined);
  108. }
  109. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  110. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  111. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  112. } else {
  113. // Otherwise track this path as a potential candidate and continue.
  114. bestPath[diagonalPath] = basePath;
  115. }
  116. }
  117. editLength++;
  118. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  119. // sync and async mode which is never fun. Loops over execEditLength until a value
  120. // is produced.
  121. if (callback) {
  122. (function exec() {
  123. setTimeout(function () {
  124. // This should not happen, but we want to be safe.
  125. /* istanbul ignore next */
  126. if (editLength > maxEditLength) {
  127. return callback();
  128. }
  129. if (!execEditLength()) {
  130. exec();
  131. }
  132. }, 0);
  133. })();
  134. } else {
  135. while (editLength <= maxEditLength) {
  136. var ret = execEditLength();
  137. if (ret) {
  138. return ret;
  139. }
  140. }
  141. }
  142. },
  143. /*istanbul ignore start*/
  144. /*istanbul ignore end*/
  145. pushComponent: function pushComponent(components, added, removed) {
  146. var last = components[components.length - 1];
  147. if (last && last.added === added && last.removed === removed) {
  148. // We need to clone here as the component clone operation is just
  149. // as shallow array clone
  150. components[components.length - 1] = {
  151. count: last.count + 1,
  152. added: added,
  153. removed: removed
  154. };
  155. } else {
  156. components.push({
  157. count: 1,
  158. added: added,
  159. removed: removed
  160. });
  161. }
  162. },
  163. /*istanbul ignore start*/
  164. /*istanbul ignore end*/
  165. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  166. var newLen = newString.length,
  167. oldLen = oldString.length,
  168. newPos = basePath.newPos,
  169. oldPos = newPos - diagonalPath,
  170. commonCount = 0;
  171. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  172. newPos++;
  173. oldPos++;
  174. commonCount++;
  175. }
  176. if (commonCount) {
  177. basePath.components.push({
  178. count: commonCount
  179. });
  180. }
  181. basePath.newPos = newPos;
  182. return oldPos;
  183. },
  184. /*istanbul ignore start*/
  185. /*istanbul ignore end*/
  186. equals: function equals(left, right) {
  187. if (this.options.comparator) {
  188. return this.options.comparator(left, right);
  189. } else {
  190. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  191. }
  192. },
  193. /*istanbul ignore start*/
  194. /*istanbul ignore end*/
  195. removeEmpty: function removeEmpty(array) {
  196. var ret = [];
  197. for (var i = 0; i < array.length; i++) {
  198. if (array[i]) {
  199. ret.push(array[i]);
  200. }
  201. }
  202. return ret;
  203. },
  204. /*istanbul ignore start*/
  205. /*istanbul ignore end*/
  206. castInput: function castInput(value) {
  207. return value;
  208. },
  209. /*istanbul ignore start*/
  210. /*istanbul ignore end*/
  211. tokenize: function tokenize(value) {
  212. return value.split('');
  213. },
  214. /*istanbul ignore start*/
  215. /*istanbul ignore end*/
  216. join: function join(chars) {
  217. return chars.join('');
  218. }
  219. };
  220. function buildValues(diff, components, newString, oldString, useLongestToken) {
  221. var componentPos = 0,
  222. componentLen = components.length,
  223. newPos = 0,
  224. oldPos = 0;
  225. for (; componentPos < componentLen; componentPos++) {
  226. var component = components[componentPos];
  227. if (!component.removed) {
  228. if (!component.added && useLongestToken) {
  229. var value = newString.slice(newPos, newPos + component.count);
  230. value = value.map(function (value, i) {
  231. var oldValue = oldString[oldPos + i];
  232. return oldValue.length > value.length ? oldValue : value;
  233. });
  234. component.value = diff.join(value);
  235. } else {
  236. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  237. }
  238. newPos += component.count; // Common case
  239. if (!component.added) {
  240. oldPos += component.count;
  241. }
  242. } else {
  243. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  244. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  245. // The diffing algorithm is tied to add then remove output and this is the simplest
  246. // route to get the desired output with minimal overhead.
  247. if (componentPos && components[componentPos - 1].added) {
  248. var tmp = components[componentPos - 1];
  249. components[componentPos - 1] = components[componentPos];
  250. components[componentPos] = tmp;
  251. }
  252. }
  253. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  254. // For this case we merge the terminal into the prior string and drop the change.
  255. // This is only available for string mode.
  256. var lastComponent = components[componentLen - 1];
  257. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  258. components[componentLen - 2].value += lastComponent.value;
  259. components.pop();
  260. }
  261. return components;
  262. }
  263. function clonePath(path) {
  264. return {
  265. newPos: path.newPos,
  266. components: path.components.slice(0)
  267. };
  268. }
  269. })(base$1);
  270. var character = {};
  271. /*istanbul ignore start*/
  272. Object.defineProperty(character, "__esModule", {
  273. value: true
  274. });
  275. character.diffChars = diffChars;
  276. character.characterDiff = void 0;
  277. /*istanbul ignore end*/
  278. var
  279. /*istanbul ignore start*/
  280. _base$6 = _interopRequireDefault$8(base$1)
  281. /*istanbul ignore end*/
  282. ;
  283. /*istanbul ignore start*/
  284. function _interopRequireDefault$8(obj) {
  285. return obj && obj.__esModule ? obj : {
  286. "default": obj
  287. };
  288. }
  289. /*istanbul ignore end*/
  290. var characterDiff = new
  291. /*istanbul ignore start*/
  292. _base$6
  293. /*istanbul ignore end*/
  294. [
  295. /*istanbul ignore start*/
  296. "default"
  297. /*istanbul ignore end*/
  298. ]();
  299. /*istanbul ignore start*/
  300. character.characterDiff = characterDiff;
  301. /*istanbul ignore end*/
  302. function diffChars(oldStr, newStr, options) {
  303. return characterDiff.diff(oldStr, newStr, options);
  304. }
  305. var word = {};
  306. var params = {};
  307. /*istanbul ignore start*/
  308. Object.defineProperty(params, "__esModule", {
  309. value: true
  310. });
  311. params.generateOptions = generateOptions;
  312. /*istanbul ignore end*/
  313. function generateOptions(options, defaults) {
  314. if (typeof options === 'function') {
  315. defaults.callback = options;
  316. } else if (options) {
  317. for (var name in options) {
  318. /* istanbul ignore else */
  319. if (options.hasOwnProperty(name)) {
  320. defaults[name] = options[name];
  321. }
  322. }
  323. }
  324. return defaults;
  325. }
  326. /*istanbul ignore start*/
  327. Object.defineProperty(word, "__esModule", {
  328. value: true
  329. });
  330. word.diffWords = diffWords;
  331. word.diffWordsWithSpace = diffWordsWithSpace;
  332. word.wordDiff = void 0;
  333. /*istanbul ignore end*/
  334. var
  335. /*istanbul ignore start*/
  336. _base$5 = _interopRequireDefault$7(base$1)
  337. /*istanbul ignore end*/
  338. ;
  339. var
  340. /*istanbul ignore start*/
  341. _params$1 = params
  342. /*istanbul ignore end*/
  343. ;
  344. /*istanbul ignore start*/
  345. function _interopRequireDefault$7(obj) {
  346. return obj && obj.__esModule ? obj : {
  347. "default": obj
  348. };
  349. }
  350. /*istanbul ignore end*/
  351. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  352. //
  353. // Ranges and exceptions:
  354. // Latin-1 Supplement, 0080–00FF
  355. // - U+00D7 × Multiplication sign
  356. // - U+00F7 ÷ Division sign
  357. // Latin Extended-A, 0100–017F
  358. // Latin Extended-B, 0180–024F
  359. // IPA Extensions, 0250–02AF
  360. // Spacing Modifier Letters, 02B0–02FF
  361. // - U+02C7 ˇ &#711; Caron
  362. // - U+02D8 ˘ &#728; Breve
  363. // - U+02D9 ˙ &#729; Dot Above
  364. // - U+02DA ˚ &#730; Ring Above
  365. // - U+02DB ˛ &#731; Ogonek
  366. // - U+02DC ˜ &#732; Small Tilde
  367. // - U+02DD ˝ &#733; Double Acute Accent
  368. // Latin Extended Additional, 1E00–1EFF
  369. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  370. var reWhitespace = /\S/;
  371. var wordDiff = new
  372. /*istanbul ignore start*/
  373. _base$5
  374. /*istanbul ignore end*/
  375. [
  376. /*istanbul ignore start*/
  377. "default"
  378. /*istanbul ignore end*/
  379. ]();
  380. /*istanbul ignore start*/
  381. word.wordDiff = wordDiff;
  382. /*istanbul ignore end*/
  383. wordDiff.equals = function (left, right) {
  384. if (this.options.ignoreCase) {
  385. left = left.toLowerCase();
  386. right = right.toLowerCase();
  387. }
  388. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  389. };
  390. wordDiff.tokenize = function (value) {
  391. // All whitespace symbols except newline group into one token, each newline - in separate token
  392. var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  393. for (var i = 0; i < tokens.length - 1; i++) {
  394. // If we have an empty string in the next field and we have only word chars before and after, merge
  395. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  396. tokens[i] += tokens[i + 2];
  397. tokens.splice(i + 1, 2);
  398. i--;
  399. }
  400. }
  401. return tokens;
  402. };
  403. function diffWords(oldStr, newStr, options) {
  404. options =
  405. /*istanbul ignore start*/
  406. (/*istanbul ignore end*/
  407. /*istanbul ignore start*/
  408. 0, _params$1
  409. /*istanbul ignore end*/
  410. .
  411. /*istanbul ignore start*/
  412. generateOptions
  413. /*istanbul ignore end*/
  414. )(options, {
  415. ignoreWhitespace: true
  416. });
  417. return wordDiff.diff(oldStr, newStr, options);
  418. }
  419. function diffWordsWithSpace(oldStr, newStr, options) {
  420. return wordDiff.diff(oldStr, newStr, options);
  421. }
  422. var line$B = {};
  423. /*istanbul ignore start*/
  424. Object.defineProperty(line$B, "__esModule", {
  425. value: true
  426. });
  427. line$B.diffLines = diffLines;
  428. line$B.diffTrimmedLines = diffTrimmedLines;
  429. line$B.lineDiff = void 0;
  430. /*istanbul ignore end*/
  431. var
  432. /*istanbul ignore start*/
  433. _base$4 = _interopRequireDefault$6(base$1)
  434. /*istanbul ignore end*/
  435. ;
  436. var
  437. /*istanbul ignore start*/
  438. _params = params
  439. /*istanbul ignore end*/
  440. ;
  441. /*istanbul ignore start*/
  442. function _interopRequireDefault$6(obj) {
  443. return obj && obj.__esModule ? obj : {
  444. "default": obj
  445. };
  446. }
  447. /*istanbul ignore end*/
  448. var lineDiff = new
  449. /*istanbul ignore start*/
  450. _base$4
  451. /*istanbul ignore end*/
  452. [
  453. /*istanbul ignore start*/
  454. "default"
  455. /*istanbul ignore end*/
  456. ]();
  457. /*istanbul ignore start*/
  458. line$B.lineDiff = lineDiff;
  459. /*istanbul ignore end*/
  460. lineDiff.tokenize = function (value) {
  461. var retLines = [],
  462. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  463. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  464. linesAndNewlines.pop();
  465. } // Merge the content and line separators into single tokens
  466. for (var i = 0; i < linesAndNewlines.length; i++) {
  467. var line = linesAndNewlines[i];
  468. if (i % 2 && !this.options.newlineIsToken) {
  469. retLines[retLines.length - 1] += line;
  470. } else {
  471. if (this.options.ignoreWhitespace) {
  472. line = line.trim();
  473. }
  474. retLines.push(line);
  475. }
  476. }
  477. return retLines;
  478. };
  479. function diffLines(oldStr, newStr, callback) {
  480. return lineDiff.diff(oldStr, newStr, callback);
  481. }
  482. function diffTrimmedLines(oldStr, newStr, callback) {
  483. var options =
  484. /*istanbul ignore start*/
  485. (/*istanbul ignore end*/
  486. /*istanbul ignore start*/
  487. 0, _params
  488. /*istanbul ignore end*/
  489. .
  490. /*istanbul ignore start*/
  491. generateOptions
  492. /*istanbul ignore end*/
  493. )(callback, {
  494. ignoreWhitespace: true
  495. });
  496. return lineDiff.diff(oldStr, newStr, options);
  497. }
  498. var sentence = {};
  499. /*istanbul ignore start*/
  500. Object.defineProperty(sentence, "__esModule", {
  501. value: true
  502. });
  503. sentence.diffSentences = diffSentences;
  504. sentence.sentenceDiff = void 0;
  505. /*istanbul ignore end*/
  506. var
  507. /*istanbul ignore start*/
  508. _base$3 = _interopRequireDefault$5(base$1)
  509. /*istanbul ignore end*/
  510. ;
  511. /*istanbul ignore start*/
  512. function _interopRequireDefault$5(obj) {
  513. return obj && obj.__esModule ? obj : {
  514. "default": obj
  515. };
  516. }
  517. /*istanbul ignore end*/
  518. var sentenceDiff = new
  519. /*istanbul ignore start*/
  520. _base$3
  521. /*istanbul ignore end*/
  522. [
  523. /*istanbul ignore start*/
  524. "default"
  525. /*istanbul ignore end*/
  526. ]();
  527. /*istanbul ignore start*/
  528. sentence.sentenceDiff = sentenceDiff;
  529. /*istanbul ignore end*/
  530. sentenceDiff.tokenize = function (value) {
  531. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  532. };
  533. function diffSentences(oldStr, newStr, callback) {
  534. return sentenceDiff.diff(oldStr, newStr, callback);
  535. }
  536. var css$1 = {};
  537. /*istanbul ignore start*/
  538. Object.defineProperty(css$1, "__esModule", {
  539. value: true
  540. });
  541. css$1.diffCss = diffCss;
  542. css$1.cssDiff = void 0;
  543. /*istanbul ignore end*/
  544. var
  545. /*istanbul ignore start*/
  546. _base$2 = _interopRequireDefault$4(base$1)
  547. /*istanbul ignore end*/
  548. ;
  549. /*istanbul ignore start*/
  550. function _interopRequireDefault$4(obj) {
  551. return obj && obj.__esModule ? obj : {
  552. "default": obj
  553. };
  554. }
  555. /*istanbul ignore end*/
  556. var cssDiff = new
  557. /*istanbul ignore start*/
  558. _base$2
  559. /*istanbul ignore end*/
  560. [
  561. /*istanbul ignore start*/
  562. "default"
  563. /*istanbul ignore end*/
  564. ]();
  565. /*istanbul ignore start*/
  566. css$1.cssDiff = cssDiff;
  567. /*istanbul ignore end*/
  568. cssDiff.tokenize = function (value) {
  569. return value.split(/([{}:;,]|\s+)/);
  570. };
  571. function diffCss(oldStr, newStr, callback) {
  572. return cssDiff.diff(oldStr, newStr, callback);
  573. }
  574. var check = function (it) {
  575. return it && it.Math == Math && it;
  576. };
  577. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  578. var global$s =
  579. // eslint-disable-next-line es/no-global-this -- safe
  580. check(typeof globalThis == 'object' && globalThis) ||
  581. check(typeof window == 'object' && window) ||
  582. // eslint-disable-next-line no-restricted-globals -- safe
  583. check(typeof self == 'object' && self) ||
  584. check(typeof global$s == 'object' && global$s) ||
  585. // eslint-disable-next-line no-new-func -- fallback
  586. (function () { return this; })() || Function('return this')();
  587. var objectGetOwnPropertyDescriptor = {};
  588. var fails$8 = function (exec) {
  589. try {
  590. return !!exec();
  591. } catch (error) {
  592. return true;
  593. }
  594. };
  595. var fails$7 = fails$8;
  596. // Detect IE8's incomplete defineProperty implementation
  597. var descriptors$1 = !fails$7(function () {
  598. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  599. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  600. });
  601. var call$7 = Function.prototype.call;
  602. var functionCall = call$7.bind ? call$7.bind(call$7) : function () {
  603. return call$7.apply(call$7, arguments);
  604. };
  605. var objectPropertyIsEnumerable = {};
  606. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  607. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  608. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  609. // Nashorn ~ JDK8 bug
  610. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  611. // `Object.prototype.propertyIsEnumerable` method implementation
  612. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  613. objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  614. var descriptor = getOwnPropertyDescriptor$1(this, V);
  615. return !!descriptor && descriptor.enumerable;
  616. } : $propertyIsEnumerable;
  617. var createPropertyDescriptor$3 = function (bitmap, value) {
  618. return {
  619. enumerable: !(bitmap & 1),
  620. configurable: !(bitmap & 2),
  621. writable: !(bitmap & 4),
  622. value: value
  623. };
  624. };
  625. var FunctionPrototype$1 = Function.prototype;
  626. var bind$4 = FunctionPrototype$1.bind;
  627. var call$6 = FunctionPrototype$1.call;
  628. var callBind = bind$4 && bind$4.bind(call$6);
  629. var functionUncurryThis = bind$4 ? function (fn) {
  630. return fn && callBind(call$6, fn);
  631. } : function (fn) {
  632. return fn && function () {
  633. return call$6.apply(fn, arguments);
  634. };
  635. };
  636. var uncurryThis$c = functionUncurryThis;
  637. var toString$5 = uncurryThis$c({}.toString);
  638. var stringSlice = uncurryThis$c(''.slice);
  639. var classofRaw$1 = function (it) {
  640. return stringSlice(toString$5(it), 8, -1);
  641. };
  642. var global$r = global$s;
  643. var uncurryThis$b = functionUncurryThis;
  644. var fails$6 = fails$8;
  645. var classof$5 = classofRaw$1;
  646. var Object$4 = global$r.Object;
  647. var split = uncurryThis$b(''.split);
  648. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  649. var indexedObject = fails$6(function () {
  650. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  651. // eslint-disable-next-line no-prototype-builtins -- safe
  652. return !Object$4('z').propertyIsEnumerable(0);
  653. }) ? function (it) {
  654. return classof$5(it) == 'String' ? split(it, '') : Object$4(it);
  655. } : Object$4;
  656. var global$q = global$s;
  657. var TypeError$a = global$q.TypeError;
  658. // `RequireObjectCoercible` abstract operation
  659. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  660. var requireObjectCoercible$2 = function (it) {
  661. if (it == undefined) throw TypeError$a("Can't call method on " + it);
  662. return it;
  663. };
  664. // toObject with fallback for non-array-like ES3 strings
  665. var IndexedObject = indexedObject;
  666. var requireObjectCoercible$1 = requireObjectCoercible$2;
  667. var toIndexedObject$4 = function (it) {
  668. return IndexedObject(requireObjectCoercible$1(it));
  669. };
  670. // `IsCallable` abstract operation
  671. // https://tc39.es/ecma262/#sec-iscallable
  672. var isCallable$b = function (argument) {
  673. return typeof argument == 'function';
  674. };
  675. var isCallable$a = isCallable$b;
  676. var isObject$c = function (it) {
  677. return typeof it == 'object' ? it !== null : isCallable$a(it);
  678. };
  679. var global$p = global$s;
  680. var isCallable$9 = isCallable$b;
  681. var aFunction = function (argument) {
  682. return isCallable$9(argument) ? argument : undefined;
  683. };
  684. var getBuiltIn$5 = function (namespace, method) {
  685. return arguments.length < 2 ? aFunction(global$p[namespace]) : global$p[namespace] && global$p[namespace][method];
  686. };
  687. var uncurryThis$a = functionUncurryThis;
  688. var objectIsPrototypeOf = uncurryThis$a({}.isPrototypeOf);
  689. var getBuiltIn$4 = getBuiltIn$5;
  690. var engineUserAgent = getBuiltIn$4('navigator', 'userAgent') || '';
  691. var global$o = global$s;
  692. var userAgent$2 = engineUserAgent;
  693. var process$3 = global$o.process;
  694. var Deno = global$o.Deno;
  695. var versions = process$3 && process$3.versions || Deno && Deno.version;
  696. var v8$2 = versions && versions.v8;
  697. var match$1, version$2;
  698. if (v8$2) {
  699. match$1 = v8$2.split('.');
  700. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  701. // but their correct versions are not interesting for us
  702. version$2 = match$1[0] > 0 && match$1[0] < 4 ? 1 : +(match$1[0] + match$1[1]);
  703. }
  704. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  705. // so check `userAgent` even if `.v8` exists, but 0
  706. if (!version$2 && userAgent$2) {
  707. match$1 = userAgent$2.match(/Edge\/(\d+)/);
  708. if (!match$1 || match$1[1] >= 74) {
  709. match$1 = userAgent$2.match(/Chrome\/(\d+)/);
  710. if (match$1) version$2 = +match$1[1];
  711. }
  712. }
  713. var engineV8Version = version$2;
  714. /* eslint-disable es/no-symbol -- required for testing */
  715. var V8_VERSION = engineV8Version;
  716. var fails$5 = fails$8;
  717. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  718. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$5(function () {
  719. var symbol = Symbol();
  720. // Chrome 38 Symbol has incorrect toString conversion
  721. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  722. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  723. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  724. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  725. });
  726. /* eslint-disable es/no-symbol -- required for testing */
  727. var NATIVE_SYMBOL$1 = nativeSymbol;
  728. var useSymbolAsUid = NATIVE_SYMBOL$1
  729. && !Symbol.sham
  730. && typeof Symbol.iterator == 'symbol';
  731. var global$n = global$s;
  732. var getBuiltIn$3 = getBuiltIn$5;
  733. var isCallable$8 = isCallable$b;
  734. var isPrototypeOf$1 = objectIsPrototypeOf;
  735. var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
  736. var Object$3 = global$n.Object;
  737. var isSymbol$6 = USE_SYMBOL_AS_UID$1 ? function (it) {
  738. return typeof it == 'symbol';
  739. } : function (it) {
  740. var $Symbol = getBuiltIn$3('Symbol');
  741. return isCallable$8($Symbol) && isPrototypeOf$1($Symbol.prototype, Object$3(it));
  742. };
  743. var global$m = global$s;
  744. var String$3 = global$m.String;
  745. var tryToString$3 = function (argument) {
  746. try {
  747. return String$3(argument);
  748. } catch (error) {
  749. return 'Object';
  750. }
  751. };
  752. var global$l = global$s;
  753. var isCallable$7 = isCallable$b;
  754. var tryToString$2 = tryToString$3;
  755. var TypeError$9 = global$l.TypeError;
  756. // `Assert: IsCallable(argument) is true`
  757. var aCallable$5 = function (argument) {
  758. if (isCallable$7(argument)) return argument;
  759. throw TypeError$9(tryToString$2(argument) + ' is not a function');
  760. };
  761. var aCallable$4 = aCallable$5;
  762. // `GetMethod` abstract operation
  763. // https://tc39.es/ecma262/#sec-getmethod
  764. var getMethod$3 = function (V, P) {
  765. var func = V[P];
  766. return func == null ? undefined : aCallable$4(func);
  767. };
  768. var global$k = global$s;
  769. var call$5 = functionCall;
  770. var isCallable$6 = isCallable$b;
  771. var isObject$b = isObject$c;
  772. var TypeError$8 = global$k.TypeError;
  773. // `OrdinaryToPrimitive` abstract operation
  774. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  775. var ordinaryToPrimitive$1 = function (input, pref) {
  776. var fn, val;
  777. if (pref === 'string' && isCallable$6(fn = input.toString) && !isObject$b(val = call$5(fn, input))) return val;
  778. if (isCallable$6(fn = input.valueOf) && !isObject$b(val = call$5(fn, input))) return val;
  779. if (pref !== 'string' && isCallable$6(fn = input.toString) && !isObject$b(val = call$5(fn, input))) return val;
  780. throw TypeError$8("Can't convert object to primitive value");
  781. };
  782. var shared$3 = {exports: {}};
  783. var global$j = global$s;
  784. // eslint-disable-next-line es/no-object-defineproperty -- safe
  785. var defineProperty$1 = Object.defineProperty;
  786. var setGlobal$3 = function (key, value) {
  787. try {
  788. defineProperty$1(global$j, key, { value: value, configurable: true, writable: true });
  789. } catch (error) {
  790. global$j[key] = value;
  791. } return value;
  792. };
  793. var global$i = global$s;
  794. var setGlobal$2 = setGlobal$3;
  795. var SHARED = '__core-js_shared__';
  796. var store$3 = global$i[SHARED] || setGlobal$2(SHARED, {});
  797. var sharedStore = store$3;
  798. var store$2 = sharedStore;
  799. (shared$3.exports = function (key, value) {
  800. return store$2[key] || (store$2[key] = value !== undefined ? value : {});
  801. })('versions', []).push({
  802. version: '3.19.1',
  803. mode: 'global',
  804. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  805. });
  806. var global$h = global$s;
  807. var requireObjectCoercible = requireObjectCoercible$2;
  808. var Object$2 = global$h.Object;
  809. // `ToObject` abstract operation
  810. // https://tc39.es/ecma262/#sec-toobject
  811. var toObject$4 = function (argument) {
  812. return Object$2(requireObjectCoercible(argument));
  813. };
  814. var uncurryThis$9 = functionUncurryThis;
  815. var toObject$3 = toObject$4;
  816. var hasOwnProperty$b = uncurryThis$9({}.hasOwnProperty);
  817. // `HasOwnProperty` abstract operation
  818. // https://tc39.es/ecma262/#sec-hasownproperty
  819. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  820. return hasOwnProperty$b(toObject$3(it), key);
  821. };
  822. var uncurryThis$8 = functionUncurryThis;
  823. var id = 0;
  824. var postfix = Math.random();
  825. var toString$4 = uncurryThis$8(1.0.toString);
  826. var uid$3 = function (key) {
  827. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$4(++id + postfix, 36);
  828. };
  829. var global$g = global$s;
  830. var shared$2 = shared$3.exports;
  831. var hasOwn$6 = hasOwnProperty_1;
  832. var uid$2 = uid$3;
  833. var NATIVE_SYMBOL = nativeSymbol;
  834. var USE_SYMBOL_AS_UID = useSymbolAsUid;
  835. var WellKnownSymbolsStore = shared$2('wks');
  836. var Symbol$6 = global$g.Symbol;
  837. var symbolFor = Symbol$6 && Symbol$6['for'];
  838. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$6 : Symbol$6 && Symbol$6.withoutSetter || uid$2;
  839. var wellKnownSymbol$7 = function (name) {
  840. if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  841. var description = 'Symbol.' + name;
  842. if (NATIVE_SYMBOL && hasOwn$6(Symbol$6, name)) {
  843. WellKnownSymbolsStore[name] = Symbol$6[name];
  844. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  845. WellKnownSymbolsStore[name] = symbolFor(description);
  846. } else {
  847. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  848. }
  849. } return WellKnownSymbolsStore[name];
  850. };
  851. var global$f = global$s;
  852. var call$4 = functionCall;
  853. var isObject$a = isObject$c;
  854. var isSymbol$5 = isSymbol$6;
  855. var getMethod$2 = getMethod$3;
  856. var ordinaryToPrimitive = ordinaryToPrimitive$1;
  857. var wellKnownSymbol$6 = wellKnownSymbol$7;
  858. var TypeError$7 = global$f.TypeError;
  859. var TO_PRIMITIVE = wellKnownSymbol$6('toPrimitive');
  860. // `ToPrimitive` abstract operation
  861. // https://tc39.es/ecma262/#sec-toprimitive
  862. var toPrimitive$1 = function (input, pref) {
  863. if (!isObject$a(input) || isSymbol$5(input)) return input;
  864. var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
  865. var result;
  866. if (exoticToPrim) {
  867. if (pref === undefined) pref = 'default';
  868. result = call$4(exoticToPrim, input, pref);
  869. if (!isObject$a(result) || isSymbol$5(result)) return result;
  870. throw TypeError$7("Can't convert object to primitive value");
  871. }
  872. if (pref === undefined) pref = 'number';
  873. return ordinaryToPrimitive(input, pref);
  874. };
  875. var toPrimitive = toPrimitive$1;
  876. var isSymbol$4 = isSymbol$6;
  877. // `ToPropertyKey` abstract operation
  878. // https://tc39.es/ecma262/#sec-topropertykey
  879. var toPropertyKey$3 = function (argument) {
  880. var key = toPrimitive(argument, 'string');
  881. return isSymbol$4(key) ? key : key + '';
  882. };
  883. var global$e = global$s;
  884. var isObject$9 = isObject$c;
  885. var document$1 = global$e.document;
  886. // typeof document.createElement is 'object' in old IE
  887. var EXISTS$1 = isObject$9(document$1) && isObject$9(document$1.createElement);
  888. var documentCreateElement$1 = function (it) {
  889. return EXISTS$1 ? document$1.createElement(it) : {};
  890. };
  891. var DESCRIPTORS$5 = descriptors$1;
  892. var fails$4 = fails$8;
  893. var createElement = documentCreateElement$1;
  894. // Thank's IE8 for his funny defineProperty
  895. var ie8DomDefine = !DESCRIPTORS$5 && !fails$4(function () {
  896. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  897. return Object.defineProperty(createElement('div'), 'a', {
  898. get: function () { return 7; }
  899. }).a != 7;
  900. });
  901. var DESCRIPTORS$4 = descriptors$1;
  902. var call$3 = functionCall;
  903. var propertyIsEnumerableModule = objectPropertyIsEnumerable;
  904. var createPropertyDescriptor$2 = createPropertyDescriptor$3;
  905. var toIndexedObject$3 = toIndexedObject$4;
  906. var toPropertyKey$2 = toPropertyKey$3;
  907. var hasOwn$5 = hasOwnProperty_1;
  908. var IE8_DOM_DEFINE$1 = ie8DomDefine;
  909. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  910. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  911. // `Object.getOwnPropertyDescriptor` method
  912. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  913. objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  914. O = toIndexedObject$3(O);
  915. P = toPropertyKey$2(P);
  916. if (IE8_DOM_DEFINE$1) try {
  917. return $getOwnPropertyDescriptor(O, P);
  918. } catch (error) { /* empty */ }
  919. if (hasOwn$5(O, P)) return createPropertyDescriptor$2(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
  920. };
  921. var objectDefineProperty = {};
  922. var global$d = global$s;
  923. var isObject$8 = isObject$c;
  924. var String$2 = global$d.String;
  925. var TypeError$6 = global$d.TypeError;
  926. // `Assert: Type(argument) is Object`
  927. var anObject$7 = function (argument) {
  928. if (isObject$8(argument)) return argument;
  929. throw TypeError$6(String$2(argument) + ' is not an object');
  930. };
  931. var global$c = global$s;
  932. var DESCRIPTORS$3 = descriptors$1;
  933. var IE8_DOM_DEFINE = ie8DomDefine;
  934. var anObject$6 = anObject$7;
  935. var toPropertyKey$1 = toPropertyKey$3;
  936. var TypeError$5 = global$c.TypeError;
  937. // eslint-disable-next-line es/no-object-defineproperty -- safe
  938. var $defineProperty = Object.defineProperty;
  939. // `Object.defineProperty` method
  940. // https://tc39.es/ecma262/#sec-object.defineproperty
  941. objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
  942. anObject$6(O);
  943. P = toPropertyKey$1(P);
  944. anObject$6(Attributes);
  945. if (IE8_DOM_DEFINE) try {
  946. return $defineProperty(O, P, Attributes);
  947. } catch (error) { /* empty */ }
  948. if ('get' in Attributes || 'set' in Attributes) throw TypeError$5('Accessors not supported');
  949. if ('value' in Attributes) O[P] = Attributes.value;
  950. return O;
  951. };
  952. var DESCRIPTORS$2 = descriptors$1;
  953. var definePropertyModule$4 = objectDefineProperty;
  954. var createPropertyDescriptor$1 = createPropertyDescriptor$3;
  955. var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
  956. return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
  957. } : function (object, key, value) {
  958. object[key] = value;
  959. return object;
  960. };
  961. var redefine$1 = {exports: {}};
  962. var uncurryThis$7 = functionUncurryThis;
  963. var isCallable$5 = isCallable$b;
  964. var store$1 = sharedStore;
  965. var functionToString = uncurryThis$7(Function.toString);
  966. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  967. if (!isCallable$5(store$1.inspectSource)) {
  968. store$1.inspectSource = function (it) {
  969. return functionToString(it);
  970. };
  971. }
  972. var inspectSource$3 = store$1.inspectSource;
  973. var global$b = global$s;
  974. var isCallable$4 = isCallable$b;
  975. var inspectSource$2 = inspectSource$3;
  976. var WeakMap$4 = global$b.WeakMap;
  977. var nativeWeakMap = isCallable$4(WeakMap$4) && /native code/.test(inspectSource$2(WeakMap$4));
  978. var shared$1 = shared$3.exports;
  979. var uid$1 = uid$3;
  980. var keys$4 = shared$1('keys');
  981. var sharedKey$2 = function (key) {
  982. return keys$4[key] || (keys$4[key] = uid$1(key));
  983. };
  984. var hiddenKeys$4 = {};
  985. var NATIVE_WEAK_MAP = nativeWeakMap;
  986. var global$a = global$s;
  987. var uncurryThis$6 = functionUncurryThis;
  988. var isObject$7 = isObject$c;
  989. var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
  990. var hasOwn$4 = hasOwnProperty_1;
  991. var shared = sharedStore;
  992. var sharedKey$1 = sharedKey$2;
  993. var hiddenKeys$3 = hiddenKeys$4;
  994. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  995. var TypeError$4 = global$a.TypeError;
  996. var WeakMap$3 = global$a.WeakMap;
  997. var set$1, get$3, has$1;
  998. var enforce = function (it) {
  999. return has$1(it) ? get$3(it) : set$1(it, {});
  1000. };
  1001. var getterFor = function (TYPE) {
  1002. return function (it) {
  1003. var state;
  1004. if (!isObject$7(it) || (state = get$3(it)).type !== TYPE) {
  1005. throw TypeError$4('Incompatible receiver, ' + TYPE + ' required');
  1006. } return state;
  1007. };
  1008. };
  1009. if (NATIVE_WEAK_MAP || shared.state) {
  1010. var store = shared.state || (shared.state = new WeakMap$3());
  1011. var wmget = uncurryThis$6(store.get);
  1012. var wmhas = uncurryThis$6(store.has);
  1013. var wmset = uncurryThis$6(store.set);
  1014. set$1 = function (it, metadata) {
  1015. if (wmhas(store, it)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
  1016. metadata.facade = it;
  1017. wmset(store, it, metadata);
  1018. return metadata;
  1019. };
  1020. get$3 = function (it) {
  1021. return wmget(store, it) || {};
  1022. };
  1023. has$1 = function (it) {
  1024. return wmhas(store, it);
  1025. };
  1026. } else {
  1027. var STATE = sharedKey$1('state');
  1028. hiddenKeys$3[STATE] = true;
  1029. set$1 = function (it, metadata) {
  1030. if (hasOwn$4(it, STATE)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
  1031. metadata.facade = it;
  1032. createNonEnumerableProperty$2(it, STATE, metadata);
  1033. return metadata;
  1034. };
  1035. get$3 = function (it) {
  1036. return hasOwn$4(it, STATE) ? it[STATE] : {};
  1037. };
  1038. has$1 = function (it) {
  1039. return hasOwn$4(it, STATE);
  1040. };
  1041. }
  1042. var internalState = {
  1043. set: set$1,
  1044. get: get$3,
  1045. has: has$1,
  1046. enforce: enforce,
  1047. getterFor: getterFor
  1048. };
  1049. var DESCRIPTORS$1 = descriptors$1;
  1050. var hasOwn$3 = hasOwnProperty_1;
  1051. var FunctionPrototype = Function.prototype;
  1052. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  1053. var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
  1054. var EXISTS = hasOwn$3(FunctionPrototype, 'name');
  1055. // additional protection from minified / mangled / dropped function names
  1056. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  1057. var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
  1058. var functionName = {
  1059. EXISTS: EXISTS,
  1060. PROPER: PROPER,
  1061. CONFIGURABLE: CONFIGURABLE
  1062. };
  1063. var global$9 = global$s;
  1064. var isCallable$3 = isCallable$b;
  1065. var hasOwn$2 = hasOwnProperty_1;
  1066. var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
  1067. var setGlobal$1 = setGlobal$3;
  1068. var inspectSource$1 = inspectSource$3;
  1069. var InternalStateModule = internalState;
  1070. var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
  1071. var getInternalState = InternalStateModule.get;
  1072. var enforceInternalState = InternalStateModule.enforce;
  1073. var TEMPLATE = String(String).split('String');
  1074. (redefine$1.exports = function (O, key, value, options) {
  1075. var unsafe = options ? !!options.unsafe : false;
  1076. var simple = options ? !!options.enumerable : false;
  1077. var noTargetGet = options ? !!options.noTargetGet : false;
  1078. var name = options && options.name !== undefined ? options.name : key;
  1079. var state;
  1080. if (isCallable$3(value)) {
  1081. if (String(name).slice(0, 7) === 'Symbol(') {
  1082. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  1083. }
  1084. if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  1085. createNonEnumerableProperty$1(value, 'name', name);
  1086. }
  1087. state = enforceInternalState(value);
  1088. if (!state.source) {
  1089. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  1090. }
  1091. }
  1092. if (O === global$9) {
  1093. if (simple) O[key] = value;
  1094. else setGlobal$1(key, value);
  1095. return;
  1096. } else if (!unsafe) {
  1097. delete O[key];
  1098. } else if (!noTargetGet && O[key]) {
  1099. simple = true;
  1100. }
  1101. if (simple) O[key] = value;
  1102. else createNonEnumerableProperty$1(O, key, value);
  1103. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  1104. })(Function.prototype, 'toString', function toString() {
  1105. return isCallable$3(this) && getInternalState(this).source || inspectSource$1(this);
  1106. });
  1107. var objectGetOwnPropertyNames = {};
  1108. var ceil = Math.ceil;
  1109. var floor$1 = Math.floor;
  1110. // `ToIntegerOrInfinity` abstract operation
  1111. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  1112. var toIntegerOrInfinity$3 = function (argument) {
  1113. var number = +argument;
  1114. // eslint-disable-next-line no-self-compare -- safe
  1115. return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
  1116. };
  1117. var toIntegerOrInfinity$2 = toIntegerOrInfinity$3;
  1118. var max = Math.max;
  1119. var min$1 = Math.min;
  1120. // Helper for a popular repeating case of the spec:
  1121. // Let integer be ? ToInteger(index).
  1122. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  1123. var toAbsoluteIndex$1 = function (index, length) {
  1124. var integer = toIntegerOrInfinity$2(index);
  1125. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  1126. };
  1127. var toIntegerOrInfinity$1 = toIntegerOrInfinity$3;
  1128. var min = Math.min;
  1129. // `ToLength` abstract operation
  1130. // https://tc39.es/ecma262/#sec-tolength
  1131. var toLength$1 = function (argument) {
  1132. return argument > 0 ? min(toIntegerOrInfinity$1(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  1133. };
  1134. var toLength = toLength$1;
  1135. // `LengthOfArrayLike` abstract operation
  1136. // https://tc39.es/ecma262/#sec-lengthofarraylike
  1137. var lengthOfArrayLike$6 = function (obj) {
  1138. return toLength(obj.length);
  1139. };
  1140. var toIndexedObject$2 = toIndexedObject$4;
  1141. var toAbsoluteIndex = toAbsoluteIndex$1;
  1142. var lengthOfArrayLike$5 = lengthOfArrayLike$6;
  1143. // `Array.prototype.{ indexOf, includes }` methods implementation
  1144. var createMethod = function (IS_INCLUDES) {
  1145. return function ($this, el, fromIndex) {
  1146. var O = toIndexedObject$2($this);
  1147. var length = lengthOfArrayLike$5(O);
  1148. var index = toAbsoluteIndex(fromIndex, length);
  1149. var value;
  1150. // Array#includes uses SameValueZero equality algorithm
  1151. // eslint-disable-next-line no-self-compare -- NaN check
  1152. if (IS_INCLUDES && el != el) while (length > index) {
  1153. value = O[index++];
  1154. // eslint-disable-next-line no-self-compare -- NaN check
  1155. if (value != value) return true;
  1156. // Array#indexOf ignores holes, Array#includes - not
  1157. } else for (;length > index; index++) {
  1158. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  1159. } return !IS_INCLUDES && -1;
  1160. };
  1161. };
  1162. var arrayIncludes$2 = {
  1163. // `Array.prototype.includes` method
  1164. // https://tc39.es/ecma262/#sec-array.prototype.includes
  1165. includes: createMethod(true),
  1166. // `Array.prototype.indexOf` method
  1167. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  1168. indexOf: createMethod(false)
  1169. };
  1170. var uncurryThis$5 = functionUncurryThis;
  1171. var hasOwn$1 = hasOwnProperty_1;
  1172. var toIndexedObject$1 = toIndexedObject$4;
  1173. var indexOf = arrayIncludes$2.indexOf;
  1174. var hiddenKeys$2 = hiddenKeys$4;
  1175. var push$3 = uncurryThis$5([].push);
  1176. var objectKeysInternal = function (object, names) {
  1177. var O = toIndexedObject$1(object);
  1178. var i = 0;
  1179. var result = [];
  1180. var key;
  1181. for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && push$3(result, key);
  1182. // Don't enum bug & hidden keys
  1183. while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
  1184. ~indexOf(result, key) || push$3(result, key);
  1185. }
  1186. return result;
  1187. };
  1188. // IE8- don't enum bug keys
  1189. var enumBugKeys$3 = [
  1190. 'constructor',
  1191. 'hasOwnProperty',
  1192. 'isPrototypeOf',
  1193. 'propertyIsEnumerable',
  1194. 'toLocaleString',
  1195. 'toString',
  1196. 'valueOf'
  1197. ];
  1198. var internalObjectKeys$1 = objectKeysInternal;
  1199. var enumBugKeys$2 = enumBugKeys$3;
  1200. var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
  1201. // `Object.getOwnPropertyNames` method
  1202. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  1203. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  1204. objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1205. return internalObjectKeys$1(O, hiddenKeys$1);
  1206. };
  1207. var objectGetOwnPropertySymbols = {};
  1208. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  1209. objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
  1210. var getBuiltIn$2 = getBuiltIn$5;
  1211. var uncurryThis$4 = functionUncurryThis;
  1212. var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
  1213. var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
  1214. var anObject$5 = anObject$7;
  1215. var concat = uncurryThis$4([].concat);
  1216. // all object keys, includes non-enumerable and symbols
  1217. var ownKeys$1 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
  1218. var keys = getOwnPropertyNamesModule.f(anObject$5(it));
  1219. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1220. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1221. };
  1222. var hasOwn = hasOwnProperty_1;
  1223. var ownKeys = ownKeys$1;
  1224. var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
  1225. var definePropertyModule$3 = objectDefineProperty;
  1226. var copyConstructorProperties$1 = function (target, source) {
  1227. var keys = ownKeys(source);
  1228. var defineProperty = definePropertyModule$3.f;
  1229. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1230. for (var i = 0; i < keys.length; i++) {
  1231. var key = keys[i];
  1232. if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1233. }
  1234. };
  1235. var fails$3 = fails$8;
  1236. var isCallable$2 = isCallable$b;
  1237. var replacement = /#|\.prototype\./;
  1238. var isForced$1 = function (feature, detection) {
  1239. var value = data$3[normalize$3(feature)];
  1240. return value == POLYFILL ? true
  1241. : value == NATIVE ? false
  1242. : isCallable$2(detection) ? fails$3(detection)
  1243. : !!detection;
  1244. };
  1245. var normalize$3 = isForced$1.normalize = function (string) {
  1246. return String(string).replace(replacement, '.').toLowerCase();
  1247. };
  1248. var data$3 = isForced$1.data = {};
  1249. var NATIVE = isForced$1.NATIVE = 'N';
  1250. var POLYFILL = isForced$1.POLYFILL = 'P';
  1251. var isForced_1 = isForced$1;
  1252. var global$8 = global$s;
  1253. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  1254. var createNonEnumerableProperty = createNonEnumerableProperty$3;
  1255. var redefine = redefine$1.exports;
  1256. var setGlobal = setGlobal$3;
  1257. var copyConstructorProperties = copyConstructorProperties$1;
  1258. var isForced = isForced_1;
  1259. /*
  1260. options.target - name of the target object
  1261. options.global - target is the global object
  1262. options.stat - export as static methods of target
  1263. options.proto - export as prototype methods of target
  1264. options.real - real prototype method for the `pure` version
  1265. options.forced - export even if the native feature is available
  1266. options.bind - bind methods to the target, required for the `pure` version
  1267. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  1268. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  1269. options.sham - add a flag to not completely full polyfills
  1270. options.enumerable - export as enumerable property
  1271. options.noTargetGet - prevent calling a getter on target
  1272. options.name - the .name of the function if it does not match the key
  1273. */
  1274. var _export = function (options, source) {
  1275. var TARGET = options.target;
  1276. var GLOBAL = options.global;
  1277. var STATIC = options.stat;
  1278. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  1279. if (GLOBAL) {
  1280. target = global$8;
  1281. } else if (STATIC) {
  1282. target = global$8[TARGET] || setGlobal(TARGET, {});
  1283. } else {
  1284. target = (global$8[TARGET] || {}).prototype;
  1285. }
  1286. if (target) for (key in source) {
  1287. sourceProperty = source[key];
  1288. if (options.noTargetGet) {
  1289. descriptor = getOwnPropertyDescriptor(target, key);
  1290. targetProperty = descriptor && descriptor.value;
  1291. } else targetProperty = target[key];
  1292. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  1293. // contained in target
  1294. if (!FORCED && targetProperty !== undefined) {
  1295. if (typeof sourceProperty == typeof targetProperty) continue;
  1296. copyConstructorProperties(sourceProperty, targetProperty);
  1297. }
  1298. // add a flag to not completely full polyfills
  1299. if (options.sham || (targetProperty && targetProperty.sham)) {
  1300. createNonEnumerableProperty(sourceProperty, 'sham', true);
  1301. }
  1302. // extend global
  1303. redefine(target, key, sourceProperty, options);
  1304. }
  1305. };
  1306. var wellKnownSymbol$5 = wellKnownSymbol$7;
  1307. var TO_STRING_TAG$1 = wellKnownSymbol$5('toStringTag');
  1308. var test$1 = {};
  1309. test$1[TO_STRING_TAG$1] = 'z';
  1310. var toStringTagSupport = String(test$1) === '[object z]';
  1311. var global$7 = global$s;
  1312. var TO_STRING_TAG_SUPPORT = toStringTagSupport;
  1313. var isCallable$1 = isCallable$b;
  1314. var classofRaw = classofRaw$1;
  1315. var wellKnownSymbol$4 = wellKnownSymbol$7;
  1316. var TO_STRING_TAG = wellKnownSymbol$4('toStringTag');
  1317. var Object$1 = global$7.Object;
  1318. // ES3 wrong here
  1319. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  1320. // fallback for IE11 Script Access Denied error
  1321. var tryGet = function (it, key) {
  1322. try {
  1323. return it[key];
  1324. } catch (error) { /* empty */ }
  1325. };
  1326. // getting tag from ES6+ `Object.prototype.toString`
  1327. var classof$4 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1328. var O, tag, result;
  1329. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1330. // @@toStringTag case
  1331. : typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
  1332. // builtinTag case
  1333. : CORRECT_ARGUMENTS ? classofRaw(O)
  1334. // ES3 arguments fallback
  1335. : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
  1336. };
  1337. var global$6 = global$s;
  1338. var classof$3 = classof$4;
  1339. var String$1 = global$6.String;
  1340. var toString$3 = function (argument) {
  1341. if (classof$3(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  1342. return String$1(argument);
  1343. };
  1344. var uncurryThis$3 = functionUncurryThis;
  1345. var arraySlice$1 = uncurryThis$3([].slice);
  1346. var arraySlice = arraySlice$1;
  1347. var floor = Math.floor;
  1348. var mergeSort = function (array, comparefn) {
  1349. var length = array.length;
  1350. var middle = floor(length / 2);
  1351. return length < 8 ? insertionSort(array, comparefn) : merge$3(
  1352. array,
  1353. mergeSort(arraySlice(array, 0, middle), comparefn),
  1354. mergeSort(arraySlice(array, middle), comparefn),
  1355. comparefn
  1356. );
  1357. };
  1358. var insertionSort = function (array, comparefn) {
  1359. var length = array.length;
  1360. var i = 1;
  1361. var element, j;
  1362. while (i < length) {
  1363. j = i;
  1364. element = array[i];
  1365. while (j && comparefn(array[j - 1], element) > 0) {
  1366. array[j] = array[--j];
  1367. }
  1368. if (j !== i++) array[j] = element;
  1369. } return array;
  1370. };
  1371. var merge$3 = function (array, left, right, comparefn) {
  1372. var llength = left.length;
  1373. var rlength = right.length;
  1374. var lindex = 0;
  1375. var rindex = 0;
  1376. while (lindex < llength || rindex < rlength) {
  1377. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  1378. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  1379. : lindex < llength ? left[lindex++] : right[rindex++];
  1380. } return array;
  1381. };
  1382. var arraySort = mergeSort;
  1383. var fails$2 = fails$8;
  1384. var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
  1385. var method = [][METHOD_NAME];
  1386. return !!method && fails$2(function () {
  1387. // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
  1388. method.call(null, argument || function () { throw 1; }, 1);
  1389. });
  1390. };
  1391. var userAgent$1 = engineUserAgent;
  1392. var firefox = userAgent$1.match(/firefox\/(\d+)/i);
  1393. var engineFfVersion = !!firefox && +firefox[1];
  1394. var UA = engineUserAgent;
  1395. var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
  1396. var userAgent = engineUserAgent;
  1397. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  1398. var engineWebkitVersion = !!webkit && +webkit[1];
  1399. var $$3 = _export;
  1400. var uncurryThis$2 = functionUncurryThis;
  1401. var aCallable$3 = aCallable$5;
  1402. var toObject$2 = toObject$4;
  1403. var lengthOfArrayLike$4 = lengthOfArrayLike$6;
  1404. var toString$2 = toString$3;
  1405. var fails$1 = fails$8;
  1406. var internalSort = arraySort;
  1407. var arrayMethodIsStrict = arrayMethodIsStrict$1;
  1408. var FF = engineFfVersion;
  1409. var IE_OR_EDGE = engineIsIeOrEdge;
  1410. var V8 = engineV8Version;
  1411. var WEBKIT = engineWebkitVersion;
  1412. var test = [];
  1413. var un$Sort = uncurryThis$2(test.sort);
  1414. var push$2 = uncurryThis$2(test.push);
  1415. // IE8-
  1416. var FAILS_ON_UNDEFINED = fails$1(function () {
  1417. test.sort(undefined);
  1418. });
  1419. // V8 bug
  1420. var FAILS_ON_NULL = fails$1(function () {
  1421. test.sort(null);
  1422. });
  1423. // Old WebKit
  1424. var STRICT_METHOD = arrayMethodIsStrict('sort');
  1425. var STABLE_SORT = !fails$1(function () {
  1426. // feature detection can be too slow, so check engines versions
  1427. if (V8) return V8 < 70;
  1428. if (FF && FF > 3) return;
  1429. if (IE_OR_EDGE) return true;
  1430. if (WEBKIT) return WEBKIT < 603;
  1431. var result = '';
  1432. var code, chr, value, index;
  1433. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  1434. for (code = 65; code < 76; code++) {
  1435. chr = String.fromCharCode(code);
  1436. switch (code) {
  1437. case 66: case 69: case 70: case 72: value = 3; break;
  1438. case 68: case 71: value = 4; break;
  1439. default: value = 2;
  1440. }
  1441. for (index = 0; index < 47; index++) {
  1442. test.push({ k: chr + index, v: value });
  1443. }
  1444. }
  1445. test.sort(function (a, b) { return b.v - a.v; });
  1446. for (index = 0; index < test.length; index++) {
  1447. chr = test[index].k.charAt(0);
  1448. if (result.charAt(result.length - 1) !== chr) result += chr;
  1449. }
  1450. return result !== 'DGBEFHACIJK';
  1451. });
  1452. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  1453. var getSortCompare = function (comparefn) {
  1454. return function (x, y) {
  1455. if (y === undefined) return -1;
  1456. if (x === undefined) return 1;
  1457. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  1458. return toString$2(x) > toString$2(y) ? 1 : -1;
  1459. };
  1460. };
  1461. // `Array.prototype.sort` method
  1462. // https://tc39.es/ecma262/#sec-array.prototype.sort
  1463. $$3({ target: 'Array', proto: true, forced: FORCED }, {
  1464. sort: function sort(comparefn) {
  1465. if (comparefn !== undefined) aCallable$3(comparefn);
  1466. var array = toObject$2(this);
  1467. if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
  1468. var items = [];
  1469. var arrayLength = lengthOfArrayLike$4(array);
  1470. var itemsLength, index;
  1471. for (index = 0; index < arrayLength; index++) {
  1472. if (index in array) push$2(items, array[index]);
  1473. }
  1474. internalSort(items, getSortCompare(comparefn));
  1475. itemsLength = items.length;
  1476. index = 0;
  1477. while (index < itemsLength) array[index] = items[index++];
  1478. while (index < arrayLength) delete array[index++];
  1479. return array;
  1480. }
  1481. });
  1482. var json = {};
  1483. Object.defineProperty(json, "__esModule", {
  1484. value: true
  1485. });
  1486. json.diffJson = diffJson;
  1487. json.canonicalize = canonicalize;
  1488. json.jsonDiff = void 0;
  1489. /*istanbul ignore end*/
  1490. var
  1491. /*istanbul ignore start*/
  1492. _base$1 = _interopRequireDefault$3(base$1)
  1493. /*istanbul ignore end*/
  1494. ;
  1495. var
  1496. /*istanbul ignore start*/
  1497. _line$1 = line$B
  1498. /*istanbul ignore end*/
  1499. ;
  1500. /*istanbul ignore start*/
  1501. function _interopRequireDefault$3(obj) {
  1502. return obj && obj.__esModule ? obj : {
  1503. "default": obj
  1504. };
  1505. }
  1506. function _typeof(obj) {
  1507. "@babel/helpers - typeof";
  1508. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1509. _typeof = function _typeof(obj) {
  1510. return typeof obj;
  1511. };
  1512. } else {
  1513. _typeof = function _typeof(obj) {
  1514. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1515. };
  1516. }
  1517. return _typeof(obj);
  1518. }
  1519. /*istanbul ignore end*/
  1520. var objectPrototypeToString = Object.prototype.toString;
  1521. var jsonDiff = new
  1522. /*istanbul ignore start*/
  1523. _base$1
  1524. /*istanbul ignore end*/
  1525. [
  1526. /*istanbul ignore start*/
  1527. "default"
  1528. /*istanbul ignore end*/
  1529. ](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  1530. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  1531. /*istanbul ignore start*/
  1532. json.jsonDiff = jsonDiff;
  1533. /*istanbul ignore end*/
  1534. jsonDiff.useLongestToken = true;
  1535. jsonDiff.tokenize =
  1536. /*istanbul ignore start*/
  1537. _line$1
  1538. /*istanbul ignore end*/
  1539. .
  1540. /*istanbul ignore start*/
  1541. lineDiff
  1542. /*istanbul ignore end*/
  1543. .tokenize;
  1544. jsonDiff.castInput = function (value) {
  1545. /*istanbul ignore start*/
  1546. var _this$options =
  1547. /*istanbul ignore end*/
  1548. this.options,
  1549. undefinedReplacement = _this$options.undefinedReplacement,
  1550. _this$options$stringi = _this$options.stringifyReplacer,
  1551. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v)
  1552. /*istanbul ignore start*/
  1553. {
  1554. return (
  1555. /*istanbul ignore end*/
  1556. typeof v === 'undefined' ? undefinedReplacement : v
  1557. );
  1558. } : _this$options$stringi;
  1559. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  1560. };
  1561. jsonDiff.equals = function (left, right) {
  1562. return (
  1563. /*istanbul ignore start*/
  1564. _base$1
  1565. /*istanbul ignore end*/
  1566. [
  1567. /*istanbul ignore start*/
  1568. "default"
  1569. /*istanbul ignore end*/
  1570. ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  1571. );
  1572. };
  1573. function diffJson(oldObj, newObj, options) {
  1574. return jsonDiff.diff(oldObj, newObj, options);
  1575. } // This function handles the presence of circular references by bailing out when encountering an
  1576. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  1577. function canonicalize(obj, stack, replacementStack, replacer, key) {
  1578. stack = stack || [];
  1579. replacementStack = replacementStack || [];
  1580. if (replacer) {
  1581. obj = replacer(key, obj);
  1582. }
  1583. var i;
  1584. for (i = 0; i < stack.length; i += 1) {
  1585. if (stack[i] === obj) {
  1586. return replacementStack[i];
  1587. }
  1588. }
  1589. var canonicalizedObj;
  1590. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  1591. stack.push(obj);
  1592. canonicalizedObj = new Array(obj.length);
  1593. replacementStack.push(canonicalizedObj);
  1594. for (i = 0; i < obj.length; i += 1) {
  1595. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  1596. }
  1597. stack.pop();
  1598. replacementStack.pop();
  1599. return canonicalizedObj;
  1600. }
  1601. if (obj && obj.toJSON) {
  1602. obj = obj.toJSON();
  1603. }
  1604. if (
  1605. /*istanbul ignore start*/
  1606. _typeof(
  1607. /*istanbul ignore end*/
  1608. obj) === 'object' && obj !== null) {
  1609. stack.push(obj);
  1610. canonicalizedObj = {};
  1611. replacementStack.push(canonicalizedObj);
  1612. var sortedKeys = [],
  1613. _key;
  1614. for (_key in obj) {
  1615. /* istanbul ignore else */
  1616. if (obj.hasOwnProperty(_key)) {
  1617. sortedKeys.push(_key);
  1618. }
  1619. }
  1620. sortedKeys.sort();
  1621. for (i = 0; i < sortedKeys.length; i += 1) {
  1622. _key = sortedKeys[i];
  1623. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  1624. }
  1625. stack.pop();
  1626. replacementStack.pop();
  1627. } else {
  1628. canonicalizedObj = obj;
  1629. }
  1630. return canonicalizedObj;
  1631. }
  1632. var array$6 = {};
  1633. /*istanbul ignore start*/
  1634. Object.defineProperty(array$6, "__esModule", {
  1635. value: true
  1636. });
  1637. array$6.diffArrays = diffArrays;
  1638. array$6.arrayDiff = void 0;
  1639. /*istanbul ignore end*/
  1640. var
  1641. /*istanbul ignore start*/
  1642. _base = _interopRequireDefault$2(base$1)
  1643. /*istanbul ignore end*/
  1644. ;
  1645. /*istanbul ignore start*/
  1646. function _interopRequireDefault$2(obj) {
  1647. return obj && obj.__esModule ? obj : {
  1648. "default": obj
  1649. };
  1650. }
  1651. /*istanbul ignore end*/
  1652. var arrayDiff = new
  1653. /*istanbul ignore start*/
  1654. _base
  1655. /*istanbul ignore end*/
  1656. [
  1657. /*istanbul ignore start*/
  1658. "default"
  1659. /*istanbul ignore end*/
  1660. ]();
  1661. /*istanbul ignore start*/
  1662. array$6.arrayDiff = arrayDiff;
  1663. /*istanbul ignore end*/
  1664. arrayDiff.tokenize = function (value) {
  1665. return value.slice();
  1666. };
  1667. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  1668. return value;
  1669. };
  1670. function diffArrays(oldArr, newArr, callback) {
  1671. return arrayDiff.diff(oldArr, newArr, callback);
  1672. }
  1673. var apply = {};
  1674. var parse$e = {};
  1675. /*istanbul ignore start*/
  1676. Object.defineProperty(parse$e, "__esModule", {
  1677. value: true
  1678. });
  1679. parse$e.parsePatch = parsePatch;
  1680. /*istanbul ignore end*/
  1681. function parsePatch(uniDiff) {
  1682. /*istanbul ignore start*/
  1683. var
  1684. /*istanbul ignore end*/
  1685. options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1686. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  1687. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1688. list = [],
  1689. i = 0;
  1690. function parseIndex() {
  1691. var index = {};
  1692. list.push(index); // Parse diff metadata
  1693. while (i < diffstr.length) {
  1694. var line = diffstr[i]; // File header found, end parsing diff metadata
  1695. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  1696. break;
  1697. } // Diff index
  1698. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  1699. if (header) {
  1700. index.index = header[1];
  1701. }
  1702. i++;
  1703. } // Parse file headers if they are defined. Unified diff requires them, but
  1704. // there's no technical issues to have an isolated hunk without file header
  1705. parseFileHeader(index);
  1706. parseFileHeader(index); // Parse hunks
  1707. index.hunks = [];
  1708. while (i < diffstr.length) {
  1709. var _line = diffstr[i];
  1710. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  1711. break;
  1712. } else if (/^@@/.test(_line)) {
  1713. index.hunks.push(parseHunk());
  1714. } else if (_line && options.strict) {
  1715. // Ignore unexpected content unless in strict mode
  1716. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1717. } else {
  1718. i++;
  1719. }
  1720. }
  1721. } // Parses the --- and +++ headers, if none are found, no lines
  1722. // are consumed.
  1723. function parseFileHeader(index) {
  1724. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  1725. if (fileHeader) {
  1726. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1727. var data = fileHeader[2].split('\t', 2);
  1728. var fileName = data[0].replace(/\\\\/g, '\\');
  1729. if (/^".*"$/.test(fileName)) {
  1730. fileName = fileName.substr(1, fileName.length - 2);
  1731. }
  1732. index[keyPrefix + 'FileName'] = fileName;
  1733. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  1734. i++;
  1735. }
  1736. } // Parses a hunk
  1737. // This assumes that we are at the start of a hunk.
  1738. function parseHunk() {
  1739. var chunkHeaderIndex = i,
  1740. chunkHeaderLine = diffstr[i++],
  1741. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1742. var hunk = {
  1743. oldStart: +chunkHeader[1],
  1744. oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
  1745. newStart: +chunkHeader[3],
  1746. newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
  1747. lines: [],
  1748. linedelimiters: []
  1749. }; // Unified Diff Format quirk: If the chunk size is 0,
  1750. // the first number is one lower than one would expect.
  1751. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  1752. if (hunk.oldLines === 0) {
  1753. hunk.oldStart += 1;
  1754. }
  1755. if (hunk.newLines === 0) {
  1756. hunk.newStart += 1;
  1757. }
  1758. var addCount = 0,
  1759. removeCount = 0;
  1760. for (; i < diffstr.length; i++) {
  1761. // Lines starting with '---' could be mistaken for the "remove line" operation
  1762. // But they could be the header for the next file. Therefore prune such cases out.
  1763. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1764. break;
  1765. }
  1766. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  1767. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1768. hunk.lines.push(diffstr[i]);
  1769. hunk.linedelimiters.push(delimiters[i] || '\n');
  1770. if (operation === '+') {
  1771. addCount++;
  1772. } else if (operation === '-') {
  1773. removeCount++;
  1774. } else if (operation === ' ') {
  1775. addCount++;
  1776. removeCount++;
  1777. }
  1778. } else {
  1779. break;
  1780. }
  1781. } // Handle the empty block count case
  1782. if (!addCount && hunk.newLines === 1) {
  1783. hunk.newLines = 0;
  1784. }
  1785. if (!removeCount && hunk.oldLines === 1) {
  1786. hunk.oldLines = 0;
  1787. } // Perform optional sanity checking
  1788. if (options.strict) {
  1789. if (addCount !== hunk.newLines) {
  1790. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1791. }
  1792. if (removeCount !== hunk.oldLines) {
  1793. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1794. }
  1795. }
  1796. return hunk;
  1797. }
  1798. while (i < diffstr.length) {
  1799. parseIndex();
  1800. }
  1801. return list;
  1802. }
  1803. var distanceIterator = {};
  1804. /*istanbul ignore start*/
  1805. (function (exports) {
  1806. Object.defineProperty(exports, "__esModule", {
  1807. value: true
  1808. });
  1809. exports["default"] = _default;
  1810. /*istanbul ignore end*/
  1811. // Iterator that traverses in the range of [min, max], stepping
  1812. // by distance from a given start position. I.e. for [0, 4], with
  1813. // start of 2, this will iterate 2, 3, 1, 4, 0.
  1814. function
  1815. /*istanbul ignore start*/
  1816. _default
  1817. /*istanbul ignore end*/
  1818. (start, minLine, maxLine) {
  1819. var wantForward = true,
  1820. backwardExhausted = false,
  1821. forwardExhausted = false,
  1822. localOffset = 1;
  1823. return function iterator() {
  1824. if (wantForward && !forwardExhausted) {
  1825. if (backwardExhausted) {
  1826. localOffset++;
  1827. } else {
  1828. wantForward = false;
  1829. } // Check if trying to fit beyond text length, and if not, check it fits
  1830. // after offset location (or desired location on first iteration)
  1831. if (start + localOffset <= maxLine) {
  1832. return localOffset;
  1833. }
  1834. forwardExhausted = true;
  1835. }
  1836. if (!backwardExhausted) {
  1837. if (!forwardExhausted) {
  1838. wantForward = true;
  1839. } // Check if trying to fit before text beginning, and if not, check it fits
  1840. // before offset location
  1841. if (minLine <= start - localOffset) {
  1842. return -localOffset++;
  1843. }
  1844. backwardExhausted = true;
  1845. return iterator();
  1846. } // We tried to fit hunk before text beginning and beyond text length, then
  1847. // hunk can't fit on the text. Return undefined
  1848. };
  1849. }
  1850. })(distanceIterator);
  1851. /*istanbul ignore start*/
  1852. Object.defineProperty(apply, "__esModule", {
  1853. value: true
  1854. });
  1855. apply.applyPatch = applyPatch;
  1856. apply.applyPatches = applyPatches;
  1857. /*istanbul ignore end*/
  1858. var
  1859. /*istanbul ignore start*/
  1860. _parse$1 = parse$e
  1861. /*istanbul ignore end*/
  1862. ;
  1863. var
  1864. /*istanbul ignore start*/
  1865. _distanceIterator = _interopRequireDefault$1(distanceIterator)
  1866. /*istanbul ignore end*/
  1867. ;
  1868. /*istanbul ignore start*/
  1869. function _interopRequireDefault$1(obj) {
  1870. return obj && obj.__esModule ? obj : {
  1871. "default": obj
  1872. };
  1873. }
  1874. /*istanbul ignore end*/
  1875. function applyPatch(source, uniDiff) {
  1876. /*istanbul ignore start*/
  1877. var
  1878. /*istanbul ignore end*/
  1879. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1880. if (typeof uniDiff === 'string') {
  1881. uniDiff =
  1882. /*istanbul ignore start*/
  1883. (/*istanbul ignore end*/
  1884. /*istanbul ignore start*/
  1885. 0, _parse$1
  1886. /*istanbul ignore end*/
  1887. .
  1888. /*istanbul ignore start*/
  1889. parsePatch
  1890. /*istanbul ignore end*/
  1891. )(uniDiff);
  1892. }
  1893. if (Array.isArray(uniDiff)) {
  1894. if (uniDiff.length > 1) {
  1895. throw new Error('applyPatch only works with a single input.');
  1896. }
  1897. uniDiff = uniDiff[0];
  1898. } // Apply the diff to the input
  1899. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1900. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1901. hunks = uniDiff.hunks,
  1902. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1903. /*istanbul ignore start*/
  1904. {
  1905. return (
  1906. /*istanbul ignore end*/
  1907. line === patchContent
  1908. );
  1909. },
  1910. errorCount = 0,
  1911. fuzzFactor = options.fuzzFactor || 0,
  1912. minLine = 0,
  1913. offset = 0,
  1914. removeEOFNL,
  1915. addEOFNL;
  1916. /**
  1917. * Checks if the hunk exactly fits on the provided location
  1918. */
  1919. function hunkFits(hunk, toPos) {
  1920. for (var j = 0; j < hunk.lines.length; j++) {
  1921. var line = hunk.lines[j],
  1922. operation = line.length > 0 ? line[0] : ' ',
  1923. content = line.length > 0 ? line.substr(1) : line;
  1924. if (operation === ' ' || operation === '-') {
  1925. // Context sanity check
  1926. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1927. errorCount++;
  1928. if (errorCount > fuzzFactor) {
  1929. return false;
  1930. }
  1931. }
  1932. toPos++;
  1933. }
  1934. }
  1935. return true;
  1936. } // Search best fit offsets for each hunk based on the previous ones
  1937. for (var i = 0; i < hunks.length; i++) {
  1938. var hunk = hunks[i],
  1939. maxLine = lines.length - hunk.oldLines,
  1940. localOffset = 0,
  1941. toPos = offset + hunk.oldStart - 1;
  1942. var iterator =
  1943. /*istanbul ignore start*/
  1944. (/*istanbul ignore end*/
  1945. /*istanbul ignore start*/
  1946. 0, _distanceIterator
  1947. /*istanbul ignore end*/
  1948. [
  1949. /*istanbul ignore start*/
  1950. "default"
  1951. /*istanbul ignore end*/
  1952. ])(toPos, minLine, maxLine);
  1953. for (; localOffset !== undefined; localOffset = iterator()) {
  1954. if (hunkFits(hunk, toPos + localOffset)) {
  1955. hunk.offset = offset += localOffset;
  1956. break;
  1957. }
  1958. }
  1959. if (localOffset === undefined) {
  1960. return false;
  1961. } // Set lower text limit to end of the current hunk, so next ones don't try
  1962. // to fit over already patched text
  1963. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1964. } // Apply patch hunks
  1965. var diffOffset = 0;
  1966. for (var _i = 0; _i < hunks.length; _i++) {
  1967. var _hunk = hunks[_i],
  1968. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  1969. diffOffset += _hunk.newLines - _hunk.oldLines;
  1970. for (var j = 0; j < _hunk.lines.length; j++) {
  1971. var line = _hunk.lines[j],
  1972. operation = line.length > 0 ? line[0] : ' ',
  1973. content = line.length > 0 ? line.substr(1) : line,
  1974. delimiter = _hunk.linedelimiters[j];
  1975. if (operation === ' ') {
  1976. _toPos++;
  1977. } else if (operation === '-') {
  1978. lines.splice(_toPos, 1);
  1979. delimiters.splice(_toPos, 1);
  1980. /* istanbul ignore else */
  1981. } else if (operation === '+') {
  1982. lines.splice(_toPos, 0, content);
  1983. delimiters.splice(_toPos, 0, delimiter);
  1984. _toPos++;
  1985. } else if (operation === '\\') {
  1986. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1987. if (previousOperation === '+') {
  1988. removeEOFNL = true;
  1989. } else if (previousOperation === '-') {
  1990. addEOFNL = true;
  1991. }
  1992. }
  1993. }
  1994. } // Handle EOFNL insertion/removal
  1995. if (removeEOFNL) {
  1996. while (!lines[lines.length - 1]) {
  1997. lines.pop();
  1998. delimiters.pop();
  1999. }
  2000. } else if (addEOFNL) {
  2001. lines.push('');
  2002. delimiters.push('\n');
  2003. }
  2004. for (var _k = 0; _k < lines.length - 1; _k++) {
  2005. lines[_k] = lines[_k] + delimiters[_k];
  2006. }
  2007. return lines.join('');
  2008. } // Wrapper that supports multiple file patches via callbacks.
  2009. function applyPatches(uniDiff, options) {
  2010. if (typeof uniDiff === 'string') {
  2011. uniDiff =
  2012. /*istanbul ignore start*/
  2013. (/*istanbul ignore end*/
  2014. /*istanbul ignore start*/
  2015. 0, _parse$1
  2016. /*istanbul ignore end*/
  2017. .
  2018. /*istanbul ignore start*/
  2019. parsePatch
  2020. /*istanbul ignore end*/
  2021. )(uniDiff);
  2022. }
  2023. var currentIndex = 0;
  2024. function processIndex() {
  2025. var index = uniDiff[currentIndex++];
  2026. if (!index) {
  2027. return options.complete();
  2028. }
  2029. options.loadFile(index, function (err, data) {
  2030. if (err) {
  2031. return options.complete(err);
  2032. }
  2033. var updatedContent = applyPatch(data, index, options);
  2034. options.patched(index, updatedContent, function (err) {
  2035. if (err) {
  2036. return options.complete(err);
  2037. }
  2038. processIndex();
  2039. });
  2040. });
  2041. }
  2042. processIndex();
  2043. }
  2044. var merge$2 = {};
  2045. var create$1 = {};
  2046. /*istanbul ignore start*/
  2047. Object.defineProperty(create$1, "__esModule", {
  2048. value: true
  2049. });
  2050. create$1.structuredPatch = structuredPatch;
  2051. create$1.formatPatch = formatPatch;
  2052. create$1.createTwoFilesPatch = createTwoFilesPatch;
  2053. create$1.createPatch = createPatch;
  2054. /*istanbul ignore end*/
  2055. var
  2056. /*istanbul ignore start*/
  2057. _line = line$B
  2058. /*istanbul ignore end*/
  2059. ;
  2060. /*istanbul ignore start*/
  2061. function _toConsumableArray$1(arr) {
  2062. return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
  2063. }
  2064. function _nonIterableSpread$1() {
  2065. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2066. }
  2067. function _unsupportedIterableToArray$1(o, minLen) {
  2068. if (!o) return;
  2069. if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
  2070. var n = Object.prototype.toString.call(o).slice(8, -1);
  2071. if (n === "Object" && o.constructor) n = o.constructor.name;
  2072. if (n === "Map" || n === "Set") return Array.from(o);
  2073. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
  2074. }
  2075. function _iterableToArray$1(iter) {
  2076. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  2077. }
  2078. function _arrayWithoutHoles$1(arr) {
  2079. if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
  2080. }
  2081. function _arrayLikeToArray$1(arr, len) {
  2082. if (len == null || len > arr.length) len = arr.length;
  2083. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2084. arr2[i] = arr[i];
  2085. }
  2086. return arr2;
  2087. }
  2088. /*istanbul ignore end*/
  2089. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  2090. if (!options) {
  2091. options = {};
  2092. }
  2093. if (typeof options.context === 'undefined') {
  2094. options.context = 4;
  2095. }
  2096. var diff =
  2097. /*istanbul ignore start*/
  2098. (/*istanbul ignore end*/
  2099. /*istanbul ignore start*/
  2100. 0, _line
  2101. /*istanbul ignore end*/
  2102. .
  2103. /*istanbul ignore start*/
  2104. diffLines
  2105. /*istanbul ignore end*/
  2106. )(oldStr, newStr, options);
  2107. diff.push({
  2108. value: '',
  2109. lines: []
  2110. }); // Append an empty value to make cleanup easier
  2111. function contextLines(lines) {
  2112. return lines.map(function (entry) {
  2113. return ' ' + entry;
  2114. });
  2115. }
  2116. var hunks = [];
  2117. var oldRangeStart = 0,
  2118. newRangeStart = 0,
  2119. curRange = [],
  2120. oldLine = 1,
  2121. newLine = 1;
  2122. /*istanbul ignore start*/
  2123. var _loop = function _loop(
  2124. /*istanbul ignore end*/
  2125. i) {
  2126. var current = diff[i],
  2127. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  2128. current.lines = lines;
  2129. if (current.added || current.removed) {
  2130. /*istanbul ignore start*/
  2131. var _curRange;
  2132. /*istanbul ignore end*/
  2133. // If we have previous context, start with that
  2134. if (!oldRangeStart) {
  2135. var prev = diff[i - 1];
  2136. oldRangeStart = oldLine;
  2137. newRangeStart = newLine;
  2138. if (prev) {
  2139. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  2140. oldRangeStart -= curRange.length;
  2141. newRangeStart -= curRange.length;
  2142. }
  2143. } // Output our changes
  2144. /*istanbul ignore start*/
  2145. /*istanbul ignore end*/
  2146. /*istanbul ignore start*/
  2147. (_curRange =
  2148. /*istanbul ignore end*/
  2149. curRange).push.apply(
  2150. /*istanbul ignore start*/
  2151. _curRange
  2152. /*istanbul ignore end*/
  2153. ,
  2154. /*istanbul ignore start*/
  2155. _toConsumableArray$1(
  2156. /*istanbul ignore end*/
  2157. lines.map(function (entry) {
  2158. return (current.added ? '+' : '-') + entry;
  2159. }))); // Track the updated file position
  2160. if (current.added) {
  2161. newLine += lines.length;
  2162. } else {
  2163. oldLine += lines.length;
  2164. }
  2165. } else {
  2166. // Identical context lines. Track line changes
  2167. if (oldRangeStart) {
  2168. // Close out any changes that have been output (or join overlapping)
  2169. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  2170. /*istanbul ignore start*/
  2171. var _curRange2;
  2172. /*istanbul ignore end*/
  2173. // Overlapping
  2174. /*istanbul ignore start*/
  2175. /*istanbul ignore end*/
  2176. /*istanbul ignore start*/
  2177. (_curRange2 =
  2178. /*istanbul ignore end*/
  2179. curRange).push.apply(
  2180. /*istanbul ignore start*/
  2181. _curRange2
  2182. /*istanbul ignore end*/
  2183. ,
  2184. /*istanbul ignore start*/
  2185. _toConsumableArray$1(
  2186. /*istanbul ignore end*/
  2187. contextLines(lines)));
  2188. } else {
  2189. /*istanbul ignore start*/
  2190. var _curRange3;
  2191. /*istanbul ignore end*/
  2192. // end the range and output
  2193. var contextSize = Math.min(lines.length, options.context);
  2194. /*istanbul ignore start*/
  2195. /*istanbul ignore end*/
  2196. /*istanbul ignore start*/
  2197. (_curRange3 =
  2198. /*istanbul ignore end*/
  2199. curRange).push.apply(
  2200. /*istanbul ignore start*/
  2201. _curRange3
  2202. /*istanbul ignore end*/
  2203. ,
  2204. /*istanbul ignore start*/
  2205. _toConsumableArray$1(
  2206. /*istanbul ignore end*/
  2207. contextLines(lines.slice(0, contextSize))));
  2208. var hunk = {
  2209. oldStart: oldRangeStart,
  2210. oldLines: oldLine - oldRangeStart + contextSize,
  2211. newStart: newRangeStart,
  2212. newLines: newLine - newRangeStart + contextSize,
  2213. lines: curRange
  2214. };
  2215. if (i >= diff.length - 2 && lines.length <= options.context) {
  2216. // EOF is inside this hunk
  2217. var oldEOFNewline = /\n$/.test(oldStr);
  2218. var newEOFNewline = /\n$/.test(newStr);
  2219. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  2220. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  2221. // special case: old has no eol and no trailing context; no-nl can end up before adds
  2222. // however, if the old file is empty, do not output the no-nl line
  2223. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  2224. }
  2225. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  2226. curRange.push('\\ No newline at end of file');
  2227. }
  2228. }
  2229. hunks.push(hunk);
  2230. oldRangeStart = 0;
  2231. newRangeStart = 0;
  2232. curRange = [];
  2233. }
  2234. }
  2235. oldLine += lines.length;
  2236. newLine += lines.length;
  2237. }
  2238. };
  2239. for (var i = 0; i < diff.length; i++) {
  2240. /*istanbul ignore start*/
  2241. _loop(
  2242. /*istanbul ignore end*/
  2243. i);
  2244. }
  2245. return {
  2246. oldFileName: oldFileName,
  2247. newFileName: newFileName,
  2248. oldHeader: oldHeader,
  2249. newHeader: newHeader,
  2250. hunks: hunks
  2251. };
  2252. }
  2253. function formatPatch(diff) {
  2254. var ret = [];
  2255. if (diff.oldFileName == diff.newFileName) {
  2256. ret.push('Index: ' + diff.oldFileName);
  2257. }
  2258. ret.push('===================================================================');
  2259. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  2260. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  2261. for (var i = 0; i < diff.hunks.length; i++) {
  2262. var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
  2263. // the first number is one lower than one would expect.
  2264. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  2265. if (hunk.oldLines === 0) {
  2266. hunk.oldStart -= 1;
  2267. }
  2268. if (hunk.newLines === 0) {
  2269. hunk.newStart -= 1;
  2270. }
  2271. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  2272. ret.push.apply(ret, hunk.lines);
  2273. }
  2274. return ret.join('\n') + '\n';
  2275. }
  2276. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  2277. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  2278. }
  2279. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  2280. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  2281. }
  2282. var array$5 = {};
  2283. /*istanbul ignore start*/
  2284. Object.defineProperty(array$5, "__esModule", {
  2285. value: true
  2286. });
  2287. array$5.arrayEqual = arrayEqual;
  2288. array$5.arrayStartsWith = arrayStartsWith;
  2289. /*istanbul ignore end*/
  2290. function arrayEqual(a, b) {
  2291. if (a.length !== b.length) {
  2292. return false;
  2293. }
  2294. return arrayStartsWith(a, b);
  2295. }
  2296. function arrayStartsWith(array, start) {
  2297. if (start.length > array.length) {
  2298. return false;
  2299. }
  2300. for (var i = 0; i < start.length; i++) {
  2301. if (start[i] !== array[i]) {
  2302. return false;
  2303. }
  2304. }
  2305. return true;
  2306. }
  2307. /*istanbul ignore start*/
  2308. Object.defineProperty(merge$2, "__esModule", {
  2309. value: true
  2310. });
  2311. merge$2.calcLineCount = calcLineCount;
  2312. merge$2.merge = merge$1;
  2313. /*istanbul ignore end*/
  2314. var
  2315. /*istanbul ignore start*/
  2316. _create = create$1
  2317. /*istanbul ignore end*/
  2318. ;
  2319. var
  2320. /*istanbul ignore start*/
  2321. _parse = parse$e
  2322. /*istanbul ignore end*/
  2323. ;
  2324. var
  2325. /*istanbul ignore start*/
  2326. _array = array$5
  2327. /*istanbul ignore end*/
  2328. ;
  2329. /*istanbul ignore start*/
  2330. function _toConsumableArray(arr) {
  2331. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  2332. }
  2333. function _nonIterableSpread() {
  2334. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2335. }
  2336. function _unsupportedIterableToArray(o, minLen) {
  2337. if (!o) return;
  2338. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2339. var n = Object.prototype.toString.call(o).slice(8, -1);
  2340. if (n === "Object" && o.constructor) n = o.constructor.name;
  2341. if (n === "Map" || n === "Set") return Array.from(o);
  2342. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2343. }
  2344. function _iterableToArray(iter) {
  2345. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  2346. }
  2347. function _arrayWithoutHoles(arr) {
  2348. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  2349. }
  2350. function _arrayLikeToArray(arr, len) {
  2351. if (len == null || len > arr.length) len = arr.length;
  2352. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2353. arr2[i] = arr[i];
  2354. }
  2355. return arr2;
  2356. }
  2357. /*istanbul ignore end*/
  2358. function calcLineCount(hunk) {
  2359. /*istanbul ignore start*/
  2360. var _calcOldNewLineCount =
  2361. /*istanbul ignore end*/
  2362. calcOldNewLineCount(hunk.lines),
  2363. oldLines = _calcOldNewLineCount.oldLines,
  2364. newLines = _calcOldNewLineCount.newLines;
  2365. if (oldLines !== undefined) {
  2366. hunk.oldLines = oldLines;
  2367. } else {
  2368. delete hunk.oldLines;
  2369. }
  2370. if (newLines !== undefined) {
  2371. hunk.newLines = newLines;
  2372. } else {
  2373. delete hunk.newLines;
  2374. }
  2375. }
  2376. function merge$1(mine, theirs, base) {
  2377. mine = loadPatch(mine, base);
  2378. theirs = loadPatch(theirs, base);
  2379. var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
  2380. // Leaving sanity checks on this to the API consumer that may know more about the
  2381. // meaning in their own context.
  2382. if (mine.index || theirs.index) {
  2383. ret.index = mine.index || theirs.index;
  2384. }
  2385. if (mine.newFileName || theirs.newFileName) {
  2386. if (!fileNameChanged(mine)) {
  2387. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  2388. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  2389. ret.newFileName = theirs.newFileName || mine.newFileName;
  2390. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  2391. ret.newHeader = theirs.newHeader || mine.newHeader;
  2392. } else if (!fileNameChanged(theirs)) {
  2393. // No header or no change in theirs, use ours
  2394. ret.oldFileName = mine.oldFileName;
  2395. ret.newFileName = mine.newFileName;
  2396. ret.oldHeader = mine.oldHeader;
  2397. ret.newHeader = mine.newHeader;
  2398. } else {
  2399. // Both changed... figure it out
  2400. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  2401. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  2402. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  2403. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  2404. }
  2405. }
  2406. ret.hunks = [];
  2407. var mineIndex = 0,
  2408. theirsIndex = 0,
  2409. mineOffset = 0,
  2410. theirsOffset = 0;
  2411. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  2412. var mineCurrent = mine.hunks[mineIndex] || {
  2413. oldStart: Infinity
  2414. },
  2415. theirsCurrent = theirs.hunks[theirsIndex] || {
  2416. oldStart: Infinity
  2417. };
  2418. if (hunkBefore(mineCurrent, theirsCurrent)) {
  2419. // This patch does not overlap with any of the others, yay.
  2420. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  2421. mineIndex++;
  2422. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  2423. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  2424. // This patch does not overlap with any of the others, yay.
  2425. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  2426. theirsIndex++;
  2427. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  2428. } else {
  2429. // Overlap, merge as best we can
  2430. var mergedHunk = {
  2431. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  2432. oldLines: 0,
  2433. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  2434. newLines: 0,
  2435. lines: []
  2436. };
  2437. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  2438. theirsIndex++;
  2439. mineIndex++;
  2440. ret.hunks.push(mergedHunk);
  2441. }
  2442. }
  2443. return ret;
  2444. }
  2445. function loadPatch(param, base) {
  2446. if (typeof param === 'string') {
  2447. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  2448. return (
  2449. /*istanbul ignore start*/
  2450. (/*istanbul ignore end*/
  2451. /*istanbul ignore start*/
  2452. 0, _parse
  2453. /*istanbul ignore end*/
  2454. .
  2455. /*istanbul ignore start*/
  2456. parsePatch
  2457. /*istanbul ignore end*/
  2458. )(param)[0]
  2459. );
  2460. }
  2461. if (!base) {
  2462. throw new Error('Must provide a base reference or pass in a patch');
  2463. }
  2464. return (
  2465. /*istanbul ignore start*/
  2466. (/*istanbul ignore end*/
  2467. /*istanbul ignore start*/
  2468. 0, _create
  2469. /*istanbul ignore end*/
  2470. .
  2471. /*istanbul ignore start*/
  2472. structuredPatch
  2473. /*istanbul ignore end*/
  2474. )(undefined, undefined, base, param)
  2475. );
  2476. }
  2477. return param;
  2478. }
  2479. function fileNameChanged(patch) {
  2480. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  2481. }
  2482. function selectField(index, mine, theirs) {
  2483. if (mine === theirs) {
  2484. return mine;
  2485. } else {
  2486. index.conflict = true;
  2487. return {
  2488. mine: mine,
  2489. theirs: theirs
  2490. };
  2491. }
  2492. }
  2493. function hunkBefore(test, check) {
  2494. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  2495. }
  2496. function cloneHunk(hunk, offset) {
  2497. return {
  2498. oldStart: hunk.oldStart,
  2499. oldLines: hunk.oldLines,
  2500. newStart: hunk.newStart + offset,
  2501. newLines: hunk.newLines,
  2502. lines: hunk.lines
  2503. };
  2504. }
  2505. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  2506. // This will generally result in a conflicted hunk, but there are cases where the context
  2507. // is the only overlap where we can successfully merge the content here.
  2508. var mine = {
  2509. offset: mineOffset,
  2510. lines: mineLines,
  2511. index: 0
  2512. },
  2513. their = {
  2514. offset: theirOffset,
  2515. lines: theirLines,
  2516. index: 0
  2517. }; // Handle any leading content
  2518. insertLeading(hunk, mine, their);
  2519. insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
  2520. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  2521. var mineCurrent = mine.lines[mine.index],
  2522. theirCurrent = their.lines[their.index];
  2523. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  2524. // Both modified ...
  2525. mutualChange(hunk, mine, their);
  2526. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  2527. /*istanbul ignore start*/
  2528. var _hunk$lines;
  2529. /*istanbul ignore end*/
  2530. // Mine inserted
  2531. /*istanbul ignore start*/
  2532. /*istanbul ignore end*/
  2533. /*istanbul ignore start*/
  2534. (_hunk$lines =
  2535. /*istanbul ignore end*/
  2536. hunk.lines).push.apply(
  2537. /*istanbul ignore start*/
  2538. _hunk$lines
  2539. /*istanbul ignore end*/
  2540. ,
  2541. /*istanbul ignore start*/
  2542. _toConsumableArray(
  2543. /*istanbul ignore end*/
  2544. collectChange(mine)));
  2545. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  2546. /*istanbul ignore start*/
  2547. var _hunk$lines2;
  2548. /*istanbul ignore end*/
  2549. // Theirs inserted
  2550. /*istanbul ignore start*/
  2551. /*istanbul ignore end*/
  2552. /*istanbul ignore start*/
  2553. (_hunk$lines2 =
  2554. /*istanbul ignore end*/
  2555. hunk.lines).push.apply(
  2556. /*istanbul ignore start*/
  2557. _hunk$lines2
  2558. /*istanbul ignore end*/
  2559. ,
  2560. /*istanbul ignore start*/
  2561. _toConsumableArray(
  2562. /*istanbul ignore end*/
  2563. collectChange(their)));
  2564. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  2565. // Mine removed or edited
  2566. removal(hunk, mine, their);
  2567. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  2568. // Their removed or edited
  2569. removal(hunk, their, mine, true);
  2570. } else if (mineCurrent === theirCurrent) {
  2571. // Context identity
  2572. hunk.lines.push(mineCurrent);
  2573. mine.index++;
  2574. their.index++;
  2575. } else {
  2576. // Context mismatch
  2577. conflict(hunk, collectChange(mine), collectChange(their));
  2578. }
  2579. } // Now push anything that may be remaining
  2580. insertTrailing(hunk, mine);
  2581. insertTrailing(hunk, their);
  2582. calcLineCount(hunk);
  2583. }
  2584. function mutualChange(hunk, mine, their) {
  2585. var myChanges = collectChange(mine),
  2586. theirChanges = collectChange(their);
  2587. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  2588. // Special case for remove changes that are supersets of one another
  2589. if (
  2590. /*istanbul ignore start*/
  2591. (/*istanbul ignore end*/
  2592. /*istanbul ignore start*/
  2593. 0, _array
  2594. /*istanbul ignore end*/
  2595. .
  2596. /*istanbul ignore start*/
  2597. arrayStartsWith
  2598. /*istanbul ignore end*/
  2599. )(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  2600. /*istanbul ignore start*/
  2601. var _hunk$lines3;
  2602. /*istanbul ignore end*/
  2603. /*istanbul ignore start*/
  2604. /*istanbul ignore end*/
  2605. /*istanbul ignore start*/
  2606. (_hunk$lines3 =
  2607. /*istanbul ignore end*/
  2608. hunk.lines).push.apply(
  2609. /*istanbul ignore start*/
  2610. _hunk$lines3
  2611. /*istanbul ignore end*/
  2612. ,
  2613. /*istanbul ignore start*/
  2614. _toConsumableArray(
  2615. /*istanbul ignore end*/
  2616. myChanges));
  2617. return;
  2618. } else if (
  2619. /*istanbul ignore start*/
  2620. (/*istanbul ignore end*/
  2621. /*istanbul ignore start*/
  2622. 0, _array
  2623. /*istanbul ignore end*/
  2624. .
  2625. /*istanbul ignore start*/
  2626. arrayStartsWith
  2627. /*istanbul ignore end*/
  2628. )(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  2629. /*istanbul ignore start*/
  2630. var _hunk$lines4;
  2631. /*istanbul ignore end*/
  2632. /*istanbul ignore start*/
  2633. /*istanbul ignore end*/
  2634. /*istanbul ignore start*/
  2635. (_hunk$lines4 =
  2636. /*istanbul ignore end*/
  2637. hunk.lines).push.apply(
  2638. /*istanbul ignore start*/
  2639. _hunk$lines4
  2640. /*istanbul ignore end*/
  2641. ,
  2642. /*istanbul ignore start*/
  2643. _toConsumableArray(
  2644. /*istanbul ignore end*/
  2645. theirChanges));
  2646. return;
  2647. }
  2648. } else if (
  2649. /*istanbul ignore start*/
  2650. (/*istanbul ignore end*/
  2651. /*istanbul ignore start*/
  2652. 0, _array
  2653. /*istanbul ignore end*/
  2654. .
  2655. /*istanbul ignore start*/
  2656. arrayEqual
  2657. /*istanbul ignore end*/
  2658. )(myChanges, theirChanges)) {
  2659. /*istanbul ignore start*/
  2660. var _hunk$lines5;
  2661. /*istanbul ignore end*/
  2662. /*istanbul ignore start*/
  2663. /*istanbul ignore end*/
  2664. /*istanbul ignore start*/
  2665. (_hunk$lines5 =
  2666. /*istanbul ignore end*/
  2667. hunk.lines).push.apply(
  2668. /*istanbul ignore start*/
  2669. _hunk$lines5
  2670. /*istanbul ignore end*/
  2671. ,
  2672. /*istanbul ignore start*/
  2673. _toConsumableArray(
  2674. /*istanbul ignore end*/
  2675. myChanges));
  2676. return;
  2677. }
  2678. conflict(hunk, myChanges, theirChanges);
  2679. }
  2680. function removal(hunk, mine, their, swap) {
  2681. var myChanges = collectChange(mine),
  2682. theirChanges = collectContext(their, myChanges);
  2683. if (theirChanges.merged) {
  2684. /*istanbul ignore start*/
  2685. var _hunk$lines6;
  2686. /*istanbul ignore end*/
  2687. /*istanbul ignore start*/
  2688. /*istanbul ignore end*/
  2689. /*istanbul ignore start*/
  2690. (_hunk$lines6 =
  2691. /*istanbul ignore end*/
  2692. hunk.lines).push.apply(
  2693. /*istanbul ignore start*/
  2694. _hunk$lines6
  2695. /*istanbul ignore end*/
  2696. ,
  2697. /*istanbul ignore start*/
  2698. _toConsumableArray(
  2699. /*istanbul ignore end*/
  2700. theirChanges.merged));
  2701. } else {
  2702. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  2703. }
  2704. }
  2705. function conflict(hunk, mine, their) {
  2706. hunk.conflict = true;
  2707. hunk.lines.push({
  2708. conflict: true,
  2709. mine: mine,
  2710. theirs: their
  2711. });
  2712. }
  2713. function insertLeading(hunk, insert, their) {
  2714. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  2715. var line = insert.lines[insert.index++];
  2716. hunk.lines.push(line);
  2717. insert.offset++;
  2718. }
  2719. }
  2720. function insertTrailing(hunk, insert) {
  2721. while (insert.index < insert.lines.length) {
  2722. var line = insert.lines[insert.index++];
  2723. hunk.lines.push(line);
  2724. }
  2725. }
  2726. function collectChange(state) {
  2727. var ret = [],
  2728. operation = state.lines[state.index][0];
  2729. while (state.index < state.lines.length) {
  2730. var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  2731. if (operation === '-' && line[0] === '+') {
  2732. operation = '+';
  2733. }
  2734. if (operation === line[0]) {
  2735. ret.push(line);
  2736. state.index++;
  2737. } else {
  2738. break;
  2739. }
  2740. }
  2741. return ret;
  2742. }
  2743. function collectContext(state, matchChanges) {
  2744. var changes = [],
  2745. merged = [],
  2746. matchIndex = 0,
  2747. contextChanges = false,
  2748. conflicted = false;
  2749. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  2750. var change = state.lines[state.index],
  2751. match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
  2752. if (match[0] === '+') {
  2753. break;
  2754. }
  2755. contextChanges = contextChanges || change[0] !== ' ';
  2756. merged.push(match);
  2757. matchIndex++; // Consume any additions in the other block as a conflict to attempt
  2758. // to pull in the remaining context after this
  2759. if (change[0] === '+') {
  2760. conflicted = true;
  2761. while (change[0] === '+') {
  2762. changes.push(change);
  2763. change = state.lines[++state.index];
  2764. }
  2765. }
  2766. if (match.substr(1) === change.substr(1)) {
  2767. changes.push(change);
  2768. state.index++;
  2769. } else {
  2770. conflicted = true;
  2771. }
  2772. }
  2773. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  2774. conflicted = true;
  2775. }
  2776. if (conflicted) {
  2777. return changes;
  2778. }
  2779. while (matchIndex < matchChanges.length) {
  2780. merged.push(matchChanges[matchIndex++]);
  2781. }
  2782. return {
  2783. merged: merged,
  2784. changes: changes
  2785. };
  2786. }
  2787. function allRemoves(changes) {
  2788. return changes.reduce(function (prev, change) {
  2789. return prev && change[0] === '-';
  2790. }, true);
  2791. }
  2792. function skipRemoveSuperset(state, removeChanges, delta) {
  2793. for (var i = 0; i < delta; i++) {
  2794. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  2795. if (state.lines[state.index + i] !== ' ' + changeContent) {
  2796. return false;
  2797. }
  2798. }
  2799. state.index += delta;
  2800. return true;
  2801. }
  2802. function calcOldNewLineCount(lines) {
  2803. var oldLines = 0;
  2804. var newLines = 0;
  2805. lines.forEach(function (line) {
  2806. if (typeof line !== 'string') {
  2807. var myCount = calcOldNewLineCount(line.mine);
  2808. var theirCount = calcOldNewLineCount(line.theirs);
  2809. if (oldLines !== undefined) {
  2810. if (myCount.oldLines === theirCount.oldLines) {
  2811. oldLines += myCount.oldLines;
  2812. } else {
  2813. oldLines = undefined;
  2814. }
  2815. }
  2816. if (newLines !== undefined) {
  2817. if (myCount.newLines === theirCount.newLines) {
  2818. newLines += myCount.newLines;
  2819. } else {
  2820. newLines = undefined;
  2821. }
  2822. }
  2823. } else {
  2824. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  2825. newLines++;
  2826. }
  2827. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  2828. oldLines++;
  2829. }
  2830. }
  2831. });
  2832. return {
  2833. oldLines: oldLines,
  2834. newLines: newLines
  2835. };
  2836. }
  2837. var dmp = {};
  2838. /*istanbul ignore start*/
  2839. Object.defineProperty(dmp, "__esModule", {
  2840. value: true
  2841. });
  2842. dmp.convertChangesToDMP = convertChangesToDMP;
  2843. /*istanbul ignore end*/
  2844. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  2845. function convertChangesToDMP(changes) {
  2846. var ret = [],
  2847. change,
  2848. operation;
  2849. for (var i = 0; i < changes.length; i++) {
  2850. change = changes[i];
  2851. if (change.added) {
  2852. operation = 1;
  2853. } else if (change.removed) {
  2854. operation = -1;
  2855. } else {
  2856. operation = 0;
  2857. }
  2858. ret.push([operation, change.value]);
  2859. }
  2860. return ret;
  2861. }
  2862. var xml = {};
  2863. /*istanbul ignore start*/
  2864. Object.defineProperty(xml, "__esModule", {
  2865. value: true
  2866. });
  2867. xml.convertChangesToXML = convertChangesToXML;
  2868. /*istanbul ignore end*/
  2869. function convertChangesToXML(changes) {
  2870. var ret = [];
  2871. for (var i = 0; i < changes.length; i++) {
  2872. var change = changes[i];
  2873. if (change.added) {
  2874. ret.push('<ins>');
  2875. } else if (change.removed) {
  2876. ret.push('<del>');
  2877. }
  2878. ret.push(escapeHTML(change.value));
  2879. if (change.added) {
  2880. ret.push('</ins>');
  2881. } else if (change.removed) {
  2882. ret.push('</del>');
  2883. }
  2884. }
  2885. return ret.join('');
  2886. }
  2887. function escapeHTML(s) {
  2888. var n = s;
  2889. n = n.replace(/&/g, '&amp;');
  2890. n = n.replace(/</g, '&lt;');
  2891. n = n.replace(/>/g, '&gt;');
  2892. n = n.replace(/"/g, '&quot;');
  2893. return n;
  2894. }
  2895. /*istanbul ignore start*/
  2896. (function (exports) {
  2897. Object.defineProperty(exports, "__esModule", {
  2898. value: true
  2899. });
  2900. Object.defineProperty(exports, "Diff", {
  2901. enumerable: true,
  2902. get: function get() {
  2903. return _base["default"];
  2904. }
  2905. });
  2906. Object.defineProperty(exports, "diffChars", {
  2907. enumerable: true,
  2908. get: function get() {
  2909. return _character.diffChars;
  2910. }
  2911. });
  2912. Object.defineProperty(exports, "diffWords", {
  2913. enumerable: true,
  2914. get: function get() {
  2915. return _word.diffWords;
  2916. }
  2917. });
  2918. Object.defineProperty(exports, "diffWordsWithSpace", {
  2919. enumerable: true,
  2920. get: function get() {
  2921. return _word.diffWordsWithSpace;
  2922. }
  2923. });
  2924. Object.defineProperty(exports, "diffLines", {
  2925. enumerable: true,
  2926. get: function get() {
  2927. return _line.diffLines;
  2928. }
  2929. });
  2930. Object.defineProperty(exports, "diffTrimmedLines", {
  2931. enumerable: true,
  2932. get: function get() {
  2933. return _line.diffTrimmedLines;
  2934. }
  2935. });
  2936. Object.defineProperty(exports, "diffSentences", {
  2937. enumerable: true,
  2938. get: function get() {
  2939. return _sentence.diffSentences;
  2940. }
  2941. });
  2942. Object.defineProperty(exports, "diffCss", {
  2943. enumerable: true,
  2944. get: function get() {
  2945. return _css.diffCss;
  2946. }
  2947. });
  2948. Object.defineProperty(exports, "diffJson", {
  2949. enumerable: true,
  2950. get: function get() {
  2951. return _json.diffJson;
  2952. }
  2953. });
  2954. Object.defineProperty(exports, "canonicalize", {
  2955. enumerable: true,
  2956. get: function get() {
  2957. return _json.canonicalize;
  2958. }
  2959. });
  2960. Object.defineProperty(exports, "diffArrays", {
  2961. enumerable: true,
  2962. get: function get() {
  2963. return _array.diffArrays;
  2964. }
  2965. });
  2966. Object.defineProperty(exports, "applyPatch", {
  2967. enumerable: true,
  2968. get: function get() {
  2969. return _apply.applyPatch;
  2970. }
  2971. });
  2972. Object.defineProperty(exports, "applyPatches", {
  2973. enumerable: true,
  2974. get: function get() {
  2975. return _apply.applyPatches;
  2976. }
  2977. });
  2978. Object.defineProperty(exports, "parsePatch", {
  2979. enumerable: true,
  2980. get: function get() {
  2981. return _parse.parsePatch;
  2982. }
  2983. });
  2984. Object.defineProperty(exports, "merge", {
  2985. enumerable: true,
  2986. get: function get() {
  2987. return _merge.merge;
  2988. }
  2989. });
  2990. Object.defineProperty(exports, "structuredPatch", {
  2991. enumerable: true,
  2992. get: function get() {
  2993. return _create.structuredPatch;
  2994. }
  2995. });
  2996. Object.defineProperty(exports, "createTwoFilesPatch", {
  2997. enumerable: true,
  2998. get: function get() {
  2999. return _create.createTwoFilesPatch;
  3000. }
  3001. });
  3002. Object.defineProperty(exports, "createPatch", {
  3003. enumerable: true,
  3004. get: function get() {
  3005. return _create.createPatch;
  3006. }
  3007. });
  3008. Object.defineProperty(exports, "convertChangesToDMP", {
  3009. enumerable: true,
  3010. get: function get() {
  3011. return _dmp.convertChangesToDMP;
  3012. }
  3013. });
  3014. Object.defineProperty(exports, "convertChangesToXML", {
  3015. enumerable: true,
  3016. get: function get() {
  3017. return _xml.convertChangesToXML;
  3018. }
  3019. });
  3020. /*istanbul ignore end*/
  3021. var
  3022. /*istanbul ignore start*/
  3023. _base = _interopRequireDefault(base$1)
  3024. /*istanbul ignore end*/
  3025. ;
  3026. var
  3027. /*istanbul ignore start*/
  3028. _character = character
  3029. /*istanbul ignore end*/
  3030. ;
  3031. var
  3032. /*istanbul ignore start*/
  3033. _word = word
  3034. /*istanbul ignore end*/
  3035. ;
  3036. var
  3037. /*istanbul ignore start*/
  3038. _line = line$B
  3039. /*istanbul ignore end*/
  3040. ;
  3041. var
  3042. /*istanbul ignore start*/
  3043. _sentence = sentence
  3044. /*istanbul ignore end*/
  3045. ;
  3046. var
  3047. /*istanbul ignore start*/
  3048. _css = css$1
  3049. /*istanbul ignore end*/
  3050. ;
  3051. var
  3052. /*istanbul ignore start*/
  3053. _json = json
  3054. /*istanbul ignore end*/
  3055. ;
  3056. var
  3057. /*istanbul ignore start*/
  3058. _array = array$6
  3059. /*istanbul ignore end*/
  3060. ;
  3061. var
  3062. /*istanbul ignore start*/
  3063. _apply = apply
  3064. /*istanbul ignore end*/
  3065. ;
  3066. var
  3067. /*istanbul ignore start*/
  3068. _parse = parse$e
  3069. /*istanbul ignore end*/
  3070. ;
  3071. var
  3072. /*istanbul ignore start*/
  3073. _merge = merge$2
  3074. /*istanbul ignore end*/
  3075. ;
  3076. var
  3077. /*istanbul ignore start*/
  3078. _create = create$1
  3079. /*istanbul ignore end*/
  3080. ;
  3081. var
  3082. /*istanbul ignore start*/
  3083. _dmp = dmp
  3084. /*istanbul ignore end*/
  3085. ;
  3086. var
  3087. /*istanbul ignore start*/
  3088. _xml = xml
  3089. /*istanbul ignore end*/
  3090. ;
  3091. /*istanbul ignore start*/
  3092. function _interopRequireDefault(obj) {
  3093. return obj && obj.__esModule ? obj : {
  3094. "default": obj
  3095. };
  3096. }
  3097. /*istanbul ignore end*/
  3098. })(lib$6);
  3099. var require$$7$3 = require("./doc.js");
  3100. var stringWidth$2 = {exports: {}};
  3101. var ansiRegex$1 = ({
  3102. onlyFirst = false
  3103. } = {}) => {
  3104. const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  3105. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  3106. };
  3107. const ansiRegex = ansiRegex$1;
  3108. var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
  3109. var isFullwidthCodePoint$2 = {exports: {}};
  3110. /* eslint-disable yoda */
  3111. const isFullwidthCodePoint$1 = codePoint => {
  3112. if (Number.isNaN(codePoint)) {
  3113. return false;
  3114. } // Code points are derived from:
  3115. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  3116. if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
  3117. codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  3118. codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
  3119. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  3120. 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  3121. 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
  3122. 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
  3123. 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
  3124. 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
  3125. 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
  3126. 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
  3127. 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
  3128. 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
  3129. 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
  3130. 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  3131. 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
  3132. return true;
  3133. }
  3134. return false;
  3135. };
  3136. isFullwidthCodePoint$2.exports = isFullwidthCodePoint$1;
  3137. isFullwidthCodePoint$2.exports.default = isFullwidthCodePoint$1;
  3138. var emojiRegex$1 = function () {
  3139. // https://mths.be/emoji
  3140. return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
  3141. };
  3142. const stripAnsi = stripAnsi$1;
  3143. const isFullwidthCodePoint = isFullwidthCodePoint$2.exports;
  3144. const emojiRegex = emojiRegex$1;
  3145. const stringWidth$1 = string => {
  3146. if (typeof string !== 'string' || string.length === 0) {
  3147. return 0;
  3148. }
  3149. string = stripAnsi(string);
  3150. if (string.length === 0) {
  3151. return 0;
  3152. }
  3153. string = string.replace(emojiRegex(), ' ');
  3154. let width = 0;
  3155. for (let i = 0; i < string.length; i++) {
  3156. const code = string.codePointAt(i); // Ignore control characters
  3157. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  3158. continue;
  3159. } // Ignore combining characters
  3160. if (code >= 0x300 && code <= 0x36F) {
  3161. continue;
  3162. } // Surrogates
  3163. if (code > 0xFFFF) {
  3164. i++;
  3165. }
  3166. width += isFullwidthCodePoint(code) ? 2 : 1;
  3167. }
  3168. return width;
  3169. };
  3170. stringWidth$2.exports = stringWidth$1; // TODO: remove this in the next major version
  3171. stringWidth$2.exports.default = stringWidth$1;
  3172. var escapeStringRegexp$3 = string => {
  3173. if (typeof string !== 'string') {
  3174. throw new TypeError('Expected a string');
  3175. } // Escape characters with special meaning either inside or outside character sets.
  3176. // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
  3177. return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
  3178. };
  3179. const getLast$p = arr => arr[arr.length - 1];
  3180. var getLast_1 = getLast$p;
  3181. function _objectWithoutPropertiesLoose(source, excluded) {
  3182. if (source == null) return {};
  3183. var target = {};
  3184. var sourceKeys = Object.keys(source);
  3185. var key, i;
  3186. for (i = 0; i < sourceKeys.length; i++) {
  3187. key = sourceKeys[i];
  3188. if (excluded.indexOf(key) >= 0) continue;
  3189. target[key] = source[key];
  3190. }
  3191. return target;
  3192. }
  3193. function _objectWithoutProperties(source, excluded) {
  3194. if (source == null) return {};
  3195. var target = _objectWithoutPropertiesLoose(source, excluded);
  3196. var key, i;
  3197. if (Object.getOwnPropertySymbols) {
  3198. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  3199. for (i = 0; i < sourceSymbolKeys.length; i++) {
  3200. key = sourceSymbolKeys[i];
  3201. if (excluded.indexOf(key) >= 0) continue;
  3202. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  3203. target[key] = source[key];
  3204. }
  3205. }
  3206. return target;
  3207. }
  3208. var classof$2 = classofRaw$1;
  3209. // `IsArray` abstract operation
  3210. // https://tc39.es/ecma262/#sec-isarray
  3211. // eslint-disable-next-line es/no-array-isarray -- safe
  3212. var isArray$e = Array.isArray || function isArray(argument) {
  3213. return classof$2(argument) == 'Array';
  3214. };
  3215. var uncurryThis$1 = functionUncurryThis;
  3216. var aCallable$2 = aCallable$5;
  3217. var bind$3 = uncurryThis$1(uncurryThis$1.bind);
  3218. // optional / simple context binding
  3219. var functionBindContext = function (fn, that) {
  3220. aCallable$2(fn);
  3221. return that === undefined ? fn : bind$3 ? bind$3(fn, that) : function (/* ...args */) {
  3222. return fn.apply(that, arguments);
  3223. };
  3224. };
  3225. var global$5 = global$s;
  3226. var isArray$d = isArray$e;
  3227. var lengthOfArrayLike$3 = lengthOfArrayLike$6;
  3228. var bind$2 = functionBindContext;
  3229. var TypeError$3 = global$5.TypeError;
  3230. // `FlattenIntoArray` abstract operation
  3231. // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
  3232. var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
  3233. var targetIndex = start;
  3234. var sourceIndex = 0;
  3235. var mapFn = mapper ? bind$2(mapper, thisArg) : false;
  3236. var element, elementLen;
  3237. while (sourceIndex < sourceLen) {
  3238. if (sourceIndex in source) {
  3239. element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
  3240. if (depth > 0 && isArray$d(element)) {
  3241. elementLen = lengthOfArrayLike$3(element);
  3242. targetIndex = flattenIntoArray$2(target, original, element, elementLen, targetIndex, depth - 1) - 1;
  3243. } else {
  3244. if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError$3('Exceed the acceptable array length');
  3245. target[targetIndex] = element;
  3246. }
  3247. targetIndex++;
  3248. }
  3249. sourceIndex++;
  3250. }
  3251. return targetIndex;
  3252. };
  3253. var flattenIntoArray_1 = flattenIntoArray$2;
  3254. var uncurryThis = functionUncurryThis;
  3255. var fails = fails$8;
  3256. var isCallable = isCallable$b;
  3257. var classof$1 = classof$4;
  3258. var getBuiltIn$1 = getBuiltIn$5;
  3259. var inspectSource = inspectSource$3;
  3260. var noop$3 = function () { /* empty */ };
  3261. var empty = [];
  3262. var construct = getBuiltIn$1('Reflect', 'construct');
  3263. var constructorRegExp = /^\s*(?:class|function)\b/;
  3264. var exec = uncurryThis(constructorRegExp.exec);
  3265. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop$3);
  3266. var isConstructorModern = function (argument) {
  3267. if (!isCallable(argument)) return false;
  3268. try {
  3269. construct(noop$3, empty, argument);
  3270. return true;
  3271. } catch (error) {
  3272. return false;
  3273. }
  3274. };
  3275. var isConstructorLegacy = function (argument) {
  3276. if (!isCallable(argument)) return false;
  3277. switch (classof$1(argument)) {
  3278. case 'AsyncFunction':
  3279. case 'GeneratorFunction':
  3280. case 'AsyncGeneratorFunction': return false;
  3281. // we can't check .prototype since constructors produced by .bind haven't it
  3282. } return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  3283. };
  3284. // `IsConstructor` abstract operation
  3285. // https://tc39.es/ecma262/#sec-isconstructor
  3286. var isConstructor$1 = !construct || fails(function () {
  3287. var called;
  3288. return isConstructorModern(isConstructorModern.call)
  3289. || !isConstructorModern(Object)
  3290. || !isConstructorModern(function () { called = true; })
  3291. || called;
  3292. }) ? isConstructorLegacy : isConstructorModern;
  3293. var global$4 = global$s;
  3294. var isArray$c = isArray$e;
  3295. var isConstructor = isConstructor$1;
  3296. var isObject$6 = isObject$c;
  3297. var wellKnownSymbol$3 = wellKnownSymbol$7;
  3298. var SPECIES = wellKnownSymbol$3('species');
  3299. var Array$1 = global$4.Array;
  3300. // a part of `ArraySpeciesCreate` abstract operation
  3301. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  3302. var arraySpeciesConstructor$1 = function (originalArray) {
  3303. var C;
  3304. if (isArray$c(originalArray)) {
  3305. C = originalArray.constructor;
  3306. // cross-realm fallback
  3307. if (isConstructor(C) && (C === Array$1 || isArray$c(C.prototype))) C = undefined;
  3308. else if (isObject$6(C)) {
  3309. C = C[SPECIES];
  3310. if (C === null) C = undefined;
  3311. }
  3312. } return C === undefined ? Array$1 : C;
  3313. };
  3314. var arraySpeciesConstructor = arraySpeciesConstructor$1;
  3315. // `ArraySpeciesCreate` abstract operation
  3316. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  3317. var arraySpeciesCreate$2 = function (originalArray, length) {
  3318. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  3319. };
  3320. var $$2 = _export;
  3321. var flattenIntoArray$1 = flattenIntoArray_1;
  3322. var aCallable$1 = aCallable$5;
  3323. var toObject$1 = toObject$4;
  3324. var lengthOfArrayLike$2 = lengthOfArrayLike$6;
  3325. var arraySpeciesCreate$1 = arraySpeciesCreate$2;
  3326. // `Array.prototype.flatMap` method
  3327. // https://tc39.es/ecma262/#sec-array.prototype.flatmap
  3328. $$2({ target: 'Array', proto: true }, {
  3329. flatMap: function flatMap(callbackfn /* , thisArg */) {
  3330. var O = toObject$1(this);
  3331. var sourceLen = lengthOfArrayLike$2(O);
  3332. var A;
  3333. aCallable$1(callbackfn);
  3334. A = arraySpeciesCreate$1(O, 0);
  3335. A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  3336. return A;
  3337. }
  3338. });
  3339. var iterators = {};
  3340. var wellKnownSymbol$2 = wellKnownSymbol$7;
  3341. var Iterators$1 = iterators;
  3342. var ITERATOR$1 = wellKnownSymbol$2('iterator');
  3343. var ArrayPrototype$1 = Array.prototype;
  3344. // check on default Array iterator
  3345. var isArrayIteratorMethod$1 = function (it) {
  3346. return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$1[ITERATOR$1] === it);
  3347. };
  3348. var classof = classof$4;
  3349. var getMethod$1 = getMethod$3;
  3350. var Iterators = iterators;
  3351. var wellKnownSymbol$1 = wellKnownSymbol$7;
  3352. var ITERATOR = wellKnownSymbol$1('iterator');
  3353. var getIteratorMethod$2 = function (it) {
  3354. if (it != undefined) return getMethod$1(it, ITERATOR)
  3355. || getMethod$1(it, '@@iterator')
  3356. || Iterators[classof(it)];
  3357. };
  3358. var global$3 = global$s;
  3359. var call$2 = functionCall;
  3360. var aCallable = aCallable$5;
  3361. var anObject$4 = anObject$7;
  3362. var tryToString$1 = tryToString$3;
  3363. var getIteratorMethod$1 = getIteratorMethod$2;
  3364. var TypeError$2 = global$3.TypeError;
  3365. var getIterator$1 = function (argument, usingIterator) {
  3366. var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
  3367. if (aCallable(iteratorMethod)) return anObject$4(call$2(iteratorMethod, argument));
  3368. throw TypeError$2(tryToString$1(argument) + ' is not iterable');
  3369. };
  3370. var call$1 = functionCall;
  3371. var anObject$3 = anObject$7;
  3372. var getMethod = getMethod$3;
  3373. var iteratorClose$1 = function (iterator, kind, value) {
  3374. var innerResult, innerError;
  3375. anObject$3(iterator);
  3376. try {
  3377. innerResult = getMethod(iterator, 'return');
  3378. if (!innerResult) {
  3379. if (kind === 'throw') throw value;
  3380. return value;
  3381. }
  3382. innerResult = call$1(innerResult, iterator);
  3383. } catch (error) {
  3384. innerError = true;
  3385. innerResult = error;
  3386. }
  3387. if (kind === 'throw') throw value;
  3388. if (innerError) throw innerResult;
  3389. anObject$3(innerResult);
  3390. return value;
  3391. };
  3392. var global$2 = global$s;
  3393. var bind$1 = functionBindContext;
  3394. var call = functionCall;
  3395. var anObject$2 = anObject$7;
  3396. var tryToString = tryToString$3;
  3397. var isArrayIteratorMethod = isArrayIteratorMethod$1;
  3398. var lengthOfArrayLike$1 = lengthOfArrayLike$6;
  3399. var isPrototypeOf = objectIsPrototypeOf;
  3400. var getIterator = getIterator$1;
  3401. var getIteratorMethod = getIteratorMethod$2;
  3402. var iteratorClose = iteratorClose$1;
  3403. var TypeError$1 = global$2.TypeError;
  3404. var Result = function (stopped, result) {
  3405. this.stopped = stopped;
  3406. this.result = result;
  3407. };
  3408. var ResultPrototype = Result.prototype;
  3409. var iterate$1 = function (iterable, unboundFunction, options) {
  3410. var that = options && options.that;
  3411. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  3412. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  3413. var INTERRUPTED = !!(options && options.INTERRUPTED);
  3414. var fn = bind$1(unboundFunction, that);
  3415. var iterator, iterFn, index, length, result, next, step;
  3416. var stop = function (condition) {
  3417. if (iterator) iteratorClose(iterator, 'normal', condition);
  3418. return new Result(true, condition);
  3419. };
  3420. var callFn = function (value) {
  3421. if (AS_ENTRIES) {
  3422. anObject$2(value);
  3423. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  3424. } return INTERRUPTED ? fn(value, stop) : fn(value);
  3425. };
  3426. if (IS_ITERATOR) {
  3427. iterator = iterable;
  3428. } else {
  3429. iterFn = getIteratorMethod(iterable);
  3430. if (!iterFn) throw TypeError$1(tryToString(iterable) + ' is not iterable');
  3431. // optimisation for array iterators
  3432. if (isArrayIteratorMethod(iterFn)) {
  3433. for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
  3434. result = callFn(iterable[index]);
  3435. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  3436. } return new Result(false);
  3437. }
  3438. iterator = getIterator(iterable, iterFn);
  3439. }
  3440. next = iterator.next;
  3441. while (!(step = call(next, iterator)).done) {
  3442. try {
  3443. result = callFn(step.value);
  3444. } catch (error) {
  3445. iteratorClose(iterator, 'throw', error);
  3446. }
  3447. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  3448. } return new Result(false);
  3449. };
  3450. var toPropertyKey = toPropertyKey$3;
  3451. var definePropertyModule$2 = objectDefineProperty;
  3452. var createPropertyDescriptor = createPropertyDescriptor$3;
  3453. var createProperty$1 = function (object, key, value) {
  3454. var propertyKey = toPropertyKey(key);
  3455. if (propertyKey in object) definePropertyModule$2.f(object, propertyKey, createPropertyDescriptor(0, value));
  3456. else object[propertyKey] = value;
  3457. };
  3458. var $$1 = _export;
  3459. var iterate = iterate$1;
  3460. var createProperty = createProperty$1;
  3461. // `Object.fromEntries` method
  3462. // https://github.com/tc39/proposal-object-from-entries
  3463. $$1({ target: 'Object', stat: true }, {
  3464. fromEntries: function fromEntries(iterable) {
  3465. var obj = {};
  3466. iterate(iterable, function (k, v) {
  3467. createProperty(obj, k, v);
  3468. }, { AS_ENTRIES: true });
  3469. return obj;
  3470. }
  3471. });
  3472. const debug$1 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
  3473. var debug_1 = debug$1;
  3474. // Not necessarily the package version of this code.
  3475. const SEMVER_SPEC_VERSION = '2.0.0';
  3476. const MAX_LENGTH$3 = 256;
  3477. const MAX_SAFE_INTEGER$3 = Number.MAX_SAFE_INTEGER ||
  3478. /* istanbul ignore next */
  3479. 9007199254740991; // Max safe segment length for coercion.
  3480. const MAX_SAFE_COMPONENT_LENGTH = 16;
  3481. var constants$7 = {
  3482. SEMVER_SPEC_VERSION,
  3483. MAX_LENGTH: MAX_LENGTH$3,
  3484. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$3,
  3485. MAX_SAFE_COMPONENT_LENGTH
  3486. };
  3487. var re$1 = {exports: {}};
  3488. (function (module, exports) {
  3489. const {
  3490. MAX_SAFE_COMPONENT_LENGTH
  3491. } = constants$7;
  3492. const debug = debug_1;
  3493. exports = module.exports = {}; // The actual regexps go on exports.re
  3494. const re = exports.re = [];
  3495. const src = exports.src = [];
  3496. const t = exports.t = {};
  3497. let R = 0;
  3498. const createToken = (name, value, isGlobal) => {
  3499. const index = R++;
  3500. debug(index, value);
  3501. t[name] = index;
  3502. src[index] = value;
  3503. re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
  3504. }; // The following Regular Expressions can be used for tokenizing,
  3505. // validating, and parsing SemVer version strings.
  3506. // ## Numeric Identifier
  3507. // A single `0`, or a non-zero digit followed by zero or more digits.
  3508. createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
  3509. createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
  3510. // Zero or more digits, followed by a letter or hyphen, and then zero or
  3511. // more letters, digits, or hyphens.
  3512. createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
  3513. // Three dot-separated numeric identifiers.
  3514. createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
  3515. createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
  3516. // A numeric identifier, or a non-numeric identifier.
  3517. createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
  3518. createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
  3519. // Hyphen, followed by one or more dot-separated pre-release version
  3520. // identifiers.
  3521. createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
  3522. createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
  3523. // Any combination of digits, letters, or hyphens.
  3524. createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
  3525. // Plus sign, followed by one or more period-separated build metadata
  3526. // identifiers.
  3527. createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
  3528. // A main version, followed optionally by a pre-release version and
  3529. // build metadata.
  3530. // Note that the only major, minor, patch, and pre-release sections of
  3531. // the version string are capturing groups. The build metadata is not a
  3532. // capturing group, because it should not ever be used in version
  3533. // comparison.
  3534. createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
  3535. createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  3536. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  3537. // common in the npm registry.
  3538. createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
  3539. createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
  3540. createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
  3541. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  3542. // Only the first item is strictly required.
  3543. createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
  3544. createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
  3545. createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
  3546. createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
  3547. createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
  3548. createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
  3549. // Extract anything that could conceivably be a part of a valid semver
  3550. createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
  3551. createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
  3552. // Meaning is "reasonably at or greater than"
  3553. createToken('LONETILDE', '(?:~>?)');
  3554. createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
  3555. exports.tildeTrimReplace = '$1~';
  3556. createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
  3557. createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
  3558. // Meaning is "at least and backwards compatible with"
  3559. createToken('LONECARET', '(?:\\^)');
  3560. createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
  3561. exports.caretTrimReplace = '$1^';
  3562. createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
  3563. createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
  3564. createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
  3565. createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
  3566. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  3567. createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
  3568. exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  3569. // Note that these all use the loose form, because they'll be
  3570. // checked against either the strict or loose comparator form
  3571. // later.
  3572. createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
  3573. createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
  3574. createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
  3575. createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
  3576. createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
  3577. })(re$1, re$1.exports);
  3578. // obj with keys in a consistent order.
  3579. const opts$1 = ['includePrerelease', 'loose', 'rtl'];
  3580. const parseOptions$1 = options => !options ? {} : typeof options !== 'object' ? {
  3581. loose: true
  3582. } : opts$1.filter(k => options[k]).reduce((options, k) => {
  3583. options[k] = true;
  3584. return options;
  3585. }, {});
  3586. var parseOptions_1 = parseOptions$1;
  3587. const numeric$1 = /^[0-9]+$/;
  3588. const compareIdentifiers$1 = (a, b) => {
  3589. const anum = numeric$1.test(a);
  3590. const bnum = numeric$1.test(b);
  3591. if (anum && bnum) {
  3592. a = +a;
  3593. b = +b;
  3594. }
  3595. return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
  3596. };
  3597. const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
  3598. var identifiers = {
  3599. compareIdentifiers: compareIdentifiers$1,
  3600. rcompareIdentifiers
  3601. };
  3602. const debug = debug_1;
  3603. const {
  3604. MAX_LENGTH: MAX_LENGTH$2,
  3605. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$2
  3606. } = constants$7;
  3607. const {
  3608. re,
  3609. t
  3610. } = re$1.exports;
  3611. const parseOptions = parseOptions_1;
  3612. const {
  3613. compareIdentifiers
  3614. } = identifiers;
  3615. class SemVer$1 {
  3616. constructor(version, options) {
  3617. options = parseOptions(options);
  3618. if (version instanceof SemVer$1) {
  3619. if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
  3620. return version;
  3621. } else {
  3622. version = version.version;
  3623. }
  3624. } else if (typeof version !== 'string') {
  3625. throw new TypeError(`Invalid Version: ${version}`);
  3626. }
  3627. if (version.length > MAX_LENGTH$2) {
  3628. throw new TypeError(`version is longer than ${MAX_LENGTH$2} characters`);
  3629. }
  3630. debug('SemVer', version, options);
  3631. this.options = options;
  3632. this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
  3633. // don't run into trouble passing this.options around.
  3634. this.includePrerelease = !!options.includePrerelease;
  3635. const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  3636. if (!m) {
  3637. throw new TypeError(`Invalid Version: ${version}`);
  3638. }
  3639. this.raw = version; // these are actually numbers
  3640. this.major = +m[1];
  3641. this.minor = +m[2];
  3642. this.patch = +m[3];
  3643. if (this.major > MAX_SAFE_INTEGER$2 || this.major < 0) {
  3644. throw new TypeError('Invalid major version');
  3645. }
  3646. if (this.minor > MAX_SAFE_INTEGER$2 || this.minor < 0) {
  3647. throw new TypeError('Invalid minor version');
  3648. }
  3649. if (this.patch > MAX_SAFE_INTEGER$2 || this.patch < 0) {
  3650. throw new TypeError('Invalid patch version');
  3651. } // numberify any prerelease numeric ids
  3652. if (!m[4]) {
  3653. this.prerelease = [];
  3654. } else {
  3655. this.prerelease = m[4].split('.').map(id => {
  3656. if (/^[0-9]+$/.test(id)) {
  3657. const num = +id;
  3658. if (num >= 0 && num < MAX_SAFE_INTEGER$2) {
  3659. return num;
  3660. }
  3661. }
  3662. return id;
  3663. });
  3664. }
  3665. this.build = m[5] ? m[5].split('.') : [];
  3666. this.format();
  3667. }
  3668. format() {
  3669. this.version = `${this.major}.${this.minor}.${this.patch}`;
  3670. if (this.prerelease.length) {
  3671. this.version += `-${this.prerelease.join('.')}`;
  3672. }
  3673. return this.version;
  3674. }
  3675. toString() {
  3676. return this.version;
  3677. }
  3678. compare(other) {
  3679. debug('SemVer.compare', this.version, this.options, other);
  3680. if (!(other instanceof SemVer$1)) {
  3681. if (typeof other === 'string' && other === this.version) {
  3682. return 0;
  3683. }
  3684. other = new SemVer$1(other, this.options);
  3685. }
  3686. if (other.version === this.version) {
  3687. return 0;
  3688. }
  3689. return this.compareMain(other) || this.comparePre(other);
  3690. }
  3691. compareMain(other) {
  3692. if (!(other instanceof SemVer$1)) {
  3693. other = new SemVer$1(other, this.options);
  3694. }
  3695. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  3696. }
  3697. comparePre(other) {
  3698. if (!(other instanceof SemVer$1)) {
  3699. other = new SemVer$1(other, this.options);
  3700. } // NOT having a prerelease is > having one
  3701. if (this.prerelease.length && !other.prerelease.length) {
  3702. return -1;
  3703. } else if (!this.prerelease.length && other.prerelease.length) {
  3704. return 1;
  3705. } else if (!this.prerelease.length && !other.prerelease.length) {
  3706. return 0;
  3707. }
  3708. let i = 0;
  3709. do {
  3710. const a = this.prerelease[i];
  3711. const b = other.prerelease[i];
  3712. debug('prerelease compare', i, a, b);
  3713. if (a === undefined && b === undefined) {
  3714. return 0;
  3715. } else if (b === undefined) {
  3716. return 1;
  3717. } else if (a === undefined) {
  3718. return -1;
  3719. } else if (a === b) {
  3720. continue;
  3721. } else {
  3722. return compareIdentifiers(a, b);
  3723. }
  3724. } while (++i);
  3725. }
  3726. compareBuild(other) {
  3727. if (!(other instanceof SemVer$1)) {
  3728. other = new SemVer$1(other, this.options);
  3729. }
  3730. let i = 0;
  3731. do {
  3732. const a = this.build[i];
  3733. const b = other.build[i];
  3734. debug('prerelease compare', i, a, b);
  3735. if (a === undefined && b === undefined) {
  3736. return 0;
  3737. } else if (b === undefined) {
  3738. return 1;
  3739. } else if (a === undefined) {
  3740. return -1;
  3741. } else if (a === b) {
  3742. continue;
  3743. } else {
  3744. return compareIdentifiers(a, b);
  3745. }
  3746. } while (++i);
  3747. } // preminor will bump the version up to the next minor release, and immediately
  3748. // down to pre-release. premajor and prepatch work the same way.
  3749. inc(release, identifier) {
  3750. switch (release) {
  3751. case 'premajor':
  3752. this.prerelease.length = 0;
  3753. this.patch = 0;
  3754. this.minor = 0;
  3755. this.major++;
  3756. this.inc('pre', identifier);
  3757. break;
  3758. case 'preminor':
  3759. this.prerelease.length = 0;
  3760. this.patch = 0;
  3761. this.minor++;
  3762. this.inc('pre', identifier);
  3763. break;
  3764. case 'prepatch':
  3765. // If this is already a prerelease, it will bump to the next version
  3766. // drop any prereleases that might already exist, since they are not
  3767. // relevant at this point.
  3768. this.prerelease.length = 0;
  3769. this.inc('patch', identifier);
  3770. this.inc('pre', identifier);
  3771. break;
  3772. // If the input is a non-prerelease version, this acts the same as
  3773. // prepatch.
  3774. case 'prerelease':
  3775. if (this.prerelease.length === 0) {
  3776. this.inc('patch', identifier);
  3777. }
  3778. this.inc('pre', identifier);
  3779. break;
  3780. case 'major':
  3781. // If this is a pre-major version, bump up to the same major version.
  3782. // Otherwise increment major.
  3783. // 1.0.0-5 bumps to 1.0.0
  3784. // 1.1.0 bumps to 2.0.0
  3785. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
  3786. this.major++;
  3787. }
  3788. this.minor = 0;
  3789. this.patch = 0;
  3790. this.prerelease = [];
  3791. break;
  3792. case 'minor':
  3793. // If this is a pre-minor version, bump up to the same minor version.
  3794. // Otherwise increment minor.
  3795. // 1.2.0-5 bumps to 1.2.0
  3796. // 1.2.1 bumps to 1.3.0
  3797. if (this.patch !== 0 || this.prerelease.length === 0) {
  3798. this.minor++;
  3799. }
  3800. this.patch = 0;
  3801. this.prerelease = [];
  3802. break;
  3803. case 'patch':
  3804. // If this is not a pre-release version, it will increment the patch.
  3805. // If it is a pre-release it will bump up to the same patch version.
  3806. // 1.2.0-5 patches to 1.2.0
  3807. // 1.2.0 patches to 1.2.1
  3808. if (this.prerelease.length === 0) {
  3809. this.patch++;
  3810. }
  3811. this.prerelease = [];
  3812. break;
  3813. // This probably shouldn't be used publicly.
  3814. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
  3815. case 'pre':
  3816. if (this.prerelease.length === 0) {
  3817. this.prerelease = [0];
  3818. } else {
  3819. let i = this.prerelease.length;
  3820. while (--i >= 0) {
  3821. if (typeof this.prerelease[i] === 'number') {
  3822. this.prerelease[i]++;
  3823. i = -2;
  3824. }
  3825. }
  3826. if (i === -1) {
  3827. // didn't increment anything
  3828. this.prerelease.push(0);
  3829. }
  3830. }
  3831. if (identifier) {
  3832. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  3833. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  3834. if (this.prerelease[0] === identifier) {
  3835. if (isNaN(this.prerelease[1])) {
  3836. this.prerelease = [identifier, 0];
  3837. }
  3838. } else {
  3839. this.prerelease = [identifier, 0];
  3840. }
  3841. }
  3842. break;
  3843. default:
  3844. throw new Error(`invalid increment argument: ${release}`);
  3845. }
  3846. this.format();
  3847. this.raw = this.version;
  3848. return this;
  3849. }
  3850. }
  3851. var semver$3 = SemVer$1;
  3852. const SemVer = semver$3;
  3853. const compare$3 = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
  3854. var compare_1 = compare$3;
  3855. const compare$2 = compare_1;
  3856. const lt = (a, b, loose) => compare$2(a, b, loose) < 0;
  3857. var lt_1 = lt;
  3858. const compare$1 = compare_1;
  3859. const gte$1 = (a, b, loose) => compare$1(a, b, loose) >= 0;
  3860. var gte_1 = gte$1;
  3861. var arrayify$1 = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
  3862. [keyName]: key
  3863. }, value));
  3864. var lib$5 = {exports: {}};
  3865. (function (module, exports) {
  3866. Object.defineProperty(exports, "__esModule", {
  3867. value: true
  3868. });
  3869. exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
  3870. function noop() {
  3871. var args = [];
  3872. for (var _i = 0; _i < arguments.length; _i++) {
  3873. args[_i] = arguments[_i];
  3874. }
  3875. }
  3876. function createWeakMap() {
  3877. if (typeof WeakMap !== "undefined") {
  3878. return new WeakMap();
  3879. } else {
  3880. return fakeSetOrMap();
  3881. }
  3882. }
  3883. /**
  3884. * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
  3885. */
  3886. function fakeSetOrMap() {
  3887. return {
  3888. add: noop,
  3889. delete: noop,
  3890. get: noop,
  3891. set: noop,
  3892. has: function (k) {
  3893. return false;
  3894. }
  3895. };
  3896. } // Safe hasOwnProperty
  3897. var hop = Object.prototype.hasOwnProperty;
  3898. var has = function (obj, prop) {
  3899. return hop.call(obj, prop);
  3900. }; // Copy all own enumerable properties from source to target
  3901. function extend(target, source) {
  3902. for (var prop in source) {
  3903. if (has(source, prop)) {
  3904. target[prop] = source[prop];
  3905. }
  3906. }
  3907. return target;
  3908. }
  3909. var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
  3910. var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
  3911. var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
  3912. var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
  3913. var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
  3914. function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
  3915. // If first interpolated value is a reference to outdent,
  3916. // determine indentation level from the indentation of the interpolated value.
  3917. var indentationLevel = 0;
  3918. var match = strings[0].match(reDetectIndentation);
  3919. if (match) {
  3920. indentationLevel = match[1].length;
  3921. }
  3922. var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
  3923. var reMatchIndent = new RegExp(reSource, "g");
  3924. if (firstInterpolatedValueSetsIndentationLevel) {
  3925. strings = strings.slice(1);
  3926. }
  3927. var newline = options.newline,
  3928. trimLeadingNewline = options.trimLeadingNewline,
  3929. trimTrailingNewline = options.trimTrailingNewline;
  3930. var normalizeNewlines = typeof newline === "string";
  3931. var l = strings.length;
  3932. var outdentedStrings = strings.map(function (v, i) {
  3933. // Remove leading indentation from all lines
  3934. v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
  3935. if (i === 0 && trimLeadingNewline) {
  3936. v = v.replace(reLeadingNewline, "");
  3937. } // Trim a trailing newline from the last string
  3938. if (i === l - 1 && trimTrailingNewline) {
  3939. v = v.replace(reTrailingNewline, "");
  3940. } // Normalize newlines
  3941. if (normalizeNewlines) {
  3942. v = v.replace(/\r\n|\n|\r/g, function (_) {
  3943. return newline;
  3944. });
  3945. }
  3946. return v;
  3947. });
  3948. return outdentedStrings;
  3949. }
  3950. function concatStringsAndValues(strings, values) {
  3951. var ret = "";
  3952. for (var i = 0, l = strings.length; i < l; i++) {
  3953. ret += strings[i];
  3954. if (i < l - 1) {
  3955. ret += values[i];
  3956. }
  3957. }
  3958. return ret;
  3959. }
  3960. function isTemplateStringsArray(v) {
  3961. return has(v, "raw") && has(v, "length");
  3962. }
  3963. /**
  3964. * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
  3965. * makeInstance
  3966. * @param options
  3967. * @return {outdent}
  3968. */
  3969. function createInstance(options) {
  3970. /** Cache of pre-processed template literal arrays */
  3971. var arrayAutoIndentCache = createWeakMap();
  3972. /**
  3973. * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
  3974. * before interpolated values are injected.
  3975. */
  3976. var arrayFirstInterpSetsIndentCache = createWeakMap();
  3977. function outdent(stringsOrOptions) {
  3978. var values = [];
  3979. for (var _i = 1; _i < arguments.length; _i++) {
  3980. values[_i - 1] = arguments[_i];
  3981. }
  3982. /* tslint:enable:no-shadowed-variable */
  3983. if (isTemplateStringsArray(stringsOrOptions)) {
  3984. var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
  3985. var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
  3986. var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
  3987. var renderedArray = cache.get(strings);
  3988. if (!renderedArray) {
  3989. renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
  3990. cache.set(strings, renderedArray);
  3991. }
  3992. /** If no interpolated values, skip concatenation step */
  3993. if (values.length === 0) {
  3994. return renderedArray[0];
  3995. }
  3996. /** Concatenate string literals with interpolated values */
  3997. var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
  3998. return rendered;
  3999. } else {
  4000. // Create and return a new instance of outdent with the given options
  4001. return createInstance(extend(extend({}, options), stringsOrOptions || {}));
  4002. }
  4003. }
  4004. var fullOutdent = extend(outdent, {
  4005. string: function (str) {
  4006. return _outdentArray([str], false, options)[0];
  4007. }
  4008. });
  4009. return fullOutdent;
  4010. }
  4011. var defaultOutdent = createInstance({
  4012. trimLeadingNewline: true,
  4013. trimTrailingNewline: true
  4014. });
  4015. exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
  4016. // import outdent from 'outdent';
  4017. exports.default = defaultOutdent;
  4018. {
  4019. // In webpack harmony-modules environments, module.exports is read-only,
  4020. // so we fail gracefully.
  4021. try {
  4022. module.exports = defaultOutdent;
  4023. Object.defineProperty(defaultOutdent, "__esModule", {
  4024. value: true
  4025. });
  4026. defaultOutdent.default = defaultOutdent;
  4027. defaultOutdent.outdent = defaultOutdent;
  4028. } catch (e) {}
  4029. }
  4030. })(lib$5, lib$5.exports);
  4031. const {
  4032. outdent
  4033. } = lib$5.exports;
  4034. const CATEGORY_CONFIG = "Config";
  4035. const CATEGORY_EDITOR = "Editor";
  4036. const CATEGORY_FORMAT = "Format";
  4037. const CATEGORY_OTHER = "Other";
  4038. const CATEGORY_OUTPUT = "Output";
  4039. const CATEGORY_GLOBAL = "Global";
  4040. const CATEGORY_SPECIAL = "Special";
  4041. /**
  4042. * @typedef {Object} OptionInfo
  4043. * @property {string} [since] - available since version
  4044. * @property {string} category
  4045. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  4046. * @property {boolean} [array] - indicate it's an array of the specified type
  4047. * @property {OptionValueInfo} [default]
  4048. * @property {OptionRangeInfo} [range] - for type int
  4049. * @property {string} description
  4050. * @property {string} [deprecated] - deprecated since version
  4051. * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
  4052. * @property {(value: any) => boolean} [exception]
  4053. * @property {OptionChoiceInfo[]} [choices] - for type choice
  4054. * @property {string} [cliName]
  4055. * @property {string} [cliCategory]
  4056. * @property {string} [cliDescription]
  4057. *
  4058. * @typedef {number | boolean | string} OptionValue
  4059. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  4060. *
  4061. * @typedef {Object} OptionRedirectInfo
  4062. * @property {string} option
  4063. * @property {OptionValue} value
  4064. *
  4065. * @typedef {Object} OptionRangeInfo
  4066. * @property {number} start - recommended range start
  4067. * @property {number} end - recommended range end
  4068. * @property {number} step - recommended range step
  4069. *
  4070. * @typedef {Object} OptionChoiceInfo
  4071. * @property {boolean | string} value - boolean for the option that is originally boolean type
  4072. * @property {string} description
  4073. * @property {string} [since] - undefined if available since the first version of the option
  4074. * @property {string} [deprecated] - deprecated since version
  4075. * @property {OptionValueInfo} [redirect] - redirect deprecated value
  4076. */
  4077. /** @type {{ [name: string]: OptionInfo }} */
  4078. const options$e = {
  4079. cursorOffset: {
  4080. since: "1.4.0",
  4081. category: CATEGORY_SPECIAL,
  4082. type: "int",
  4083. default: -1,
  4084. range: {
  4085. start: -1,
  4086. end: Number.POSITIVE_INFINITY,
  4087. step: 1
  4088. },
  4089. description: outdent`
  4090. Print (to stderr) where a cursor at the given position would move to after formatting.
  4091. This option cannot be used with --range-start and --range-end.
  4092. `,
  4093. cliCategory: CATEGORY_EDITOR
  4094. },
  4095. endOfLine: {
  4096. since: "1.15.0",
  4097. category: CATEGORY_GLOBAL,
  4098. type: "choice",
  4099. default: [{
  4100. since: "1.15.0",
  4101. value: "auto"
  4102. }, {
  4103. since: "2.0.0",
  4104. value: "lf"
  4105. }],
  4106. description: "Which end of line characters to apply.",
  4107. choices: [{
  4108. value: "lf",
  4109. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  4110. }, {
  4111. value: "crlf",
  4112. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  4113. }, {
  4114. value: "cr",
  4115. description: "Carriage Return character only (\\r), used very rarely"
  4116. }, {
  4117. value: "auto",
  4118. description: outdent`
  4119. Maintain existing
  4120. (mixed values within one file are normalised by looking at what's used after the first line)
  4121. `
  4122. }]
  4123. },
  4124. filepath: {
  4125. since: "1.4.0",
  4126. category: CATEGORY_SPECIAL,
  4127. type: "path",
  4128. description: "Specify the input filepath. This will be used to do parser inference.",
  4129. cliName: "stdin-filepath",
  4130. cliCategory: CATEGORY_OTHER,
  4131. cliDescription: "Path to the file to pretend that stdin comes from."
  4132. },
  4133. insertPragma: {
  4134. since: "1.8.0",
  4135. category: CATEGORY_SPECIAL,
  4136. type: "boolean",
  4137. default: false,
  4138. description: "Insert @format pragma into file's first docblock comment.",
  4139. cliCategory: CATEGORY_OTHER
  4140. },
  4141. parser: {
  4142. since: "0.0.10",
  4143. category: CATEGORY_GLOBAL,
  4144. type: "choice",
  4145. default: [{
  4146. since: "0.0.10",
  4147. value: "babylon"
  4148. }, {
  4149. since: "1.13.0",
  4150. value: undefined
  4151. }],
  4152. description: "Which parser to use.",
  4153. exception: value => typeof value === "string" || typeof value === "function",
  4154. choices: [{
  4155. value: "flow",
  4156. description: "Flow"
  4157. }, {
  4158. value: "babel",
  4159. since: "1.16.0",
  4160. description: "JavaScript"
  4161. }, {
  4162. value: "babel-flow",
  4163. since: "1.16.0",
  4164. description: "Flow"
  4165. }, {
  4166. value: "babel-ts",
  4167. since: "2.0.0",
  4168. description: "TypeScript"
  4169. }, {
  4170. value: "typescript",
  4171. since: "1.4.0",
  4172. description: "TypeScript"
  4173. }, {
  4174. value: "espree",
  4175. since: "2.2.0",
  4176. description: "JavaScript"
  4177. }, {
  4178. value: "meriyah",
  4179. since: "2.2.0",
  4180. description: "JavaScript"
  4181. }, {
  4182. value: "css",
  4183. since: "1.7.1",
  4184. description: "CSS"
  4185. }, {
  4186. value: "less",
  4187. since: "1.7.1",
  4188. description: "Less"
  4189. }, {
  4190. value: "scss",
  4191. since: "1.7.1",
  4192. description: "SCSS"
  4193. }, {
  4194. value: "json",
  4195. since: "1.5.0",
  4196. description: "JSON"
  4197. }, {
  4198. value: "json5",
  4199. since: "1.13.0",
  4200. description: "JSON5"
  4201. }, {
  4202. value: "json-stringify",
  4203. since: "1.13.0",
  4204. description: "JSON.stringify"
  4205. }, {
  4206. value: "graphql",
  4207. since: "1.5.0",
  4208. description: "GraphQL"
  4209. }, {
  4210. value: "markdown",
  4211. since: "1.8.0",
  4212. description: "Markdown"
  4213. }, {
  4214. value: "mdx",
  4215. since: "1.15.0",
  4216. description: "MDX"
  4217. }, {
  4218. value: "vue",
  4219. since: "1.10.0",
  4220. description: "Vue"
  4221. }, {
  4222. value: "yaml",
  4223. since: "1.14.0",
  4224. description: "YAML"
  4225. }, {
  4226. value: "glimmer",
  4227. since: "2.3.0",
  4228. description: "Ember / Handlebars"
  4229. }, {
  4230. value: "html",
  4231. since: "1.15.0",
  4232. description: "HTML"
  4233. }, {
  4234. value: "angular",
  4235. since: "1.15.0",
  4236. description: "Angular"
  4237. }, {
  4238. value: "lwc",
  4239. since: "1.17.0",
  4240. description: "Lightning Web Components"
  4241. }]
  4242. },
  4243. plugins: {
  4244. since: "1.10.0",
  4245. type: "path",
  4246. array: true,
  4247. default: [{
  4248. value: []
  4249. }],
  4250. category: CATEGORY_GLOBAL,
  4251. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  4252. exception: value => typeof value === "string" || typeof value === "object",
  4253. cliName: "plugin",
  4254. cliCategory: CATEGORY_CONFIG
  4255. },
  4256. pluginSearchDirs: {
  4257. since: "1.13.0",
  4258. type: "path",
  4259. array: true,
  4260. default: [{
  4261. value: []
  4262. }],
  4263. category: CATEGORY_GLOBAL,
  4264. description: outdent`
  4265. Custom directory that contains prettier plugins in node_modules subdirectory.
  4266. Overrides default behavior when plugins are searched relatively to the location of Prettier.
  4267. Multiple values are accepted.
  4268. `,
  4269. exception: value => typeof value === "string" || typeof value === "object",
  4270. cliName: "plugin-search-dir",
  4271. cliCategory: CATEGORY_CONFIG
  4272. },
  4273. printWidth: {
  4274. since: "0.0.0",
  4275. category: CATEGORY_GLOBAL,
  4276. type: "int",
  4277. default: 80,
  4278. description: "The line length where Prettier will try wrap.",
  4279. range: {
  4280. start: 0,
  4281. end: Number.POSITIVE_INFINITY,
  4282. step: 1
  4283. }
  4284. },
  4285. rangeEnd: {
  4286. since: "1.4.0",
  4287. category: CATEGORY_SPECIAL,
  4288. type: "int",
  4289. default: Number.POSITIVE_INFINITY,
  4290. range: {
  4291. start: 0,
  4292. end: Number.POSITIVE_INFINITY,
  4293. step: 1
  4294. },
  4295. description: outdent`
  4296. Format code ending at a given character offset (exclusive).
  4297. The range will extend forwards to the end of the selected statement.
  4298. This option cannot be used with --cursor-offset.
  4299. `,
  4300. cliCategory: CATEGORY_EDITOR
  4301. },
  4302. rangeStart: {
  4303. since: "1.4.0",
  4304. category: CATEGORY_SPECIAL,
  4305. type: "int",
  4306. default: 0,
  4307. range: {
  4308. start: 0,
  4309. end: Number.POSITIVE_INFINITY,
  4310. step: 1
  4311. },
  4312. description: outdent`
  4313. Format code starting at a given character offset.
  4314. The range will extend backwards to the start of the first line containing the selected statement.
  4315. This option cannot be used with --cursor-offset.
  4316. `,
  4317. cliCategory: CATEGORY_EDITOR
  4318. },
  4319. requirePragma: {
  4320. since: "1.7.0",
  4321. category: CATEGORY_SPECIAL,
  4322. type: "boolean",
  4323. default: false,
  4324. description: outdent`
  4325. Require either '@prettier' or '@format' to be present in the file's first docblock comment
  4326. in order for it to be formatted.
  4327. `,
  4328. cliCategory: CATEGORY_OTHER
  4329. },
  4330. tabWidth: {
  4331. type: "int",
  4332. category: CATEGORY_GLOBAL,
  4333. default: 2,
  4334. description: "Number of spaces per indentation level.",
  4335. range: {
  4336. start: 0,
  4337. end: Number.POSITIVE_INFINITY,
  4338. step: 1
  4339. }
  4340. },
  4341. useTabs: {
  4342. since: "1.0.0",
  4343. category: CATEGORY_GLOBAL,
  4344. type: "boolean",
  4345. default: false,
  4346. description: "Indent with tabs instead of spaces."
  4347. },
  4348. embeddedLanguageFormatting: {
  4349. since: "2.1.0",
  4350. category: CATEGORY_GLOBAL,
  4351. type: "choice",
  4352. default: [{
  4353. since: "2.1.0",
  4354. value: "auto"
  4355. }],
  4356. description: "Control how Prettier formats quoted code embedded in the file.",
  4357. choices: [{
  4358. value: "auto",
  4359. description: "Format embedded code if Prettier can automatically identify it."
  4360. }, {
  4361. value: "off",
  4362. description: "Never automatically format embedded code."
  4363. }]
  4364. }
  4365. };
  4366. var coreOptions$1 = {
  4367. CATEGORY_CONFIG,
  4368. CATEGORY_EDITOR,
  4369. CATEGORY_FORMAT,
  4370. CATEGORY_OTHER,
  4371. CATEGORY_OUTPUT,
  4372. CATEGORY_GLOBAL,
  4373. CATEGORY_SPECIAL,
  4374. options: options$e
  4375. };
  4376. const _excluded$3 = ["cliName", "cliCategory", "cliDescription"];
  4377. const semver$2 = {
  4378. compare: compare_1,
  4379. lt: lt_1,
  4380. gte: gte_1
  4381. };
  4382. const arrayify = arrayify$1;
  4383. const currentVersion = require$$0$5.version;
  4384. const coreOptions = coreOptions$1.options;
  4385. /**
  4386. * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
  4387. * of this function created by `withPlugins`. Don't pass them here directly.
  4388. * @param {object} param0
  4389. * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
  4390. * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
  4391. * @param {boolean=} param0.showUnreleased
  4392. * @param {boolean=} param0.showDeprecated
  4393. * @param {boolean=} param0.showInternal
  4394. */
  4395. function getSupportInfo$3({
  4396. plugins = [],
  4397. showUnreleased = false,
  4398. showDeprecated = false,
  4399. showInternal = false
  4400. } = {}) {
  4401. // pre-release version is smaller than the normal version in semver,
  4402. // we need to treat it as the normal one so as to test new features.
  4403. const version = currentVersion.split("-", 1)[0];
  4404. const languages = plugins.flatMap(plugin => plugin.languages || []).filter(filterSince);
  4405. const options = arrayify(Object.assign({}, ...plugins.map(({
  4406. options
  4407. }) => options), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
  4408. option = Object.assign({}, option);
  4409. if (Array.isArray(option.default)) {
  4410. option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$2.compare(info2.since, info1.since))[0].value;
  4411. }
  4412. if (Array.isArray(option.choices)) {
  4413. option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
  4414. if (option.name === "parser") {
  4415. collectParsersFromLanguages(option, languages, plugins);
  4416. }
  4417. }
  4418. const pluginDefaults = Object.fromEntries(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
  4419. return Object.assign(Object.assign({}, option), {}, {
  4420. pluginDefaults
  4421. });
  4422. });
  4423. return {
  4424. languages,
  4425. options
  4426. };
  4427. function filterSince(object) {
  4428. return showUnreleased || !("since" in object) || object.since && semver$2.gte(version, object.since);
  4429. }
  4430. function filterDeprecated(object) {
  4431. return showDeprecated || !("deprecated" in object) || object.deprecated && semver$2.lt(version, object.deprecated);
  4432. }
  4433. function mapInternal(object) {
  4434. if (showInternal) {
  4435. return object;
  4436. }
  4437. const newObject = _objectWithoutProperties(object, _excluded$3);
  4438. return newObject;
  4439. }
  4440. }
  4441. function collectParsersFromLanguages(option, languages, plugins) {
  4442. const existingValues = new Set(option.choices.map(choice => choice.value));
  4443. for (const language of languages) {
  4444. if (language.parsers) {
  4445. for (const value of language.parsers) {
  4446. if (!existingValues.has(value)) {
  4447. existingValues.add(value);
  4448. const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
  4449. let description = language.name;
  4450. if (plugin && plugin.name) {
  4451. description += ` (plugin: ${plugin.name})`;
  4452. }
  4453. option.choices.push({
  4454. value,
  4455. description
  4456. });
  4457. }
  4458. }
  4459. }
  4460. }
  4461. }
  4462. var support = {
  4463. getSupportInfo: getSupportInfo$3
  4464. };
  4465. const stringWidth = stringWidth$2.exports;
  4466. const escapeStringRegexp$2 = escapeStringRegexp$3;
  4467. const getLast$o = getLast_1;
  4468. const {
  4469. getSupportInfo: getSupportInfo$2
  4470. } = support;
  4471. const notAsciiRegex = /[^\x20-\x7F]/;
  4472. const getPenultimate$1 = arr => arr[arr.length - 2];
  4473. /**
  4474. * @typedef {{backwards?: boolean}} SkipOptions
  4475. */
  4476. /**
  4477. * @param {string | RegExp} chars
  4478. * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4479. */
  4480. function skip$1(chars) {
  4481. return (text, index, opts) => {
  4482. const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  4483. // to check for failures (did someone say monads?).
  4484. /* istanbul ignore next */
  4485. if (index === false) {
  4486. return false;
  4487. }
  4488. const {
  4489. length
  4490. } = text;
  4491. let cursor = index;
  4492. while (cursor >= 0 && cursor < length) {
  4493. const c = text.charAt(cursor);
  4494. if (chars instanceof RegExp) {
  4495. if (!chars.test(c)) {
  4496. return cursor;
  4497. }
  4498. } else if (!chars.includes(c)) {
  4499. return cursor;
  4500. }
  4501. backwards ? cursor-- : cursor++;
  4502. }
  4503. if (cursor === -1 || cursor === length) {
  4504. // If we reached the beginning or end of the file, return the
  4505. // out-of-bounds cursor. It's up to the caller to handle this
  4506. // correctly. We don't want to indicate `false` though if it
  4507. // actually skipped valid characters.
  4508. return cursor;
  4509. }
  4510. return false;
  4511. };
  4512. }
  4513. /**
  4514. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4515. */
  4516. const skipWhitespace$2 = skip$1(/\s/);
  4517. /**
  4518. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4519. */
  4520. const skipSpaces$2 = skip$1(" \t");
  4521. /**
  4522. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4523. */
  4524. const skipToLineEnd$1 = skip$1(",; \t");
  4525. /**
  4526. * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
  4527. */
  4528. const skipEverythingButNewLine$2 = skip$1(/[^\n\r]/);
  4529. /**
  4530. * @param {string} text
  4531. * @param {number | false} index
  4532. * @returns {number | false}
  4533. */
  4534. function skipInlineComment$1(text, index) {
  4535. /* istanbul ignore next */
  4536. if (index === false) {
  4537. return false;
  4538. }
  4539. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  4540. for (let i = index + 2; i < text.length; ++i) {
  4541. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  4542. return i + 2;
  4543. }
  4544. }
  4545. }
  4546. return index;
  4547. }
  4548. /**
  4549. * @param {string} text
  4550. * @param {number | false} index
  4551. * @returns {number | false}
  4552. */
  4553. function skipTrailingComment$1(text, index) {
  4554. /* istanbul ignore next */
  4555. if (index === false) {
  4556. return false;
  4557. }
  4558. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  4559. return skipEverythingButNewLine$2(text, index);
  4560. }
  4561. return index;
  4562. } // This one doesn't use the above helper function because it wants to
  4563. // test \r\n in order and `skip` doesn't support ordering and we only
  4564. // want to skip one newline. It's simple to implement.
  4565. /**
  4566. * @param {string} text
  4567. * @param {number | false} index
  4568. * @param {SkipOptions=} opts
  4569. * @returns {number | false}
  4570. */
  4571. function skipNewline$2(text, index, opts) {
  4572. const backwards = opts && opts.backwards;
  4573. if (index === false) {
  4574. return false;
  4575. }
  4576. const atIndex = text.charAt(index);
  4577. if (backwards) {
  4578. // We already replace `\r\n` with `\n` before parsing
  4579. /* istanbul ignore next */
  4580. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  4581. return index - 2;
  4582. }
  4583. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  4584. return index - 1;
  4585. }
  4586. } else {
  4587. // We already replace `\r\n` with `\n` before parsing
  4588. /* istanbul ignore next */
  4589. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  4590. return index + 2;
  4591. }
  4592. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  4593. return index + 1;
  4594. }
  4595. }
  4596. return index;
  4597. }
  4598. /**
  4599. * @param {string} text
  4600. * @param {number} index
  4601. * @param {SkipOptions=} opts
  4602. * @returns {boolean}
  4603. */
  4604. function hasNewline$a(text, index, opts = {}) {
  4605. const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
  4606. const idx2 = skipNewline$2(text, idx, opts);
  4607. return idx !== idx2;
  4608. }
  4609. /**
  4610. * @param {string} text
  4611. * @param {number} start
  4612. * @param {number} end
  4613. * @returns {boolean}
  4614. */
  4615. function hasNewlineInRange$5(text, start, end) {
  4616. for (let i = start; i < end; ++i) {
  4617. if (text.charAt(i) === "\n") {
  4618. return true;
  4619. }
  4620. }
  4621. return false;
  4622. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  4623. /**
  4624. * @template N
  4625. * @param {string} text
  4626. * @param {N} node
  4627. * @param {(node: N) => number} locStart
  4628. */
  4629. function isPreviousLineEmpty$3(text, node, locStart) {
  4630. /** @type {number | false} */
  4631. let idx = locStart(node) - 1;
  4632. idx = skipSpaces$2(text, idx, {
  4633. backwards: true
  4634. });
  4635. idx = skipNewline$2(text, idx, {
  4636. backwards: true
  4637. });
  4638. idx = skipSpaces$2(text, idx, {
  4639. backwards: true
  4640. });
  4641. const idx2 = skipNewline$2(text, idx, {
  4642. backwards: true
  4643. });
  4644. return idx !== idx2;
  4645. }
  4646. /**
  4647. * @param {string} text
  4648. * @param {number} index
  4649. * @returns {boolean}
  4650. */
  4651. function isNextLineEmptyAfterIndex$3(text, index) {
  4652. /** @type {number | false} */
  4653. let oldIdx = null;
  4654. /** @type {number | false} */
  4655. let idx = index;
  4656. while (idx !== oldIdx) {
  4657. // We need to skip all the potential trailing inline comments
  4658. oldIdx = idx;
  4659. idx = skipToLineEnd$1(text, idx);
  4660. idx = skipInlineComment$1(text, idx);
  4661. idx = skipSpaces$2(text, idx);
  4662. }
  4663. idx = skipTrailingComment$1(text, idx);
  4664. idx = skipNewline$2(text, idx);
  4665. return idx !== false && hasNewline$a(text, idx);
  4666. }
  4667. /**
  4668. * @template N
  4669. * @param {string} text
  4670. * @param {N} node
  4671. * @param {(node: N) => number} locEnd
  4672. * @returns {boolean}
  4673. */
  4674. function isNextLineEmpty$e(text, node, locEnd) {
  4675. return isNextLineEmptyAfterIndex$3(text, locEnd(node));
  4676. }
  4677. /**
  4678. * @param {string} text
  4679. * @param {number} idx
  4680. * @returns {number | false}
  4681. */
  4682. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, idx) {
  4683. /** @type {number | false} */
  4684. let oldIdx = null;
  4685. /** @type {number | false} */
  4686. let nextIdx = idx;
  4687. while (nextIdx !== oldIdx) {
  4688. oldIdx = nextIdx;
  4689. nextIdx = skipSpaces$2(text, nextIdx);
  4690. nextIdx = skipInlineComment$1(text, nextIdx);
  4691. nextIdx = skipTrailingComment$1(text, nextIdx);
  4692. nextIdx = skipNewline$2(text, nextIdx);
  4693. }
  4694. return nextIdx;
  4695. }
  4696. /**
  4697. * @template N
  4698. * @param {string} text
  4699. * @param {N} node
  4700. * @param {(node: N) => number} locEnd
  4701. * @returns {number | false}
  4702. */
  4703. function getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd) {
  4704. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1(text, locEnd(node));
  4705. }
  4706. /**
  4707. * @template N
  4708. * @param {string} text
  4709. * @param {N} node
  4710. * @param {(node: N) => number} locEnd
  4711. * @returns {string}
  4712. */
  4713. function getNextNonSpaceNonCommentCharacter$2(text, node, locEnd) {
  4714. return text.charAt( // @ts-expect-error => TBD: can return false, should we define a fallback?
  4715. getNextNonSpaceNonCommentCharacterIndex$4(text, node, locEnd));
  4716. } // Not using, but it's public utils
  4717. /* istanbul ignore next */
  4718. /**
  4719. * @param {string} text
  4720. * @param {number} index
  4721. * @param {SkipOptions=} opts
  4722. * @returns {boolean}
  4723. */
  4724. function hasSpaces$1(text, index, opts = {}) {
  4725. const idx = skipSpaces$2(text, opts.backwards ? index - 1 : index, opts);
  4726. return idx !== index;
  4727. }
  4728. /**
  4729. * @param {string} value
  4730. * @param {number} tabWidth
  4731. * @param {number=} startIndex
  4732. * @returns {number}
  4733. */
  4734. function getAlignmentSize$2(value, tabWidth, startIndex = 0) {
  4735. let size = 0;
  4736. for (let i = startIndex; i < value.length; ++i) {
  4737. if (value[i] === "\t") {
  4738. // Tabs behave in a way that they are aligned to the nearest
  4739. // multiple of tabWidth:
  4740. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  4741. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  4742. size = size + tabWidth - size % tabWidth;
  4743. } else {
  4744. size++;
  4745. }
  4746. }
  4747. return size;
  4748. }
  4749. /**
  4750. * @param {string} value
  4751. * @param {number} tabWidth
  4752. * @returns {number}
  4753. */
  4754. function getIndentSize$2(value, tabWidth) {
  4755. const lastNewlineIndex = value.lastIndexOf("\n");
  4756. if (lastNewlineIndex === -1) {
  4757. return 0;
  4758. }
  4759. return getAlignmentSize$2( // All the leading whitespaces
  4760. value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
  4761. }
  4762. /**
  4763. * @typedef {'"' | "'"} Quote
  4764. */
  4765. /**
  4766. *
  4767. * @param {string} rawContent
  4768. * @param {Quote} preferredQuote
  4769. * @returns {{ quote: Quote, regex: RegExp, escaped: string }}
  4770. */
  4771. function getPreferredQuote$2(rawContent, preferredQuote) {
  4772. /** @type {{ quote: '"', regex: RegExp, escaped: "&quot;" }} */
  4773. const double = {
  4774. quote: '"',
  4775. regex: /"/g,
  4776. escaped: "&quot;"
  4777. };
  4778. /** @type {{ quote: "'", regex: RegExp, escaped: "&apos;" }} */
  4779. const single = {
  4780. quote: "'",
  4781. regex: /'/g,
  4782. escaped: "&apos;"
  4783. };
  4784. const preferred = preferredQuote === "'" ? single : double;
  4785. const alternate = preferred === single ? double : single;
  4786. let result = preferred; // If `rawContent` contains at least one of the quote preferred for enclosing
  4787. // the string, we might want to enclose with the alternate quote instead, to
  4788. // minimize the number of escaped quotes.
  4789. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  4790. const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  4791. const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  4792. result = numPreferredQuotes > numAlternateQuotes ? alternate : preferred;
  4793. }
  4794. return result;
  4795. }
  4796. function printString$4(raw, options) {
  4797. // `rawContent` is the string exactly like it appeared in the input source
  4798. // code, without its enclosing quotes.
  4799. const rawContent = raw.slice(1, -1);
  4800. /** @type {Quote} */
  4801. const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote$2(rawContent, options.singleQuote ? "'" : '"').quote; // It might sound unnecessary to use `makeString` even if the string already
  4802. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  4803. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  4804. // sure that we consistently output the minimum amount of escaped quotes.
  4805. return makeString$1(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
  4806. }
  4807. /**
  4808. * @param {string} rawContent
  4809. * @param {Quote} enclosingQuote
  4810. * @param {boolean=} unescapeUnnecessaryEscapes
  4811. * @returns {string}
  4812. */
  4813. function makeString$1(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  4814. const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  4815. const regex = /\\(.)|(["'])/gs; // Escape and unescape single and double quotes as needed to be able to
  4816. // enclose `rawContent` with `enclosingQuote`.
  4817. const newContent = rawContent.replace(regex, (match, escaped, quote) => {
  4818. // If we matched an escape, and the escaped character is a quote of the
  4819. // other type than we intend to enclose the string with, there's no need for
  4820. // it to be escaped, so return it _without_ the backslash.
  4821. if (escaped === otherQuote) {
  4822. return escaped;
  4823. } // If we matched an unescaped quote and it is of the _same_ type as we
  4824. // intend to enclose the string with, it must be escaped, so return it with
  4825. // a backslash.
  4826. if (quote === enclosingQuote) {
  4827. return "\\" + quote;
  4828. }
  4829. if (quote) {
  4830. return quote;
  4831. } // Unescape any unnecessarily escaped character.
  4832. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  4833. return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
  4834. });
  4835. return enclosingQuote + newContent + enclosingQuote;
  4836. }
  4837. function printNumber$4(rawNumber) {
  4838. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  4839. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  4840. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  4841. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  4842. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  4843. .replace(/\.(?=e|$)/, "");
  4844. }
  4845. /**
  4846. * @param {string} str
  4847. * @param {string} target
  4848. * @returns {number}
  4849. */
  4850. function getMaxContinuousCount$3(str, target) {
  4851. const results = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
  4852. if (results === null) {
  4853. return 0;
  4854. }
  4855. return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
  4856. }
  4857. function getMinNotPresentContinuousCount$1(str, target) {
  4858. const matches = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
  4859. if (matches === null) {
  4860. return 0;
  4861. }
  4862. const countPresent = new Map();
  4863. let max = 0;
  4864. for (const match of matches) {
  4865. const count = match.length / target.length;
  4866. countPresent.set(count, true);
  4867. if (count > max) {
  4868. max = count;
  4869. }
  4870. }
  4871. for (let i = 1; i < max; i++) {
  4872. if (!countPresent.get(i)) {
  4873. return i;
  4874. }
  4875. }
  4876. return max + 1;
  4877. }
  4878. /**
  4879. * @param {string} text
  4880. * @returns {number}
  4881. */
  4882. function getStringWidth$5(text) {
  4883. if (!text) {
  4884. return 0;
  4885. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  4886. if (!notAsciiRegex.test(text)) {
  4887. return text.length;
  4888. }
  4889. return stringWidth(text);
  4890. }
  4891. function addCommentHelper(node, comment) {
  4892. const comments = node.comments || (node.comments = []);
  4893. comments.push(comment);
  4894. comment.printed = false;
  4895. comment.nodeDescription = describeNodeForDebugging(node);
  4896. }
  4897. function addLeadingComment$3(node, comment) {
  4898. comment.leading = true;
  4899. comment.trailing = false;
  4900. addCommentHelper(node, comment);
  4901. }
  4902. function addDanglingComment$3(node, comment, marker) {
  4903. comment.leading = false;
  4904. comment.trailing = false;
  4905. if (marker) {
  4906. comment.marker = marker;
  4907. }
  4908. addCommentHelper(node, comment);
  4909. }
  4910. function addTrailingComment$3(node, comment) {
  4911. comment.leading = false;
  4912. comment.trailing = true;
  4913. addCommentHelper(node, comment);
  4914. }
  4915. function inferParserByLanguage$2(language, options) {
  4916. const {
  4917. languages
  4918. } = getSupportInfo$2({
  4919. plugins: options.plugins
  4920. });
  4921. const matched = languages.find(({
  4922. name
  4923. }) => name.toLowerCase() === language) || languages.find(({
  4924. aliases
  4925. }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
  4926. extensions
  4927. }) => Array.isArray(extensions) && extensions.includes(`.${language}`));
  4928. return matched && matched.parsers[0];
  4929. }
  4930. function isFrontMatterNode$5(node) {
  4931. return node && node.type === "front-matter";
  4932. }
  4933. function getShebang$1(text) {
  4934. if (!text.startsWith("#!")) {
  4935. return "";
  4936. }
  4937. const index = text.indexOf("\n");
  4938. if (index === -1) {
  4939. return text;
  4940. }
  4941. return text.slice(0, index);
  4942. }
  4943. /**
  4944. * @param {any} object
  4945. * @returns {object is Array<any>}
  4946. */
  4947. function isNonEmptyArray$k(object) {
  4948. return Array.isArray(object) && object.length > 0;
  4949. }
  4950. /**
  4951. * @param {string} description
  4952. * @returns {(node: any) => symbol}
  4953. */
  4954. function createGroupIdMapper$2(description) {
  4955. const groupIds = new WeakMap();
  4956. return function (node) {
  4957. if (!groupIds.has(node)) {
  4958. groupIds.set(node, Symbol(description));
  4959. }
  4960. return groupIds.get(node);
  4961. };
  4962. }
  4963. function describeNodeForDebugging(node) {
  4964. const nodeType = node.type || node.kind || "(unknown type)";
  4965. let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
  4966. if (nodeName.length > 20) {
  4967. nodeName = nodeName.slice(0, 19) + "…";
  4968. }
  4969. return nodeType + (nodeName ? " " + nodeName : "");
  4970. }
  4971. var util$8 = {
  4972. inferParserByLanguage: inferParserByLanguage$2,
  4973. getStringWidth: getStringWidth$5,
  4974. getMaxContinuousCount: getMaxContinuousCount$3,
  4975. getMinNotPresentContinuousCount: getMinNotPresentContinuousCount$1,
  4976. getPenultimate: getPenultimate$1,
  4977. getLast: getLast$o,
  4978. getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex$1,
  4979. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$4,
  4980. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$2,
  4981. skip: skip$1,
  4982. skipWhitespace: skipWhitespace$2,
  4983. skipSpaces: skipSpaces$2,
  4984. skipToLineEnd: skipToLineEnd$1,
  4985. skipEverythingButNewLine: skipEverythingButNewLine$2,
  4986. skipInlineComment: skipInlineComment$1,
  4987. skipTrailingComment: skipTrailingComment$1,
  4988. skipNewline: skipNewline$2,
  4989. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$3,
  4990. isNextLineEmpty: isNextLineEmpty$e,
  4991. isPreviousLineEmpty: isPreviousLineEmpty$3,
  4992. hasNewline: hasNewline$a,
  4993. hasNewlineInRange: hasNewlineInRange$5,
  4994. hasSpaces: hasSpaces$1,
  4995. getAlignmentSize: getAlignmentSize$2,
  4996. getIndentSize: getIndentSize$2,
  4997. getPreferredQuote: getPreferredQuote$2,
  4998. printString: printString$4,
  4999. printNumber: printNumber$4,
  5000. makeString: makeString$1,
  5001. addLeadingComment: addLeadingComment$3,
  5002. addDanglingComment: addDanglingComment$3,
  5003. addTrailingComment: addTrailingComment$3,
  5004. isFrontMatterNode: isFrontMatterNode$5,
  5005. getShebang: getShebang$1,
  5006. isNonEmptyArray: isNonEmptyArray$k,
  5007. createGroupIdMapper: createGroupIdMapper$2
  5008. };
  5009. function guessEndOfLine$1(text) {
  5010. const index = text.indexOf("\r");
  5011. if (index >= 0) {
  5012. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  5013. }
  5014. return "lf";
  5015. }
  5016. function convertEndOfLineToChars$1(value) {
  5017. switch (value) {
  5018. case "cr":
  5019. return "\r";
  5020. case "crlf":
  5021. return "\r\n";
  5022. default:
  5023. return "\n";
  5024. }
  5025. }
  5026. function countEndOfLineChars$1(text, eol) {
  5027. let regex;
  5028. /* istanbul ignore else */
  5029. if (eol === "\n") {
  5030. regex = /\n/g;
  5031. } else if (eol === "\r") {
  5032. regex = /\r/g;
  5033. } else if (eol === "\r\n") {
  5034. regex = /\r\n/g;
  5035. } else {
  5036. throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
  5037. }
  5038. const endOfLines = text.match(regex);
  5039. return endOfLines ? endOfLines.length : 0;
  5040. }
  5041. function normalizeEndOfLine$2(text) {
  5042. return text.replace(/\r\n?/g, "\n");
  5043. }
  5044. var endOfLine = {
  5045. guessEndOfLine: guessEndOfLine$1,
  5046. convertEndOfLineToChars: convertEndOfLineToChars$1,
  5047. countEndOfLineChars: countEndOfLineChars$1,
  5048. normalizeEndOfLine: normalizeEndOfLine$2
  5049. };
  5050. const fs$l = require$$0__default["default"];
  5051. /**
  5052. * @class
  5053. */
  5054. class LineByLine {
  5055. constructor(file, options) {
  5056. options = options || {};
  5057. if (!options.readChunk) options.readChunk = 1024;
  5058. if (!options.newLineCharacter) {
  5059. options.newLineCharacter = 0x0a; //linux line ending
  5060. } else {
  5061. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  5062. }
  5063. if (typeof file === 'number') {
  5064. this.fd = file;
  5065. } else {
  5066. this.fd = fs$l.openSync(file, 'r');
  5067. }
  5068. this.options = options;
  5069. this.newLineCharacter = options.newLineCharacter;
  5070. this.reset();
  5071. }
  5072. _searchInBuffer(buffer, hexNeedle) {
  5073. let found = -1;
  5074. for (let i = 0; i <= buffer.length; i++) {
  5075. let b_byte = buffer[i];
  5076. if (b_byte === hexNeedle) {
  5077. found = i;
  5078. break;
  5079. }
  5080. }
  5081. return found;
  5082. }
  5083. reset() {
  5084. this.eofReached = false;
  5085. this.linesCache = [];
  5086. this.fdPosition = 0;
  5087. }
  5088. close() {
  5089. fs$l.closeSync(this.fd);
  5090. this.fd = null;
  5091. }
  5092. _extractLines(buffer) {
  5093. let line;
  5094. const lines = [];
  5095. let bufferPosition = 0;
  5096. let lastNewLineBufferPosition = 0;
  5097. while (true) {
  5098. let bufferPositionValue = buffer[bufferPosition++];
  5099. if (bufferPositionValue === this.newLineCharacter) {
  5100. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  5101. lines.push(line);
  5102. lastNewLineBufferPosition = bufferPosition;
  5103. } else if (bufferPositionValue === undefined) {
  5104. break;
  5105. }
  5106. }
  5107. let leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  5108. if (leftovers.length) {
  5109. lines.push(leftovers);
  5110. }
  5111. return lines;
  5112. }
  5113. _readChunk(lineLeftovers) {
  5114. let totalBytesRead = 0;
  5115. let bytesRead;
  5116. const buffers = [];
  5117. do {
  5118. const readBuffer = new Buffer(this.options.readChunk);
  5119. bytesRead = fs$l.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  5120. totalBytesRead = totalBytesRead + bytesRead;
  5121. this.fdPosition = this.fdPosition + bytesRead;
  5122. buffers.push(readBuffer);
  5123. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  5124. let bufferData = Buffer.concat(buffers);
  5125. if (bytesRead < this.options.readChunk) {
  5126. this.eofReached = true;
  5127. bufferData = bufferData.slice(0, totalBytesRead);
  5128. }
  5129. if (totalBytesRead) {
  5130. this.linesCache = this._extractLines(bufferData);
  5131. if (lineLeftovers) {
  5132. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  5133. }
  5134. }
  5135. return totalBytesRead;
  5136. }
  5137. next() {
  5138. if (!this.fd) return false;
  5139. let line = false;
  5140. if (this.eofReached && this.linesCache.length === 0) {
  5141. return line;
  5142. }
  5143. let bytesRead;
  5144. if (!this.linesCache.length) {
  5145. bytesRead = this._readChunk();
  5146. }
  5147. if (this.linesCache.length) {
  5148. line = this.linesCache.shift();
  5149. const lastLineCharacter = line[line.length - 1];
  5150. if (lastLineCharacter !== this.newLineCharacter) {
  5151. bytesRead = this._readChunk(line);
  5152. if (bytesRead) {
  5153. line = this.linesCache.shift();
  5154. }
  5155. }
  5156. }
  5157. if (this.eofReached && this.linesCache.length === 0) {
  5158. this.close();
  5159. }
  5160. if (line && line[line.length - 1] === this.newLineCharacter) {
  5161. line = line.slice(0, line.length - 1);
  5162. }
  5163. return line;
  5164. }
  5165. }
  5166. var readlines$1 = LineByLine;
  5167. class ConfigError$1 extends Error {}
  5168. class DebugError extends Error {}
  5169. class UndefinedParserError$1 extends Error {}
  5170. class ArgExpansionBailout$3 extends Error {}
  5171. var errors = {
  5172. ConfigError: ConfigError$1,
  5173. DebugError,
  5174. UndefinedParserError: UndefinedParserError$1,
  5175. ArgExpansionBailout: ArgExpansionBailout$3
  5176. };
  5177. var lib$4 = {};
  5178. /*! *****************************************************************************
  5179. Copyright (c) Microsoft Corporation.
  5180. Permission to use, copy, modify, and/or distribute this software for any
  5181. purpose with or without fee is hereby granted.
  5182. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  5183. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  5184. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  5185. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  5186. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  5187. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  5188. PERFORMANCE OF THIS SOFTWARE.
  5189. ***************************************************************************** */
  5190. /* global Reflect, Promise */
  5191. var extendStatics = function (d, b) {
  5192. extendStatics = Object.setPrototypeOf || {
  5193. __proto__: []
  5194. } instanceof Array && function (d, b) {
  5195. d.__proto__ = b;
  5196. } || function (d, b) {
  5197. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  5198. };
  5199. return extendStatics(d, b);
  5200. };
  5201. function __extends(d, b) {
  5202. extendStatics(d, b);
  5203. function __() {
  5204. this.constructor = d;
  5205. }
  5206. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5207. }
  5208. var __assign = function () {
  5209. __assign = Object.assign || function __assign(t) {
  5210. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5211. s = arguments[i];
  5212. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5213. }
  5214. return t;
  5215. };
  5216. return __assign.apply(this, arguments);
  5217. };
  5218. function __rest(s, e) {
  5219. var t = {};
  5220. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5221. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5222. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  5223. }
  5224. return t;
  5225. }
  5226. function __decorate(decorators, target, key, desc) {
  5227. var c = arguments.length,
  5228. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  5229. d;
  5230. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5231. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5232. }
  5233. function __param(paramIndex, decorator) {
  5234. return function (target, key) {
  5235. decorator(target, key, paramIndex);
  5236. };
  5237. }
  5238. function __metadata(metadataKey, metadataValue) {
  5239. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  5240. }
  5241. function __awaiter$2(thisArg, _arguments, P, generator) {
  5242. function adopt(value) {
  5243. return value instanceof P ? value : new P(function (resolve) {
  5244. resolve(value);
  5245. });
  5246. }
  5247. return new (P || (P = Promise))(function (resolve, reject) {
  5248. function fulfilled(value) {
  5249. try {
  5250. step(generator.next(value));
  5251. } catch (e) {
  5252. reject(e);
  5253. }
  5254. }
  5255. function rejected(value) {
  5256. try {
  5257. step(generator["throw"](value));
  5258. } catch (e) {
  5259. reject(e);
  5260. }
  5261. }
  5262. function step(result) {
  5263. result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
  5264. }
  5265. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5266. });
  5267. }
  5268. function __generator$2(thisArg, body) {
  5269. var _ = {
  5270. label: 0,
  5271. sent: function () {
  5272. if (t[0] & 1) throw t[1];
  5273. return t[1];
  5274. },
  5275. trys: [],
  5276. ops: []
  5277. },
  5278. f,
  5279. y,
  5280. t,
  5281. g;
  5282. return g = {
  5283. next: verb(0),
  5284. "throw": verb(1),
  5285. "return": verb(2)
  5286. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  5287. return this;
  5288. }), g;
  5289. function verb(n) {
  5290. return function (v) {
  5291. return step([n, v]);
  5292. };
  5293. }
  5294. function step(op) {
  5295. if (f) throw new TypeError("Generator is already executing.");
  5296. while (_) try {
  5297. 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;
  5298. if (y = 0, t) op = [op[0] & 2, t.value];
  5299. switch (op[0]) {
  5300. case 0:
  5301. case 1:
  5302. t = op;
  5303. break;
  5304. case 4:
  5305. _.label++;
  5306. return {
  5307. value: op[1],
  5308. done: false
  5309. };
  5310. case 5:
  5311. _.label++;
  5312. y = op[1];
  5313. op = [0];
  5314. continue;
  5315. case 7:
  5316. op = _.ops.pop();
  5317. _.trys.pop();
  5318. continue;
  5319. default:
  5320. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  5321. _ = 0;
  5322. continue;
  5323. }
  5324. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  5325. _.label = op[1];
  5326. break;
  5327. }
  5328. if (op[0] === 6 && _.label < t[1]) {
  5329. _.label = t[1];
  5330. t = op;
  5331. break;
  5332. }
  5333. if (t && _.label < t[2]) {
  5334. _.label = t[2];
  5335. _.ops.push(op);
  5336. break;
  5337. }
  5338. if (t[2]) _.ops.pop();
  5339. _.trys.pop();
  5340. continue;
  5341. }
  5342. op = body.call(thisArg, _);
  5343. } catch (e) {
  5344. op = [6, e];
  5345. y = 0;
  5346. } finally {
  5347. f = t = 0;
  5348. }
  5349. if (op[0] & 5) throw op[1];
  5350. return {
  5351. value: op[0] ? op[1] : void 0,
  5352. done: true
  5353. };
  5354. }
  5355. }
  5356. function __createBinding(o, m, k, k2) {
  5357. if (k2 === undefined) k2 = k;
  5358. o[k2] = m[k];
  5359. }
  5360. function __exportStar(m, exports) {
  5361. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
  5362. }
  5363. function __values(o) {
  5364. var s = typeof Symbol === "function" && Symbol.iterator,
  5365. m = s && o[s],
  5366. i = 0;
  5367. if (m) return m.call(o);
  5368. if (o && typeof o.length === "number") return {
  5369. next: function () {
  5370. if (o && i >= o.length) o = void 0;
  5371. return {
  5372. value: o && o[i++],
  5373. done: !o
  5374. };
  5375. }
  5376. };
  5377. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  5378. }
  5379. function __read(o, n) {
  5380. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5381. if (!m) return o;
  5382. var i = m.call(o),
  5383. r,
  5384. ar = [],
  5385. e;
  5386. try {
  5387. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  5388. } catch (error) {
  5389. e = {
  5390. error: error
  5391. };
  5392. } finally {
  5393. try {
  5394. if (r && !r.done && (m = i["return"])) m.call(i);
  5395. } finally {
  5396. if (e) throw e.error;
  5397. }
  5398. }
  5399. return ar;
  5400. }
  5401. function __spread() {
  5402. for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
  5403. return ar;
  5404. }
  5405. function __spreadArrays() {
  5406. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  5407. for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
  5408. return r;
  5409. }
  5410. function __await(v) {
  5411. return this instanceof __await ? (this.v = v, this) : new __await(v);
  5412. }
  5413. function __asyncGenerator(thisArg, _arguments, generator) {
  5414. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5415. var g = generator.apply(thisArg, _arguments || []),
  5416. i,
  5417. q = [];
  5418. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  5419. return this;
  5420. }, i;
  5421. function verb(n) {
  5422. if (g[n]) i[n] = function (v) {
  5423. return new Promise(function (a, b) {
  5424. q.push([n, v, a, b]) > 1 || resume(n, v);
  5425. });
  5426. };
  5427. }
  5428. function resume(n, v) {
  5429. try {
  5430. step(g[n](v));
  5431. } catch (e) {
  5432. settle(q[0][3], e);
  5433. }
  5434. }
  5435. function step(r) {
  5436. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  5437. }
  5438. function fulfill(value) {
  5439. resume("next", value);
  5440. }
  5441. function reject(value) {
  5442. resume("throw", value);
  5443. }
  5444. function settle(f, v) {
  5445. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  5446. }
  5447. }
  5448. function __asyncDelegator(o) {
  5449. var i, p;
  5450. return i = {}, verb("next"), verb("throw", function (e) {
  5451. throw e;
  5452. }), verb("return"), i[Symbol.iterator] = function () {
  5453. return this;
  5454. }, i;
  5455. function verb(n, f) {
  5456. i[n] = o[n] ? function (v) {
  5457. return (p = !p) ? {
  5458. value: __await(o[n](v)),
  5459. done: n === "return"
  5460. } : f ? f(v) : v;
  5461. } : f;
  5462. }
  5463. }
  5464. function __asyncValues(o) {
  5465. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5466. var m = o[Symbol.asyncIterator],
  5467. i;
  5468. 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 () {
  5469. return this;
  5470. }, i);
  5471. function verb(n) {
  5472. i[n] = o[n] && function (v) {
  5473. return new Promise(function (resolve, reject) {
  5474. v = o[n](v), settle(resolve, reject, v.done, v.value);
  5475. });
  5476. };
  5477. }
  5478. function settle(resolve, reject, d, v) {
  5479. Promise.resolve(v).then(function (v) {
  5480. resolve({
  5481. value: v,
  5482. done: d
  5483. });
  5484. }, reject);
  5485. }
  5486. }
  5487. function __makeTemplateObject(cooked, raw) {
  5488. if (Object.defineProperty) {
  5489. Object.defineProperty(cooked, "raw", {
  5490. value: raw
  5491. });
  5492. } else {
  5493. cooked.raw = raw;
  5494. }
  5495. return cooked;
  5496. }
  5497. function __importStar$2(mod) {
  5498. if (mod && mod.__esModule) return mod;
  5499. var result = {};
  5500. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5501. result.default = mod;
  5502. return result;
  5503. }
  5504. function __importDefault$1(mod) {
  5505. return mod && mod.__esModule ? mod : {
  5506. default: mod
  5507. };
  5508. }
  5509. function __classPrivateFieldGet(receiver, privateMap) {
  5510. if (!privateMap.has(receiver)) {
  5511. throw new TypeError("attempted to get private field on non-instance");
  5512. }
  5513. return privateMap.get(receiver);
  5514. }
  5515. function __classPrivateFieldSet(receiver, privateMap, value) {
  5516. if (!privateMap.has(receiver)) {
  5517. throw new TypeError("attempted to set private field on non-instance");
  5518. }
  5519. privateMap.set(receiver, value);
  5520. return value;
  5521. }
  5522. var tslib_es6 = /*#__PURE__*/Object.freeze({
  5523. __proto__: null,
  5524. __extends: __extends,
  5525. get __assign () { return __assign; },
  5526. __rest: __rest,
  5527. __decorate: __decorate,
  5528. __param: __param,
  5529. __metadata: __metadata,
  5530. __awaiter: __awaiter$2,
  5531. __generator: __generator$2,
  5532. __createBinding: __createBinding,
  5533. __exportStar: __exportStar,
  5534. __values: __values,
  5535. __read: __read,
  5536. __spread: __spread,
  5537. __spreadArrays: __spreadArrays,
  5538. __await: __await,
  5539. __asyncGenerator: __asyncGenerator,
  5540. __asyncDelegator: __asyncDelegator,
  5541. __asyncValues: __asyncValues,
  5542. __makeTemplateObject: __makeTemplateObject,
  5543. __importStar: __importStar$2,
  5544. __importDefault: __importDefault$1,
  5545. __classPrivateFieldGet: __classPrivateFieldGet,
  5546. __classPrivateFieldSet: __classPrivateFieldSet
  5547. });
  5548. var descriptors = {};
  5549. var api = {};
  5550. (function (exports) {
  5551. Object.defineProperty(exports, "__esModule", {
  5552. value: true
  5553. });
  5554. exports.apiDescriptor = {
  5555. key: key => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key),
  5556. value(value) {
  5557. if (value === null || typeof value !== 'object') {
  5558. return JSON.stringify(value);
  5559. }
  5560. if (Array.isArray(value)) {
  5561. return `[${value.map(subValue => exports.apiDescriptor.value(subValue)).join(', ')}]`;
  5562. }
  5563. const keys = Object.keys(value);
  5564. return keys.length === 0 ? '{}' : `{ ${keys.map(key => `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`).join(', ')} }`;
  5565. },
  5566. pair: ({
  5567. key,
  5568. value
  5569. }) => exports.apiDescriptor.value({
  5570. [key]: value
  5571. })
  5572. };
  5573. })(api);
  5574. (function (exports) {
  5575. Object.defineProperty(exports, "__esModule", {
  5576. value: true
  5577. });
  5578. const tslib_1 = tslib_es6;
  5579. tslib_1.__exportStar(api, exports);
  5580. })(descriptors);
  5581. var handlers = {};
  5582. var deprecated = {};
  5583. var common$8 = {};
  5584. var chalk$3 = {exports: {}};
  5585. var matchOperatorsRe$1 = /[|\\{}()[\]^$+*?.]/g;
  5586. var escapeStringRegexp$1 = function (str) {
  5587. if (typeof str !== 'string') {
  5588. throw new TypeError('Expected a string');
  5589. }
  5590. return str.replace(matchOperatorsRe$1, '\\$&');
  5591. };
  5592. var ansiStyles$2 = {exports: {}};
  5593. var conversions$5 = {exports: {}};
  5594. var colorName$1 = {
  5595. "aliceblue": [240, 248, 255],
  5596. "antiquewhite": [250, 235, 215],
  5597. "aqua": [0, 255, 255],
  5598. "aquamarine": [127, 255, 212],
  5599. "azure": [240, 255, 255],
  5600. "beige": [245, 245, 220],
  5601. "bisque": [255, 228, 196],
  5602. "black": [0, 0, 0],
  5603. "blanchedalmond": [255, 235, 205],
  5604. "blue": [0, 0, 255],
  5605. "blueviolet": [138, 43, 226],
  5606. "brown": [165, 42, 42],
  5607. "burlywood": [222, 184, 135],
  5608. "cadetblue": [95, 158, 160],
  5609. "chartreuse": [127, 255, 0],
  5610. "chocolate": [210, 105, 30],
  5611. "coral": [255, 127, 80],
  5612. "cornflowerblue": [100, 149, 237],
  5613. "cornsilk": [255, 248, 220],
  5614. "crimson": [220, 20, 60],
  5615. "cyan": [0, 255, 255],
  5616. "darkblue": [0, 0, 139],
  5617. "darkcyan": [0, 139, 139],
  5618. "darkgoldenrod": [184, 134, 11],
  5619. "darkgray": [169, 169, 169],
  5620. "darkgreen": [0, 100, 0],
  5621. "darkgrey": [169, 169, 169],
  5622. "darkkhaki": [189, 183, 107],
  5623. "darkmagenta": [139, 0, 139],
  5624. "darkolivegreen": [85, 107, 47],
  5625. "darkorange": [255, 140, 0],
  5626. "darkorchid": [153, 50, 204],
  5627. "darkred": [139, 0, 0],
  5628. "darksalmon": [233, 150, 122],
  5629. "darkseagreen": [143, 188, 143],
  5630. "darkslateblue": [72, 61, 139],
  5631. "darkslategray": [47, 79, 79],
  5632. "darkslategrey": [47, 79, 79],
  5633. "darkturquoise": [0, 206, 209],
  5634. "darkviolet": [148, 0, 211],
  5635. "deeppink": [255, 20, 147],
  5636. "deepskyblue": [0, 191, 255],
  5637. "dimgray": [105, 105, 105],
  5638. "dimgrey": [105, 105, 105],
  5639. "dodgerblue": [30, 144, 255],
  5640. "firebrick": [178, 34, 34],
  5641. "floralwhite": [255, 250, 240],
  5642. "forestgreen": [34, 139, 34],
  5643. "fuchsia": [255, 0, 255],
  5644. "gainsboro": [220, 220, 220],
  5645. "ghostwhite": [248, 248, 255],
  5646. "gold": [255, 215, 0],
  5647. "goldenrod": [218, 165, 32],
  5648. "gray": [128, 128, 128],
  5649. "green": [0, 128, 0],
  5650. "greenyellow": [173, 255, 47],
  5651. "grey": [128, 128, 128],
  5652. "honeydew": [240, 255, 240],
  5653. "hotpink": [255, 105, 180],
  5654. "indianred": [205, 92, 92],
  5655. "indigo": [75, 0, 130],
  5656. "ivory": [255, 255, 240],
  5657. "khaki": [240, 230, 140],
  5658. "lavender": [230, 230, 250],
  5659. "lavenderblush": [255, 240, 245],
  5660. "lawngreen": [124, 252, 0],
  5661. "lemonchiffon": [255, 250, 205],
  5662. "lightblue": [173, 216, 230],
  5663. "lightcoral": [240, 128, 128],
  5664. "lightcyan": [224, 255, 255],
  5665. "lightgoldenrodyellow": [250, 250, 210],
  5666. "lightgray": [211, 211, 211],
  5667. "lightgreen": [144, 238, 144],
  5668. "lightgrey": [211, 211, 211],
  5669. "lightpink": [255, 182, 193],
  5670. "lightsalmon": [255, 160, 122],
  5671. "lightseagreen": [32, 178, 170],
  5672. "lightskyblue": [135, 206, 250],
  5673. "lightslategray": [119, 136, 153],
  5674. "lightslategrey": [119, 136, 153],
  5675. "lightsteelblue": [176, 196, 222],
  5676. "lightyellow": [255, 255, 224],
  5677. "lime": [0, 255, 0],
  5678. "limegreen": [50, 205, 50],
  5679. "linen": [250, 240, 230],
  5680. "magenta": [255, 0, 255],
  5681. "maroon": [128, 0, 0],
  5682. "mediumaquamarine": [102, 205, 170],
  5683. "mediumblue": [0, 0, 205],
  5684. "mediumorchid": [186, 85, 211],
  5685. "mediumpurple": [147, 112, 219],
  5686. "mediumseagreen": [60, 179, 113],
  5687. "mediumslateblue": [123, 104, 238],
  5688. "mediumspringgreen": [0, 250, 154],
  5689. "mediumturquoise": [72, 209, 204],
  5690. "mediumvioletred": [199, 21, 133],
  5691. "midnightblue": [25, 25, 112],
  5692. "mintcream": [245, 255, 250],
  5693. "mistyrose": [255, 228, 225],
  5694. "moccasin": [255, 228, 181],
  5695. "navajowhite": [255, 222, 173],
  5696. "navy": [0, 0, 128],
  5697. "oldlace": [253, 245, 230],
  5698. "olive": [128, 128, 0],
  5699. "olivedrab": [107, 142, 35],
  5700. "orange": [255, 165, 0],
  5701. "orangered": [255, 69, 0],
  5702. "orchid": [218, 112, 214],
  5703. "palegoldenrod": [238, 232, 170],
  5704. "palegreen": [152, 251, 152],
  5705. "paleturquoise": [175, 238, 238],
  5706. "palevioletred": [219, 112, 147],
  5707. "papayawhip": [255, 239, 213],
  5708. "peachpuff": [255, 218, 185],
  5709. "peru": [205, 133, 63],
  5710. "pink": [255, 192, 203],
  5711. "plum": [221, 160, 221],
  5712. "powderblue": [176, 224, 230],
  5713. "purple": [128, 0, 128],
  5714. "rebeccapurple": [102, 51, 153],
  5715. "red": [255, 0, 0],
  5716. "rosybrown": [188, 143, 143],
  5717. "royalblue": [65, 105, 225],
  5718. "saddlebrown": [139, 69, 19],
  5719. "salmon": [250, 128, 114],
  5720. "sandybrown": [244, 164, 96],
  5721. "seagreen": [46, 139, 87],
  5722. "seashell": [255, 245, 238],
  5723. "sienna": [160, 82, 45],
  5724. "silver": [192, 192, 192],
  5725. "skyblue": [135, 206, 235],
  5726. "slateblue": [106, 90, 205],
  5727. "slategray": [112, 128, 144],
  5728. "slategrey": [112, 128, 144],
  5729. "snow": [255, 250, 250],
  5730. "springgreen": [0, 255, 127],
  5731. "steelblue": [70, 130, 180],
  5732. "tan": [210, 180, 140],
  5733. "teal": [0, 128, 128],
  5734. "thistle": [216, 191, 216],
  5735. "tomato": [255, 99, 71],
  5736. "turquoise": [64, 224, 208],
  5737. "violet": [238, 130, 238],
  5738. "wheat": [245, 222, 179],
  5739. "white": [255, 255, 255],
  5740. "whitesmoke": [245, 245, 245],
  5741. "yellow": [255, 255, 0],
  5742. "yellowgreen": [154, 205, 50]
  5743. };
  5744. /* MIT license */
  5745. var cssKeywords$1 = colorName$1; // NOTE: conversions should only return primitive values (i.e. arrays, or
  5746. // values that give correct `typeof` results).
  5747. // do not use box values types (i.e. Number(), String(), etc.)
  5748. var reverseKeywords$1 = {};
  5749. for (var key$1 in cssKeywords$1) {
  5750. if (cssKeywords$1.hasOwnProperty(key$1)) {
  5751. reverseKeywords$1[cssKeywords$1[key$1]] = key$1;
  5752. }
  5753. }
  5754. var convert$3 = conversions$5.exports = {
  5755. rgb: {
  5756. channels: 3,
  5757. labels: 'rgb'
  5758. },
  5759. hsl: {
  5760. channels: 3,
  5761. labels: 'hsl'
  5762. },
  5763. hsv: {
  5764. channels: 3,
  5765. labels: 'hsv'
  5766. },
  5767. hwb: {
  5768. channels: 3,
  5769. labels: 'hwb'
  5770. },
  5771. cmyk: {
  5772. channels: 4,
  5773. labels: 'cmyk'
  5774. },
  5775. xyz: {
  5776. channels: 3,
  5777. labels: 'xyz'
  5778. },
  5779. lab: {
  5780. channels: 3,
  5781. labels: 'lab'
  5782. },
  5783. lch: {
  5784. channels: 3,
  5785. labels: 'lch'
  5786. },
  5787. hex: {
  5788. channels: 1,
  5789. labels: ['hex']
  5790. },
  5791. keyword: {
  5792. channels: 1,
  5793. labels: ['keyword']
  5794. },
  5795. ansi16: {
  5796. channels: 1,
  5797. labels: ['ansi16']
  5798. },
  5799. ansi256: {
  5800. channels: 1,
  5801. labels: ['ansi256']
  5802. },
  5803. hcg: {
  5804. channels: 3,
  5805. labels: ['h', 'c', 'g']
  5806. },
  5807. apple: {
  5808. channels: 3,
  5809. labels: ['r16', 'g16', 'b16']
  5810. },
  5811. gray: {
  5812. channels: 1,
  5813. labels: ['gray']
  5814. }
  5815. }; // hide .channels and .labels properties
  5816. for (var model in convert$3) {
  5817. if (convert$3.hasOwnProperty(model)) {
  5818. if (!('channels' in convert$3[model])) {
  5819. throw new Error('missing channels property: ' + model);
  5820. }
  5821. if (!('labels' in convert$3[model])) {
  5822. throw new Error('missing channel labels property: ' + model);
  5823. }
  5824. if (convert$3[model].labels.length !== convert$3[model].channels) {
  5825. throw new Error('channel and label counts mismatch: ' + model);
  5826. }
  5827. var channels = convert$3[model].channels;
  5828. var labels = convert$3[model].labels;
  5829. delete convert$3[model].channels;
  5830. delete convert$3[model].labels;
  5831. Object.defineProperty(convert$3[model], 'channels', {
  5832. value: channels
  5833. });
  5834. Object.defineProperty(convert$3[model], 'labels', {
  5835. value: labels
  5836. });
  5837. }
  5838. }
  5839. convert$3.rgb.hsl = function (rgb) {
  5840. var r = rgb[0] / 255;
  5841. var g = rgb[1] / 255;
  5842. var b = rgb[2] / 255;
  5843. var min = Math.min(r, g, b);
  5844. var max = Math.max(r, g, b);
  5845. var delta = max - min;
  5846. var h;
  5847. var s;
  5848. var l;
  5849. if (max === min) {
  5850. h = 0;
  5851. } else if (r === max) {
  5852. h = (g - b) / delta;
  5853. } else if (g === max) {
  5854. h = 2 + (b - r) / delta;
  5855. } else if (b === max) {
  5856. h = 4 + (r - g) / delta;
  5857. }
  5858. h = Math.min(h * 60, 360);
  5859. if (h < 0) {
  5860. h += 360;
  5861. }
  5862. l = (min + max) / 2;
  5863. if (max === min) {
  5864. s = 0;
  5865. } else if (l <= 0.5) {
  5866. s = delta / (max + min);
  5867. } else {
  5868. s = delta / (2 - max - min);
  5869. }
  5870. return [h, s * 100, l * 100];
  5871. };
  5872. convert$3.rgb.hsv = function (rgb) {
  5873. var rdif;
  5874. var gdif;
  5875. var bdif;
  5876. var h;
  5877. var s;
  5878. var r = rgb[0] / 255;
  5879. var g = rgb[1] / 255;
  5880. var b = rgb[2] / 255;
  5881. var v = Math.max(r, g, b);
  5882. var diff = v - Math.min(r, g, b);
  5883. var diffc = function (c) {
  5884. return (v - c) / 6 / diff + 1 / 2;
  5885. };
  5886. if (diff === 0) {
  5887. h = s = 0;
  5888. } else {
  5889. s = diff / v;
  5890. rdif = diffc(r);
  5891. gdif = diffc(g);
  5892. bdif = diffc(b);
  5893. if (r === v) {
  5894. h = bdif - gdif;
  5895. } else if (g === v) {
  5896. h = 1 / 3 + rdif - bdif;
  5897. } else if (b === v) {
  5898. h = 2 / 3 + gdif - rdif;
  5899. }
  5900. if (h < 0) {
  5901. h += 1;
  5902. } else if (h > 1) {
  5903. h -= 1;
  5904. }
  5905. }
  5906. return [h * 360, s * 100, v * 100];
  5907. };
  5908. convert$3.rgb.hwb = function (rgb) {
  5909. var r = rgb[0];
  5910. var g = rgb[1];
  5911. var b = rgb[2];
  5912. var h = convert$3.rgb.hsl(rgb)[0];
  5913. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  5914. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  5915. return [h, w * 100, b * 100];
  5916. };
  5917. convert$3.rgb.cmyk = function (rgb) {
  5918. var r = rgb[0] / 255;
  5919. var g = rgb[1] / 255;
  5920. var b = rgb[2] / 255;
  5921. var c;
  5922. var m;
  5923. var y;
  5924. var k;
  5925. k = Math.min(1 - r, 1 - g, 1 - b);
  5926. c = (1 - r - k) / (1 - k) || 0;
  5927. m = (1 - g - k) / (1 - k) || 0;
  5928. y = (1 - b - k) / (1 - k) || 0;
  5929. return [c * 100, m * 100, y * 100, k * 100];
  5930. };
  5931. /**
  5932. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  5933. * */
  5934. function comparativeDistance$1(x, y) {
  5935. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  5936. }
  5937. convert$3.rgb.keyword = function (rgb) {
  5938. var reversed = reverseKeywords$1[rgb];
  5939. if (reversed) {
  5940. return reversed;
  5941. }
  5942. var currentClosestDistance = Infinity;
  5943. var currentClosestKeyword;
  5944. for (var keyword in cssKeywords$1) {
  5945. if (cssKeywords$1.hasOwnProperty(keyword)) {
  5946. var value = cssKeywords$1[keyword]; // Compute comparative distance
  5947. var distance = comparativeDistance$1(rgb, value); // Check if its less, if so set as closest
  5948. if (distance < currentClosestDistance) {
  5949. currentClosestDistance = distance;
  5950. currentClosestKeyword = keyword;
  5951. }
  5952. }
  5953. }
  5954. return currentClosestKeyword;
  5955. };
  5956. convert$3.keyword.rgb = function (keyword) {
  5957. return cssKeywords$1[keyword];
  5958. };
  5959. convert$3.rgb.xyz = function (rgb) {
  5960. var r = rgb[0] / 255;
  5961. var g = rgb[1] / 255;
  5962. var b = rgb[2] / 255; // assume sRGB
  5963. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  5964. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  5965. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  5966. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  5967. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  5968. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  5969. return [x * 100, y * 100, z * 100];
  5970. };
  5971. convert$3.rgb.lab = function (rgb) {
  5972. var xyz = convert$3.rgb.xyz(rgb);
  5973. var x = xyz[0];
  5974. var y = xyz[1];
  5975. var z = xyz[2];
  5976. var l;
  5977. var a;
  5978. var b;
  5979. x /= 95.047;
  5980. y /= 100;
  5981. z /= 108.883;
  5982. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  5983. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  5984. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  5985. l = 116 * y - 16;
  5986. a = 500 * (x - y);
  5987. b = 200 * (y - z);
  5988. return [l, a, b];
  5989. };
  5990. convert$3.hsl.rgb = function (hsl) {
  5991. var h = hsl[0] / 360;
  5992. var s = hsl[1] / 100;
  5993. var l = hsl[2] / 100;
  5994. var t1;
  5995. var t2;
  5996. var t3;
  5997. var rgb;
  5998. var val;
  5999. if (s === 0) {
  6000. val = l * 255;
  6001. return [val, val, val];
  6002. }
  6003. if (l < 0.5) {
  6004. t2 = l * (1 + s);
  6005. } else {
  6006. t2 = l + s - l * s;
  6007. }
  6008. t1 = 2 * l - t2;
  6009. rgb = [0, 0, 0];
  6010. for (var i = 0; i < 3; i++) {
  6011. t3 = h + 1 / 3 * -(i - 1);
  6012. if (t3 < 0) {
  6013. t3++;
  6014. }
  6015. if (t3 > 1) {
  6016. t3--;
  6017. }
  6018. if (6 * t3 < 1) {
  6019. val = t1 + (t2 - t1) * 6 * t3;
  6020. } else if (2 * t3 < 1) {
  6021. val = t2;
  6022. } else if (3 * t3 < 2) {
  6023. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  6024. } else {
  6025. val = t1;
  6026. }
  6027. rgb[i] = val * 255;
  6028. }
  6029. return rgb;
  6030. };
  6031. convert$3.hsl.hsv = function (hsl) {
  6032. var h = hsl[0];
  6033. var s = hsl[1] / 100;
  6034. var l = hsl[2] / 100;
  6035. var smin = s;
  6036. var lmin = Math.max(l, 0.01);
  6037. var sv;
  6038. var v;
  6039. l *= 2;
  6040. s *= l <= 1 ? l : 2 - l;
  6041. smin *= lmin <= 1 ? lmin : 2 - lmin;
  6042. v = (l + s) / 2;
  6043. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  6044. return [h, sv * 100, v * 100];
  6045. };
  6046. convert$3.hsv.rgb = function (hsv) {
  6047. var h = hsv[0] / 60;
  6048. var s = hsv[1] / 100;
  6049. var v = hsv[2] / 100;
  6050. var hi = Math.floor(h) % 6;
  6051. var f = h - Math.floor(h);
  6052. var p = 255 * v * (1 - s);
  6053. var q = 255 * v * (1 - s * f);
  6054. var t = 255 * v * (1 - s * (1 - f));
  6055. v *= 255;
  6056. switch (hi) {
  6057. case 0:
  6058. return [v, t, p];
  6059. case 1:
  6060. return [q, v, p];
  6061. case 2:
  6062. return [p, v, t];
  6063. case 3:
  6064. return [p, q, v];
  6065. case 4:
  6066. return [t, p, v];
  6067. case 5:
  6068. return [v, p, q];
  6069. }
  6070. };
  6071. convert$3.hsv.hsl = function (hsv) {
  6072. var h = hsv[0];
  6073. var s = hsv[1] / 100;
  6074. var v = hsv[2] / 100;
  6075. var vmin = Math.max(v, 0.01);
  6076. var lmin;
  6077. var sl;
  6078. var l;
  6079. l = (2 - s) * v;
  6080. lmin = (2 - s) * vmin;
  6081. sl = s * vmin;
  6082. sl /= lmin <= 1 ? lmin : 2 - lmin;
  6083. sl = sl || 0;
  6084. l /= 2;
  6085. return [h, sl * 100, l * 100];
  6086. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  6087. convert$3.hwb.rgb = function (hwb) {
  6088. var h = hwb[0] / 360;
  6089. var wh = hwb[1] / 100;
  6090. var bl = hwb[2] / 100;
  6091. var ratio = wh + bl;
  6092. var i;
  6093. var v;
  6094. var f;
  6095. var n; // wh + bl cant be > 1
  6096. if (ratio > 1) {
  6097. wh /= ratio;
  6098. bl /= ratio;
  6099. }
  6100. i = Math.floor(6 * h);
  6101. v = 1 - bl;
  6102. f = 6 * h - i;
  6103. if ((i & 0x01) !== 0) {
  6104. f = 1 - f;
  6105. }
  6106. n = wh + f * (v - wh); // linear interpolation
  6107. var r;
  6108. var g;
  6109. var b;
  6110. switch (i) {
  6111. default:
  6112. case 6:
  6113. case 0:
  6114. r = v;
  6115. g = n;
  6116. b = wh;
  6117. break;
  6118. case 1:
  6119. r = n;
  6120. g = v;
  6121. b = wh;
  6122. break;
  6123. case 2:
  6124. r = wh;
  6125. g = v;
  6126. b = n;
  6127. break;
  6128. case 3:
  6129. r = wh;
  6130. g = n;
  6131. b = v;
  6132. break;
  6133. case 4:
  6134. r = n;
  6135. g = wh;
  6136. b = v;
  6137. break;
  6138. case 5:
  6139. r = v;
  6140. g = wh;
  6141. b = n;
  6142. break;
  6143. }
  6144. return [r * 255, g * 255, b * 255];
  6145. };
  6146. convert$3.cmyk.rgb = function (cmyk) {
  6147. var c = cmyk[0] / 100;
  6148. var m = cmyk[1] / 100;
  6149. var y = cmyk[2] / 100;
  6150. var k = cmyk[3] / 100;
  6151. var r;
  6152. var g;
  6153. var b;
  6154. r = 1 - Math.min(1, c * (1 - k) + k);
  6155. g = 1 - Math.min(1, m * (1 - k) + k);
  6156. b = 1 - Math.min(1, y * (1 - k) + k);
  6157. return [r * 255, g * 255, b * 255];
  6158. };
  6159. convert$3.xyz.rgb = function (xyz) {
  6160. var x = xyz[0] / 100;
  6161. var y = xyz[1] / 100;
  6162. var z = xyz[2] / 100;
  6163. var r;
  6164. var g;
  6165. var b;
  6166. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  6167. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  6168. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  6169. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  6170. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  6171. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  6172. r = Math.min(Math.max(0, r), 1);
  6173. g = Math.min(Math.max(0, g), 1);
  6174. b = Math.min(Math.max(0, b), 1);
  6175. return [r * 255, g * 255, b * 255];
  6176. };
  6177. convert$3.xyz.lab = function (xyz) {
  6178. var x = xyz[0];
  6179. var y = xyz[1];
  6180. var z = xyz[2];
  6181. var l;
  6182. var a;
  6183. var b;
  6184. x /= 95.047;
  6185. y /= 100;
  6186. z /= 108.883;
  6187. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  6188. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  6189. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  6190. l = 116 * y - 16;
  6191. a = 500 * (x - y);
  6192. b = 200 * (y - z);
  6193. return [l, a, b];
  6194. };
  6195. convert$3.lab.xyz = function (lab) {
  6196. var l = lab[0];
  6197. var a = lab[1];
  6198. var b = lab[2];
  6199. var x;
  6200. var y;
  6201. var z;
  6202. y = (l + 16) / 116;
  6203. x = a / 500 + y;
  6204. z = y - b / 200;
  6205. var y2 = Math.pow(y, 3);
  6206. var x2 = Math.pow(x, 3);
  6207. var z2 = Math.pow(z, 3);
  6208. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  6209. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  6210. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  6211. x *= 95.047;
  6212. y *= 100;
  6213. z *= 108.883;
  6214. return [x, y, z];
  6215. };
  6216. convert$3.lab.lch = function (lab) {
  6217. var l = lab[0];
  6218. var a = lab[1];
  6219. var b = lab[2];
  6220. var hr;
  6221. var h;
  6222. var c;
  6223. hr = Math.atan2(b, a);
  6224. h = hr * 360 / 2 / Math.PI;
  6225. if (h < 0) {
  6226. h += 360;
  6227. }
  6228. c = Math.sqrt(a * a + b * b);
  6229. return [l, c, h];
  6230. };
  6231. convert$3.lch.lab = function (lch) {
  6232. var l = lch[0];
  6233. var c = lch[1];
  6234. var h = lch[2];
  6235. var a;
  6236. var b;
  6237. var hr;
  6238. hr = h / 360 * 2 * Math.PI;
  6239. a = c * Math.cos(hr);
  6240. b = c * Math.sin(hr);
  6241. return [l, a, b];
  6242. };
  6243. convert$3.rgb.ansi16 = function (args) {
  6244. var r = args[0];
  6245. var g = args[1];
  6246. var b = args[2];
  6247. var value = 1 in arguments ? arguments[1] : convert$3.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  6248. value = Math.round(value / 50);
  6249. if (value === 0) {
  6250. return 30;
  6251. }
  6252. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  6253. if (value === 2) {
  6254. ansi += 60;
  6255. }
  6256. return ansi;
  6257. };
  6258. convert$3.hsv.ansi16 = function (args) {
  6259. // optimization here; we already know the value and don't need to get
  6260. // it converted for us.
  6261. return convert$3.rgb.ansi16(convert$3.hsv.rgb(args), args[2]);
  6262. };
  6263. convert$3.rgb.ansi256 = function (args) {
  6264. var r = args[0];
  6265. var g = args[1];
  6266. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  6267. // black and white. normal palette only has 4 greyscale shades.
  6268. if (r === g && g === b) {
  6269. if (r < 8) {
  6270. return 16;
  6271. }
  6272. if (r > 248) {
  6273. return 231;
  6274. }
  6275. return Math.round((r - 8) / 247 * 24) + 232;
  6276. }
  6277. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  6278. return ansi;
  6279. };
  6280. convert$3.ansi16.rgb = function (args) {
  6281. var color = args % 10; // handle greyscale
  6282. if (color === 0 || color === 7) {
  6283. if (args > 50) {
  6284. color += 3.5;
  6285. }
  6286. color = color / 10.5 * 255;
  6287. return [color, color, color];
  6288. }
  6289. var mult = (~~(args > 50) + 1) * 0.5;
  6290. var r = (color & 1) * mult * 255;
  6291. var g = (color >> 1 & 1) * mult * 255;
  6292. var b = (color >> 2 & 1) * mult * 255;
  6293. return [r, g, b];
  6294. };
  6295. convert$3.ansi256.rgb = function (args) {
  6296. // handle greyscale
  6297. if (args >= 232) {
  6298. var c = (args - 232) * 10 + 8;
  6299. return [c, c, c];
  6300. }
  6301. args -= 16;
  6302. var rem;
  6303. var r = Math.floor(args / 36) / 5 * 255;
  6304. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  6305. var b = rem % 6 / 5 * 255;
  6306. return [r, g, b];
  6307. };
  6308. convert$3.rgb.hex = function (args) {
  6309. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  6310. var string = integer.toString(16).toUpperCase();
  6311. return '000000'.substring(string.length) + string;
  6312. };
  6313. convert$3.hex.rgb = function (args) {
  6314. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  6315. if (!match) {
  6316. return [0, 0, 0];
  6317. }
  6318. var colorString = match[0];
  6319. if (match[0].length === 3) {
  6320. colorString = colorString.split('').map(function (char) {
  6321. return char + char;
  6322. }).join('');
  6323. }
  6324. var integer = parseInt(colorString, 16);
  6325. var r = integer >> 16 & 0xFF;
  6326. var g = integer >> 8 & 0xFF;
  6327. var b = integer & 0xFF;
  6328. return [r, g, b];
  6329. };
  6330. convert$3.rgb.hcg = function (rgb) {
  6331. var r = rgb[0] / 255;
  6332. var g = rgb[1] / 255;
  6333. var b = rgb[2] / 255;
  6334. var max = Math.max(Math.max(r, g), b);
  6335. var min = Math.min(Math.min(r, g), b);
  6336. var chroma = max - min;
  6337. var grayscale;
  6338. var hue;
  6339. if (chroma < 1) {
  6340. grayscale = min / (1 - chroma);
  6341. } else {
  6342. grayscale = 0;
  6343. }
  6344. if (chroma <= 0) {
  6345. hue = 0;
  6346. } else if (max === r) {
  6347. hue = (g - b) / chroma % 6;
  6348. } else if (max === g) {
  6349. hue = 2 + (b - r) / chroma;
  6350. } else {
  6351. hue = 4 + (r - g) / chroma + 4;
  6352. }
  6353. hue /= 6;
  6354. hue %= 1;
  6355. return [hue * 360, chroma * 100, grayscale * 100];
  6356. };
  6357. convert$3.hsl.hcg = function (hsl) {
  6358. var s = hsl[1] / 100;
  6359. var l = hsl[2] / 100;
  6360. var c = 1;
  6361. var f = 0;
  6362. if (l < 0.5) {
  6363. c = 2.0 * s * l;
  6364. } else {
  6365. c = 2.0 * s * (1.0 - l);
  6366. }
  6367. if (c < 1.0) {
  6368. f = (l - 0.5 * c) / (1.0 - c);
  6369. }
  6370. return [hsl[0], c * 100, f * 100];
  6371. };
  6372. convert$3.hsv.hcg = function (hsv) {
  6373. var s = hsv[1] / 100;
  6374. var v = hsv[2] / 100;
  6375. var c = s * v;
  6376. var f = 0;
  6377. if (c < 1.0) {
  6378. f = (v - c) / (1 - c);
  6379. }
  6380. return [hsv[0], c * 100, f * 100];
  6381. };
  6382. convert$3.hcg.rgb = function (hcg) {
  6383. var h = hcg[0] / 360;
  6384. var c = hcg[1] / 100;
  6385. var g = hcg[2] / 100;
  6386. if (c === 0.0) {
  6387. return [g * 255, g * 255, g * 255];
  6388. }
  6389. var pure = [0, 0, 0];
  6390. var hi = h % 1 * 6;
  6391. var v = hi % 1;
  6392. var w = 1 - v;
  6393. var mg = 0;
  6394. switch (Math.floor(hi)) {
  6395. case 0:
  6396. pure[0] = 1;
  6397. pure[1] = v;
  6398. pure[2] = 0;
  6399. break;
  6400. case 1:
  6401. pure[0] = w;
  6402. pure[1] = 1;
  6403. pure[2] = 0;
  6404. break;
  6405. case 2:
  6406. pure[0] = 0;
  6407. pure[1] = 1;
  6408. pure[2] = v;
  6409. break;
  6410. case 3:
  6411. pure[0] = 0;
  6412. pure[1] = w;
  6413. pure[2] = 1;
  6414. break;
  6415. case 4:
  6416. pure[0] = v;
  6417. pure[1] = 0;
  6418. pure[2] = 1;
  6419. break;
  6420. default:
  6421. pure[0] = 1;
  6422. pure[1] = 0;
  6423. pure[2] = w;
  6424. }
  6425. mg = (1.0 - c) * g;
  6426. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  6427. };
  6428. convert$3.hcg.hsv = function (hcg) {
  6429. var c = hcg[1] / 100;
  6430. var g = hcg[2] / 100;
  6431. var v = c + g * (1.0 - c);
  6432. var f = 0;
  6433. if (v > 0.0) {
  6434. f = c / v;
  6435. }
  6436. return [hcg[0], f * 100, v * 100];
  6437. };
  6438. convert$3.hcg.hsl = function (hcg) {
  6439. var c = hcg[1] / 100;
  6440. var g = hcg[2] / 100;
  6441. var l = g * (1.0 - c) + 0.5 * c;
  6442. var s = 0;
  6443. if (l > 0.0 && l < 0.5) {
  6444. s = c / (2 * l);
  6445. } else if (l >= 0.5 && l < 1.0) {
  6446. s = c / (2 * (1 - l));
  6447. }
  6448. return [hcg[0], s * 100, l * 100];
  6449. };
  6450. convert$3.hcg.hwb = function (hcg) {
  6451. var c = hcg[1] / 100;
  6452. var g = hcg[2] / 100;
  6453. var v = c + g * (1.0 - c);
  6454. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  6455. };
  6456. convert$3.hwb.hcg = function (hwb) {
  6457. var w = hwb[1] / 100;
  6458. var b = hwb[2] / 100;
  6459. var v = 1 - b;
  6460. var c = v - w;
  6461. var g = 0;
  6462. if (c < 1) {
  6463. g = (v - c) / (1 - c);
  6464. }
  6465. return [hwb[0], c * 100, g * 100];
  6466. };
  6467. convert$3.apple.rgb = function (apple) {
  6468. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  6469. };
  6470. convert$3.rgb.apple = function (rgb) {
  6471. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  6472. };
  6473. convert$3.gray.rgb = function (args) {
  6474. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  6475. };
  6476. convert$3.gray.hsl = convert$3.gray.hsv = function (args) {
  6477. return [0, 0, args[0]];
  6478. };
  6479. convert$3.gray.hwb = function (gray) {
  6480. return [0, 100, gray[0]];
  6481. };
  6482. convert$3.gray.cmyk = function (gray) {
  6483. return [0, 0, 0, gray[0]];
  6484. };
  6485. convert$3.gray.lab = function (gray) {
  6486. return [gray[0], 0, 0];
  6487. };
  6488. convert$3.gray.hex = function (gray) {
  6489. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  6490. var integer = (val << 16) + (val << 8) + val;
  6491. var string = integer.toString(16).toUpperCase();
  6492. return '000000'.substring(string.length) + string;
  6493. };
  6494. convert$3.rgb.gray = function (rgb) {
  6495. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  6496. return [val / 255 * 100];
  6497. };
  6498. var conversions$4 = conversions$5.exports;
  6499. /*
  6500. this function routes a model to all other models.
  6501. all functions that are routed have a property `.conversion` attached
  6502. to the returned synthetic function. This property is an array
  6503. of strings, each with the steps in between the 'from' and 'to'
  6504. color models (inclusive).
  6505. conversions that are not possible simply are not included.
  6506. */
  6507. function buildGraph$1() {
  6508. var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  6509. var models = Object.keys(conversions$4);
  6510. for (var len = models.length, i = 0; i < len; i++) {
  6511. graph[models[i]] = {
  6512. // http://jsperf.com/1-vs-infinity
  6513. // micro-opt, but this is simple.
  6514. distance: -1,
  6515. parent: null
  6516. };
  6517. }
  6518. return graph;
  6519. } // https://en.wikipedia.org/wiki/Breadth-first_search
  6520. function deriveBFS$1(fromModel) {
  6521. var graph = buildGraph$1();
  6522. var queue = [fromModel]; // unshift -> queue -> pop
  6523. graph[fromModel].distance = 0;
  6524. while (queue.length) {
  6525. var current = queue.pop();
  6526. var adjacents = Object.keys(conversions$4[current]);
  6527. for (var len = adjacents.length, i = 0; i < len; i++) {
  6528. var adjacent = adjacents[i];
  6529. var node = graph[adjacent];
  6530. if (node.distance === -1) {
  6531. node.distance = graph[current].distance + 1;
  6532. node.parent = current;
  6533. queue.unshift(adjacent);
  6534. }
  6535. }
  6536. }
  6537. return graph;
  6538. }
  6539. function link$2(from, to) {
  6540. return function (args) {
  6541. return to(from(args));
  6542. };
  6543. }
  6544. function wrapConversion$1(toModel, graph) {
  6545. var path = [graph[toModel].parent, toModel];
  6546. var fn = conversions$4[graph[toModel].parent][toModel];
  6547. var cur = graph[toModel].parent;
  6548. while (graph[cur].parent) {
  6549. path.unshift(graph[cur].parent);
  6550. fn = link$2(conversions$4[graph[cur].parent][cur], fn);
  6551. cur = graph[cur].parent;
  6552. }
  6553. fn.conversion = path;
  6554. return fn;
  6555. }
  6556. var route$3 = function (fromModel) {
  6557. var graph = deriveBFS$1(fromModel);
  6558. var conversion = {};
  6559. var models = Object.keys(graph);
  6560. for (var len = models.length, i = 0; i < len; i++) {
  6561. var toModel = models[i];
  6562. var node = graph[toModel];
  6563. if (node.parent === null) {
  6564. // no possible conversion, or this node is the source model.
  6565. continue;
  6566. }
  6567. conversion[toModel] = wrapConversion$1(toModel, graph);
  6568. }
  6569. return conversion;
  6570. };
  6571. var conversions$3 = conversions$5.exports;
  6572. var route$2 = route$3;
  6573. var convert$2 = {};
  6574. var models$1 = Object.keys(conversions$3);
  6575. function wrapRaw$1(fn) {
  6576. var wrappedFn = function (args) {
  6577. if (args === undefined || args === null) {
  6578. return args;
  6579. }
  6580. if (arguments.length > 1) {
  6581. args = Array.prototype.slice.call(arguments);
  6582. }
  6583. return fn(args);
  6584. }; // preserve .conversion property if there is one
  6585. if ('conversion' in fn) {
  6586. wrappedFn.conversion = fn.conversion;
  6587. }
  6588. return wrappedFn;
  6589. }
  6590. function wrapRounded$1(fn) {
  6591. var wrappedFn = function (args) {
  6592. if (args === undefined || args === null) {
  6593. return args;
  6594. }
  6595. if (arguments.length > 1) {
  6596. args = Array.prototype.slice.call(arguments);
  6597. }
  6598. var result = fn(args); // we're assuming the result is an array here.
  6599. // see notice in conversions.js; don't use box types
  6600. // in conversion functions.
  6601. if (typeof result === 'object') {
  6602. for (var len = result.length, i = 0; i < len; i++) {
  6603. result[i] = Math.round(result[i]);
  6604. }
  6605. }
  6606. return result;
  6607. }; // preserve .conversion property if there is one
  6608. if ('conversion' in fn) {
  6609. wrappedFn.conversion = fn.conversion;
  6610. }
  6611. return wrappedFn;
  6612. }
  6613. models$1.forEach(function (fromModel) {
  6614. convert$2[fromModel] = {};
  6615. Object.defineProperty(convert$2[fromModel], 'channels', {
  6616. value: conversions$3[fromModel].channels
  6617. });
  6618. Object.defineProperty(convert$2[fromModel], 'labels', {
  6619. value: conversions$3[fromModel].labels
  6620. });
  6621. var routes = route$2(fromModel);
  6622. var routeModels = Object.keys(routes);
  6623. routeModels.forEach(function (toModel) {
  6624. var fn = routes[toModel];
  6625. convert$2[fromModel][toModel] = wrapRounded$1(fn);
  6626. convert$2[fromModel][toModel].raw = wrapRaw$1(fn);
  6627. });
  6628. });
  6629. var colorConvert$1 = convert$2;
  6630. (function (module) {
  6631. const colorConvert = colorConvert$1;
  6632. const wrapAnsi16 = (fn, offset) => function () {
  6633. const code = fn.apply(colorConvert, arguments);
  6634. return `\u001B[${code + offset}m`;
  6635. };
  6636. const wrapAnsi256 = (fn, offset) => function () {
  6637. const code = fn.apply(colorConvert, arguments);
  6638. return `\u001B[${38 + offset};5;${code}m`;
  6639. };
  6640. const wrapAnsi16m = (fn, offset) => function () {
  6641. const rgb = fn.apply(colorConvert, arguments);
  6642. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  6643. };
  6644. function assembleStyles() {
  6645. const codes = new Map();
  6646. const styles = {
  6647. modifier: {
  6648. reset: [0, 0],
  6649. // 21 isn't widely supported and 22 does the same thing
  6650. bold: [1, 22],
  6651. dim: [2, 22],
  6652. italic: [3, 23],
  6653. underline: [4, 24],
  6654. inverse: [7, 27],
  6655. hidden: [8, 28],
  6656. strikethrough: [9, 29]
  6657. },
  6658. color: {
  6659. black: [30, 39],
  6660. red: [31, 39],
  6661. green: [32, 39],
  6662. yellow: [33, 39],
  6663. blue: [34, 39],
  6664. magenta: [35, 39],
  6665. cyan: [36, 39],
  6666. white: [37, 39],
  6667. gray: [90, 39],
  6668. // Bright color
  6669. redBright: [91, 39],
  6670. greenBright: [92, 39],
  6671. yellowBright: [93, 39],
  6672. blueBright: [94, 39],
  6673. magentaBright: [95, 39],
  6674. cyanBright: [96, 39],
  6675. whiteBright: [97, 39]
  6676. },
  6677. bgColor: {
  6678. bgBlack: [40, 49],
  6679. bgRed: [41, 49],
  6680. bgGreen: [42, 49],
  6681. bgYellow: [43, 49],
  6682. bgBlue: [44, 49],
  6683. bgMagenta: [45, 49],
  6684. bgCyan: [46, 49],
  6685. bgWhite: [47, 49],
  6686. // Bright color
  6687. bgBlackBright: [100, 49],
  6688. bgRedBright: [101, 49],
  6689. bgGreenBright: [102, 49],
  6690. bgYellowBright: [103, 49],
  6691. bgBlueBright: [104, 49],
  6692. bgMagentaBright: [105, 49],
  6693. bgCyanBright: [106, 49],
  6694. bgWhiteBright: [107, 49]
  6695. }
  6696. }; // Fix humans
  6697. styles.color.grey = styles.color.gray;
  6698. for (const groupName of Object.keys(styles)) {
  6699. const group = styles[groupName];
  6700. for (const styleName of Object.keys(group)) {
  6701. const style = group[styleName];
  6702. styles[styleName] = {
  6703. open: `\u001B[${style[0]}m`,
  6704. close: `\u001B[${style[1]}m`
  6705. };
  6706. group[styleName] = styles[styleName];
  6707. codes.set(style[0], style[1]);
  6708. }
  6709. Object.defineProperty(styles, groupName, {
  6710. value: group,
  6711. enumerable: false
  6712. });
  6713. Object.defineProperty(styles, 'codes', {
  6714. value: codes,
  6715. enumerable: false
  6716. });
  6717. }
  6718. const ansi2ansi = n => n;
  6719. const rgb2rgb = (r, g, b) => [r, g, b];
  6720. styles.color.close = '\u001B[39m';
  6721. styles.bgColor.close = '\u001B[49m';
  6722. styles.color.ansi = {
  6723. ansi: wrapAnsi16(ansi2ansi, 0)
  6724. };
  6725. styles.color.ansi256 = {
  6726. ansi256: wrapAnsi256(ansi2ansi, 0)
  6727. };
  6728. styles.color.ansi16m = {
  6729. rgb: wrapAnsi16m(rgb2rgb, 0)
  6730. };
  6731. styles.bgColor.ansi = {
  6732. ansi: wrapAnsi16(ansi2ansi, 10)
  6733. };
  6734. styles.bgColor.ansi256 = {
  6735. ansi256: wrapAnsi256(ansi2ansi, 10)
  6736. };
  6737. styles.bgColor.ansi16m = {
  6738. rgb: wrapAnsi16m(rgb2rgb, 10)
  6739. };
  6740. for (let key of Object.keys(colorConvert)) {
  6741. if (typeof colorConvert[key] !== 'object') {
  6742. continue;
  6743. }
  6744. const suite = colorConvert[key];
  6745. if (key === 'ansi16') {
  6746. key = 'ansi';
  6747. }
  6748. if ('ansi16' in suite) {
  6749. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  6750. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  6751. }
  6752. if ('ansi256' in suite) {
  6753. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  6754. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  6755. }
  6756. if ('rgb' in suite) {
  6757. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  6758. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  6759. }
  6760. }
  6761. return styles;
  6762. } // Make the export immutable
  6763. Object.defineProperty(module, 'exports', {
  6764. enumerable: true,
  6765. get: assembleStyles
  6766. });
  6767. })(ansiStyles$2);
  6768. var hasFlag$5 = (flag, argv) => {
  6769. argv = argv || process.argv;
  6770. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  6771. const pos = argv.indexOf(prefix + flag);
  6772. const terminatorPos = argv.indexOf('--');
  6773. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6774. };
  6775. const os$4 = require$$0__default$1["default"];
  6776. const hasFlag$4 = hasFlag$5;
  6777. const env$2 = process.env;
  6778. let forceColor$2;
  6779. if (hasFlag$4('no-color') || hasFlag$4('no-colors') || hasFlag$4('color=false')) {
  6780. forceColor$2 = false;
  6781. } else if (hasFlag$4('color') || hasFlag$4('colors') || hasFlag$4('color=true') || hasFlag$4('color=always')) {
  6782. forceColor$2 = true;
  6783. }
  6784. if ('FORCE_COLOR' in env$2) {
  6785. forceColor$2 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
  6786. }
  6787. function translateLevel$2(level) {
  6788. if (level === 0) {
  6789. return false;
  6790. }
  6791. return {
  6792. level,
  6793. hasBasic: true,
  6794. has256: level >= 2,
  6795. has16m: level >= 3
  6796. };
  6797. }
  6798. function supportsColor$2(stream) {
  6799. if (forceColor$2 === false) {
  6800. return 0;
  6801. }
  6802. if (hasFlag$4('color=16m') || hasFlag$4('color=full') || hasFlag$4('color=truecolor')) {
  6803. return 3;
  6804. }
  6805. if (hasFlag$4('color=256')) {
  6806. return 2;
  6807. }
  6808. if (stream && !stream.isTTY && forceColor$2 !== true) {
  6809. return 0;
  6810. }
  6811. const min = forceColor$2 ? 1 : 0;
  6812. if (process.platform === 'win32') {
  6813. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6814. // libuv that enables 256 color output on Windows. Anything earlier and it
  6815. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6816. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6817. // release that supports 256 colors. Windows 10 build 14931 is the first release
  6818. // that supports 16m/TrueColor.
  6819. const osRelease = os$4.release().split('.');
  6820. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6821. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  6822. }
  6823. return 1;
  6824. }
  6825. if ('CI' in env$2) {
  6826. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') {
  6827. return 1;
  6828. }
  6829. return min;
  6830. }
  6831. if ('TEAMCITY_VERSION' in env$2) {
  6832. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
  6833. }
  6834. if (env$2.COLORTERM === 'truecolor') {
  6835. return 3;
  6836. }
  6837. if ('TERM_PROGRAM' in env$2) {
  6838. const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6839. switch (env$2.TERM_PROGRAM) {
  6840. case 'iTerm.app':
  6841. return version >= 3 ? 3 : 2;
  6842. case 'Apple_Terminal':
  6843. return 2;
  6844. // No default
  6845. }
  6846. }
  6847. if (/-256(color)?$/i.test(env$2.TERM)) {
  6848. return 2;
  6849. }
  6850. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
  6851. return 1;
  6852. }
  6853. if ('COLORTERM' in env$2) {
  6854. return 1;
  6855. }
  6856. if (env$2.TERM === 'dumb') {
  6857. return min;
  6858. }
  6859. return min;
  6860. }
  6861. function getSupportLevel$2(stream) {
  6862. const level = supportsColor$2(stream);
  6863. return translateLevel$2(level);
  6864. }
  6865. var supportsColor_1$2 = {
  6866. supportsColor: getSupportLevel$2,
  6867. stdout: getSupportLevel$2(process.stdout),
  6868. stderr: getSupportLevel$2(process.stderr)
  6869. };
  6870. const TEMPLATE_REGEX$2 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  6871. const STYLE_REGEX$2 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  6872. const STRING_REGEX$3 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  6873. const ESCAPE_REGEX$2 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  6874. const ESCAPES$2 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  6875. function unescape$2(c) {
  6876. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  6877. return String.fromCharCode(parseInt(c.slice(1), 16));
  6878. }
  6879. return ESCAPES$2.get(c) || c;
  6880. }
  6881. function parseArguments$2(name, args) {
  6882. const results = [];
  6883. const chunks = args.trim().split(/\s*,\s*/g);
  6884. let matches;
  6885. for (const chunk of chunks) {
  6886. if (!isNaN(chunk)) {
  6887. results.push(Number(chunk));
  6888. } else if (matches = chunk.match(STRING_REGEX$3)) {
  6889. results.push(matches[2].replace(ESCAPE_REGEX$2, (m, escape, chr) => escape ? unescape$2(escape) : chr));
  6890. } else {
  6891. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  6892. }
  6893. }
  6894. return results;
  6895. }
  6896. function parseStyle$2(style) {
  6897. STYLE_REGEX$2.lastIndex = 0;
  6898. const results = [];
  6899. let matches;
  6900. while ((matches = STYLE_REGEX$2.exec(style)) !== null) {
  6901. const name = matches[1];
  6902. if (matches[2]) {
  6903. const args = parseArguments$2(name, matches[2]);
  6904. results.push([name].concat(args));
  6905. } else {
  6906. results.push([name]);
  6907. }
  6908. }
  6909. return results;
  6910. }
  6911. function buildStyle$2(chalk, styles) {
  6912. const enabled = {};
  6913. for (const layer of styles) {
  6914. for (const style of layer.styles) {
  6915. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  6916. }
  6917. }
  6918. let current = chalk;
  6919. for (const styleName of Object.keys(enabled)) {
  6920. if (Array.isArray(enabled[styleName])) {
  6921. if (!(styleName in current)) {
  6922. throw new Error(`Unknown Chalk style: ${styleName}`);
  6923. }
  6924. if (enabled[styleName].length > 0) {
  6925. current = current[styleName].apply(current, enabled[styleName]);
  6926. } else {
  6927. current = current[styleName];
  6928. }
  6929. }
  6930. }
  6931. return current;
  6932. }
  6933. var templates$2 = (chalk, tmp) => {
  6934. const styles = [];
  6935. const chunks = [];
  6936. let chunk = []; // eslint-disable-next-line max-params
  6937. tmp.replace(TEMPLATE_REGEX$2, (m, escapeChar, inverse, style, close, chr) => {
  6938. if (escapeChar) {
  6939. chunk.push(unescape$2(escapeChar));
  6940. } else if (style) {
  6941. const str = chunk.join('');
  6942. chunk = [];
  6943. chunks.push(styles.length === 0 ? str : buildStyle$2(chalk, styles)(str));
  6944. styles.push({
  6945. inverse,
  6946. styles: parseStyle$2(style)
  6947. });
  6948. } else if (close) {
  6949. if (styles.length === 0) {
  6950. throw new Error('Found extraneous } in Chalk template literal');
  6951. }
  6952. chunks.push(buildStyle$2(chalk, styles)(chunk.join('')));
  6953. chunk = [];
  6954. styles.pop();
  6955. } else {
  6956. chunk.push(chr);
  6957. }
  6958. });
  6959. chunks.push(chunk.join(''));
  6960. if (styles.length > 0) {
  6961. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  6962. throw new Error(errMsg);
  6963. }
  6964. return chunks.join('');
  6965. };
  6966. (function (module) {
  6967. const escapeStringRegexp = escapeStringRegexp$1;
  6968. const ansiStyles = ansiStyles$2.exports;
  6969. const stdoutColor = supportsColor_1$2.stdout;
  6970. const template = templates$2;
  6971. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  6972. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  6973. const skipModels = new Set(['gray']);
  6974. const styles = Object.create(null);
  6975. function applyOptions(obj, options) {
  6976. options = options || {}; // Detect level if not set manually
  6977. const scLevel = stdoutColor ? stdoutColor.level : 0;
  6978. obj.level = options.level === undefined ? scLevel : options.level;
  6979. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  6980. }
  6981. function Chalk(options) {
  6982. // We check for this.template here since calling `chalk.constructor()`
  6983. // by itself will have a `this` of a previously constructed chalk object
  6984. if (!this || !(this instanceof Chalk) || this.template) {
  6985. const chalk = {};
  6986. applyOptions(chalk, options);
  6987. chalk.template = function () {
  6988. const args = [].slice.call(arguments);
  6989. return chalkTag.apply(null, [chalk.template].concat(args));
  6990. };
  6991. Object.setPrototypeOf(chalk, Chalk.prototype);
  6992. Object.setPrototypeOf(chalk.template, chalk);
  6993. chalk.template.constructor = Chalk;
  6994. return chalk.template;
  6995. }
  6996. applyOptions(this, options);
  6997. } // Use bright blue on Windows as the normal blue color is illegible
  6998. if (isSimpleWindowsTerm) {
  6999. ansiStyles.blue.open = '\u001B[94m';
  7000. }
  7001. for (const key of Object.keys(ansiStyles)) {
  7002. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  7003. styles[key] = {
  7004. get() {
  7005. const codes = ansiStyles[key];
  7006. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  7007. }
  7008. };
  7009. }
  7010. styles.visible = {
  7011. get() {
  7012. return build.call(this, this._styles || [], true, 'visible');
  7013. }
  7014. };
  7015. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  7016. for (const model of Object.keys(ansiStyles.color.ansi)) {
  7017. if (skipModels.has(model)) {
  7018. continue;
  7019. }
  7020. styles[model] = {
  7021. get() {
  7022. const level = this.level;
  7023. return function () {
  7024. const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7025. const codes = {
  7026. open,
  7027. close: ansiStyles.color.close,
  7028. closeRe: ansiStyles.color.closeRe
  7029. };
  7030. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7031. };
  7032. }
  7033. };
  7034. }
  7035. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7036. for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
  7037. if (skipModels.has(model)) {
  7038. continue;
  7039. }
  7040. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7041. styles[bgModel] = {
  7042. get() {
  7043. const level = this.level;
  7044. return function () {
  7045. const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7046. const codes = {
  7047. open,
  7048. close: ansiStyles.bgColor.close,
  7049. closeRe: ansiStyles.bgColor.closeRe
  7050. };
  7051. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7052. };
  7053. }
  7054. };
  7055. }
  7056. const proto = Object.defineProperties(() => {}, styles);
  7057. function build(_styles, _empty, key) {
  7058. const builder = function () {
  7059. return applyStyle.apply(builder, arguments);
  7060. };
  7061. builder._styles = _styles;
  7062. builder._empty = _empty;
  7063. const self = this;
  7064. Object.defineProperty(builder, 'level', {
  7065. enumerable: true,
  7066. get() {
  7067. return self.level;
  7068. },
  7069. set(level) {
  7070. self.level = level;
  7071. }
  7072. });
  7073. Object.defineProperty(builder, 'enabled', {
  7074. enumerable: true,
  7075. get() {
  7076. return self.enabled;
  7077. },
  7078. set(enabled) {
  7079. self.enabled = enabled;
  7080. }
  7081. }); // See below for fix regarding invisible grey/dim combination on Windows
  7082. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  7083. // no way to create a function with a different prototype
  7084. builder.__proto__ = proto; // eslint-disable-line no-proto
  7085. return builder;
  7086. }
  7087. function applyStyle() {
  7088. // Support varags, but simply cast to string in case there's only one arg
  7089. const args = arguments;
  7090. const argsLen = args.length;
  7091. let str = String(arguments[0]);
  7092. if (argsLen === 0) {
  7093. return '';
  7094. }
  7095. if (argsLen > 1) {
  7096. // Don't slice `arguments`, it prevents V8 optimizations
  7097. for (let a = 1; a < argsLen; a++) {
  7098. str += ' ' + args[a];
  7099. }
  7100. }
  7101. if (!this.enabled || this.level <= 0 || !str) {
  7102. return this._empty ? '' : str;
  7103. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  7104. // see https://github.com/chalk/chalk/issues/58
  7105. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  7106. const originalDim = ansiStyles.dim.open;
  7107. if (isSimpleWindowsTerm && this.hasGrey) {
  7108. ansiStyles.dim.open = '';
  7109. }
  7110. for (const code of this._styles.slice().reverse()) {
  7111. // Replace any instances already present with a re-opening code
  7112. // otherwise only the part of the string until said closing code
  7113. // will be colored, and the rest will simply be 'plain'.
  7114. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  7115. // after next line to fix a bleed issue on macOS
  7116. // https://github.com/chalk/chalk/pull/92
  7117. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  7118. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  7119. ansiStyles.dim.open = originalDim;
  7120. return str;
  7121. }
  7122. function chalkTag(chalk, strings) {
  7123. if (!Array.isArray(strings)) {
  7124. // If chalk() was called by itself or with a string,
  7125. // return the string itself as a string.
  7126. return [].slice.call(arguments, 1).join(' ');
  7127. }
  7128. const args = [].slice.call(arguments, 2);
  7129. const parts = [strings.raw[0]];
  7130. for (let i = 1; i < strings.length; i++) {
  7131. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7132. parts.push(String(strings.raw[i]));
  7133. }
  7134. return template(chalk, parts.join(''));
  7135. }
  7136. Object.defineProperties(Chalk.prototype, styles);
  7137. module.exports = Chalk(); // eslint-disable-line new-cap
  7138. module.exports.supportsColor = stdoutColor;
  7139. module.exports.default = module.exports; // For TypeScript
  7140. })(chalk$3);
  7141. Object.defineProperty(common$8, "__esModule", {
  7142. value: true
  7143. });
  7144. const chalk_1$2 = chalk$3.exports;
  7145. common$8.commonDeprecatedHandler = (keyOrPair, redirectTo, {
  7146. descriptor
  7147. }) => {
  7148. const messages = [`${chalk_1$2.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
  7149. if (redirectTo) {
  7150. messages.push(`we now treat it as ${chalk_1$2.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
  7151. }
  7152. return messages.join('; ') + '.';
  7153. };
  7154. (function (exports) {
  7155. Object.defineProperty(exports, "__esModule", {
  7156. value: true
  7157. });
  7158. const tslib_1 = tslib_es6;
  7159. tslib_1.__exportStar(common$8, exports);
  7160. })(deprecated);
  7161. var invalid = {};
  7162. var common$7 = {};
  7163. Object.defineProperty(common$7, "__esModule", {
  7164. value: true
  7165. });
  7166. const chalk_1$1 = chalk$3.exports;
  7167. common$7.commonInvalidHandler = (key, value, utils) => [`Invalid ${chalk_1$1.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk_1$1.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk_1$1.default.red(utils.descriptor.value(value))}.`].join(' ');
  7168. (function (exports) {
  7169. Object.defineProperty(exports, "__esModule", {
  7170. value: true
  7171. });
  7172. const tslib_1 = tslib_es6;
  7173. tslib_1.__exportStar(common$7, exports);
  7174. })(invalid);
  7175. var unknown = {};
  7176. var leven$5 = {};
  7177. /* eslint-disable no-nested-ternary */
  7178. var arr = [];
  7179. var charCodeCache$1 = [];
  7180. var leven$4 = function (a, b) {
  7181. if (a === b) {
  7182. return 0;
  7183. }
  7184. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  7185. // shortest & which one is the longest
  7186. if (a.length > b.length) {
  7187. a = b;
  7188. b = swap;
  7189. }
  7190. var aLen = a.length;
  7191. var bLen = b.length;
  7192. if (aLen === 0) {
  7193. return bLen;
  7194. }
  7195. if (bLen === 0) {
  7196. return aLen;
  7197. } // Performing suffix trimming:
  7198. // We can linearly drop suffix common to both strings since they
  7199. // don't increase distance at all
  7200. // Note: `~-` is the bitwise way to perform a `- 1` operation
  7201. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  7202. aLen--;
  7203. bLen--;
  7204. }
  7205. if (aLen === 0) {
  7206. return bLen;
  7207. } // Performing prefix trimming
  7208. // We can linearly drop prefix common to both strings since they
  7209. // don't increase distance at all
  7210. var start = 0;
  7211. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  7212. start++;
  7213. }
  7214. aLen -= start;
  7215. bLen -= start;
  7216. if (aLen === 0) {
  7217. return bLen;
  7218. }
  7219. var bCharCode;
  7220. var ret;
  7221. var tmp;
  7222. var tmp2;
  7223. var i = 0;
  7224. var j = 0;
  7225. while (i < aLen) {
  7226. charCodeCache$1[start + i] = a.charCodeAt(start + i);
  7227. arr[i] = ++i;
  7228. }
  7229. while (j < bLen) {
  7230. bCharCode = b.charCodeAt(start + j);
  7231. tmp = j++;
  7232. ret = j;
  7233. for (i = 0; i < aLen; i++) {
  7234. tmp2 = bCharCode === charCodeCache$1[start + i] ? tmp : tmp + 1;
  7235. tmp = arr[i];
  7236. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  7237. }
  7238. }
  7239. return ret;
  7240. };
  7241. Object.defineProperty(leven$5, "__esModule", {
  7242. value: true
  7243. });
  7244. const chalk_1 = chalk$3.exports;
  7245. const leven$3 = leven$4;
  7246. leven$5.levenUnknownHandler = (key, value, {
  7247. descriptor,
  7248. logger,
  7249. schemas
  7250. }) => {
  7251. const messages = [`Ignored unknown option ${chalk_1.default.yellow(descriptor.pair({
  7252. key,
  7253. value
  7254. }))}.`];
  7255. const suggestion = Object.keys(schemas).sort().find(knownKey => leven$3(key, knownKey) < 3);
  7256. if (suggestion) {
  7257. messages.push(`Did you mean ${chalk_1.default.blue(descriptor.key(suggestion))}?`);
  7258. }
  7259. logger.warn(messages.join(' '));
  7260. };
  7261. (function (exports) {
  7262. Object.defineProperty(exports, "__esModule", {
  7263. value: true
  7264. });
  7265. const tslib_1 = tslib_es6;
  7266. tslib_1.__exportStar(leven$5, exports);
  7267. })(unknown);
  7268. (function (exports) {
  7269. Object.defineProperty(exports, "__esModule", {
  7270. value: true
  7271. });
  7272. const tslib_1 = tslib_es6;
  7273. tslib_1.__exportStar(deprecated, exports);
  7274. tslib_1.__exportStar(invalid, exports);
  7275. tslib_1.__exportStar(unknown, exports);
  7276. })(handlers);
  7277. var schemas = {};
  7278. var alias = {};
  7279. var schema = {};
  7280. Object.defineProperty(schema, "__esModule", {
  7281. value: true
  7282. });
  7283. const HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  7284. function createSchema(SchemaConstructor, parameters) {
  7285. const schema = new SchemaConstructor(parameters);
  7286. const subSchema = Object.create(schema);
  7287. for (const handlerKey of HANDLER_KEYS) {
  7288. if (handlerKey in parameters) {
  7289. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  7290. }
  7291. }
  7292. return subSchema;
  7293. }
  7294. schema.createSchema = createSchema;
  7295. class Schema {
  7296. constructor(parameters) {
  7297. this.name = parameters.name;
  7298. }
  7299. static create(parameters) {
  7300. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  7301. return createSchema(this, parameters);
  7302. }
  7303. default(_utils) {
  7304. return undefined;
  7305. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7306. expected(_utils) {
  7307. return 'nothing';
  7308. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7309. validate(_value, _utils) {
  7310. return false;
  7311. }
  7312. deprecated(_value, _utils) {
  7313. return false;
  7314. }
  7315. forward(_value, _utils) {
  7316. return undefined;
  7317. }
  7318. redirect(_value, _utils) {
  7319. return undefined;
  7320. }
  7321. overlap(currentValue, _newValue, _utils) {
  7322. return currentValue;
  7323. }
  7324. preprocess(value, _utils) {
  7325. return value;
  7326. }
  7327. postprocess(value, _utils) {
  7328. return value;
  7329. }
  7330. }
  7331. schema.Schema = Schema;
  7332. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  7333. return typeof handler === 'function' ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler;
  7334. }
  7335. Object.defineProperty(alias, "__esModule", {
  7336. value: true
  7337. });
  7338. const schema_1$6 = schema;
  7339. class AliasSchema extends schema_1$6.Schema {
  7340. constructor(parameters) {
  7341. super(parameters);
  7342. this._sourceName = parameters.sourceName;
  7343. }
  7344. expected(utils) {
  7345. return utils.schemas[this._sourceName].expected(utils);
  7346. }
  7347. validate(value, utils) {
  7348. return utils.schemas[this._sourceName].validate(value, utils);
  7349. }
  7350. redirect(_value, _utils) {
  7351. return this._sourceName;
  7352. }
  7353. }
  7354. alias.AliasSchema = AliasSchema;
  7355. var any = {};
  7356. Object.defineProperty(any, "__esModule", {
  7357. value: true
  7358. });
  7359. const schema_1$5 = schema;
  7360. class AnySchema extends schema_1$5.Schema {
  7361. expected() {
  7362. return 'anything';
  7363. }
  7364. validate() {
  7365. return true;
  7366. }
  7367. }
  7368. any.AnySchema = AnySchema;
  7369. var array$4 = {};
  7370. Object.defineProperty(array$4, "__esModule", {
  7371. value: true
  7372. });
  7373. const tslib_1 = tslib_es6;
  7374. const schema_1$4 = schema;
  7375. class ArraySchema extends schema_1$4.Schema {
  7376. constructor(_a) {
  7377. var {
  7378. valueSchema,
  7379. name = valueSchema.name
  7380. } = _a,
  7381. handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
  7382. super(Object.assign({}, handlers, {
  7383. name
  7384. }));
  7385. this._valueSchema = valueSchema;
  7386. }
  7387. expected(utils) {
  7388. return `an array of ${this._valueSchema.expected(utils)}`;
  7389. }
  7390. validate(value, utils) {
  7391. if (!Array.isArray(value)) {
  7392. return false;
  7393. }
  7394. const invalidValues = [];
  7395. for (const subValue of value) {
  7396. const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  7397. if (subValidateResult !== true) {
  7398. invalidValues.push(subValidateResult.value);
  7399. }
  7400. }
  7401. return invalidValues.length === 0 ? true : {
  7402. value: invalidValues
  7403. };
  7404. }
  7405. deprecated(value, utils) {
  7406. const deprecatedResult = [];
  7407. for (const subValue of value) {
  7408. const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  7409. if (subDeprecatedResult !== false) {
  7410. deprecatedResult.push(...subDeprecatedResult.map(({
  7411. value: deprecatedValue
  7412. }) => ({
  7413. value: [deprecatedValue]
  7414. })));
  7415. }
  7416. }
  7417. return deprecatedResult;
  7418. }
  7419. forward(value, utils) {
  7420. const forwardResult = [];
  7421. for (const subValue of value) {
  7422. const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  7423. forwardResult.push(...subForwardResult.map(wrapTransferResult));
  7424. }
  7425. return forwardResult;
  7426. }
  7427. redirect(value, utils) {
  7428. const remain = [];
  7429. const redirect = [];
  7430. for (const subValue of value) {
  7431. const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  7432. if ('remain' in subRedirectResult) {
  7433. remain.push(subRedirectResult.remain);
  7434. }
  7435. redirect.push(...subRedirectResult.redirect.map(wrapTransferResult));
  7436. }
  7437. return remain.length === 0 ? {
  7438. redirect
  7439. } : {
  7440. redirect,
  7441. remain
  7442. };
  7443. }
  7444. overlap(currentValue, newValue) {
  7445. return currentValue.concat(newValue);
  7446. }
  7447. }
  7448. array$4.ArraySchema = ArraySchema;
  7449. function wrapTransferResult({
  7450. from,
  7451. to
  7452. }) {
  7453. return {
  7454. from: [from],
  7455. to
  7456. };
  7457. }
  7458. var boolean = {};
  7459. Object.defineProperty(boolean, "__esModule", {
  7460. value: true
  7461. });
  7462. const schema_1$3 = schema;
  7463. class BooleanSchema extends schema_1$3.Schema {
  7464. expected() {
  7465. return 'true or false';
  7466. }
  7467. validate(value) {
  7468. return typeof value === 'boolean';
  7469. }
  7470. }
  7471. boolean.BooleanSchema = BooleanSchema;
  7472. var choice = {};
  7473. var utils$s = {};
  7474. Object.defineProperty(utils$s, "__esModule", {
  7475. value: true
  7476. });
  7477. function recordFromArray(array, mainKey) {
  7478. const record = Object.create(null);
  7479. for (const value of array) {
  7480. const key = value[mainKey]; // istanbul ignore next
  7481. if (record[key]) {
  7482. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  7483. } // @ts-ignore
  7484. record[key] = value;
  7485. }
  7486. return record;
  7487. }
  7488. utils$s.recordFromArray = recordFromArray;
  7489. function mapFromArray(array, mainKey) {
  7490. const map = new Map();
  7491. for (const value of array) {
  7492. const key = value[mainKey]; // istanbul ignore next
  7493. if (map.has(key)) {
  7494. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  7495. }
  7496. map.set(key, value);
  7497. }
  7498. return map;
  7499. }
  7500. utils$s.mapFromArray = mapFromArray;
  7501. function createAutoChecklist() {
  7502. const map = Object.create(null);
  7503. return id => {
  7504. const idString = JSON.stringify(id);
  7505. if (map[idString]) {
  7506. return true;
  7507. }
  7508. map[idString] = true;
  7509. return false;
  7510. };
  7511. }
  7512. utils$s.createAutoChecklist = createAutoChecklist;
  7513. function partition$2(array, predicate) {
  7514. const trueArray = [];
  7515. const falseArray = [];
  7516. for (const value of array) {
  7517. if (predicate(value)) {
  7518. trueArray.push(value);
  7519. } else {
  7520. falseArray.push(value);
  7521. }
  7522. }
  7523. return [trueArray, falseArray];
  7524. }
  7525. utils$s.partition = partition$2;
  7526. function isInt(value) {
  7527. return value === Math.floor(value);
  7528. }
  7529. utils$s.isInt = isInt;
  7530. function comparePrimitive(a, b) {
  7531. if (a === b) {
  7532. return 0;
  7533. }
  7534. const typeofA = typeof a;
  7535. const typeofB = typeof b;
  7536. const orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  7537. if (typeofA !== typeofB) {
  7538. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  7539. }
  7540. if (typeofA !== 'string') {
  7541. return Number(a) - Number(b);
  7542. }
  7543. return a.localeCompare(b);
  7544. }
  7545. utils$s.comparePrimitive = comparePrimitive;
  7546. function normalizeDefaultResult(result) {
  7547. return result === undefined ? {} : result;
  7548. }
  7549. utils$s.normalizeDefaultResult = normalizeDefaultResult;
  7550. function normalizeValidateResult(result, value) {
  7551. return result === true ? true : result === false ? {
  7552. value
  7553. } : result;
  7554. }
  7555. utils$s.normalizeValidateResult = normalizeValidateResult;
  7556. function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) {
  7557. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  7558. value
  7559. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  7560. }
  7561. utils$s.normalizeDeprecatedResult = normalizeDeprecatedResult;
  7562. function normalizeTransferResult(result, value) {
  7563. return typeof result === 'string' || 'key' in result ? {
  7564. from: value,
  7565. to: result
  7566. } : 'from' in result ? {
  7567. from: result.from,
  7568. to: result.to
  7569. } : {
  7570. from: value,
  7571. to: result.to
  7572. };
  7573. }
  7574. utils$s.normalizeTransferResult = normalizeTransferResult;
  7575. function normalizeForwardResult(result, value) {
  7576. return result === undefined ? [] : Array.isArray(result) ? result.map(transferResult => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)];
  7577. }
  7578. utils$s.normalizeForwardResult = normalizeForwardResult;
  7579. function normalizeRedirectResult(result, value) {
  7580. const redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
  7581. return redirect.length === 0 ? {
  7582. remain: value,
  7583. redirect
  7584. } : typeof result === 'object' && 'remain' in result ? {
  7585. remain: result.remain,
  7586. redirect
  7587. } : {
  7588. redirect
  7589. };
  7590. }
  7591. utils$s.normalizeRedirectResult = normalizeRedirectResult;
  7592. Object.defineProperty(choice, "__esModule", {
  7593. value: true
  7594. });
  7595. const schema_1$2 = schema;
  7596. const utils_1$2 = utils$s;
  7597. class ChoiceSchema extends schema_1$2.Schema {
  7598. constructor(parameters) {
  7599. super(parameters);
  7600. this._choices = utils_1$2.mapFromArray(parameters.choices.map(choice => choice && typeof choice === 'object' ? choice : {
  7601. value: choice
  7602. }), 'value');
  7603. }
  7604. expected({
  7605. descriptor
  7606. }) {
  7607. const choiceValues = Array.from(this._choices.keys()).map(value => this._choices.get(value)).filter(choiceInfo => !choiceInfo.deprecated).map(choiceInfo => choiceInfo.value).sort(utils_1$2.comparePrimitive).map(descriptor.value);
  7608. const head = choiceValues.slice(0, -2);
  7609. const tail = choiceValues.slice(-2);
  7610. return head.concat(tail.join(' or ')).join(', ');
  7611. }
  7612. validate(value) {
  7613. return this._choices.has(value);
  7614. }
  7615. deprecated(value) {
  7616. const choiceInfo = this._choices.get(value);
  7617. return choiceInfo && choiceInfo.deprecated ? {
  7618. value
  7619. } : false;
  7620. }
  7621. forward(value) {
  7622. const choiceInfo = this._choices.get(value);
  7623. return choiceInfo ? choiceInfo.forward : undefined;
  7624. }
  7625. redirect(value) {
  7626. const choiceInfo = this._choices.get(value);
  7627. return choiceInfo ? choiceInfo.redirect : undefined;
  7628. }
  7629. }
  7630. choice.ChoiceSchema = ChoiceSchema;
  7631. var integer = {};
  7632. var number = {};
  7633. Object.defineProperty(number, "__esModule", {
  7634. value: true
  7635. });
  7636. const schema_1$1 = schema;
  7637. class NumberSchema extends schema_1$1.Schema {
  7638. expected() {
  7639. return 'a number';
  7640. }
  7641. validate(value, _utils) {
  7642. return typeof value === 'number';
  7643. }
  7644. }
  7645. number.NumberSchema = NumberSchema;
  7646. Object.defineProperty(integer, "__esModule", {
  7647. value: true
  7648. });
  7649. const utils_1$1 = utils$s;
  7650. const number_1 = number;
  7651. class IntegerSchema extends number_1.NumberSchema {
  7652. expected() {
  7653. return 'an integer';
  7654. }
  7655. validate(value, utils) {
  7656. return utils.normalizeValidateResult(super.validate(value, utils), value) === true && utils_1$1.isInt(value);
  7657. }
  7658. }
  7659. integer.IntegerSchema = IntegerSchema;
  7660. var string$2 = {};
  7661. Object.defineProperty(string$2, "__esModule", {
  7662. value: true
  7663. });
  7664. const schema_1 = schema;
  7665. class StringSchema extends schema_1.Schema {
  7666. expected() {
  7667. return 'a string';
  7668. }
  7669. validate(value) {
  7670. return typeof value === 'string';
  7671. }
  7672. }
  7673. string$2.StringSchema = StringSchema;
  7674. (function (exports) {
  7675. Object.defineProperty(exports, "__esModule", {
  7676. value: true
  7677. });
  7678. const tslib_1 = tslib_es6;
  7679. tslib_1.__exportStar(alias, exports);
  7680. tslib_1.__exportStar(any, exports);
  7681. tslib_1.__exportStar(array$4, exports);
  7682. tslib_1.__exportStar(boolean, exports);
  7683. tslib_1.__exportStar(choice, exports);
  7684. tslib_1.__exportStar(integer, exports);
  7685. tslib_1.__exportStar(number, exports);
  7686. tslib_1.__exportStar(string$2, exports);
  7687. })(schemas);
  7688. var normalize$2 = {};
  7689. var defaults = {};
  7690. Object.defineProperty(defaults, "__esModule", {
  7691. value: true
  7692. });
  7693. const api_1 = api;
  7694. const common_1 = common$8;
  7695. const invalid_1 = invalid;
  7696. const leven_1 = leven$5;
  7697. defaults.defaultDescriptor = api_1.apiDescriptor;
  7698. defaults.defaultUnknownHandler = leven_1.levenUnknownHandler;
  7699. defaults.defaultInvalidHandler = invalid_1.commonInvalidHandler;
  7700. defaults.defaultDeprecatedHandler = common_1.commonDeprecatedHandler;
  7701. Object.defineProperty(normalize$2, "__esModule", {
  7702. value: true
  7703. });
  7704. const defaults_1 = defaults;
  7705. const utils_1 = utils$s;
  7706. normalize$2.normalize = (options, schemas, opts) => new Normalizer(schemas, opts).normalize(options);
  7707. class Normalizer {
  7708. constructor(schemas, opts) {
  7709. // istanbul ignore next
  7710. const {
  7711. logger = console,
  7712. descriptor = defaults_1.defaultDescriptor,
  7713. unknown = defaults_1.defaultUnknownHandler,
  7714. invalid = defaults_1.defaultInvalidHandler,
  7715. deprecated = defaults_1.defaultDeprecatedHandler
  7716. } = opts || {};
  7717. this._utils = {
  7718. descriptor,
  7719. logger:
  7720. /* istanbul ignore next */
  7721. logger || {
  7722. warn: () => {}
  7723. },
  7724. schemas: utils_1.recordFromArray(schemas, 'name'),
  7725. normalizeDefaultResult: utils_1.normalizeDefaultResult,
  7726. normalizeDeprecatedResult: utils_1.normalizeDeprecatedResult,
  7727. normalizeForwardResult: utils_1.normalizeForwardResult,
  7728. normalizeRedirectResult: utils_1.normalizeRedirectResult,
  7729. normalizeValidateResult: utils_1.normalizeValidateResult
  7730. };
  7731. this._unknownHandler = unknown;
  7732. this._invalidHandler = invalid;
  7733. this._deprecatedHandler = deprecated;
  7734. this.cleanHistory();
  7735. }
  7736. cleanHistory() {
  7737. this._hasDeprecationWarned = utils_1.createAutoChecklist();
  7738. }
  7739. normalize(options) {
  7740. const normalized = {};
  7741. const restOptionsArray = [options];
  7742. const applyNormalization = () => {
  7743. while (restOptionsArray.length !== 0) {
  7744. const currentOptions = restOptionsArray.shift();
  7745. const transferredOptionsArray = this._applyNormalization(currentOptions, normalized);
  7746. restOptionsArray.push(...transferredOptionsArray);
  7747. }
  7748. };
  7749. applyNormalization();
  7750. for (const key of Object.keys(this._utils.schemas)) {
  7751. const schema = this._utils.schemas[key];
  7752. if (!(key in normalized)) {
  7753. const defaultResult = utils_1.normalizeDefaultResult(schema.default(this._utils));
  7754. if ('value' in defaultResult) {
  7755. restOptionsArray.push({
  7756. [key]: defaultResult.value
  7757. });
  7758. }
  7759. }
  7760. }
  7761. applyNormalization();
  7762. for (const key of Object.keys(this._utils.schemas)) {
  7763. const schema = this._utils.schemas[key];
  7764. if (key in normalized) {
  7765. normalized[key] = schema.postprocess(normalized[key], this._utils);
  7766. }
  7767. }
  7768. return normalized;
  7769. }
  7770. _applyNormalization(options, normalized) {
  7771. const transferredOptionsArray = [];
  7772. const [knownOptionNames, unknownOptionNames] = utils_1.partition(Object.keys(options), key => key in this._utils.schemas);
  7773. for (const key of knownOptionNames) {
  7774. const schema = this._utils.schemas[key];
  7775. const value = schema.preprocess(options[key], this._utils);
  7776. const validateResult = utils_1.normalizeValidateResult(schema.validate(value, this._utils), value);
  7777. if (validateResult !== true) {
  7778. const {
  7779. value: invalidValue
  7780. } = validateResult;
  7781. const errorMessageOrError = this._invalidHandler(key, invalidValue, this._utils);
  7782. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  7783. /* istanbul ignore next*/
  7784. errorMessageOrError;
  7785. }
  7786. const appendTransferredOptions = ({
  7787. from,
  7788. to
  7789. }) => {
  7790. transferredOptionsArray.push(typeof to === 'string' ? {
  7791. [to]: from
  7792. } : {
  7793. [to.key]: to.value
  7794. });
  7795. };
  7796. const warnDeprecated = ({
  7797. value: currentValue,
  7798. redirectTo
  7799. }) => {
  7800. const deprecatedResult = utils_1.normalizeDeprecatedResult(schema.deprecated(currentValue, this._utils), value,
  7801. /* doNotNormalizeTrue */
  7802. true);
  7803. if (deprecatedResult === false) {
  7804. return;
  7805. }
  7806. if (deprecatedResult === true) {
  7807. if (!this._hasDeprecationWarned(key)) {
  7808. this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils));
  7809. }
  7810. } else {
  7811. for (const {
  7812. value: deprecatedValue
  7813. } of deprecatedResult) {
  7814. const pair = {
  7815. key,
  7816. value: deprecatedValue
  7817. };
  7818. if (!this._hasDeprecationWarned(pair)) {
  7819. const redirectToPair = typeof redirectTo === 'string' ? {
  7820. key: redirectTo,
  7821. value: deprecatedValue
  7822. } : redirectTo;
  7823. this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils));
  7824. }
  7825. }
  7826. }
  7827. };
  7828. const forwardResult = utils_1.normalizeForwardResult(schema.forward(value, this._utils), value);
  7829. forwardResult.forEach(appendTransferredOptions);
  7830. const redirectResult = utils_1.normalizeRedirectResult(schema.redirect(value, this._utils), value);
  7831. redirectResult.redirect.forEach(appendTransferredOptions);
  7832. if ('remain' in redirectResult) {
  7833. const remainingValue = redirectResult.remain;
  7834. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, this._utils) : remainingValue;
  7835. warnDeprecated({
  7836. value: remainingValue
  7837. });
  7838. }
  7839. for (const {
  7840. from,
  7841. to
  7842. } of redirectResult.redirect) {
  7843. warnDeprecated({
  7844. value: from,
  7845. redirectTo: to
  7846. });
  7847. }
  7848. }
  7849. for (const key of unknownOptionNames) {
  7850. const value = options[key];
  7851. const unknownResult = this._unknownHandler(key, value, this._utils);
  7852. if (unknownResult) {
  7853. for (const unknownKey of Object.keys(unknownResult)) {
  7854. const unknownOption = {
  7855. [unknownKey]: unknownResult[unknownKey]
  7856. };
  7857. if (unknownKey in this._utils.schemas) {
  7858. transferredOptionsArray.push(unknownOption);
  7859. } else {
  7860. Object.assign(normalized, unknownOption);
  7861. }
  7862. }
  7863. }
  7864. }
  7865. return transferredOptionsArray;
  7866. }
  7867. }
  7868. normalize$2.Normalizer = Normalizer;
  7869. (function (exports) {
  7870. Object.defineProperty(exports, "__esModule", {
  7871. value: true
  7872. });
  7873. const tslib_1 = tslib_es6;
  7874. tslib_1.__exportStar(descriptors, exports);
  7875. tslib_1.__exportStar(handlers, exports);
  7876. tslib_1.__exportStar(schemas, exports);
  7877. tslib_1.__exportStar(normalize$2, exports);
  7878. tslib_1.__exportStar(schema, exports);
  7879. })(lib$4);
  7880. var leven$2 = {exports: {}};
  7881. const array$3 = [];
  7882. const charCodeCache = [];
  7883. const leven$1 = (left, right) => {
  7884. if (left === right) {
  7885. return 0;
  7886. }
  7887. const swap = left; // Swapping the strings if `a` is longer than `b` so we know which one is the
  7888. // shortest & which one is the longest
  7889. if (left.length > right.length) {
  7890. left = right;
  7891. right = swap;
  7892. }
  7893. let leftLength = left.length;
  7894. let rightLength = right.length; // Performing suffix trimming:
  7895. // We can linearly drop suffix common to both strings since they
  7896. // don't increase distance at all
  7897. // Note: `~-` is the bitwise way to perform a `- 1` operation
  7898. while (leftLength > 0 && left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength)) {
  7899. leftLength--;
  7900. rightLength--;
  7901. } // Performing prefix trimming
  7902. // We can linearly drop prefix common to both strings since they
  7903. // don't increase distance at all
  7904. let start = 0;
  7905. while (start < leftLength && left.charCodeAt(start) === right.charCodeAt(start)) {
  7906. start++;
  7907. }
  7908. leftLength -= start;
  7909. rightLength -= start;
  7910. if (leftLength === 0) {
  7911. return rightLength;
  7912. }
  7913. let bCharCode;
  7914. let result;
  7915. let temp;
  7916. let temp2;
  7917. let i = 0;
  7918. let j = 0;
  7919. while (i < leftLength) {
  7920. charCodeCache[i] = left.charCodeAt(start + i);
  7921. array$3[i] = ++i;
  7922. }
  7923. while (j < rightLength) {
  7924. bCharCode = right.charCodeAt(start + j);
  7925. temp = j++;
  7926. result = j;
  7927. for (i = 0; i < leftLength; i++) {
  7928. temp2 = bCharCode === charCodeCache[i] ? temp : temp + 1;
  7929. temp = array$3[i]; // eslint-disable-next-line no-multi-assign
  7930. result = array$3[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2;
  7931. }
  7932. }
  7933. return result;
  7934. };
  7935. leven$2.exports = leven$1; // TODO: Remove this for the next major release
  7936. leven$2.exports.default = leven$1;
  7937. var ansiStyles$1 = {exports: {}};
  7938. var colorName = {
  7939. "aliceblue": [240, 248, 255],
  7940. "antiquewhite": [250, 235, 215],
  7941. "aqua": [0, 255, 255],
  7942. "aquamarine": [127, 255, 212],
  7943. "azure": [240, 255, 255],
  7944. "beige": [245, 245, 220],
  7945. "bisque": [255, 228, 196],
  7946. "black": [0, 0, 0],
  7947. "blanchedalmond": [255, 235, 205],
  7948. "blue": [0, 0, 255],
  7949. "blueviolet": [138, 43, 226],
  7950. "brown": [165, 42, 42],
  7951. "burlywood": [222, 184, 135],
  7952. "cadetblue": [95, 158, 160],
  7953. "chartreuse": [127, 255, 0],
  7954. "chocolate": [210, 105, 30],
  7955. "coral": [255, 127, 80],
  7956. "cornflowerblue": [100, 149, 237],
  7957. "cornsilk": [255, 248, 220],
  7958. "crimson": [220, 20, 60],
  7959. "cyan": [0, 255, 255],
  7960. "darkblue": [0, 0, 139],
  7961. "darkcyan": [0, 139, 139],
  7962. "darkgoldenrod": [184, 134, 11],
  7963. "darkgray": [169, 169, 169],
  7964. "darkgreen": [0, 100, 0],
  7965. "darkgrey": [169, 169, 169],
  7966. "darkkhaki": [189, 183, 107],
  7967. "darkmagenta": [139, 0, 139],
  7968. "darkolivegreen": [85, 107, 47],
  7969. "darkorange": [255, 140, 0],
  7970. "darkorchid": [153, 50, 204],
  7971. "darkred": [139, 0, 0],
  7972. "darksalmon": [233, 150, 122],
  7973. "darkseagreen": [143, 188, 143],
  7974. "darkslateblue": [72, 61, 139],
  7975. "darkslategray": [47, 79, 79],
  7976. "darkslategrey": [47, 79, 79],
  7977. "darkturquoise": [0, 206, 209],
  7978. "darkviolet": [148, 0, 211],
  7979. "deeppink": [255, 20, 147],
  7980. "deepskyblue": [0, 191, 255],
  7981. "dimgray": [105, 105, 105],
  7982. "dimgrey": [105, 105, 105],
  7983. "dodgerblue": [30, 144, 255],
  7984. "firebrick": [178, 34, 34],
  7985. "floralwhite": [255, 250, 240],
  7986. "forestgreen": [34, 139, 34],
  7987. "fuchsia": [255, 0, 255],
  7988. "gainsboro": [220, 220, 220],
  7989. "ghostwhite": [248, 248, 255],
  7990. "gold": [255, 215, 0],
  7991. "goldenrod": [218, 165, 32],
  7992. "gray": [128, 128, 128],
  7993. "green": [0, 128, 0],
  7994. "greenyellow": [173, 255, 47],
  7995. "grey": [128, 128, 128],
  7996. "honeydew": [240, 255, 240],
  7997. "hotpink": [255, 105, 180],
  7998. "indianred": [205, 92, 92],
  7999. "indigo": [75, 0, 130],
  8000. "ivory": [255, 255, 240],
  8001. "khaki": [240, 230, 140],
  8002. "lavender": [230, 230, 250],
  8003. "lavenderblush": [255, 240, 245],
  8004. "lawngreen": [124, 252, 0],
  8005. "lemonchiffon": [255, 250, 205],
  8006. "lightblue": [173, 216, 230],
  8007. "lightcoral": [240, 128, 128],
  8008. "lightcyan": [224, 255, 255],
  8009. "lightgoldenrodyellow": [250, 250, 210],
  8010. "lightgray": [211, 211, 211],
  8011. "lightgreen": [144, 238, 144],
  8012. "lightgrey": [211, 211, 211],
  8013. "lightpink": [255, 182, 193],
  8014. "lightsalmon": [255, 160, 122],
  8015. "lightseagreen": [32, 178, 170],
  8016. "lightskyblue": [135, 206, 250],
  8017. "lightslategray": [119, 136, 153],
  8018. "lightslategrey": [119, 136, 153],
  8019. "lightsteelblue": [176, 196, 222],
  8020. "lightyellow": [255, 255, 224],
  8021. "lime": [0, 255, 0],
  8022. "limegreen": [50, 205, 50],
  8023. "linen": [250, 240, 230],
  8024. "magenta": [255, 0, 255],
  8025. "maroon": [128, 0, 0],
  8026. "mediumaquamarine": [102, 205, 170],
  8027. "mediumblue": [0, 0, 205],
  8028. "mediumorchid": [186, 85, 211],
  8029. "mediumpurple": [147, 112, 219],
  8030. "mediumseagreen": [60, 179, 113],
  8031. "mediumslateblue": [123, 104, 238],
  8032. "mediumspringgreen": [0, 250, 154],
  8033. "mediumturquoise": [72, 209, 204],
  8034. "mediumvioletred": [199, 21, 133],
  8035. "midnightblue": [25, 25, 112],
  8036. "mintcream": [245, 255, 250],
  8037. "mistyrose": [255, 228, 225],
  8038. "moccasin": [255, 228, 181],
  8039. "navajowhite": [255, 222, 173],
  8040. "navy": [0, 0, 128],
  8041. "oldlace": [253, 245, 230],
  8042. "olive": [128, 128, 0],
  8043. "olivedrab": [107, 142, 35],
  8044. "orange": [255, 165, 0],
  8045. "orangered": [255, 69, 0],
  8046. "orchid": [218, 112, 214],
  8047. "palegoldenrod": [238, 232, 170],
  8048. "palegreen": [152, 251, 152],
  8049. "paleturquoise": [175, 238, 238],
  8050. "palevioletred": [219, 112, 147],
  8051. "papayawhip": [255, 239, 213],
  8052. "peachpuff": [255, 218, 185],
  8053. "peru": [205, 133, 63],
  8054. "pink": [255, 192, 203],
  8055. "plum": [221, 160, 221],
  8056. "powderblue": [176, 224, 230],
  8057. "purple": [128, 0, 128],
  8058. "rebeccapurple": [102, 51, 153],
  8059. "red": [255, 0, 0],
  8060. "rosybrown": [188, 143, 143],
  8061. "royalblue": [65, 105, 225],
  8062. "saddlebrown": [139, 69, 19],
  8063. "salmon": [250, 128, 114],
  8064. "sandybrown": [244, 164, 96],
  8065. "seagreen": [46, 139, 87],
  8066. "seashell": [255, 245, 238],
  8067. "sienna": [160, 82, 45],
  8068. "silver": [192, 192, 192],
  8069. "skyblue": [135, 206, 235],
  8070. "slateblue": [106, 90, 205],
  8071. "slategray": [112, 128, 144],
  8072. "slategrey": [112, 128, 144],
  8073. "snow": [255, 250, 250],
  8074. "springgreen": [0, 255, 127],
  8075. "steelblue": [70, 130, 180],
  8076. "tan": [210, 180, 140],
  8077. "teal": [0, 128, 128],
  8078. "thistle": [216, 191, 216],
  8079. "tomato": [255, 99, 71],
  8080. "turquoise": [64, 224, 208],
  8081. "violet": [238, 130, 238],
  8082. "wheat": [245, 222, 179],
  8083. "white": [255, 255, 255],
  8084. "whitesmoke": [245, 245, 245],
  8085. "yellow": [255, 255, 0],
  8086. "yellowgreen": [154, 205, 50]
  8087. };
  8088. /* MIT license */
  8089. /* eslint-disable no-mixed-operators */
  8090. const cssKeywords = colorName; // NOTE: conversions should only return primitive values (i.e. arrays, or
  8091. // values that give correct `typeof` results).
  8092. // do not use box values types (i.e. Number(), String(), etc.)
  8093. const reverseKeywords = {};
  8094. for (const key of Object.keys(cssKeywords)) {
  8095. reverseKeywords[cssKeywords[key]] = key;
  8096. }
  8097. const convert$1 = {
  8098. rgb: {
  8099. channels: 3,
  8100. labels: 'rgb'
  8101. },
  8102. hsl: {
  8103. channels: 3,
  8104. labels: 'hsl'
  8105. },
  8106. hsv: {
  8107. channels: 3,
  8108. labels: 'hsv'
  8109. },
  8110. hwb: {
  8111. channels: 3,
  8112. labels: 'hwb'
  8113. },
  8114. cmyk: {
  8115. channels: 4,
  8116. labels: 'cmyk'
  8117. },
  8118. xyz: {
  8119. channels: 3,
  8120. labels: 'xyz'
  8121. },
  8122. lab: {
  8123. channels: 3,
  8124. labels: 'lab'
  8125. },
  8126. lch: {
  8127. channels: 3,
  8128. labels: 'lch'
  8129. },
  8130. hex: {
  8131. channels: 1,
  8132. labels: ['hex']
  8133. },
  8134. keyword: {
  8135. channels: 1,
  8136. labels: ['keyword']
  8137. },
  8138. ansi16: {
  8139. channels: 1,
  8140. labels: ['ansi16']
  8141. },
  8142. ansi256: {
  8143. channels: 1,
  8144. labels: ['ansi256']
  8145. },
  8146. hcg: {
  8147. channels: 3,
  8148. labels: ['h', 'c', 'g']
  8149. },
  8150. apple: {
  8151. channels: 3,
  8152. labels: ['r16', 'g16', 'b16']
  8153. },
  8154. gray: {
  8155. channels: 1,
  8156. labels: ['gray']
  8157. }
  8158. };
  8159. var conversions$2 = convert$1; // Hide .channels and .labels properties
  8160. for (const model of Object.keys(convert$1)) {
  8161. if (!('channels' in convert$1[model])) {
  8162. throw new Error('missing channels property: ' + model);
  8163. }
  8164. if (!('labels' in convert$1[model])) {
  8165. throw new Error('missing channel labels property: ' + model);
  8166. }
  8167. if (convert$1[model].labels.length !== convert$1[model].channels) {
  8168. throw new Error('channel and label counts mismatch: ' + model);
  8169. }
  8170. const {
  8171. channels,
  8172. labels
  8173. } = convert$1[model];
  8174. delete convert$1[model].channels;
  8175. delete convert$1[model].labels;
  8176. Object.defineProperty(convert$1[model], 'channels', {
  8177. value: channels
  8178. });
  8179. Object.defineProperty(convert$1[model], 'labels', {
  8180. value: labels
  8181. });
  8182. }
  8183. convert$1.rgb.hsl = function (rgb) {
  8184. const r = rgb[0] / 255;
  8185. const g = rgb[1] / 255;
  8186. const b = rgb[2] / 255;
  8187. const min = Math.min(r, g, b);
  8188. const max = Math.max(r, g, b);
  8189. const delta = max - min;
  8190. let h;
  8191. let s;
  8192. if (max === min) {
  8193. h = 0;
  8194. } else if (r === max) {
  8195. h = (g - b) / delta;
  8196. } else if (g === max) {
  8197. h = 2 + (b - r) / delta;
  8198. } else if (b === max) {
  8199. h = 4 + (r - g) / delta;
  8200. }
  8201. h = Math.min(h * 60, 360);
  8202. if (h < 0) {
  8203. h += 360;
  8204. }
  8205. const l = (min + max) / 2;
  8206. if (max === min) {
  8207. s = 0;
  8208. } else if (l <= 0.5) {
  8209. s = delta / (max + min);
  8210. } else {
  8211. s = delta / (2 - max - min);
  8212. }
  8213. return [h, s * 100, l * 100];
  8214. };
  8215. convert$1.rgb.hsv = function (rgb) {
  8216. let rdif;
  8217. let gdif;
  8218. let bdif;
  8219. let h;
  8220. let s;
  8221. const r = rgb[0] / 255;
  8222. const g = rgb[1] / 255;
  8223. const b = rgb[2] / 255;
  8224. const v = Math.max(r, g, b);
  8225. const diff = v - Math.min(r, g, b);
  8226. const diffc = function (c) {
  8227. return (v - c) / 6 / diff + 1 / 2;
  8228. };
  8229. if (diff === 0) {
  8230. h = 0;
  8231. s = 0;
  8232. } else {
  8233. s = diff / v;
  8234. rdif = diffc(r);
  8235. gdif = diffc(g);
  8236. bdif = diffc(b);
  8237. if (r === v) {
  8238. h = bdif - gdif;
  8239. } else if (g === v) {
  8240. h = 1 / 3 + rdif - bdif;
  8241. } else if (b === v) {
  8242. h = 2 / 3 + gdif - rdif;
  8243. }
  8244. if (h < 0) {
  8245. h += 1;
  8246. } else if (h > 1) {
  8247. h -= 1;
  8248. }
  8249. }
  8250. return [h * 360, s * 100, v * 100];
  8251. };
  8252. convert$1.rgb.hwb = function (rgb) {
  8253. const r = rgb[0];
  8254. const g = rgb[1];
  8255. let b = rgb[2];
  8256. const h = convert$1.rgb.hsl(rgb)[0];
  8257. const w = 1 / 255 * Math.min(r, Math.min(g, b));
  8258. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  8259. return [h, w * 100, b * 100];
  8260. };
  8261. convert$1.rgb.cmyk = function (rgb) {
  8262. const r = rgb[0] / 255;
  8263. const g = rgb[1] / 255;
  8264. const b = rgb[2] / 255;
  8265. const k = Math.min(1 - r, 1 - g, 1 - b);
  8266. const c = (1 - r - k) / (1 - k) || 0;
  8267. const m = (1 - g - k) / (1 - k) || 0;
  8268. const y = (1 - b - k) / (1 - k) || 0;
  8269. return [c * 100, m * 100, y * 100, k * 100];
  8270. };
  8271. function comparativeDistance(x, y) {
  8272. /*
  8273. See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  8274. */
  8275. return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
  8276. }
  8277. convert$1.rgb.keyword = function (rgb) {
  8278. const reversed = reverseKeywords[rgb];
  8279. if (reversed) {
  8280. return reversed;
  8281. }
  8282. let currentClosestDistance = Infinity;
  8283. let currentClosestKeyword;
  8284. for (const keyword of Object.keys(cssKeywords)) {
  8285. const value = cssKeywords[keyword]; // Compute comparative distance
  8286. const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  8287. if (distance < currentClosestDistance) {
  8288. currentClosestDistance = distance;
  8289. currentClosestKeyword = keyword;
  8290. }
  8291. }
  8292. return currentClosestKeyword;
  8293. };
  8294. convert$1.keyword.rgb = function (keyword) {
  8295. return cssKeywords[keyword];
  8296. };
  8297. convert$1.rgb.xyz = function (rgb) {
  8298. let r = rgb[0] / 255;
  8299. let g = rgb[1] / 255;
  8300. let b = rgb[2] / 255; // Assume sRGB
  8301. r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
  8302. g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
  8303. b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
  8304. const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  8305. const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  8306. const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  8307. return [x * 100, y * 100, z * 100];
  8308. };
  8309. convert$1.rgb.lab = function (rgb) {
  8310. const xyz = convert$1.rgb.xyz(rgb);
  8311. let x = xyz[0];
  8312. let y = xyz[1];
  8313. let z = xyz[2];
  8314. x /= 95.047;
  8315. y /= 100;
  8316. z /= 108.883;
  8317. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  8318. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  8319. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  8320. const l = 116 * y - 16;
  8321. const a = 500 * (x - y);
  8322. const b = 200 * (y - z);
  8323. return [l, a, b];
  8324. };
  8325. convert$1.hsl.rgb = function (hsl) {
  8326. const h = hsl[0] / 360;
  8327. const s = hsl[1] / 100;
  8328. const l = hsl[2] / 100;
  8329. let t2;
  8330. let t3;
  8331. let val;
  8332. if (s === 0) {
  8333. val = l * 255;
  8334. return [val, val, val];
  8335. }
  8336. if (l < 0.5) {
  8337. t2 = l * (1 + s);
  8338. } else {
  8339. t2 = l + s - l * s;
  8340. }
  8341. const t1 = 2 * l - t2;
  8342. const rgb = [0, 0, 0];
  8343. for (let i = 0; i < 3; i++) {
  8344. t3 = h + 1 / 3 * -(i - 1);
  8345. if (t3 < 0) {
  8346. t3++;
  8347. }
  8348. if (t3 > 1) {
  8349. t3--;
  8350. }
  8351. if (6 * t3 < 1) {
  8352. val = t1 + (t2 - t1) * 6 * t3;
  8353. } else if (2 * t3 < 1) {
  8354. val = t2;
  8355. } else if (3 * t3 < 2) {
  8356. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  8357. } else {
  8358. val = t1;
  8359. }
  8360. rgb[i] = val * 255;
  8361. }
  8362. return rgb;
  8363. };
  8364. convert$1.hsl.hsv = function (hsl) {
  8365. const h = hsl[0];
  8366. let s = hsl[1] / 100;
  8367. let l = hsl[2] / 100;
  8368. let smin = s;
  8369. const lmin = Math.max(l, 0.01);
  8370. l *= 2;
  8371. s *= l <= 1 ? l : 2 - l;
  8372. smin *= lmin <= 1 ? lmin : 2 - lmin;
  8373. const v = (l + s) / 2;
  8374. const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  8375. return [h, sv * 100, v * 100];
  8376. };
  8377. convert$1.hsv.rgb = function (hsv) {
  8378. const h = hsv[0] / 60;
  8379. const s = hsv[1] / 100;
  8380. let v = hsv[2] / 100;
  8381. const hi = Math.floor(h) % 6;
  8382. const f = h - Math.floor(h);
  8383. const p = 255 * v * (1 - s);
  8384. const q = 255 * v * (1 - s * f);
  8385. const t = 255 * v * (1 - s * (1 - f));
  8386. v *= 255;
  8387. switch (hi) {
  8388. case 0:
  8389. return [v, t, p];
  8390. case 1:
  8391. return [q, v, p];
  8392. case 2:
  8393. return [p, v, t];
  8394. case 3:
  8395. return [p, q, v];
  8396. case 4:
  8397. return [t, p, v];
  8398. case 5:
  8399. return [v, p, q];
  8400. }
  8401. };
  8402. convert$1.hsv.hsl = function (hsv) {
  8403. const h = hsv[0];
  8404. const s = hsv[1] / 100;
  8405. const v = hsv[2] / 100;
  8406. const vmin = Math.max(v, 0.01);
  8407. let sl;
  8408. let l;
  8409. l = (2 - s) * v;
  8410. const lmin = (2 - s) * vmin;
  8411. sl = s * vmin;
  8412. sl /= lmin <= 1 ? lmin : 2 - lmin;
  8413. sl = sl || 0;
  8414. l /= 2;
  8415. return [h, sl * 100, l * 100];
  8416. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  8417. convert$1.hwb.rgb = function (hwb) {
  8418. const h = hwb[0] / 360;
  8419. let wh = hwb[1] / 100;
  8420. let bl = hwb[2] / 100;
  8421. const ratio = wh + bl;
  8422. let f; // Wh + bl cant be > 1
  8423. if (ratio > 1) {
  8424. wh /= ratio;
  8425. bl /= ratio;
  8426. }
  8427. const i = Math.floor(6 * h);
  8428. const v = 1 - bl;
  8429. f = 6 * h - i;
  8430. if ((i & 0x01) !== 0) {
  8431. f = 1 - f;
  8432. }
  8433. const n = wh + f * (v - wh); // Linear interpolation
  8434. let r;
  8435. let g;
  8436. let b;
  8437. /* eslint-disable max-statements-per-line,no-multi-spaces */
  8438. switch (i) {
  8439. default:
  8440. case 6:
  8441. case 0:
  8442. r = v;
  8443. g = n;
  8444. b = wh;
  8445. break;
  8446. case 1:
  8447. r = n;
  8448. g = v;
  8449. b = wh;
  8450. break;
  8451. case 2:
  8452. r = wh;
  8453. g = v;
  8454. b = n;
  8455. break;
  8456. case 3:
  8457. r = wh;
  8458. g = n;
  8459. b = v;
  8460. break;
  8461. case 4:
  8462. r = n;
  8463. g = wh;
  8464. b = v;
  8465. break;
  8466. case 5:
  8467. r = v;
  8468. g = wh;
  8469. b = n;
  8470. break;
  8471. }
  8472. /* eslint-enable max-statements-per-line,no-multi-spaces */
  8473. return [r * 255, g * 255, b * 255];
  8474. };
  8475. convert$1.cmyk.rgb = function (cmyk) {
  8476. const c = cmyk[0] / 100;
  8477. const m = cmyk[1] / 100;
  8478. const y = cmyk[2] / 100;
  8479. const k = cmyk[3] / 100;
  8480. const r = 1 - Math.min(1, c * (1 - k) + k);
  8481. const g = 1 - Math.min(1, m * (1 - k) + k);
  8482. const b = 1 - Math.min(1, y * (1 - k) + k);
  8483. return [r * 255, g * 255, b * 255];
  8484. };
  8485. convert$1.xyz.rgb = function (xyz) {
  8486. const x = xyz[0] / 100;
  8487. const y = xyz[1] / 100;
  8488. const z = xyz[2] / 100;
  8489. let r;
  8490. let g;
  8491. let b;
  8492. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  8493. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  8494. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
  8495. r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
  8496. g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
  8497. b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
  8498. r = Math.min(Math.max(0, r), 1);
  8499. g = Math.min(Math.max(0, g), 1);
  8500. b = Math.min(Math.max(0, b), 1);
  8501. return [r * 255, g * 255, b * 255];
  8502. };
  8503. convert$1.xyz.lab = function (xyz) {
  8504. let x = xyz[0];
  8505. let y = xyz[1];
  8506. let z = xyz[2];
  8507. x /= 95.047;
  8508. y /= 100;
  8509. z /= 108.883;
  8510. x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
  8511. y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
  8512. z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
  8513. const l = 116 * y - 16;
  8514. const a = 500 * (x - y);
  8515. const b = 200 * (y - z);
  8516. return [l, a, b];
  8517. };
  8518. convert$1.lab.xyz = function (lab) {
  8519. const l = lab[0];
  8520. const a = lab[1];
  8521. const b = lab[2];
  8522. let x;
  8523. let y;
  8524. let z;
  8525. y = (l + 16) / 116;
  8526. x = a / 500 + y;
  8527. z = y - b / 200;
  8528. const y2 = y ** 3;
  8529. const x2 = x ** 3;
  8530. const z2 = z ** 3;
  8531. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  8532. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  8533. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  8534. x *= 95.047;
  8535. y *= 100;
  8536. z *= 108.883;
  8537. return [x, y, z];
  8538. };
  8539. convert$1.lab.lch = function (lab) {
  8540. const l = lab[0];
  8541. const a = lab[1];
  8542. const b = lab[2];
  8543. let h;
  8544. const hr = Math.atan2(b, a);
  8545. h = hr * 360 / 2 / Math.PI;
  8546. if (h < 0) {
  8547. h += 360;
  8548. }
  8549. const c = Math.sqrt(a * a + b * b);
  8550. return [l, c, h];
  8551. };
  8552. convert$1.lch.lab = function (lch) {
  8553. const l = lch[0];
  8554. const c = lch[1];
  8555. const h = lch[2];
  8556. const hr = h / 360 * 2 * Math.PI;
  8557. const a = c * Math.cos(hr);
  8558. const b = c * Math.sin(hr);
  8559. return [l, a, b];
  8560. };
  8561. convert$1.rgb.ansi16 = function (args, saturation = null) {
  8562. const [r, g, b] = args;
  8563. let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
  8564. value = Math.round(value / 50);
  8565. if (value === 0) {
  8566. return 30;
  8567. }
  8568. let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  8569. if (value === 2) {
  8570. ansi += 60;
  8571. }
  8572. return ansi;
  8573. };
  8574. convert$1.hsv.ansi16 = function (args) {
  8575. // Optimization here; we already know the value and don't need to get
  8576. // it converted for us.
  8577. return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
  8578. };
  8579. convert$1.rgb.ansi256 = function (args) {
  8580. const r = args[0];
  8581. const g = args[1];
  8582. const b = args[2]; // We use the extended greyscale palette here, with the exception of
  8583. // black and white. normal palette only has 4 greyscale shades.
  8584. if (r === g && g === b) {
  8585. if (r < 8) {
  8586. return 16;
  8587. }
  8588. if (r > 248) {
  8589. return 231;
  8590. }
  8591. return Math.round((r - 8) / 247 * 24) + 232;
  8592. }
  8593. const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  8594. return ansi;
  8595. };
  8596. convert$1.ansi16.rgb = function (args) {
  8597. let color = args % 10; // Handle greyscale
  8598. if (color === 0 || color === 7) {
  8599. if (args > 50) {
  8600. color += 3.5;
  8601. }
  8602. color = color / 10.5 * 255;
  8603. return [color, color, color];
  8604. }
  8605. const mult = (~~(args > 50) + 1) * 0.5;
  8606. const r = (color & 1) * mult * 255;
  8607. const g = (color >> 1 & 1) * mult * 255;
  8608. const b = (color >> 2 & 1) * mult * 255;
  8609. return [r, g, b];
  8610. };
  8611. convert$1.ansi256.rgb = function (args) {
  8612. // Handle greyscale
  8613. if (args >= 232) {
  8614. const c = (args - 232) * 10 + 8;
  8615. return [c, c, c];
  8616. }
  8617. args -= 16;
  8618. let rem;
  8619. const r = Math.floor(args / 36) / 5 * 255;
  8620. const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  8621. const b = rem % 6 / 5 * 255;
  8622. return [r, g, b];
  8623. };
  8624. convert$1.rgb.hex = function (args) {
  8625. const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  8626. const string = integer.toString(16).toUpperCase();
  8627. return '000000'.substring(string.length) + string;
  8628. };
  8629. convert$1.hex.rgb = function (args) {
  8630. const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  8631. if (!match) {
  8632. return [0, 0, 0];
  8633. }
  8634. let colorString = match[0];
  8635. if (match[0].length === 3) {
  8636. colorString = colorString.split('').map(char => {
  8637. return char + char;
  8638. }).join('');
  8639. }
  8640. const integer = parseInt(colorString, 16);
  8641. const r = integer >> 16 & 0xFF;
  8642. const g = integer >> 8 & 0xFF;
  8643. const b = integer & 0xFF;
  8644. return [r, g, b];
  8645. };
  8646. convert$1.rgb.hcg = function (rgb) {
  8647. const r = rgb[0] / 255;
  8648. const g = rgb[1] / 255;
  8649. const b = rgb[2] / 255;
  8650. const max = Math.max(Math.max(r, g), b);
  8651. const min = Math.min(Math.min(r, g), b);
  8652. const chroma = max - min;
  8653. let grayscale;
  8654. let hue;
  8655. if (chroma < 1) {
  8656. grayscale = min / (1 - chroma);
  8657. } else {
  8658. grayscale = 0;
  8659. }
  8660. if (chroma <= 0) {
  8661. hue = 0;
  8662. } else if (max === r) {
  8663. hue = (g - b) / chroma % 6;
  8664. } else if (max === g) {
  8665. hue = 2 + (b - r) / chroma;
  8666. } else {
  8667. hue = 4 + (r - g) / chroma;
  8668. }
  8669. hue /= 6;
  8670. hue %= 1;
  8671. return [hue * 360, chroma * 100, grayscale * 100];
  8672. };
  8673. convert$1.hsl.hcg = function (hsl) {
  8674. const s = hsl[1] / 100;
  8675. const l = hsl[2] / 100;
  8676. const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
  8677. let f = 0;
  8678. if (c < 1.0) {
  8679. f = (l - 0.5 * c) / (1.0 - c);
  8680. }
  8681. return [hsl[0], c * 100, f * 100];
  8682. };
  8683. convert$1.hsv.hcg = function (hsv) {
  8684. const s = hsv[1] / 100;
  8685. const v = hsv[2] / 100;
  8686. const c = s * v;
  8687. let f = 0;
  8688. if (c < 1.0) {
  8689. f = (v - c) / (1 - c);
  8690. }
  8691. return [hsv[0], c * 100, f * 100];
  8692. };
  8693. convert$1.hcg.rgb = function (hcg) {
  8694. const h = hcg[0] / 360;
  8695. const c = hcg[1] / 100;
  8696. const g = hcg[2] / 100;
  8697. if (c === 0.0) {
  8698. return [g * 255, g * 255, g * 255];
  8699. }
  8700. const pure = [0, 0, 0];
  8701. const hi = h % 1 * 6;
  8702. const v = hi % 1;
  8703. const w = 1 - v;
  8704. let mg = 0;
  8705. /* eslint-disable max-statements-per-line */
  8706. switch (Math.floor(hi)) {
  8707. case 0:
  8708. pure[0] = 1;
  8709. pure[1] = v;
  8710. pure[2] = 0;
  8711. break;
  8712. case 1:
  8713. pure[0] = w;
  8714. pure[1] = 1;
  8715. pure[2] = 0;
  8716. break;
  8717. case 2:
  8718. pure[0] = 0;
  8719. pure[1] = 1;
  8720. pure[2] = v;
  8721. break;
  8722. case 3:
  8723. pure[0] = 0;
  8724. pure[1] = w;
  8725. pure[2] = 1;
  8726. break;
  8727. case 4:
  8728. pure[0] = v;
  8729. pure[1] = 0;
  8730. pure[2] = 1;
  8731. break;
  8732. default:
  8733. pure[0] = 1;
  8734. pure[1] = 0;
  8735. pure[2] = w;
  8736. }
  8737. /* eslint-enable max-statements-per-line */
  8738. mg = (1.0 - c) * g;
  8739. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  8740. };
  8741. convert$1.hcg.hsv = function (hcg) {
  8742. const c = hcg[1] / 100;
  8743. const g = hcg[2] / 100;
  8744. const v = c + g * (1.0 - c);
  8745. let f = 0;
  8746. if (v > 0.0) {
  8747. f = c / v;
  8748. }
  8749. return [hcg[0], f * 100, v * 100];
  8750. };
  8751. convert$1.hcg.hsl = function (hcg) {
  8752. const c = hcg[1] / 100;
  8753. const g = hcg[2] / 100;
  8754. const l = g * (1.0 - c) + 0.5 * c;
  8755. let s = 0;
  8756. if (l > 0.0 && l < 0.5) {
  8757. s = c / (2 * l);
  8758. } else if (l >= 0.5 && l < 1.0) {
  8759. s = c / (2 * (1 - l));
  8760. }
  8761. return [hcg[0], s * 100, l * 100];
  8762. };
  8763. convert$1.hcg.hwb = function (hcg) {
  8764. const c = hcg[1] / 100;
  8765. const g = hcg[2] / 100;
  8766. const v = c + g * (1.0 - c);
  8767. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  8768. };
  8769. convert$1.hwb.hcg = function (hwb) {
  8770. const w = hwb[1] / 100;
  8771. const b = hwb[2] / 100;
  8772. const v = 1 - b;
  8773. const c = v - w;
  8774. let g = 0;
  8775. if (c < 1) {
  8776. g = (v - c) / (1 - c);
  8777. }
  8778. return [hwb[0], c * 100, g * 100];
  8779. };
  8780. convert$1.apple.rgb = function (apple) {
  8781. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  8782. };
  8783. convert$1.rgb.apple = function (rgb) {
  8784. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  8785. };
  8786. convert$1.gray.rgb = function (args) {
  8787. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  8788. };
  8789. convert$1.gray.hsl = function (args) {
  8790. return [0, 0, args[0]];
  8791. };
  8792. convert$1.gray.hsv = convert$1.gray.hsl;
  8793. convert$1.gray.hwb = function (gray) {
  8794. return [0, 100, gray[0]];
  8795. };
  8796. convert$1.gray.cmyk = function (gray) {
  8797. return [0, 0, 0, gray[0]];
  8798. };
  8799. convert$1.gray.lab = function (gray) {
  8800. return [gray[0], 0, 0];
  8801. };
  8802. convert$1.gray.hex = function (gray) {
  8803. const val = Math.round(gray[0] / 100 * 255) & 0xFF;
  8804. const integer = (val << 16) + (val << 8) + val;
  8805. const string = integer.toString(16).toUpperCase();
  8806. return '000000'.substring(string.length) + string;
  8807. };
  8808. convert$1.rgb.gray = function (rgb) {
  8809. const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  8810. return [val / 255 * 100];
  8811. };
  8812. const conversions$1 = conversions$2;
  8813. /*
  8814. This function routes a model to all other models.
  8815. all functions that are routed have a property `.conversion` attached
  8816. to the returned synthetic function. This property is an array
  8817. of strings, each with the steps in between the 'from' and 'to'
  8818. color models (inclusive).
  8819. conversions that are not possible simply are not included.
  8820. */
  8821. function buildGraph() {
  8822. const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  8823. const models = Object.keys(conversions$1);
  8824. for (let len = models.length, i = 0; i < len; i++) {
  8825. graph[models[i]] = {
  8826. // http://jsperf.com/1-vs-infinity
  8827. // micro-opt, but this is simple.
  8828. distance: -1,
  8829. parent: null
  8830. };
  8831. }
  8832. return graph;
  8833. } // https://en.wikipedia.org/wiki/Breadth-first_search
  8834. function deriveBFS(fromModel) {
  8835. const graph = buildGraph();
  8836. const queue = [fromModel]; // Unshift -> queue -> pop
  8837. graph[fromModel].distance = 0;
  8838. while (queue.length) {
  8839. const current = queue.pop();
  8840. const adjacents = Object.keys(conversions$1[current]);
  8841. for (let len = adjacents.length, i = 0; i < len; i++) {
  8842. const adjacent = adjacents[i];
  8843. const node = graph[adjacent];
  8844. if (node.distance === -1) {
  8845. node.distance = graph[current].distance + 1;
  8846. node.parent = current;
  8847. queue.unshift(adjacent);
  8848. }
  8849. }
  8850. }
  8851. return graph;
  8852. }
  8853. function link$1(from, to) {
  8854. return function (args) {
  8855. return to(from(args));
  8856. };
  8857. }
  8858. function wrapConversion(toModel, graph) {
  8859. const path = [graph[toModel].parent, toModel];
  8860. let fn = conversions$1[graph[toModel].parent][toModel];
  8861. let cur = graph[toModel].parent;
  8862. while (graph[cur].parent) {
  8863. path.unshift(graph[cur].parent);
  8864. fn = link$1(conversions$1[graph[cur].parent][cur], fn);
  8865. cur = graph[cur].parent;
  8866. }
  8867. fn.conversion = path;
  8868. return fn;
  8869. }
  8870. var route$1 = function (fromModel) {
  8871. const graph = deriveBFS(fromModel);
  8872. const conversion = {};
  8873. const models = Object.keys(graph);
  8874. for (let len = models.length, i = 0; i < len; i++) {
  8875. const toModel = models[i];
  8876. const node = graph[toModel];
  8877. if (node.parent === null) {
  8878. // No possible conversion, or this node is the source model.
  8879. continue;
  8880. }
  8881. conversion[toModel] = wrapConversion(toModel, graph);
  8882. }
  8883. return conversion;
  8884. };
  8885. const conversions = conversions$2;
  8886. const route = route$1;
  8887. const convert = {};
  8888. const models = Object.keys(conversions);
  8889. function wrapRaw(fn) {
  8890. const wrappedFn = function (...args) {
  8891. const arg0 = args[0];
  8892. if (arg0 === undefined || arg0 === null) {
  8893. return arg0;
  8894. }
  8895. if (arg0.length > 1) {
  8896. args = arg0;
  8897. }
  8898. return fn(args);
  8899. }; // Preserve .conversion property if there is one
  8900. if ('conversion' in fn) {
  8901. wrappedFn.conversion = fn.conversion;
  8902. }
  8903. return wrappedFn;
  8904. }
  8905. function wrapRounded(fn) {
  8906. const wrappedFn = function (...args) {
  8907. const arg0 = args[0];
  8908. if (arg0 === undefined || arg0 === null) {
  8909. return arg0;
  8910. }
  8911. if (arg0.length > 1) {
  8912. args = arg0;
  8913. }
  8914. const result = fn(args); // We're assuming the result is an array here.
  8915. // see notice in conversions.js; don't use box types
  8916. // in conversion functions.
  8917. if (typeof result === 'object') {
  8918. for (let len = result.length, i = 0; i < len; i++) {
  8919. result[i] = Math.round(result[i]);
  8920. }
  8921. }
  8922. return result;
  8923. }; // Preserve .conversion property if there is one
  8924. if ('conversion' in fn) {
  8925. wrappedFn.conversion = fn.conversion;
  8926. }
  8927. return wrappedFn;
  8928. }
  8929. models.forEach(fromModel => {
  8930. convert[fromModel] = {};
  8931. Object.defineProperty(convert[fromModel], 'channels', {
  8932. value: conversions[fromModel].channels
  8933. });
  8934. Object.defineProperty(convert[fromModel], 'labels', {
  8935. value: conversions[fromModel].labels
  8936. });
  8937. const routes = route(fromModel);
  8938. const routeModels = Object.keys(routes);
  8939. routeModels.forEach(toModel => {
  8940. const fn = routes[toModel];
  8941. convert[fromModel][toModel] = wrapRounded(fn);
  8942. convert[fromModel][toModel].raw = wrapRaw(fn);
  8943. });
  8944. });
  8945. var colorConvert = convert;
  8946. (function (module) {
  8947. const wrapAnsi16 = (fn, offset) => (...args) => {
  8948. const code = fn(...args);
  8949. return `\u001B[${code + offset}m`;
  8950. };
  8951. const wrapAnsi256 = (fn, offset) => (...args) => {
  8952. const code = fn(...args);
  8953. return `\u001B[${38 + offset};5;${code}m`;
  8954. };
  8955. const wrapAnsi16m = (fn, offset) => (...args) => {
  8956. const rgb = fn(...args);
  8957. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  8958. };
  8959. const ansi2ansi = n => n;
  8960. const rgb2rgb = (r, g, b) => [r, g, b];
  8961. const setLazyProperty = (object, property, get) => {
  8962. Object.defineProperty(object, property, {
  8963. get: () => {
  8964. const value = get();
  8965. Object.defineProperty(object, property, {
  8966. value,
  8967. enumerable: true,
  8968. configurable: true
  8969. });
  8970. return value;
  8971. },
  8972. enumerable: true,
  8973. configurable: true
  8974. });
  8975. };
  8976. /** @type {typeof import('color-convert')} */
  8977. let colorConvert$1;
  8978. const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
  8979. if (colorConvert$1 === undefined) {
  8980. colorConvert$1 = colorConvert;
  8981. }
  8982. const offset = isBackground ? 10 : 0;
  8983. const styles = {};
  8984. for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
  8985. const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
  8986. if (sourceSpace === targetSpace) {
  8987. styles[name] = wrap(identity, offset);
  8988. } else if (typeof suite === 'object') {
  8989. styles[name] = wrap(suite[targetSpace], offset);
  8990. }
  8991. }
  8992. return styles;
  8993. };
  8994. function assembleStyles() {
  8995. const codes = new Map();
  8996. const styles = {
  8997. modifier: {
  8998. reset: [0, 0],
  8999. // 21 isn't widely supported and 22 does the same thing
  9000. bold: [1, 22],
  9001. dim: [2, 22],
  9002. italic: [3, 23],
  9003. underline: [4, 24],
  9004. inverse: [7, 27],
  9005. hidden: [8, 28],
  9006. strikethrough: [9, 29]
  9007. },
  9008. color: {
  9009. black: [30, 39],
  9010. red: [31, 39],
  9011. green: [32, 39],
  9012. yellow: [33, 39],
  9013. blue: [34, 39],
  9014. magenta: [35, 39],
  9015. cyan: [36, 39],
  9016. white: [37, 39],
  9017. // Bright color
  9018. blackBright: [90, 39],
  9019. redBright: [91, 39],
  9020. greenBright: [92, 39],
  9021. yellowBright: [93, 39],
  9022. blueBright: [94, 39],
  9023. magentaBright: [95, 39],
  9024. cyanBright: [96, 39],
  9025. whiteBright: [97, 39]
  9026. },
  9027. bgColor: {
  9028. bgBlack: [40, 49],
  9029. bgRed: [41, 49],
  9030. bgGreen: [42, 49],
  9031. bgYellow: [43, 49],
  9032. bgBlue: [44, 49],
  9033. bgMagenta: [45, 49],
  9034. bgCyan: [46, 49],
  9035. bgWhite: [47, 49],
  9036. // Bright color
  9037. bgBlackBright: [100, 49],
  9038. bgRedBright: [101, 49],
  9039. bgGreenBright: [102, 49],
  9040. bgYellowBright: [103, 49],
  9041. bgBlueBright: [104, 49],
  9042. bgMagentaBright: [105, 49],
  9043. bgCyanBright: [106, 49],
  9044. bgWhiteBright: [107, 49]
  9045. }
  9046. }; // Alias bright black as gray (and grey)
  9047. styles.color.gray = styles.color.blackBright;
  9048. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  9049. styles.color.grey = styles.color.blackBright;
  9050. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  9051. for (const [groupName, group] of Object.entries(styles)) {
  9052. for (const [styleName, style] of Object.entries(group)) {
  9053. styles[styleName] = {
  9054. open: `\u001B[${style[0]}m`,
  9055. close: `\u001B[${style[1]}m`
  9056. };
  9057. group[styleName] = styles[styleName];
  9058. codes.set(style[0], style[1]);
  9059. }
  9060. Object.defineProperty(styles, groupName, {
  9061. value: group,
  9062. enumerable: false
  9063. });
  9064. }
  9065. Object.defineProperty(styles, 'codes', {
  9066. value: codes,
  9067. enumerable: false
  9068. });
  9069. styles.color.close = '\u001B[39m';
  9070. styles.bgColor.close = '\u001B[49m';
  9071. setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
  9072. setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
  9073. setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
  9074. setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
  9075. setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
  9076. setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
  9077. return styles;
  9078. } // Make the export immutable
  9079. Object.defineProperty(module, 'exports', {
  9080. enumerable: true,
  9081. get: assembleStyles
  9082. });
  9083. })(ansiStyles$1);
  9084. var hasFlag$3 = (flag, argv = process.argv) => {
  9085. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  9086. const position = argv.indexOf(prefix + flag);
  9087. const terminatorPosition = argv.indexOf('--');
  9088. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  9089. };
  9090. const os$3 = require$$0__default$1["default"];
  9091. const tty$2 = require$$1__default["default"];
  9092. const hasFlag$2 = hasFlag$3;
  9093. const {
  9094. env: env$1
  9095. } = process;
  9096. let forceColor$1;
  9097. if (hasFlag$2('no-color') || hasFlag$2('no-colors') || hasFlag$2('color=false') || hasFlag$2('color=never')) {
  9098. forceColor$1 = 0;
  9099. } else if (hasFlag$2('color') || hasFlag$2('colors') || hasFlag$2('color=true') || hasFlag$2('color=always')) {
  9100. forceColor$1 = 1;
  9101. }
  9102. if ('FORCE_COLOR' in env$1) {
  9103. if (env$1.FORCE_COLOR === 'true') {
  9104. forceColor$1 = 1;
  9105. } else if (env$1.FORCE_COLOR === 'false') {
  9106. forceColor$1 = 0;
  9107. } else {
  9108. forceColor$1 = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3);
  9109. }
  9110. }
  9111. function translateLevel$1(level) {
  9112. if (level === 0) {
  9113. return false;
  9114. }
  9115. return {
  9116. level,
  9117. hasBasic: true,
  9118. has256: level >= 2,
  9119. has16m: level >= 3
  9120. };
  9121. }
  9122. function supportsColor$1(haveStream, streamIsTTY) {
  9123. if (forceColor$1 === 0) {
  9124. return 0;
  9125. }
  9126. if (hasFlag$2('color=16m') || hasFlag$2('color=full') || hasFlag$2('color=truecolor')) {
  9127. return 3;
  9128. }
  9129. if (hasFlag$2('color=256')) {
  9130. return 2;
  9131. }
  9132. if (haveStream && !streamIsTTY && forceColor$1 === undefined) {
  9133. return 0;
  9134. }
  9135. const min = forceColor$1 || 0;
  9136. if (env$1.TERM === 'dumb') {
  9137. return min;
  9138. }
  9139. if (process.platform === 'win32') {
  9140. // Windows 10 build 10586 is the first Windows release that supports 256 colors.
  9141. // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
  9142. const osRelease = os$3.release().split('.');
  9143. if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  9144. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  9145. }
  9146. return 1;
  9147. }
  9148. if ('CI' in env$1) {
  9149. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
  9150. return 1;
  9151. }
  9152. return min;
  9153. }
  9154. if ('TEAMCITY_VERSION' in env$1) {
  9155. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  9156. }
  9157. if (env$1.COLORTERM === 'truecolor') {
  9158. return 3;
  9159. }
  9160. if ('TERM_PROGRAM' in env$1) {
  9161. const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  9162. switch (env$1.TERM_PROGRAM) {
  9163. case 'iTerm.app':
  9164. return version >= 3 ? 3 : 2;
  9165. case 'Apple_Terminal':
  9166. return 2;
  9167. // No default
  9168. }
  9169. }
  9170. if (/-256(color)?$/i.test(env$1.TERM)) {
  9171. return 2;
  9172. }
  9173. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  9174. return 1;
  9175. }
  9176. if ('COLORTERM' in env$1) {
  9177. return 1;
  9178. }
  9179. return min;
  9180. }
  9181. function getSupportLevel$1(stream) {
  9182. const level = supportsColor$1(stream, stream && stream.isTTY);
  9183. return translateLevel$1(level);
  9184. }
  9185. var supportsColor_1$1 = {
  9186. supportsColor: getSupportLevel$1,
  9187. stdout: translateLevel$1(supportsColor$1(true, tty$2.isatty(1))),
  9188. stderr: translateLevel$1(supportsColor$1(true, tty$2.isatty(2)))
  9189. };
  9190. const stringReplaceAll$1 = (string, substring, replacer) => {
  9191. let index = string.indexOf(substring);
  9192. if (index === -1) {
  9193. return string;
  9194. }
  9195. const substringLength = substring.length;
  9196. let endIndex = 0;
  9197. let returnValue = '';
  9198. do {
  9199. returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
  9200. endIndex = index + substringLength;
  9201. index = string.indexOf(substring, endIndex);
  9202. } while (index !== -1);
  9203. returnValue += string.substr(endIndex);
  9204. return returnValue;
  9205. };
  9206. const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
  9207. let endIndex = 0;
  9208. let returnValue = '';
  9209. do {
  9210. const gotCR = string[index - 1] === '\r';
  9211. returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
  9212. endIndex = index + 1;
  9213. index = string.indexOf('\n', endIndex);
  9214. } while (index !== -1);
  9215. returnValue += string.substr(endIndex);
  9216. return returnValue;
  9217. };
  9218. var util$7 = {
  9219. stringReplaceAll: stringReplaceAll$1,
  9220. stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
  9221. };
  9222. const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  9223. const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  9224. const STRING_REGEX$2 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  9225. const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
  9226. const ESCAPES$1 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  9227. function unescape$1(c) {
  9228. const u = c[0] === 'u';
  9229. const bracket = c[1] === '{';
  9230. if (u && !bracket && c.length === 5 || c[0] === 'x' && c.length === 3) {
  9231. return String.fromCharCode(parseInt(c.slice(1), 16));
  9232. }
  9233. if (u && bracket) {
  9234. return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
  9235. }
  9236. return ESCAPES$1.get(c) || c;
  9237. }
  9238. function parseArguments$1(name, arguments_) {
  9239. const results = [];
  9240. const chunks = arguments_.trim().split(/\s*,\s*/g);
  9241. let matches;
  9242. for (const chunk of chunks) {
  9243. const number = Number(chunk);
  9244. if (!Number.isNaN(number)) {
  9245. results.push(number);
  9246. } else if (matches = chunk.match(STRING_REGEX$2)) {
  9247. results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$1(escape) : character));
  9248. } else {
  9249. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  9250. }
  9251. }
  9252. return results;
  9253. }
  9254. function parseStyle$1(style) {
  9255. STYLE_REGEX$1.lastIndex = 0;
  9256. const results = [];
  9257. let matches;
  9258. while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
  9259. const name = matches[1];
  9260. if (matches[2]) {
  9261. const args = parseArguments$1(name, matches[2]);
  9262. results.push([name].concat(args));
  9263. } else {
  9264. results.push([name]);
  9265. }
  9266. }
  9267. return results;
  9268. }
  9269. function buildStyle$1(chalk, styles) {
  9270. const enabled = {};
  9271. for (const layer of styles) {
  9272. for (const style of layer.styles) {
  9273. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  9274. }
  9275. }
  9276. let current = chalk;
  9277. for (const [styleName, styles] of Object.entries(enabled)) {
  9278. if (!Array.isArray(styles)) {
  9279. continue;
  9280. }
  9281. if (!(styleName in current)) {
  9282. throw new Error(`Unknown Chalk style: ${styleName}`);
  9283. }
  9284. current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
  9285. }
  9286. return current;
  9287. }
  9288. var templates$1 = (chalk, temporary) => {
  9289. const styles = [];
  9290. const chunks = [];
  9291. let chunk = []; // eslint-disable-next-line max-params
  9292. temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => {
  9293. if (escapeCharacter) {
  9294. chunk.push(unescape$1(escapeCharacter));
  9295. } else if (style) {
  9296. const string = chunk.join('');
  9297. chunk = [];
  9298. chunks.push(styles.length === 0 ? string : buildStyle$1(chalk, styles)(string));
  9299. styles.push({
  9300. inverse,
  9301. styles: parseStyle$1(style)
  9302. });
  9303. } else if (close) {
  9304. if (styles.length === 0) {
  9305. throw new Error('Found extraneous } in Chalk template literal');
  9306. }
  9307. chunks.push(buildStyle$1(chalk, styles)(chunk.join('')));
  9308. chunk = [];
  9309. styles.pop();
  9310. } else {
  9311. chunk.push(character);
  9312. }
  9313. });
  9314. chunks.push(chunk.join(''));
  9315. if (styles.length > 0) {
  9316. const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  9317. throw new Error(errMessage);
  9318. }
  9319. return chunks.join('');
  9320. };
  9321. const ansiStyles = ansiStyles$1.exports;
  9322. const {
  9323. stdout: stdoutColor,
  9324. stderr: stderrColor
  9325. } = supportsColor_1$1;
  9326. const {
  9327. stringReplaceAll,
  9328. stringEncaseCRLFWithFirstIndex
  9329. } = util$7;
  9330. const {
  9331. isArray: isArray$b
  9332. } = Array; // `supportsColor.level` → `ansiStyles.color[name]` mapping
  9333. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
  9334. const styles = Object.create(null);
  9335. const applyOptions = (object, options = {}) => {
  9336. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  9337. throw new Error('The `level` option should be an integer from 0 to 3');
  9338. } // Detect level if not set manually
  9339. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  9340. object.level = options.level === undefined ? colorLevel : options.level;
  9341. };
  9342. class ChalkClass {
  9343. constructor(options) {
  9344. // eslint-disable-next-line no-constructor-return
  9345. return chalkFactory(options);
  9346. }
  9347. }
  9348. const chalkFactory = options => {
  9349. const chalk = {};
  9350. applyOptions(chalk, options);
  9351. chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
  9352. Object.setPrototypeOf(chalk, Chalk.prototype);
  9353. Object.setPrototypeOf(chalk.template, chalk);
  9354. chalk.template.constructor = () => {
  9355. throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
  9356. };
  9357. chalk.template.Instance = ChalkClass;
  9358. return chalk.template;
  9359. };
  9360. function Chalk(options) {
  9361. return chalkFactory(options);
  9362. }
  9363. for (const [styleName, style] of Object.entries(ansiStyles)) {
  9364. styles[styleName] = {
  9365. get() {
  9366. const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
  9367. Object.defineProperty(this, styleName, {
  9368. value: builder
  9369. });
  9370. return builder;
  9371. }
  9372. };
  9373. }
  9374. styles.visible = {
  9375. get() {
  9376. const builder = createBuilder(this, this._styler, true);
  9377. Object.defineProperty(this, 'visible', {
  9378. value: builder
  9379. });
  9380. return builder;
  9381. }
  9382. };
  9383. const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
  9384. for (const model of usedModels) {
  9385. styles[model] = {
  9386. get() {
  9387. const {
  9388. level
  9389. } = this;
  9390. return function (...arguments_) {
  9391. const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
  9392. return createBuilder(this, styler, this._isEmpty);
  9393. };
  9394. }
  9395. };
  9396. }
  9397. for (const model of usedModels) {
  9398. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  9399. styles[bgModel] = {
  9400. get() {
  9401. const {
  9402. level
  9403. } = this;
  9404. return function (...arguments_) {
  9405. const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
  9406. return createBuilder(this, styler, this._isEmpty);
  9407. };
  9408. }
  9409. };
  9410. }
  9411. const proto = Object.defineProperties(() => {}, Object.assign(Object.assign({}, styles), {}, {
  9412. level: {
  9413. enumerable: true,
  9414. get() {
  9415. return this._generator.level;
  9416. },
  9417. set(level) {
  9418. this._generator.level = level;
  9419. }
  9420. }
  9421. }));
  9422. const createStyler = (open, close, parent) => {
  9423. let openAll;
  9424. let closeAll;
  9425. if (parent === undefined) {
  9426. openAll = open;
  9427. closeAll = close;
  9428. } else {
  9429. openAll = parent.openAll + open;
  9430. closeAll = close + parent.closeAll;
  9431. }
  9432. return {
  9433. open,
  9434. close,
  9435. openAll,
  9436. closeAll,
  9437. parent
  9438. };
  9439. };
  9440. const createBuilder = (self, _styler, _isEmpty) => {
  9441. const builder = (...arguments_) => {
  9442. if (isArray$b(arguments_[0]) && isArray$b(arguments_[0].raw)) {
  9443. // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
  9444. return applyStyle(builder, chalkTag(builder, ...arguments_));
  9445. } // Single argument is hot path, implicit coercion is faster than anything
  9446. // eslint-disable-next-line no-implicit-coercion
  9447. return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
  9448. }; // We alter the prototype because we must return a function, but there is
  9449. // no way to create a function with a different prototype
  9450. Object.setPrototypeOf(builder, proto);
  9451. builder._generator = self;
  9452. builder._styler = _styler;
  9453. builder._isEmpty = _isEmpty;
  9454. return builder;
  9455. };
  9456. const applyStyle = (self, string) => {
  9457. if (self.level <= 0 || !string) {
  9458. return self._isEmpty ? '' : string;
  9459. }
  9460. let styler = self._styler;
  9461. if (styler === undefined) {
  9462. return string;
  9463. }
  9464. const {
  9465. openAll,
  9466. closeAll
  9467. } = styler;
  9468. if (string.indexOf('\u001B') !== -1) {
  9469. while (styler !== undefined) {
  9470. // Replace any instances already present with a re-opening code
  9471. // otherwise only the part of the string until said closing code
  9472. // will be colored, and the rest will simply be 'plain'.
  9473. string = stringReplaceAll(string, styler.close, styler.open);
  9474. styler = styler.parent;
  9475. }
  9476. } // We can move both next actions out of loop, because remaining actions in loop won't have
  9477. // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
  9478. // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
  9479. const lfIndex = string.indexOf('\n');
  9480. if (lfIndex !== -1) {
  9481. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  9482. }
  9483. return openAll + string + closeAll;
  9484. };
  9485. let template;
  9486. const chalkTag = (chalk, ...strings) => {
  9487. const [firstString] = strings;
  9488. if (!isArray$b(firstString) || !isArray$b(firstString.raw)) {
  9489. // If chalk() was called by itself or with a string,
  9490. // return the string itself as a string.
  9491. return strings.join(' ');
  9492. }
  9493. const arguments_ = strings.slice(1);
  9494. const parts = [firstString.raw[0]];
  9495. for (let i = 1; i < firstString.length; i++) {
  9496. parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
  9497. }
  9498. if (template === undefined) {
  9499. template = templates$1;
  9500. }
  9501. return template(chalk, parts.join(''));
  9502. };
  9503. Object.defineProperties(Chalk.prototype, styles);
  9504. const chalk$2 = Chalk(); // eslint-disable-line new-cap
  9505. chalk$2.supportsColor = stdoutColor;
  9506. chalk$2.stderr = Chalk({
  9507. level: stderrColor ? stderrColor.level : 0
  9508. }); // eslint-disable-line new-cap
  9509. chalk$2.stderr.supportsColor = stderrColor;
  9510. var source$2 = chalk$2;
  9511. const _excluded$2 = ["_"];
  9512. const vnopts = lib$4;
  9513. const leven = leven$2.exports;
  9514. const chalk$1 = source$2;
  9515. const getLast$n = getLast_1;
  9516. const cliDescriptor = {
  9517. key: key => key.length === 1 ? `-${key}` : `--${key}`,
  9518. value: value => vnopts.apiDescriptor.value(value),
  9519. pair: ({
  9520. key,
  9521. value
  9522. }) => value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`
  9523. };
  9524. class FlagSchema extends vnopts.ChoiceSchema {
  9525. constructor({
  9526. name,
  9527. flags
  9528. }) {
  9529. super({
  9530. name,
  9531. choices: flags
  9532. });
  9533. this._flags = [...flags].sort();
  9534. }
  9535. preprocess(value, utils) {
  9536. if (typeof value === "string" && value.length > 0 && !this._flags.includes(value)) {
  9537. const suggestion = this._flags.find(flag => leven(flag, value) < 3);
  9538. if (suggestion) {
  9539. utils.logger.warn([`Unknown flag ${chalk$1.yellow(utils.descriptor.value(value))},`, `did you mean ${chalk$1.blue(utils.descriptor.value(suggestion))}?`].join(" "));
  9540. return suggestion;
  9541. }
  9542. }
  9543. return value;
  9544. }
  9545. expected() {
  9546. return "a flag";
  9547. }
  9548. }
  9549. let hasDeprecationWarned;
  9550. function normalizeOptions$5(options, optionInfos, {
  9551. logger,
  9552. isCLI = false,
  9553. passThrough = false
  9554. } = {}) {
  9555. const unknown = !passThrough ? (key, value, options) => {
  9556. // Don't suggest `_` for unknown flags
  9557. const _options$schemas = options.schemas,
  9558. schemas = _objectWithoutProperties(_options$schemas, _excluded$2);
  9559. return vnopts.levenUnknownHandler(key, value, Object.assign(Object.assign({}, options), {}, {
  9560. schemas
  9561. }));
  9562. } : Array.isArray(passThrough) ? (key, value) => !passThrough.includes(key) ? undefined : {
  9563. [key]: value
  9564. } : (key, value) => ({
  9565. [key]: value
  9566. });
  9567. const descriptor = isCLI ? cliDescriptor : vnopts.apiDescriptor;
  9568. const schemas = optionInfosToSchemas(optionInfos, {
  9569. isCLI
  9570. });
  9571. const normalizer = new vnopts.Normalizer(schemas, {
  9572. logger,
  9573. unknown,
  9574. descriptor
  9575. });
  9576. const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  9577. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  9578. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  9579. }
  9580. const normalized = normalizer.normalize(options);
  9581. if (shouldSuppressDuplicateDeprecationWarnings) {
  9582. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  9583. }
  9584. return normalized;
  9585. }
  9586. function optionInfosToSchemas(optionInfos, {
  9587. isCLI
  9588. }) {
  9589. const schemas = [];
  9590. if (isCLI) {
  9591. schemas.push(vnopts.AnySchema.create({
  9592. name: "_"
  9593. }));
  9594. }
  9595. for (const optionInfo of optionInfos) {
  9596. schemas.push(optionInfoToSchema(optionInfo, {
  9597. isCLI,
  9598. optionInfos
  9599. }));
  9600. if (optionInfo.alias && isCLI) {
  9601. schemas.push(vnopts.AliasSchema.create({
  9602. name: optionInfo.alias,
  9603. sourceName: optionInfo.name
  9604. }));
  9605. }
  9606. }
  9607. return schemas;
  9608. }
  9609. function optionInfoToSchema(optionInfo, {
  9610. isCLI,
  9611. optionInfos
  9612. }) {
  9613. let SchemaConstructor;
  9614. const parameters = {
  9615. name: optionInfo.name
  9616. };
  9617. const handlers = {};
  9618. switch (optionInfo.type) {
  9619. case "int":
  9620. SchemaConstructor = vnopts.IntegerSchema;
  9621. if (isCLI) {
  9622. parameters.preprocess = value => Number(value);
  9623. }
  9624. break;
  9625. case "string":
  9626. SchemaConstructor = vnopts.StringSchema;
  9627. break;
  9628. case "choice":
  9629. SchemaConstructor = vnopts.ChoiceSchema;
  9630. parameters.choices = optionInfo.choices.map(choiceInfo => typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign(Object.assign({}, choiceInfo), {}, {
  9631. redirect: {
  9632. to: {
  9633. key: optionInfo.name,
  9634. value: choiceInfo.redirect
  9635. }
  9636. }
  9637. }) : choiceInfo);
  9638. break;
  9639. case "boolean":
  9640. SchemaConstructor = vnopts.BooleanSchema;
  9641. break;
  9642. case "flag":
  9643. SchemaConstructor = FlagSchema;
  9644. parameters.flags = optionInfos.flatMap(optionInfo => [optionInfo.alias, optionInfo.description && optionInfo.name, optionInfo.oppositeDescription && `no-${optionInfo.name}`].filter(Boolean));
  9645. break;
  9646. case "path":
  9647. SchemaConstructor = vnopts.StringSchema;
  9648. break;
  9649. default:
  9650. /* istanbul ignore next */
  9651. throw new Error(`Unexpected type ${optionInfo.type}`);
  9652. }
  9653. if (optionInfo.exception) {
  9654. parameters.validate = (value, schema, utils) => optionInfo.exception(value) || schema.validate(value, utils);
  9655. } else {
  9656. parameters.validate = (value, schema, utils) => value === undefined || schema.validate(value, utils);
  9657. }
  9658. /* istanbul ignore next */
  9659. if (optionInfo.redirect) {
  9660. handlers.redirect = value => !value ? undefined : {
  9661. to: {
  9662. key: optionInfo.redirect.option,
  9663. value: optionInfo.redirect.value
  9664. }
  9665. };
  9666. }
  9667. /* istanbul ignore next */
  9668. if (optionInfo.deprecated) {
  9669. handlers.deprecated = true;
  9670. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  9671. if (isCLI && !optionInfo.array) {
  9672. const originalPreprocess = parameters.preprocess || (x => x);
  9673. parameters.preprocess = (value, schema, utils) => schema.preprocess(originalPreprocess(Array.isArray(value) ? getLast$n(value) : value), utils);
  9674. }
  9675. return optionInfo.array ? vnopts.ArraySchema.create(Object.assign(Object.assign(Object.assign({}, isCLI ? {
  9676. preprocess: v => Array.isArray(v) ? v : [v]
  9677. } : {}), handlers), {}, {
  9678. valueSchema: SchemaConstructor.create(parameters)
  9679. })) : SchemaConstructor.create(Object.assign(Object.assign({}, parameters), handlers));
  9680. }
  9681. function normalizeApiOptions(options, optionInfos, opts) {
  9682. return normalizeOptions$5(options, optionInfos, opts);
  9683. }
  9684. function normalizeCliOptions(options, optionInfos, opts) {
  9685. return normalizeOptions$5(options, optionInfos, Object.assign({
  9686. isCLI: true
  9687. }, opts));
  9688. }
  9689. var optionsNormalizer = {
  9690. normalizeApiOptions,
  9691. normalizeCliOptions
  9692. };
  9693. const {
  9694. isNonEmptyArray: isNonEmptyArray$j
  9695. } = util$8;
  9696. /**
  9697. * @typedef {import("./types/estree").Node} Node
  9698. */
  9699. function locStart$s(node, opts) {
  9700. const {
  9701. ignoreDecorators
  9702. } = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  9703. if (!ignoreDecorators) {
  9704. const decorators = node.declaration && node.declaration.decorators || node.decorators;
  9705. if (isNonEmptyArray$j(decorators)) {
  9706. return locStart$s(decorators[0]);
  9707. }
  9708. }
  9709. return node.range ? node.range[0] : node.start;
  9710. }
  9711. function locEnd$r(node) {
  9712. return node.range ? node.range[1] : node.end;
  9713. }
  9714. /**
  9715. * @param {Node} nodeA
  9716. * @param {Node} nodeB
  9717. * @returns {boolean}
  9718. */
  9719. function hasSameLocStart$1(nodeA, nodeB) {
  9720. return locStart$s(nodeA) === locStart$s(nodeB);
  9721. }
  9722. /**
  9723. * @param {Node} nodeA
  9724. * @param {Node} nodeB
  9725. * @returns {boolean}
  9726. */
  9727. function hasSameLocEnd(nodeA, nodeB) {
  9728. return locEnd$r(nodeA) === locEnd$r(nodeB);
  9729. }
  9730. /**
  9731. * @param {Node} nodeA
  9732. * @param {Node} nodeB
  9733. * @returns {boolean}
  9734. */
  9735. function hasSameLoc$1(nodeA, nodeB) {
  9736. return hasSameLocStart$1(nodeA, nodeB) && hasSameLocEnd(nodeA, nodeB);
  9737. }
  9738. var loc$6 = {
  9739. locStart: locStart$s,
  9740. locEnd: locEnd$r,
  9741. hasSameLocStart: hasSameLocStart$1,
  9742. hasSameLoc: hasSameLoc$1
  9743. };
  9744. var lib$3 = {};
  9745. var lib$2 = {};
  9746. var jsTokens = {};
  9747. // License: MIT. (See LICENSE.)
  9748. Object.defineProperty(jsTokens, "__esModule", {
  9749. value: true
  9750. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  9751. // (run `npm run build`).
  9752. jsTokens.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;
  9753. jsTokens.matchToToken = function (match) {
  9754. var token = {
  9755. type: "invalid",
  9756. value: match[0],
  9757. closed: undefined
  9758. };
  9759. 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";
  9760. return token;
  9761. };
  9762. var lib$1 = {};
  9763. var identifier = {};
  9764. Object.defineProperty(identifier, "__esModule", {
  9765. value: true
  9766. });
  9767. identifier.isIdentifierStart = isIdentifierStart;
  9768. identifier.isIdentifierChar = isIdentifierChar;
  9769. identifier.isIdentifierName = isIdentifierName$1;
  9770. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  9771. let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
  9772. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  9773. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  9774. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  9775. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1070, 4050, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 46, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 482, 44, 11, 6, 17, 0, 322, 29, 19, 43, 1269, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4152, 8, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
  9776. const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  9777. function isInAstralSet(code, set) {
  9778. let pos = 0x10000;
  9779. for (let i = 0, length = set.length; i < length; i += 2) {
  9780. pos += set[i];
  9781. if (pos > code) return false;
  9782. pos += set[i + 1];
  9783. if (pos >= code) return true;
  9784. }
  9785. return false;
  9786. }
  9787. function isIdentifierStart(code) {
  9788. if (code < 65) return code === 36;
  9789. if (code <= 90) return true;
  9790. if (code < 97) return code === 95;
  9791. if (code <= 122) return true;
  9792. if (code <= 0xffff) {
  9793. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  9794. }
  9795. return isInAstralSet(code, astralIdentifierStartCodes);
  9796. }
  9797. function isIdentifierChar(code) {
  9798. if (code < 48) return code === 36;
  9799. if (code < 58) return true;
  9800. if (code < 65) return false;
  9801. if (code <= 90) return true;
  9802. if (code < 97) return code === 95;
  9803. if (code <= 122) return true;
  9804. if (code <= 0xffff) {
  9805. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  9806. }
  9807. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  9808. }
  9809. function isIdentifierName$1(name) {
  9810. let isFirst = true;
  9811. for (let i = 0; i < name.length; i++) {
  9812. let cp = name.charCodeAt(i);
  9813. if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
  9814. const trail = name.charCodeAt(++i);
  9815. if ((trail & 0xfc00) === 0xdc00) {
  9816. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  9817. }
  9818. }
  9819. if (isFirst) {
  9820. isFirst = false;
  9821. if (!isIdentifierStart(cp)) {
  9822. return false;
  9823. }
  9824. } else if (!isIdentifierChar(cp)) {
  9825. return false;
  9826. }
  9827. }
  9828. return !isFirst;
  9829. }
  9830. var keyword$1 = {};
  9831. Object.defineProperty(keyword$1, "__esModule", {
  9832. value: true
  9833. });
  9834. keyword$1.isReservedWord = isReservedWord;
  9835. keyword$1.isStrictReservedWord = isStrictReservedWord;
  9836. keyword$1.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
  9837. keyword$1.isStrictBindReservedWord = isStrictBindReservedWord;
  9838. keyword$1.isKeyword = isKeyword;
  9839. const reservedWords = {
  9840. keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
  9841. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  9842. strictBind: ["eval", "arguments"]
  9843. };
  9844. const keywords$1 = new Set(reservedWords.keyword);
  9845. const reservedWordsStrictSet = new Set(reservedWords.strict);
  9846. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  9847. function isReservedWord(word, inModule) {
  9848. return inModule && word === "await" || word === "enum";
  9849. }
  9850. function isStrictReservedWord(word, inModule) {
  9851. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  9852. }
  9853. function isStrictBindOnlyReservedWord(word) {
  9854. return reservedWordsStrictBindSet.has(word);
  9855. }
  9856. function isStrictBindReservedWord(word, inModule) {
  9857. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  9858. }
  9859. function isKeyword(word) {
  9860. return keywords$1.has(word);
  9861. }
  9862. (function (exports) {
  9863. Object.defineProperty(exports, "__esModule", {
  9864. value: true
  9865. });
  9866. Object.defineProperty(exports, "isIdentifierName", {
  9867. enumerable: true,
  9868. get: function () {
  9869. return _identifier.isIdentifierName;
  9870. }
  9871. });
  9872. Object.defineProperty(exports, "isIdentifierChar", {
  9873. enumerable: true,
  9874. get: function () {
  9875. return _identifier.isIdentifierChar;
  9876. }
  9877. });
  9878. Object.defineProperty(exports, "isIdentifierStart", {
  9879. enumerable: true,
  9880. get: function () {
  9881. return _identifier.isIdentifierStart;
  9882. }
  9883. });
  9884. Object.defineProperty(exports, "isReservedWord", {
  9885. enumerable: true,
  9886. get: function () {
  9887. return _keyword.isReservedWord;
  9888. }
  9889. });
  9890. Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
  9891. enumerable: true,
  9892. get: function () {
  9893. return _keyword.isStrictBindOnlyReservedWord;
  9894. }
  9895. });
  9896. Object.defineProperty(exports, "isStrictBindReservedWord", {
  9897. enumerable: true,
  9898. get: function () {
  9899. return _keyword.isStrictBindReservedWord;
  9900. }
  9901. });
  9902. Object.defineProperty(exports, "isStrictReservedWord", {
  9903. enumerable: true,
  9904. get: function () {
  9905. return _keyword.isStrictReservedWord;
  9906. }
  9907. });
  9908. Object.defineProperty(exports, "isKeyword", {
  9909. enumerable: true,
  9910. get: function () {
  9911. return _keyword.isKeyword;
  9912. }
  9913. });
  9914. var _identifier = identifier;
  9915. var _keyword = keyword$1;
  9916. })(lib$1);
  9917. var chalk = {exports: {}};
  9918. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  9919. var escapeStringRegexp = function (str) {
  9920. if (typeof str !== 'string') {
  9921. throw new TypeError('Expected a string');
  9922. }
  9923. return str.replace(matchOperatorsRe, '\\$&');
  9924. };
  9925. var hasFlag$1 = (flag, argv) => {
  9926. argv = argv || process.argv;
  9927. const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  9928. const pos = argv.indexOf(prefix + flag);
  9929. const terminatorPos = argv.indexOf('--');
  9930. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  9931. };
  9932. const os$2 = require$$0__default$1["default"];
  9933. const hasFlag = hasFlag$1;
  9934. const env = process.env;
  9935. let forceColor;
  9936. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  9937. forceColor = false;
  9938. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  9939. forceColor = true;
  9940. }
  9941. if ('FORCE_COLOR' in env) {
  9942. forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
  9943. }
  9944. function translateLevel(level) {
  9945. if (level === 0) {
  9946. return false;
  9947. }
  9948. return {
  9949. level,
  9950. hasBasic: true,
  9951. has256: level >= 2,
  9952. has16m: level >= 3
  9953. };
  9954. }
  9955. function supportsColor(stream) {
  9956. if (forceColor === false) {
  9957. return 0;
  9958. }
  9959. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  9960. return 3;
  9961. }
  9962. if (hasFlag('color=256')) {
  9963. return 2;
  9964. }
  9965. if (stream && !stream.isTTY && forceColor !== true) {
  9966. return 0;
  9967. }
  9968. const min = forceColor ? 1 : 0;
  9969. if (process.platform === 'win32') {
  9970. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  9971. // libuv that enables 256 color output on Windows. Anything earlier and it
  9972. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  9973. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  9974. // release that supports 256 colors. Windows 10 build 14931 is the first release
  9975. // that supports 16m/TrueColor.
  9976. const osRelease = os$2.release().split('.');
  9977. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  9978. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  9979. }
  9980. return 1;
  9981. }
  9982. if ('CI' in env) {
  9983. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
  9984. return 1;
  9985. }
  9986. return min;
  9987. }
  9988. if ('TEAMCITY_VERSION' in env) {
  9989. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  9990. }
  9991. if (env.COLORTERM === 'truecolor') {
  9992. return 3;
  9993. }
  9994. if ('TERM_PROGRAM' in env) {
  9995. const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  9996. switch (env.TERM_PROGRAM) {
  9997. case 'iTerm.app':
  9998. return version >= 3 ? 3 : 2;
  9999. case 'Apple_Terminal':
  10000. return 2;
  10001. // No default
  10002. }
  10003. }
  10004. if (/-256(color)?$/i.test(env.TERM)) {
  10005. return 2;
  10006. }
  10007. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  10008. return 1;
  10009. }
  10010. if ('COLORTERM' in env) {
  10011. return 1;
  10012. }
  10013. if (env.TERM === 'dumb') {
  10014. return min;
  10015. }
  10016. return min;
  10017. }
  10018. function getSupportLevel(stream) {
  10019. const level = supportsColor(stream);
  10020. return translateLevel(level);
  10021. }
  10022. var supportsColor_1 = {
  10023. supportsColor: getSupportLevel,
  10024. stdout: getSupportLevel(process.stdout),
  10025. stderr: getSupportLevel(process.stderr)
  10026. };
  10027. const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  10028. const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  10029. const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  10030. const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  10031. const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  10032. function unescape(c) {
  10033. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  10034. return String.fromCharCode(parseInt(c.slice(1), 16));
  10035. }
  10036. return ESCAPES.get(c) || c;
  10037. }
  10038. function parseArguments(name, args) {
  10039. const results = [];
  10040. const chunks = args.trim().split(/\s*,\s*/g);
  10041. let matches;
  10042. for (const chunk of chunks) {
  10043. if (!isNaN(chunk)) {
  10044. results.push(Number(chunk));
  10045. } else if (matches = chunk.match(STRING_REGEX$1)) {
  10046. results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
  10047. } else {
  10048. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  10049. }
  10050. }
  10051. return results;
  10052. }
  10053. function parseStyle(style) {
  10054. STYLE_REGEX.lastIndex = 0;
  10055. const results = [];
  10056. let matches;
  10057. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  10058. const name = matches[1];
  10059. if (matches[2]) {
  10060. const args = parseArguments(name, matches[2]);
  10061. results.push([name].concat(args));
  10062. } else {
  10063. results.push([name]);
  10064. }
  10065. }
  10066. return results;
  10067. }
  10068. function buildStyle(chalk, styles) {
  10069. const enabled = {};
  10070. for (const layer of styles) {
  10071. for (const style of layer.styles) {
  10072. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  10073. }
  10074. }
  10075. let current = chalk;
  10076. for (const styleName of Object.keys(enabled)) {
  10077. if (Array.isArray(enabled[styleName])) {
  10078. if (!(styleName in current)) {
  10079. throw new Error(`Unknown Chalk style: ${styleName}`);
  10080. }
  10081. if (enabled[styleName].length > 0) {
  10082. current = current[styleName].apply(current, enabled[styleName]);
  10083. } else {
  10084. current = current[styleName];
  10085. }
  10086. }
  10087. }
  10088. return current;
  10089. }
  10090. var templates = (chalk, tmp) => {
  10091. const styles = [];
  10092. const chunks = [];
  10093. let chunk = []; // eslint-disable-next-line max-params
  10094. tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
  10095. if (escapeChar) {
  10096. chunk.push(unescape(escapeChar));
  10097. } else if (style) {
  10098. const str = chunk.join('');
  10099. chunk = [];
  10100. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  10101. styles.push({
  10102. inverse,
  10103. styles: parseStyle(style)
  10104. });
  10105. } else if (close) {
  10106. if (styles.length === 0) {
  10107. throw new Error('Found extraneous } in Chalk template literal');
  10108. }
  10109. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  10110. chunk = [];
  10111. styles.pop();
  10112. } else {
  10113. chunk.push(chr);
  10114. }
  10115. });
  10116. chunks.push(chunk.join(''));
  10117. if (styles.length > 0) {
  10118. const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  10119. throw new Error(errMsg);
  10120. }
  10121. return chunks.join('');
  10122. };
  10123. (function (module) {
  10124. const escapeStringRegexp$1 = escapeStringRegexp;
  10125. const ansiStyles = ansiStyles$2.exports;
  10126. const stdoutColor = supportsColor_1.stdout;
  10127. const template = templates;
  10128. const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  10129. const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  10130. const skipModels = new Set(['gray']);
  10131. const styles = Object.create(null);
  10132. function applyOptions(obj, options) {
  10133. options = options || {}; // Detect level if not set manually
  10134. const scLevel = stdoutColor ? stdoutColor.level : 0;
  10135. obj.level = options.level === undefined ? scLevel : options.level;
  10136. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  10137. }
  10138. function Chalk(options) {
  10139. // We check for this.template here since calling `chalk.constructor()`
  10140. // by itself will have a `this` of a previously constructed chalk object
  10141. if (!this || !(this instanceof Chalk) || this.template) {
  10142. const chalk = {};
  10143. applyOptions(chalk, options);
  10144. chalk.template = function () {
  10145. const args = [].slice.call(arguments);
  10146. return chalkTag.apply(null, [chalk.template].concat(args));
  10147. };
  10148. Object.setPrototypeOf(chalk, Chalk.prototype);
  10149. Object.setPrototypeOf(chalk.template, chalk);
  10150. chalk.template.constructor = Chalk;
  10151. return chalk.template;
  10152. }
  10153. applyOptions(this, options);
  10154. } // Use bright blue on Windows as the normal blue color is illegible
  10155. if (isSimpleWindowsTerm) {
  10156. ansiStyles.blue.open = '\u001B[94m';
  10157. }
  10158. for (const key of Object.keys(ansiStyles)) {
  10159. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles[key].close), 'g');
  10160. styles[key] = {
  10161. get() {
  10162. const codes = ansiStyles[key];
  10163. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  10164. }
  10165. };
  10166. }
  10167. styles.visible = {
  10168. get() {
  10169. return build.call(this, this._styles || [], true, 'visible');
  10170. }
  10171. };
  10172. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.color.close), 'g');
  10173. for (const model of Object.keys(ansiStyles.color.ansi)) {
  10174. if (skipModels.has(model)) {
  10175. continue;
  10176. }
  10177. styles[model] = {
  10178. get() {
  10179. const level = this.level;
  10180. return function () {
  10181. const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  10182. const codes = {
  10183. open,
  10184. close: ansiStyles.color.close,
  10185. closeRe: ansiStyles.color.closeRe
  10186. };
  10187. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10188. };
  10189. }
  10190. };
  10191. }
  10192. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles.bgColor.close), 'g');
  10193. for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
  10194. if (skipModels.has(model)) {
  10195. continue;
  10196. }
  10197. const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  10198. styles[bgModel] = {
  10199. get() {
  10200. const level = this.level;
  10201. return function () {
  10202. const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  10203. const codes = {
  10204. open,
  10205. close: ansiStyles.bgColor.close,
  10206. closeRe: ansiStyles.bgColor.closeRe
  10207. };
  10208. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10209. };
  10210. }
  10211. };
  10212. }
  10213. const proto = Object.defineProperties(() => {}, styles);
  10214. function build(_styles, _empty, key) {
  10215. const builder = function () {
  10216. return applyStyle.apply(builder, arguments);
  10217. };
  10218. builder._styles = _styles;
  10219. builder._empty = _empty;
  10220. const self = this;
  10221. Object.defineProperty(builder, 'level', {
  10222. enumerable: true,
  10223. get() {
  10224. return self.level;
  10225. },
  10226. set(level) {
  10227. self.level = level;
  10228. }
  10229. });
  10230. Object.defineProperty(builder, 'enabled', {
  10231. enumerable: true,
  10232. get() {
  10233. return self.enabled;
  10234. },
  10235. set(enabled) {
  10236. self.enabled = enabled;
  10237. }
  10238. }); // See below for fix regarding invisible grey/dim combination on Windows
  10239. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  10240. // no way to create a function with a different prototype
  10241. builder.__proto__ = proto; // eslint-disable-line no-proto
  10242. return builder;
  10243. }
  10244. function applyStyle() {
  10245. // Support varags, but simply cast to string in case there's only one arg
  10246. const args = arguments;
  10247. const argsLen = args.length;
  10248. let str = String(arguments[0]);
  10249. if (argsLen === 0) {
  10250. return '';
  10251. }
  10252. if (argsLen > 1) {
  10253. // Don't slice `arguments`, it prevents V8 optimizations
  10254. for (let a = 1; a < argsLen; a++) {
  10255. str += ' ' + args[a];
  10256. }
  10257. }
  10258. if (!this.enabled || this.level <= 0 || !str) {
  10259. return this._empty ? '' : str;
  10260. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  10261. // see https://github.com/chalk/chalk/issues/58
  10262. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  10263. const originalDim = ansiStyles.dim.open;
  10264. if (isSimpleWindowsTerm && this.hasGrey) {
  10265. ansiStyles.dim.open = '';
  10266. }
  10267. for (const code of this._styles.slice().reverse()) {
  10268. // Replace any instances already present with a re-opening code
  10269. // otherwise only the part of the string until said closing code
  10270. // will be colored, and the rest will simply be 'plain'.
  10271. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  10272. // after next line to fix a bleed issue on macOS
  10273. // https://github.com/chalk/chalk/pull/92
  10274. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  10275. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  10276. ansiStyles.dim.open = originalDim;
  10277. return str;
  10278. }
  10279. function chalkTag(chalk, strings) {
  10280. if (!Array.isArray(strings)) {
  10281. // If chalk() was called by itself or with a string,
  10282. // return the string itself as a string.
  10283. return [].slice.call(arguments, 1).join(' ');
  10284. }
  10285. const args = [].slice.call(arguments, 2);
  10286. const parts = [strings.raw[0]];
  10287. for (let i = 1; i < strings.length; i++) {
  10288. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  10289. parts.push(String(strings.raw[i]));
  10290. }
  10291. return template(chalk, parts.join(''));
  10292. }
  10293. Object.defineProperties(Chalk.prototype, styles);
  10294. module.exports = Chalk(); // eslint-disable-line new-cap
  10295. module.exports.supportsColor = stdoutColor;
  10296. module.exports.default = module.exports; // For TypeScript
  10297. })(chalk);
  10298. Object.defineProperty(lib$2, "__esModule", {
  10299. value: true
  10300. });
  10301. lib$2.default = highlight;
  10302. lib$2.getChalk = getChalk;
  10303. lib$2.shouldHighlight = shouldHighlight;
  10304. var _jsTokens = jsTokens;
  10305. var _helperValidatorIdentifier = lib$1;
  10306. var _chalk = chalk.exports;
  10307. const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
  10308. function getDefs$1(chalk) {
  10309. return {
  10310. keyword: chalk.cyan,
  10311. capitalized: chalk.yellow,
  10312. jsxIdentifier: chalk.yellow,
  10313. punctuator: chalk.yellow,
  10314. number: chalk.magenta,
  10315. string: chalk.green,
  10316. regex: chalk.magenta,
  10317. comment: chalk.grey,
  10318. invalid: chalk.white.bgRed.bold
  10319. };
  10320. }
  10321. const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
  10322. const BRACKET = /^[()[\]{}]$/;
  10323. let tokenize;
  10324. {
  10325. const JSX_TAG = /^[a-z][\w-]*$/i;
  10326. const getTokenType = function (token, offset, text) {
  10327. if (token.type === "name") {
  10328. if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
  10329. return "keyword";
  10330. }
  10331. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  10332. return "jsxIdentifier";
  10333. }
  10334. if (token.value[0] !== token.value[0].toLowerCase()) {
  10335. return "capitalized";
  10336. }
  10337. }
  10338. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  10339. return "bracket";
  10340. }
  10341. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  10342. return "punctuator";
  10343. }
  10344. return token.type;
  10345. };
  10346. tokenize = function* (text) {
  10347. let match;
  10348. while (match = _jsTokens.default.exec(text)) {
  10349. const token = _jsTokens.matchToToken(match);
  10350. yield {
  10351. type: getTokenType(token, match.index, text),
  10352. value: token.value
  10353. };
  10354. }
  10355. };
  10356. }
  10357. function highlightTokens(defs, text) {
  10358. let highlighted = "";
  10359. for (const {
  10360. type,
  10361. value
  10362. } of tokenize(text)) {
  10363. const colorize = defs[type];
  10364. if (colorize) {
  10365. highlighted += value.split(NEWLINE$1).map(str => colorize(str)).join("\n");
  10366. } else {
  10367. highlighted += value;
  10368. }
  10369. }
  10370. return highlighted;
  10371. }
  10372. function shouldHighlight(options) {
  10373. return !!_chalk.supportsColor || options.forceColor;
  10374. }
  10375. function getChalk(options) {
  10376. return options.forceColor ? new _chalk.constructor({
  10377. enabled: true,
  10378. level: 1
  10379. }) : _chalk;
  10380. }
  10381. function highlight(code, options = {}) {
  10382. if (shouldHighlight(options)) {
  10383. const chalk = getChalk(options);
  10384. const defs = getDefs$1(chalk);
  10385. return highlightTokens(defs, code);
  10386. } else {
  10387. return code;
  10388. }
  10389. }
  10390. Object.defineProperty(lib$3, "__esModule", {
  10391. value: true
  10392. });
  10393. lib$3.codeFrameColumns = codeFrameColumns;
  10394. lib$3.default = _default;
  10395. var _highlight = lib$2;
  10396. let deprecationWarningShown = false;
  10397. function getDefs(chalk) {
  10398. return {
  10399. gutter: chalk.grey,
  10400. marker: chalk.red.bold,
  10401. message: chalk.red.bold
  10402. };
  10403. }
  10404. const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10405. function getMarkerLines(loc, source, opts) {
  10406. const startLoc = Object.assign({
  10407. column: 0,
  10408. line: -1
  10409. }, loc.start);
  10410. const endLoc = Object.assign({}, startLoc, loc.end);
  10411. const {
  10412. linesAbove = 2,
  10413. linesBelow = 3
  10414. } = opts || {};
  10415. const startLine = startLoc.line;
  10416. const startColumn = startLoc.column;
  10417. const endLine = endLoc.line;
  10418. const endColumn = endLoc.column;
  10419. let start = Math.max(startLine - (linesAbove + 1), 0);
  10420. let end = Math.min(source.length, endLine + linesBelow);
  10421. if (startLine === -1) {
  10422. start = 0;
  10423. }
  10424. if (endLine === -1) {
  10425. end = source.length;
  10426. }
  10427. const lineDiff = endLine - startLine;
  10428. const markerLines = {};
  10429. if (lineDiff) {
  10430. for (let i = 0; i <= lineDiff; i++) {
  10431. const lineNumber = i + startLine;
  10432. if (!startColumn) {
  10433. markerLines[lineNumber] = true;
  10434. } else if (i === 0) {
  10435. const sourceLength = source[lineNumber - 1].length;
  10436. markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
  10437. } else if (i === lineDiff) {
  10438. markerLines[lineNumber] = [0, endColumn];
  10439. } else {
  10440. const sourceLength = source[lineNumber - i].length;
  10441. markerLines[lineNumber] = [0, sourceLength];
  10442. }
  10443. }
  10444. } else {
  10445. if (startColumn === endColumn) {
  10446. if (startColumn) {
  10447. markerLines[startLine] = [startColumn, 0];
  10448. } else {
  10449. markerLines[startLine] = true;
  10450. }
  10451. } else {
  10452. markerLines[startLine] = [startColumn, endColumn - startColumn];
  10453. }
  10454. }
  10455. return {
  10456. start,
  10457. end,
  10458. markerLines
  10459. };
  10460. }
  10461. function codeFrameColumns(rawLines, loc, opts = {}) {
  10462. const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
  10463. const chalk = (0, _highlight.getChalk)(opts);
  10464. const defs = getDefs(chalk);
  10465. const maybeHighlight = (chalkFn, string) => {
  10466. return highlighted ? chalkFn(string) : string;
  10467. };
  10468. const lines = rawLines.split(NEWLINE);
  10469. const {
  10470. start,
  10471. end,
  10472. markerLines
  10473. } = getMarkerLines(loc, lines, opts);
  10474. const hasColumns = loc.start && typeof loc.start.column === "number";
  10475. const numberMaxWidth = String(end).length;
  10476. const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
  10477. let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
  10478. const number = start + 1 + index;
  10479. const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
  10480. const gutter = ` ${paddedNumber} |`;
  10481. const hasMarker = markerLines[number];
  10482. const lastMarkerLine = !markerLines[number + 1];
  10483. if (hasMarker) {
  10484. let markerLine = "";
  10485. if (Array.isArray(hasMarker)) {
  10486. const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  10487. const numberOfMarkers = hasMarker[1] || 1;
  10488. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  10489. if (lastMarkerLine && opts.message) {
  10490. markerLine += " " + maybeHighlight(defs.message, opts.message);
  10491. }
  10492. }
  10493. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
  10494. } else {
  10495. return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
  10496. }
  10497. }).join("\n");
  10498. if (opts.message && !hasColumns) {
  10499. frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
  10500. }
  10501. if (highlighted) {
  10502. return chalk.reset(frame);
  10503. } else {
  10504. return frame;
  10505. }
  10506. }
  10507. function _default(rawLines, lineNumber, colNumber, opts = {}) {
  10508. if (!deprecationWarningShown) {
  10509. deprecationWarningShown = true;
  10510. const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  10511. if (process.emitWarning) {
  10512. process.emitWarning(message, "DeprecationWarning");
  10513. } else {
  10514. const deprecationError = new Error(message);
  10515. deprecationError.name = "DeprecationWarning";
  10516. console.warn(new Error(message));
  10517. }
  10518. }
  10519. colNumber = Math.max(colNumber, 0);
  10520. const location = {
  10521. start: {
  10522. column: colNumber,
  10523. line: lineNumber
  10524. }
  10525. };
  10526. return codeFrameColumns(rawLines, location, opts);
  10527. }
  10528. const path$q = require$$0__default$2["default"];
  10529. const {
  10530. ConfigError
  10531. } = errors;
  10532. const jsLoc = loc$6;
  10533. const {
  10534. locStart: locStart$r,
  10535. locEnd: locEnd$q
  10536. } = jsLoc; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  10537. // triggering the parsers getters.
  10538. const ownNames = Object.getOwnPropertyNames;
  10539. const ownDescriptor = Object.getOwnPropertyDescriptor;
  10540. function getParsers(options) {
  10541. const parsers = {};
  10542. for (const plugin of options.plugins) {
  10543. // TODO: test this with plugins
  10544. /* istanbul ignore next */
  10545. if (!plugin.parsers) {
  10546. continue;
  10547. }
  10548. for (const name of ownNames(plugin.parsers)) {
  10549. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  10550. }
  10551. }
  10552. return parsers;
  10553. }
  10554. function resolveParser$1(opts, parsers = getParsers(opts)) {
  10555. if (typeof opts.parser === "function") {
  10556. // Custom parser API always works with JavaScript.
  10557. return {
  10558. parse: opts.parser,
  10559. astFormat: "estree",
  10560. locStart: locStart$r,
  10561. locEnd: locEnd$q
  10562. };
  10563. }
  10564. if (typeof opts.parser === "string") {
  10565. if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) {
  10566. return parsers[opts.parser];
  10567. }
  10568. try {
  10569. return {
  10570. parse: require(path$q.resolve(process.cwd(), opts.parser)),
  10571. astFormat: "estree",
  10572. locStart: locStart$r,
  10573. locEnd: locEnd$q
  10574. };
  10575. } catch {
  10576. /* istanbul ignore next */
  10577. throw new ConfigError(`Couldn't resolve parser "${opts.parser}"`);
  10578. }
  10579. }
  10580. }
  10581. function parse$d(text, opts) {
  10582. const parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  10583. // the parsers getters when actually calling the parser `parse` function.
  10584. const parsersForCustomParserApi = Object.defineProperties({}, Object.fromEntries(Object.keys(parsers).map(parserName => [parserName, {
  10585. enumerable: true,
  10586. get() {
  10587. return parsers[parserName].parse;
  10588. }
  10589. }])));
  10590. const parser = resolveParser$1(opts, parsers);
  10591. try {
  10592. if (parser.preprocess) {
  10593. text = parser.preprocess(text, opts);
  10594. }
  10595. return {
  10596. text,
  10597. ast: parser.parse(text, parsersForCustomParserApi, opts)
  10598. };
  10599. } catch (error) {
  10600. const {
  10601. loc
  10602. } = error;
  10603. if (loc) {
  10604. const {
  10605. codeFrameColumns
  10606. } = lib$3;
  10607. error.codeFrame = codeFrameColumns(text, loc, {
  10608. highlightCode: true
  10609. });
  10610. error.message += "\n" + error.codeFrame;
  10611. throw error;
  10612. }
  10613. /* istanbul ignore next */
  10614. throw error.stack;
  10615. }
  10616. }
  10617. var parser$2 = {
  10618. parse: parse$d,
  10619. resolveParser: resolveParser$1
  10620. };
  10621. const fs$k = require$$0__default["default"];
  10622. const path$p = require$$0__default$2["default"];
  10623. const readlines = readlines$1;
  10624. const {
  10625. UndefinedParserError
  10626. } = errors;
  10627. const {
  10628. getSupportInfo: getSupportInfo$1
  10629. } = support;
  10630. const normalizer = optionsNormalizer;
  10631. const {
  10632. resolveParser
  10633. } = parser$2;
  10634. const hiddenDefaults = {
  10635. astFormat: "estree",
  10636. printer: {},
  10637. originalText: undefined,
  10638. locStart: null,
  10639. locEnd: null
  10640. }; // Copy options and fill in default values.
  10641. function normalize$1(options, opts = {}) {
  10642. const rawOptions = Object.assign({}, options);
  10643. const supportOptions = getSupportInfo$1({
  10644. plugins: options.plugins,
  10645. showUnreleased: true,
  10646. showDeprecated: true
  10647. }).options;
  10648. const defaults = Object.assign(Object.assign({}, hiddenDefaults), Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.default !== undefined).map(option => [option.name, option.default])));
  10649. if (!rawOptions.parser) {
  10650. if (!rawOptions.filepath) {
  10651. const logger = opts.logger || console;
  10652. 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.");
  10653. rawOptions.parser = "babel";
  10654. } else {
  10655. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  10656. if (!rawOptions.parser) {
  10657. throw new UndefinedParserError(`No parser could be inferred for file: ${rawOptions.filepath}`);
  10658. }
  10659. }
  10660. }
  10661. const parser = resolveParser(normalizer.normalizeApiOptions(rawOptions, [supportOptions.find(x => x.name === "parser")], {
  10662. passThrough: true,
  10663. logger: false
  10664. }));
  10665. rawOptions.astFormat = parser.astFormat;
  10666. rawOptions.locEnd = parser.locEnd;
  10667. rawOptions.locStart = parser.locStart;
  10668. const plugin = getPlugin(rawOptions);
  10669. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  10670. const pluginDefaults = Object.fromEntries(supportOptions.filter(optionInfo => optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined).map(optionInfo => [optionInfo.name, optionInfo.pluginDefaults[plugin.name]]));
  10671. const mixedDefaults = Object.assign(Object.assign({}, defaults), pluginDefaults);
  10672. for (const [k, value] of Object.entries(mixedDefaults)) {
  10673. if (rawOptions[k] === null || rawOptions[k] === undefined) {
  10674. rawOptions[k] = value;
  10675. }
  10676. }
  10677. if (rawOptions.parser === "json") {
  10678. rawOptions.trailingComma = "none";
  10679. }
  10680. return normalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  10681. passThrough: Object.keys(hiddenDefaults)
  10682. }, opts));
  10683. }
  10684. function getPlugin(options) {
  10685. const {
  10686. astFormat
  10687. } = options; // TODO: test this with plugins
  10688. /* istanbul ignore next */
  10689. if (!astFormat) {
  10690. throw new Error("getPlugin() requires astFormat to be set");
  10691. }
  10692. const printerPlugin = options.plugins.find(plugin => plugin.printers && plugin.printers[astFormat]); // TODO: test this with plugins
  10693. /* istanbul ignore next */
  10694. if (!printerPlugin) {
  10695. throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
  10696. }
  10697. return printerPlugin;
  10698. }
  10699. function getInterpreter(filepath) {
  10700. /* istanbul ignore next */
  10701. if (typeof filepath !== "string") {
  10702. return "";
  10703. }
  10704. let fd;
  10705. try {
  10706. fd = fs$k.openSync(filepath, "r");
  10707. } catch {
  10708. // istanbul ignore next
  10709. return "";
  10710. }
  10711. try {
  10712. const liner = new readlines(fd);
  10713. const firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  10714. const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  10715. if (m1) {
  10716. return m1[1];
  10717. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  10718. const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  10719. if (m2) {
  10720. return m2[1];
  10721. }
  10722. return "";
  10723. } catch {
  10724. // There are some weird cases where paths are missing, causing Jest
  10725. // failures. It's unclear what these correspond to in the real world.
  10726. /* istanbul ignore next */
  10727. return "";
  10728. } finally {
  10729. try {
  10730. // There are some weird cases where paths are missing, causing Jest
  10731. // failures. It's unclear what these correspond to in the real world.
  10732. fs$k.closeSync(fd);
  10733. } catch {// nop
  10734. }
  10735. }
  10736. }
  10737. function inferParser(filepath, plugins) {
  10738. const filename = path$p.basename(filepath).toLowerCase();
  10739. const languages = getSupportInfo$1({
  10740. plugins
  10741. }).languages.filter(language => language.since !== null); // If the file has no extension, we can try to infer the language from the
  10742. // interpreter in the shebang line, if any; but since this requires FS access,
  10743. // do it last.
  10744. let language = languages.find(language => language.extensions && language.extensions.some(extension => filename.endsWith(extension)) || language.filenames && language.filenames.some(name => name.toLowerCase() === filename));
  10745. if (!language && !filename.includes(".")) {
  10746. const interpreter = getInterpreter(filepath);
  10747. language = languages.find(language => language.interpreters && language.interpreters.includes(interpreter));
  10748. }
  10749. return language && language.parsers[0];
  10750. }
  10751. var options$d = {
  10752. normalize: normalize$1,
  10753. hiddenDefaults,
  10754. inferParser
  10755. };
  10756. function massageAST$1(ast, options, parent) {
  10757. if (Array.isArray(ast)) {
  10758. return ast.map(e => massageAST$1(e, options, parent)).filter(Boolean);
  10759. }
  10760. if (!ast || typeof ast !== "object") {
  10761. return ast;
  10762. }
  10763. const cleanFunction = options.printer.massageAstNode;
  10764. let ignoredProperties;
  10765. if (cleanFunction && cleanFunction.ignoredProperties) {
  10766. ignoredProperties = cleanFunction.ignoredProperties;
  10767. } else {
  10768. ignoredProperties = new Set();
  10769. }
  10770. const newObj = {};
  10771. for (const [key, value] of Object.entries(ast)) {
  10772. if (!ignoredProperties.has(key) && typeof value !== "function") {
  10773. newObj[key] = massageAST$1(value, options, ast);
  10774. }
  10775. }
  10776. if (cleanFunction) {
  10777. const result = cleanFunction(ast, newObj, parent);
  10778. if (result === null) {
  10779. return;
  10780. }
  10781. if (result) {
  10782. return result;
  10783. }
  10784. }
  10785. return newObj;
  10786. }
  10787. var massageAst = massageAST$1;
  10788. const assert$6 = require$$0__default$3["default"];
  10789. const {
  10790. builders: {
  10791. line: line$A,
  10792. hardline: hardline$C,
  10793. breakParent: breakParent$a,
  10794. indent: indent$z,
  10795. lineSuffix: lineSuffix$1,
  10796. join: join$v,
  10797. cursor
  10798. }
  10799. } = require$$7$3;
  10800. const {
  10801. hasNewline: hasNewline$9,
  10802. skipNewline: skipNewline$1,
  10803. skipSpaces: skipSpaces$1,
  10804. isPreviousLineEmpty: isPreviousLineEmpty$2,
  10805. addLeadingComment: addLeadingComment$2,
  10806. addDanglingComment: addDanglingComment$2,
  10807. addTrailingComment: addTrailingComment$2
  10808. } = util$8;
  10809. const childNodesCache = new WeakMap();
  10810. function getSortedChildNodes(node, options, resultArray) {
  10811. if (!node) {
  10812. return;
  10813. }
  10814. const {
  10815. printer,
  10816. locStart,
  10817. locEnd
  10818. } = options;
  10819. if (resultArray) {
  10820. if (printer.canAttachComment && printer.canAttachComment(node)) {
  10821. // This reverse insertion sort almost always takes constant
  10822. // time because we almost always (maybe always?) append the
  10823. // nodes in order anyway.
  10824. let i;
  10825. for (i = resultArray.length - 1; i >= 0; --i) {
  10826. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  10827. break;
  10828. }
  10829. }
  10830. resultArray.splice(i + 1, 0, node);
  10831. return;
  10832. }
  10833. } else if (childNodesCache.has(node)) {
  10834. return childNodesCache.get(node);
  10835. }
  10836. const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === "object" && Object.entries(node).filter(([key]) => key !== "enclosingNode" && key !== "precedingNode" && key !== "followingNode" && key !== "tokens" && key !== "comments").map(([, value]) => value);
  10837. if (!childNodes) {
  10838. return;
  10839. }
  10840. if (!resultArray) {
  10841. resultArray = [];
  10842. childNodesCache.set(node, resultArray);
  10843. }
  10844. for (const childNode of childNodes) {
  10845. getSortedChildNodes(childNode, options, resultArray);
  10846. }
  10847. return resultArray;
  10848. } // As efficiently as possible, decorate the comment object with
  10849. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  10850. // least one of which is guaranteed to be defined.
  10851. function decorateComment(node, comment, options, enclosingNode) {
  10852. const {
  10853. locStart,
  10854. locEnd
  10855. } = options;
  10856. const commentStart = locStart(comment);
  10857. const commentEnd = locEnd(comment);
  10858. const childNodes = getSortedChildNodes(node, options);
  10859. let precedingNode;
  10860. let followingNode; // Time to dust off the old binary search robes and wizard hat.
  10861. let left = 0;
  10862. let right = childNodes.length;
  10863. while (left < right) {
  10864. const middle = left + right >> 1;
  10865. const child = childNodes[middle];
  10866. const start = locStart(child);
  10867. const end = locEnd(child); // The comment is completely contained by this child node.
  10868. if (start <= commentStart && commentEnd <= end) {
  10869. // Abandon the binary search at this level.
  10870. return decorateComment(child, comment, options, child);
  10871. }
  10872. if (end <= commentStart) {
  10873. // This child node falls completely before the comment.
  10874. // Because we will never consider this node or any nodes
  10875. // before it again, this node must be the closest preceding
  10876. // node we have encountered so far.
  10877. precedingNode = child;
  10878. left = middle + 1;
  10879. continue;
  10880. }
  10881. if (commentEnd <= start) {
  10882. // This child node falls completely after the comment.
  10883. // Because we will never consider this node or any nodes after
  10884. // it again, this node must be the closest following node we
  10885. // have encountered so far.
  10886. followingNode = child;
  10887. right = middle;
  10888. continue;
  10889. }
  10890. /* istanbul ignore next */
  10891. throw new Error("Comment location overlaps with node location");
  10892. } // We don't want comments inside of different expressions inside of the same
  10893. // template literal to move to another expression.
  10894. if (enclosingNode && enclosingNode.type === "TemplateLiteral") {
  10895. const {
  10896. quasis
  10897. } = enclosingNode;
  10898. const commentIndex = findExpressionIndexForComment(quasis, comment, options);
  10899. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  10900. precedingNode = null;
  10901. }
  10902. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  10903. followingNode = null;
  10904. }
  10905. }
  10906. return {
  10907. enclosingNode,
  10908. precedingNode,
  10909. followingNode
  10910. };
  10911. }
  10912. const returnFalse$1 = () => false;
  10913. function attach(comments, ast, text, options) {
  10914. if (!Array.isArray(comments)) {
  10915. return;
  10916. }
  10917. const tiesToBreak = [];
  10918. const {
  10919. locStart,
  10920. locEnd,
  10921. printer: {
  10922. handleComments = {}
  10923. }
  10924. } = options; // TODO: Make this as default behavior
  10925. const {
  10926. avoidAstMutation,
  10927. ownLine: handleOwnLineComment = returnFalse$1,
  10928. endOfLine: handleEndOfLineComment = returnFalse$1,
  10929. remaining: handleRemainingComment = returnFalse$1
  10930. } = handleComments;
  10931. const decoratedComments = comments.map((comment, index) => Object.assign(Object.assign({}, decorateComment(ast, comment, options)), {}, {
  10932. comment,
  10933. text,
  10934. options,
  10935. ast,
  10936. isLastComment: comments.length - 1 === index
  10937. }));
  10938. for (const [index, context] of decoratedComments.entries()) {
  10939. const {
  10940. comment,
  10941. precedingNode,
  10942. enclosingNode,
  10943. followingNode,
  10944. text,
  10945. options,
  10946. ast,
  10947. isLastComment
  10948. } = context;
  10949. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  10950. if (locStart(comment) - locStart(ast) <= 0) {
  10951. addLeadingComment$2(ast, comment);
  10952. continue;
  10953. }
  10954. if (locEnd(comment) - locEnd(ast) >= 0) {
  10955. addTrailingComment$2(ast, comment);
  10956. continue;
  10957. }
  10958. }
  10959. let args;
  10960. if (avoidAstMutation) {
  10961. args = [context];
  10962. } else {
  10963. comment.enclosingNode = enclosingNode;
  10964. comment.precedingNode = precedingNode;
  10965. comment.followingNode = followingNode;
  10966. args = [comment, text, options, ast, isLastComment];
  10967. }
  10968. if (isOwnLineComment(text, options, decoratedComments, index)) {
  10969. comment.placement = "ownLine"; // If a comment exists on its own line, prefer a leading comment.
  10970. // We also need to check if it's the first line of the file.
  10971. if (handleOwnLineComment(...args)) ; else if (followingNode) {
  10972. // Always a leading comment.
  10973. addLeadingComment$2(followingNode, comment);
  10974. } else if (precedingNode) {
  10975. addTrailingComment$2(precedingNode, comment);
  10976. } else if (enclosingNode) {
  10977. addDanglingComment$2(enclosingNode, comment);
  10978. } else {
  10979. // There are no nodes, let's attach it to the root of the ast
  10980. /* istanbul ignore next */
  10981. addDanglingComment$2(ast, comment);
  10982. }
  10983. } else if (isEndOfLineComment(text, options, decoratedComments, index)) {
  10984. comment.placement = "endOfLine";
  10985. if (handleEndOfLineComment(...args)) ; else if (precedingNode) {
  10986. // There is content before this comment on the same line, but
  10987. // none after it, so prefer a trailing comment of the previous node.
  10988. addTrailingComment$2(precedingNode, comment);
  10989. } else if (followingNode) {
  10990. addLeadingComment$2(followingNode, comment);
  10991. } else if (enclosingNode) {
  10992. addDanglingComment$2(enclosingNode, comment);
  10993. } else {
  10994. // There are no nodes, let's attach it to the root of the ast
  10995. /* istanbul ignore next */
  10996. addDanglingComment$2(ast, comment);
  10997. }
  10998. } else {
  10999. comment.placement = "remaining";
  11000. if (handleRemainingComment(...args)) ; else if (precedingNode && followingNode) {
  11001. // Otherwise, text exists both before and after the comment on
  11002. // the same line. If there is both a preceding and following
  11003. // node, use a tie-breaking algorithm to determine if it should
  11004. // be attached to the next or previous node. In the last case,
  11005. // simply attach the right node;
  11006. const tieCount = tiesToBreak.length;
  11007. if (tieCount > 0) {
  11008. const lastTie = tiesToBreak[tieCount - 1];
  11009. if (lastTie.followingNode !== followingNode) {
  11010. breakTies(tiesToBreak, text, options);
  11011. }
  11012. }
  11013. tiesToBreak.push(context);
  11014. } else if (precedingNode) {
  11015. addTrailingComment$2(precedingNode, comment);
  11016. } else if (followingNode) {
  11017. addLeadingComment$2(followingNode, comment);
  11018. } else if (enclosingNode) {
  11019. addDanglingComment$2(enclosingNode, comment);
  11020. } else {
  11021. // There are no nodes, let's attach it to the root of the ast
  11022. /* istanbul ignore next */
  11023. addDanglingComment$2(ast, comment);
  11024. }
  11025. }
  11026. }
  11027. breakTies(tiesToBreak, text, options);
  11028. if (!avoidAstMutation) {
  11029. for (const comment of comments) {
  11030. // These node references were useful for breaking ties, but we
  11031. // don't need them anymore, and they create cycles in the AST that
  11032. // may lead to infinite recursion if we don't delete them here.
  11033. delete comment.precedingNode;
  11034. delete comment.enclosingNode;
  11035. delete comment.followingNode;
  11036. }
  11037. }
  11038. }
  11039. const isAllEmptyAndNoLineBreak = text => !/[\S\n\u2028\u2029]/.test(text);
  11040. function isOwnLineComment(text, options, decoratedComments, commentIndex) {
  11041. const {
  11042. comment,
  11043. precedingNode
  11044. } = decoratedComments[commentIndex];
  11045. const {
  11046. locStart,
  11047. locEnd
  11048. } = options;
  11049. let start = locStart(comment);
  11050. if (precedingNode) {
  11051. // Find first comment on the same line
  11052. for (let index = commentIndex - 1; index >= 0; index--) {
  11053. const {
  11054. comment,
  11055. precedingNode: currentCommentPrecedingNode
  11056. } = decoratedComments[index];
  11057. if (currentCommentPrecedingNode !== precedingNode || !isAllEmptyAndNoLineBreak(text.slice(locEnd(comment), start))) {
  11058. break;
  11059. }
  11060. start = locStart(comment);
  11061. }
  11062. }
  11063. return hasNewline$9(text, start, {
  11064. backwards: true
  11065. });
  11066. }
  11067. function isEndOfLineComment(text, options, decoratedComments, commentIndex) {
  11068. const {
  11069. comment,
  11070. followingNode
  11071. } = decoratedComments[commentIndex];
  11072. const {
  11073. locStart,
  11074. locEnd
  11075. } = options;
  11076. let end = locEnd(comment);
  11077. if (followingNode) {
  11078. // Find last comment on the same line
  11079. for (let index = commentIndex + 1; index < decoratedComments.length; index++) {
  11080. const {
  11081. comment,
  11082. followingNode: currentCommentFollowingNode
  11083. } = decoratedComments[index];
  11084. if (currentCommentFollowingNode !== followingNode || !isAllEmptyAndNoLineBreak(text.slice(end, locStart(comment)))) {
  11085. break;
  11086. }
  11087. end = locEnd(comment);
  11088. }
  11089. }
  11090. return hasNewline$9(text, end);
  11091. }
  11092. function breakTies(tiesToBreak, text, options) {
  11093. const tieCount = tiesToBreak.length;
  11094. if (tieCount === 0) {
  11095. return;
  11096. }
  11097. const {
  11098. precedingNode,
  11099. followingNode,
  11100. enclosingNode
  11101. } = tiesToBreak[0];
  11102. const gapRegExp = options.printer.getGapRegex && options.printer.getGapRegex(enclosingNode) || /^[\s(]*$/;
  11103. let gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  11104. // between the tied comments. In order to qualify as leading, a
  11105. // comment must be separated from followingNode by an unbroken series of
  11106. // gaps (or other comments). Gaps should only contain whitespace or open
  11107. // parentheses.
  11108. let indexOfFirstLeadingComment;
  11109. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  11110. const {
  11111. comment,
  11112. precedingNode: currentCommentPrecedingNode,
  11113. followingNode: currentCommentFollowingNode
  11114. } = tiesToBreak[indexOfFirstLeadingComment - 1];
  11115. assert$6.strictEqual(currentCommentPrecedingNode, precedingNode);
  11116. assert$6.strictEqual(currentCommentFollowingNode, followingNode);
  11117. const gap = text.slice(options.locEnd(comment), gapEndPos);
  11118. if (gapRegExp.test(gap)) {
  11119. gapEndPos = options.locStart(comment);
  11120. } else {
  11121. // The gap string contained something other than whitespace or open
  11122. // parentheses.
  11123. break;
  11124. }
  11125. }
  11126. for (const [i, {
  11127. comment
  11128. }] of tiesToBreak.entries()) {
  11129. if (i < indexOfFirstLeadingComment) {
  11130. addTrailingComment$2(precedingNode, comment);
  11131. } else {
  11132. addLeadingComment$2(followingNode, comment);
  11133. }
  11134. }
  11135. for (const node of [precedingNode, followingNode]) {
  11136. if (node.comments && node.comments.length > 1) {
  11137. node.comments.sort((a, b) => options.locStart(a) - options.locStart(b));
  11138. }
  11139. }
  11140. tiesToBreak.length = 0;
  11141. }
  11142. function printComment$3(path, options) {
  11143. const comment = path.getValue();
  11144. comment.printed = true;
  11145. return options.printer.printComment(path, options);
  11146. }
  11147. function findExpressionIndexForComment(quasis, comment, options) {
  11148. const startPos = options.locStart(comment) - 1;
  11149. for (let i = 1; i < quasis.length; ++i) {
  11150. if (startPos < options.locStart(quasis[i])) {
  11151. return i - 1;
  11152. }
  11153. } // We haven't found it, it probably means that some of the locations are off.
  11154. // Let's just return the first one.
  11155. /* istanbul ignore next */
  11156. return 0;
  11157. }
  11158. function printLeadingComment(path, options) {
  11159. const comment = path.getValue();
  11160. const parts = [printComment$3(path, options)];
  11161. const {
  11162. printer,
  11163. originalText,
  11164. locStart,
  11165. locEnd
  11166. } = options;
  11167. const isBlock = printer.isBlockComment && printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  11168. // same line or not.
  11169. if (isBlock) {
  11170. const lineBreak = hasNewline$9(originalText, locEnd(comment)) ? hasNewline$9(originalText, locStart(comment), {
  11171. backwards: true
  11172. }) ? hardline$C : line$A : " ";
  11173. parts.push(lineBreak);
  11174. } else {
  11175. parts.push(hardline$C);
  11176. }
  11177. const index = skipNewline$1(originalText, skipSpaces$1(originalText, locEnd(comment)));
  11178. if (index !== false && hasNewline$9(originalText, index)) {
  11179. parts.push(hardline$C);
  11180. }
  11181. return parts;
  11182. }
  11183. function printTrailingComment(path, options) {
  11184. const comment = path.getValue();
  11185. const printed = printComment$3(path, options);
  11186. const {
  11187. printer,
  11188. originalText,
  11189. locStart
  11190. } = options;
  11191. const isBlock = printer.isBlockComment && printer.isBlockComment(comment);
  11192. if (hasNewline$9(originalText, locStart(comment), {
  11193. backwards: true
  11194. })) {
  11195. // This allows comments at the end of nested structures:
  11196. // {
  11197. // x: 1,
  11198. // y: 2
  11199. // // A comment
  11200. // }
  11201. // Those kinds of comments are almost always leading comments, but
  11202. // here it doesn't go "outside" the block and turns it into a
  11203. // trailing comment for `2`. We can simulate the above by checking
  11204. // if this a comment on its own line; normal trailing comments are
  11205. // always at the end of another expression.
  11206. const isLineBeforeEmpty = isPreviousLineEmpty$2(originalText, comment, locStart);
  11207. return lineSuffix$1([hardline$C, isLineBeforeEmpty ? hardline$C : "", printed]);
  11208. }
  11209. let parts = [" ", printed]; // Trailing block comments never need a newline
  11210. if (!isBlock) {
  11211. parts = [lineSuffix$1(parts), breakParent$a];
  11212. }
  11213. return parts;
  11214. }
  11215. function printDanglingComments$e(path, options, sameIndent, filter) {
  11216. const parts = [];
  11217. const node = path.getValue();
  11218. if (!node || !node.comments) {
  11219. return "";
  11220. }
  11221. path.each(() => {
  11222. const comment = path.getValue();
  11223. if (!comment.leading && !comment.trailing && (!filter || filter(comment))) {
  11224. parts.push(printComment$3(path, options));
  11225. }
  11226. }, "comments");
  11227. if (parts.length === 0) {
  11228. return "";
  11229. }
  11230. if (sameIndent) {
  11231. return join$v(hardline$C, parts);
  11232. }
  11233. return indent$z([hardline$C, join$v(hardline$C, parts)]);
  11234. }
  11235. function printCommentsSeparately$1(path, options, ignored) {
  11236. const value = path.getValue();
  11237. if (!value) {
  11238. return {};
  11239. }
  11240. let comments = value.comments || [];
  11241. if (ignored) {
  11242. comments = comments.filter(comment => !ignored.has(comment));
  11243. }
  11244. const isCursorNode = value === options.cursorNode;
  11245. if (comments.length === 0) {
  11246. const maybeCursor = isCursorNode ? cursor : "";
  11247. return {
  11248. leading: maybeCursor,
  11249. trailing: maybeCursor
  11250. };
  11251. }
  11252. const leadingParts = [];
  11253. const trailingParts = [];
  11254. path.each(() => {
  11255. const comment = path.getValue();
  11256. if (ignored && ignored.has(comment)) {
  11257. return;
  11258. }
  11259. const {
  11260. leading,
  11261. trailing
  11262. } = comment;
  11263. if (leading) {
  11264. leadingParts.push(printLeadingComment(path, options));
  11265. } else if (trailing) {
  11266. trailingParts.push(printTrailingComment(path, options));
  11267. }
  11268. }, "comments");
  11269. if (isCursorNode) {
  11270. leadingParts.unshift(cursor);
  11271. trailingParts.push(cursor);
  11272. }
  11273. return {
  11274. leading: leadingParts,
  11275. trailing: trailingParts
  11276. };
  11277. }
  11278. function printComments$7(path, doc, options, ignored) {
  11279. const {
  11280. leading,
  11281. trailing
  11282. } = printCommentsSeparately$1(path, options, ignored);
  11283. if (!leading && !trailing) {
  11284. return doc;
  11285. }
  11286. return [leading, doc, trailing];
  11287. }
  11288. function ensureAllCommentsPrinted(astComments) {
  11289. if (!astComments) {
  11290. return;
  11291. }
  11292. for (const comment of astComments) {
  11293. if (!comment.printed) {
  11294. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  11295. }
  11296. delete comment.printed;
  11297. }
  11298. }
  11299. var comments$4 = {
  11300. attach,
  11301. printComments: printComments$7,
  11302. printCommentsSeparately: printCommentsSeparately$1,
  11303. printDanglingComments: printDanglingComments$e,
  11304. getSortedChildNodes,
  11305. ensureAllCommentsPrinted
  11306. };
  11307. const getLast$m = getLast_1;
  11308. function getNodeHelper(path, count) {
  11309. const stackIndex = getNodeStackIndexHelper(path.stack, count);
  11310. return stackIndex === -1 ? null : path.stack[stackIndex];
  11311. }
  11312. function getNodeStackIndexHelper(stack, count) {
  11313. for (let i = stack.length - 1; i >= 0; i -= 2) {
  11314. const value = stack[i];
  11315. if (value && !Array.isArray(value) && --count < 0) {
  11316. return i;
  11317. }
  11318. }
  11319. return -1;
  11320. }
  11321. class AstPath$1 {
  11322. constructor(value) {
  11323. this.stack = [value];
  11324. } // The name of the current property is always the penultimate element of
  11325. // this.stack, and always a String.
  11326. getName() {
  11327. const {
  11328. stack
  11329. } = this;
  11330. const {
  11331. length
  11332. } = stack;
  11333. if (length > 1) {
  11334. return stack[length - 2];
  11335. } // Since the name is always a string, null is a safe sentinel value to
  11336. // return if we do not know the name of the (root) value.
  11337. /* istanbul ignore next */
  11338. return null;
  11339. } // The value of the current property is always the final element of
  11340. // this.stack.
  11341. getValue() {
  11342. return getLast$m(this.stack);
  11343. }
  11344. getNode(count = 0) {
  11345. return getNodeHelper(this, count);
  11346. }
  11347. getParentNode(count = 0) {
  11348. return getNodeHelper(this, count + 1);
  11349. } // Temporarily push properties named by string arguments given after the
  11350. // callback function onto this.stack, then call the callback with a
  11351. // reference to this (modified) AstPath object. Note that the stack will
  11352. // be restored to its original state after the callback is finished, so it
  11353. // is probably a mistake to retain a reference to the path.
  11354. call(callback, ...names) {
  11355. const {
  11356. stack
  11357. } = this;
  11358. const {
  11359. length
  11360. } = stack;
  11361. let value = getLast$m(stack);
  11362. for (const name of names) {
  11363. value = value[name];
  11364. stack.push(name, value);
  11365. }
  11366. const result = callback(this);
  11367. stack.length = length;
  11368. return result;
  11369. }
  11370. callParent(callback, count = 0) {
  11371. const stackIndex = getNodeStackIndexHelper(this.stack, count + 1);
  11372. const parentValues = this.stack.splice(stackIndex + 1);
  11373. const result = callback(this);
  11374. this.stack.push(...parentValues);
  11375. return result;
  11376. } // Similar to AstPath.prototype.call, except that the value obtained by
  11377. // accessing this.getValue()[name1][name2]... should be array. The
  11378. // callback will be called with a reference to this path object for each
  11379. // element of the array.
  11380. each(callback, ...names) {
  11381. const {
  11382. stack
  11383. } = this;
  11384. const {
  11385. length
  11386. } = stack;
  11387. let value = getLast$m(stack);
  11388. for (const name of names) {
  11389. value = value[name];
  11390. stack.push(name, value);
  11391. }
  11392. for (let i = 0; i < value.length; ++i) {
  11393. stack.push(i, value[i]);
  11394. callback(this, i, value);
  11395. stack.length -= 2;
  11396. }
  11397. stack.length = length;
  11398. } // Similar to AstPath.prototype.each, except that the results of the
  11399. // callback function invocations are stored in an array and returned at
  11400. // the end of the iteration.
  11401. map(callback, ...names) {
  11402. const result = [];
  11403. this.each((path, index, value) => {
  11404. result[index] = callback(path, index, value);
  11405. }, ...names);
  11406. return result;
  11407. }
  11408. /**
  11409. * @param {() => void} callback
  11410. * @internal Unstable API. Don't use in plugins for now.
  11411. */
  11412. try(callback) {
  11413. const {
  11414. stack
  11415. } = this;
  11416. const stackBackup = [...stack];
  11417. try {
  11418. return callback();
  11419. } finally {
  11420. stack.length = 0;
  11421. stack.push(...stackBackup);
  11422. }
  11423. }
  11424. /**
  11425. * @param {...(
  11426. * | ((node: any, name: string | null, number: number | null) => boolean)
  11427. * | undefined
  11428. * )} predicates
  11429. */
  11430. match(...predicates) {
  11431. let stackPointer = this.stack.length - 1;
  11432. let name = null;
  11433. let node = this.stack[stackPointer--];
  11434. for (const predicate of predicates) {
  11435. /* istanbul ignore next */
  11436. if (node === undefined) {
  11437. return false;
  11438. } // skip index/array
  11439. let number = null;
  11440. if (typeof name === "number") {
  11441. number = name;
  11442. name = this.stack[stackPointer--];
  11443. node = this.stack[stackPointer--];
  11444. }
  11445. if (predicate && !predicate(node, name, number)) {
  11446. return false;
  11447. }
  11448. name = this.stack[stackPointer--];
  11449. node = this.stack[stackPointer--];
  11450. }
  11451. return true;
  11452. }
  11453. /**
  11454. * Traverses the ancestors of the current node heading toward the tree root
  11455. * until it finds a node that matches the provided predicate function. Will
  11456. * return the first matching ancestor. If no such node exists, returns undefined.
  11457. * @param {(node: any, name: string, number: number | null) => boolean} predicate
  11458. * @internal Unstable API. Don't use in plugins for now.
  11459. */
  11460. findAncestor(predicate) {
  11461. let stackPointer = this.stack.length - 1;
  11462. let name = null;
  11463. let node = this.stack[stackPointer--];
  11464. while (node) {
  11465. // skip index/array
  11466. let number = null;
  11467. if (typeof name === "number") {
  11468. number = name;
  11469. name = this.stack[stackPointer--];
  11470. node = this.stack[stackPointer--];
  11471. }
  11472. if (name !== null && predicate(node, name, number)) {
  11473. return node;
  11474. }
  11475. name = this.stack[stackPointer--];
  11476. node = this.stack[stackPointer--];
  11477. }
  11478. }
  11479. }
  11480. var astPath = AstPath$1;
  11481. const {
  11482. utils: {
  11483. stripTrailingHardline
  11484. }
  11485. } = require$$7$3;
  11486. const {
  11487. normalize
  11488. } = options$d;
  11489. const comments$3 = comments$4;
  11490. function printSubtree(path, print, options, printAstToDoc) {
  11491. if (options.printer.embed && options.embeddedLanguageFormatting === "auto") {
  11492. return options.printer.embed(path, print, (text, partialNextOptions, textToDocOptions) => textToDoc(text, partialNextOptions, options, printAstToDoc, textToDocOptions), options);
  11493. }
  11494. }
  11495. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc, // TODO: remove `stripTrailingHardline` in v3.0.0
  11496. {
  11497. stripTrailingHardline: shouldStripTrailingHardline = false
  11498. } = {}) {
  11499. const nextOptions = normalize(Object.assign(Object.assign(Object.assign({}, parentOptions), partialNextOptions), {}, {
  11500. parentParser: parentOptions.parser,
  11501. originalText: text
  11502. }), {
  11503. passThrough: true
  11504. });
  11505. const result = parser$2.parse(text, nextOptions);
  11506. const {
  11507. ast
  11508. } = result;
  11509. text = result.text;
  11510. const astComments = ast.comments;
  11511. delete ast.comments;
  11512. comments$3.attach(astComments, ast, text, nextOptions);
  11513. nextOptions[Symbol.for("comments")] = astComments || [];
  11514. nextOptions[Symbol.for("tokens")] = ast.tokens || [];
  11515. const doc = printAstToDoc(ast, nextOptions);
  11516. comments$3.ensureAllCommentsPrinted(astComments);
  11517. if (shouldStripTrailingHardline) {
  11518. // TODO: move this to `stripTrailingHardline` function in `/src/document/doc-utils.js`
  11519. if (typeof doc === "string") {
  11520. return doc.replace(/(?:\r?\n)*$/, "");
  11521. }
  11522. return stripTrailingHardline(doc);
  11523. }
  11524. /* istanbul ignore next */
  11525. return doc;
  11526. }
  11527. var multiparser$1 = {
  11528. printSubtree
  11529. };
  11530. const AstPath = astPath;
  11531. const {
  11532. builders: {
  11533. hardline: hardline$B,
  11534. addAlignmentToDoc: addAlignmentToDoc$1
  11535. },
  11536. utils: {
  11537. propagateBreaks
  11538. }
  11539. } = require$$7$3;
  11540. const {
  11541. printComments: printComments$6
  11542. } = comments$4;
  11543. const multiparser = multiparser$1;
  11544. /**
  11545. * Takes an abstract syntax tree (AST) and recursively converts it to a
  11546. * document (series of printing primitives).
  11547. *
  11548. * This is done by descending down the AST recursively. The recursion
  11549. * involves two functions that call each other:
  11550. *
  11551. * 1. mainPrint(), which is defined as an inner function here.
  11552. * It basically takes care of node caching.
  11553. * 2. callPluginPrintFunction(), which checks for some options, and
  11554. * ultimately calls the print() function provided by the plugin.
  11555. *
  11556. * The plugin function will call mainPrint() again for child nodes
  11557. * of the current node. mainPrint() will do its housekeeping, then call
  11558. * the plugin function again, and so on.
  11559. *
  11560. * All the while, these functions pass a "path" variable around, which
  11561. * is a stack-like data structure (AstPath) that maintains the current
  11562. * state of the recursion. It is called "path", because it represents
  11563. * the path to the current node through the Abstract Syntax Tree.
  11564. */
  11565. function printAstToDoc$1(ast, options, alignmentSize = 0) {
  11566. const {
  11567. printer
  11568. } = options;
  11569. if (printer.preprocess) {
  11570. ast = printer.preprocess(ast, options);
  11571. }
  11572. const cache = new Map();
  11573. const path = new AstPath(ast);
  11574. let doc = mainPrint();
  11575. if (alignmentSize > 0) {
  11576. // Add a hardline to make the indents take effect
  11577. // It should be removed in index.js format()
  11578. doc = addAlignmentToDoc$1([hardline$B, doc], alignmentSize, options.tabWidth);
  11579. }
  11580. propagateBreaks(doc);
  11581. return doc;
  11582. function mainPrint(selector, args) {
  11583. if (selector === undefined || selector === path) {
  11584. return mainPrintInternal(args);
  11585. }
  11586. if (Array.isArray(selector)) {
  11587. return path.call(() => mainPrintInternal(args), ...selector);
  11588. }
  11589. return path.call(() => mainPrintInternal(args), selector);
  11590. }
  11591. function mainPrintInternal(args) {
  11592. const value = path.getValue();
  11593. const shouldCache = value && typeof value === "object" && args === undefined;
  11594. if (shouldCache && cache.has(value)) {
  11595. return cache.get(value);
  11596. }
  11597. const doc = callPluginPrintFunction(path, options, mainPrint, args);
  11598. if (shouldCache) {
  11599. cache.set(value, doc);
  11600. }
  11601. return doc;
  11602. }
  11603. }
  11604. function printPrettierIgnoredNode(node, options) {
  11605. const {
  11606. originalText,
  11607. [Symbol.for("comments")]: comments,
  11608. locStart,
  11609. locEnd
  11610. } = options;
  11611. const start = locStart(node);
  11612. const end = locEnd(node);
  11613. const printedComments = new Set();
  11614. for (const comment of comments) {
  11615. if (locStart(comment) >= start && locEnd(comment) <= end) {
  11616. comment.printed = true;
  11617. printedComments.add(comment);
  11618. }
  11619. }
  11620. return {
  11621. doc: originalText.slice(start, end),
  11622. printedComments
  11623. };
  11624. }
  11625. function callPluginPrintFunction(path, options, printPath, args) {
  11626. const node = path.getValue();
  11627. const {
  11628. printer
  11629. } = options;
  11630. let doc;
  11631. let printedComments; // Escape hatch
  11632. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
  11633. ({
  11634. doc,
  11635. printedComments
  11636. } = printPrettierIgnoredNode(node, options));
  11637. } else {
  11638. if (node) {
  11639. try {
  11640. // Potentially switch to a different parser
  11641. doc = multiparser.printSubtree(path, printPath, options, printAstToDoc$1);
  11642. } catch (error) {
  11643. /* istanbul ignore if */
  11644. if (process.env.PRETTIER_DEBUG) {
  11645. throw error;
  11646. } // Continue with current parser
  11647. }
  11648. }
  11649. if (!doc) {
  11650. doc = printer.print(path, options, printPath, args);
  11651. }
  11652. } // We let JSXElement print its comments itself because it adds () around
  11653. // UnionTypeAnnotation has to align the child without the comments
  11654. if (!printer.willPrintOwnComments || !printer.willPrintOwnComments(path, options)) {
  11655. // printComments will call the plugin print function and check for
  11656. // comments to print
  11657. doc = printComments$6(path, doc, options, printedComments);
  11658. }
  11659. return doc;
  11660. }
  11661. var astToDoc = printAstToDoc$1;
  11662. const assert$5 = require$$0__default$3["default"];
  11663. const comments$2 = comments$4;
  11664. const isJsonParser = ({
  11665. parser
  11666. }) => parser === "json" || parser === "json5" || parser === "json-stringify";
  11667. function findCommonAncestor(startNodeAndParents, endNodeAndParents) {
  11668. const startNodeAndAncestors = [startNodeAndParents.node, ...startNodeAndParents.parentNodes];
  11669. const endNodeAndAncestors = new Set([endNodeAndParents.node, ...endNodeAndParents.parentNodes]);
  11670. return startNodeAndAncestors.find(node => jsonSourceElements.has(node.type) && endNodeAndAncestors.has(node));
  11671. }
  11672. function dropRootParents(parents) {
  11673. let lastParentIndex = parents.length - 1;
  11674. for (;;) {
  11675. const parent = parents[lastParentIndex];
  11676. if (parent && (parent.type === "Program" || parent.type === "File")) {
  11677. lastParentIndex--;
  11678. } else {
  11679. break;
  11680. }
  11681. }
  11682. return parents.slice(0, lastParentIndex + 1);
  11683. }
  11684. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, {
  11685. locStart,
  11686. locEnd
  11687. }) {
  11688. let resultStartNode = startNodeAndParents.node;
  11689. let resultEndNode = endNodeAndParents.node;
  11690. if (resultStartNode === resultEndNode) {
  11691. return {
  11692. startNode: resultStartNode,
  11693. endNode: resultEndNode
  11694. };
  11695. }
  11696. const startNodeStart = locStart(startNodeAndParents.node);
  11697. for (const endParent of dropRootParents(endNodeAndParents.parentNodes)) {
  11698. if (locStart(endParent) >= startNodeStart) {
  11699. resultEndNode = endParent;
  11700. } else {
  11701. break;
  11702. }
  11703. }
  11704. const endNodeEnd = locEnd(endNodeAndParents.node);
  11705. for (const startParent of dropRootParents(startNodeAndParents.parentNodes)) {
  11706. if (locEnd(startParent) <= endNodeEnd) {
  11707. resultStartNode = startParent;
  11708. } else {
  11709. break;
  11710. }
  11711. }
  11712. return {
  11713. startNode: resultStartNode,
  11714. endNode: resultEndNode
  11715. };
  11716. }
  11717. function findNodeAtOffset(node, offset, options, predicate, parentNodes = [], type) {
  11718. const {
  11719. locStart,
  11720. locEnd
  11721. } = options;
  11722. const start = locStart(node);
  11723. const end = locEnd(node);
  11724. if (offset > end || offset < start || type === "rangeEnd" && offset === start || type === "rangeStart" && offset === end) {
  11725. return;
  11726. }
  11727. for (const childNode of comments$2.getSortedChildNodes(node, options)) {
  11728. const childResult = findNodeAtOffset(childNode, offset, options, predicate, [node, ...parentNodes], type);
  11729. if (childResult) {
  11730. return childResult;
  11731. }
  11732. }
  11733. if (!predicate || predicate(node, parentNodes[0])) {
  11734. return {
  11735. node,
  11736. parentNodes
  11737. };
  11738. }
  11739. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  11740. function isJsSourceElement(type, parentType) {
  11741. return parentType !== "DeclareExportDeclaration" && type !== "TypeParameterDeclaration" && (type === "Directive" || type === "TypeAlias" || type === "TSExportAssignment" || type.startsWith("Declare") || type.startsWith("TSDeclare") || type.endsWith("Statement") || type.endsWith("Declaration"));
  11742. }
  11743. const jsonSourceElements = new Set(["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral", "UnaryExpression", "TemplateLiteral"]);
  11744. const graphqlSourceElements = new Set(["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"]);
  11745. function isSourceElement(opts, node, parentNode) {
  11746. /* istanbul ignore next */
  11747. if (!node) {
  11748. return false;
  11749. }
  11750. switch (opts.parser) {
  11751. case "flow":
  11752. case "babel":
  11753. case "babel-flow":
  11754. case "babel-ts":
  11755. case "typescript":
  11756. case "espree":
  11757. case "meriyah":
  11758. case "__babel_estree":
  11759. return isJsSourceElement(node.type, parentNode && parentNode.type);
  11760. case "json":
  11761. case "json5":
  11762. case "json-stringify":
  11763. return jsonSourceElements.has(node.type);
  11764. case "graphql":
  11765. return graphqlSourceElements.has(node.kind);
  11766. case "vue":
  11767. return node.tag !== "root";
  11768. }
  11769. return false;
  11770. }
  11771. function calculateRange(text, opts, ast) {
  11772. let {
  11773. rangeStart: start,
  11774. rangeEnd: end,
  11775. locStart,
  11776. locEnd
  11777. } = opts;
  11778. assert$5.ok(end > start); // Contract the range so that it has non-whitespace characters at its endpoints.
  11779. // This ensures we can format a range that doesn't end on a node.
  11780. const firstNonWhitespaceCharacterIndex = text.slice(start, end).search(/\S/);
  11781. const isAllWhitespace = firstNonWhitespaceCharacterIndex === -1;
  11782. if (!isAllWhitespace) {
  11783. start += firstNonWhitespaceCharacterIndex;
  11784. for (; end > start; --end) {
  11785. if (/\S/.test(text[end - 1])) {
  11786. break;
  11787. }
  11788. }
  11789. }
  11790. const startNodeAndParents = findNodeAtOffset(ast, start, opts, (node, parentNode) => isSourceElement(opts, node, parentNode), [], "rangeStart");
  11791. const endNodeAndParents = // No need find Node at `end`, it will be the same as `startNodeAndParents`
  11792. isAllWhitespace ? startNodeAndParents : findNodeAtOffset(ast, end, opts, node => isSourceElement(opts, node), [], "rangeEnd");
  11793. if (!startNodeAndParents || !endNodeAndParents) {
  11794. return {
  11795. rangeStart: 0,
  11796. rangeEnd: 0
  11797. };
  11798. }
  11799. let startNode;
  11800. let endNode;
  11801. if (isJsonParser(opts)) {
  11802. const commonAncestor = findCommonAncestor(startNodeAndParents, endNodeAndParents);
  11803. startNode = commonAncestor;
  11804. endNode = commonAncestor;
  11805. } else {
  11806. ({
  11807. startNode,
  11808. endNode
  11809. } = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts));
  11810. }
  11811. return {
  11812. rangeStart: Math.min(locStart(startNode), locStart(endNode)),
  11813. rangeEnd: Math.max(locEnd(startNode), locEnd(endNode))
  11814. };
  11815. }
  11816. var rangeUtil$1 = {
  11817. calculateRange,
  11818. findNodeAtOffset
  11819. };
  11820. const diff = lib$6;
  11821. const {
  11822. printer: {
  11823. printDocToString: printDocToString$2
  11824. },
  11825. debug: {
  11826. printDocToDebug
  11827. }
  11828. } = require$$7$3;
  11829. const {
  11830. getAlignmentSize: getAlignmentSize$1
  11831. } = util$8;
  11832. const {
  11833. guessEndOfLine,
  11834. convertEndOfLineToChars,
  11835. countEndOfLineChars,
  11836. normalizeEndOfLine: normalizeEndOfLine$1
  11837. } = endOfLine;
  11838. const normalizeOptions$4 = options$d.normalize;
  11839. const massageAST = massageAst;
  11840. const comments$1 = comments$4;
  11841. const parser$1 = parser$2;
  11842. const printAstToDoc = astToDoc;
  11843. const rangeUtil = rangeUtil$1;
  11844. const BOM = "\uFEFF";
  11845. const CURSOR = Symbol("cursor");
  11846. function attachComments(text, ast, opts) {
  11847. const astComments = ast.comments;
  11848. if (astComments) {
  11849. delete ast.comments;
  11850. comments$1.attach(astComments, ast, text, opts);
  11851. }
  11852. opts[Symbol.for("comments")] = astComments || [];
  11853. opts[Symbol.for("tokens")] = ast.tokens || [];
  11854. opts.originalText = text;
  11855. return astComments;
  11856. }
  11857. function coreFormat(originalText, opts, addAlignmentSize = 0) {
  11858. if (!originalText || originalText.trim().length === 0) {
  11859. return {
  11860. formatted: "",
  11861. cursorOffset: -1,
  11862. comments: []
  11863. };
  11864. }
  11865. const {
  11866. ast,
  11867. text
  11868. } = parser$1.parse(originalText, opts);
  11869. if (opts.cursorOffset >= 0) {
  11870. const nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  11871. if (nodeResult && nodeResult.node) {
  11872. opts.cursorNode = nodeResult.node;
  11873. }
  11874. }
  11875. const astComments = attachComments(text, ast, opts);
  11876. const doc = printAstToDoc(ast, opts, addAlignmentSize);
  11877. const result = printDocToString$2(doc, opts);
  11878. comments$1.ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  11879. if (addAlignmentSize > 0) {
  11880. const trimmed = result.formatted.trim();
  11881. if (result.cursorNodeStart !== undefined) {
  11882. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  11883. }
  11884. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  11885. }
  11886. if (opts.cursorOffset >= 0) {
  11887. let oldCursorNodeStart;
  11888. let oldCursorNodeText;
  11889. let cursorOffsetRelativeToOldCursorNode;
  11890. let newCursorNodeStart;
  11891. let newCursorNodeText;
  11892. if (opts.cursorNode && result.cursorNodeText) {
  11893. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  11894. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  11895. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  11896. newCursorNodeStart = result.cursorNodeStart;
  11897. newCursorNodeText = result.cursorNodeText;
  11898. } else {
  11899. oldCursorNodeStart = 0;
  11900. oldCursorNodeText = text;
  11901. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  11902. newCursorNodeStart = 0;
  11903. newCursorNodeText = result.formatted;
  11904. }
  11905. if (oldCursorNodeText === newCursorNodeText) {
  11906. return {
  11907. formatted: result.formatted,
  11908. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode,
  11909. comments: astComments
  11910. };
  11911. } // diff old and new cursor node texts, with a special cursor
  11912. // symbol inserted to find out where it moves to
  11913. const oldCursorNodeCharArray = [...oldCursorNodeText];
  11914. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  11915. const newCursorNodeCharArray = [...newCursorNodeText];
  11916. const cursorNodeDiff = diff.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  11917. let cursorOffset = newCursorNodeStart;
  11918. for (const entry of cursorNodeDiff) {
  11919. if (entry.removed) {
  11920. if (entry.value.includes(CURSOR)) {
  11921. break;
  11922. }
  11923. } else {
  11924. cursorOffset += entry.count;
  11925. }
  11926. }
  11927. return {
  11928. formatted: result.formatted,
  11929. cursorOffset,
  11930. comments: astComments
  11931. };
  11932. }
  11933. return {
  11934. formatted: result.formatted,
  11935. cursorOffset: -1,
  11936. comments: astComments
  11937. };
  11938. }
  11939. function formatRange(originalText, opts) {
  11940. const {
  11941. ast,
  11942. text
  11943. } = parser$1.parse(originalText, opts);
  11944. const {
  11945. rangeStart,
  11946. rangeEnd
  11947. } = rangeUtil.calculateRange(text, opts, ast);
  11948. const rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  11949. // This is so we can detect indentation correctly and restore it.
  11950. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  11951. const rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  11952. const indentString = text.slice(rangeStart2, rangeStart).match(/^\s*/)[0];
  11953. const alignmentSize = getAlignmentSize$1(indentString, opts.tabWidth);
  11954. const rangeResult = coreFormat(rangeString, Object.assign(Object.assign({}, opts), {}, {
  11955. rangeStart: 0,
  11956. rangeEnd: Number.POSITIVE_INFINITY,
  11957. // Track the cursor offset only if it's within our range
  11958. cursorOffset: opts.cursorOffset > rangeStart && opts.cursorOffset <= rangeEnd ? opts.cursorOffset - rangeStart : -1,
  11959. // Always use `lf` to format, we'll replace it later
  11960. endOfLine: "lf"
  11961. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  11962. // we need to remove the newline that was inserted by the `format` call.
  11963. const rangeTrimmed = rangeResult.formatted.trimEnd();
  11964. let {
  11965. cursorOffset
  11966. } = opts;
  11967. if (cursorOffset > rangeEnd) {
  11968. // handle the case where the cursor was past the end of the range
  11969. cursorOffset += rangeTrimmed.length - rangeString.length;
  11970. } else if (rangeResult.cursorOffset >= 0) {
  11971. // handle the case where the cursor was in the range
  11972. cursorOffset = rangeResult.cursorOffset + rangeStart;
  11973. } // keep the cursor as it was if it was before the start of the range
  11974. let formatted = text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd);
  11975. if (opts.endOfLine !== "lf") {
  11976. const eol = convertEndOfLineToChars(opts.endOfLine);
  11977. if (cursorOffset >= 0 && eol === "\r\n") {
  11978. cursorOffset += countEndOfLineChars(formatted.slice(0, cursorOffset), "\n");
  11979. }
  11980. formatted = formatted.replace(/\n/g, eol);
  11981. }
  11982. return {
  11983. formatted,
  11984. cursorOffset,
  11985. comments: rangeResult.comments
  11986. };
  11987. }
  11988. function ensureIndexInText(text, index, defaultValue) {
  11989. if (typeof index !== "number" || Number.isNaN(index) || index < 0 || index > text.length) {
  11990. return defaultValue;
  11991. }
  11992. return index;
  11993. }
  11994. function normalizeIndexes(text, options) {
  11995. let {
  11996. cursorOffset,
  11997. rangeStart,
  11998. rangeEnd
  11999. } = options;
  12000. cursorOffset = ensureIndexInText(text, cursorOffset, -1);
  12001. rangeStart = ensureIndexInText(text, rangeStart, 0);
  12002. rangeEnd = ensureIndexInText(text, rangeEnd, text.length);
  12003. return Object.assign(Object.assign({}, options), {}, {
  12004. cursorOffset,
  12005. rangeStart,
  12006. rangeEnd
  12007. });
  12008. }
  12009. function normalizeInputAndOptions(text, options) {
  12010. let {
  12011. cursorOffset,
  12012. rangeStart,
  12013. rangeEnd,
  12014. endOfLine
  12015. } = normalizeIndexes(text, options);
  12016. const hasBOM = text.charAt(0) === BOM;
  12017. if (hasBOM) {
  12018. text = text.slice(1);
  12019. cursorOffset--;
  12020. rangeStart--;
  12021. rangeEnd--;
  12022. }
  12023. if (endOfLine === "auto") {
  12024. endOfLine = guessEndOfLine(text);
  12025. } // get rid of CR/CRLF parsing
  12026. if (text.includes("\r")) {
  12027. const countCrlfBefore = index => countEndOfLineChars(text.slice(0, Math.max(index, 0)), "\r\n");
  12028. cursorOffset -= countCrlfBefore(cursorOffset);
  12029. rangeStart -= countCrlfBefore(rangeStart);
  12030. rangeEnd -= countCrlfBefore(rangeEnd);
  12031. text = normalizeEndOfLine$1(text);
  12032. }
  12033. return {
  12034. hasBOM,
  12035. text,
  12036. options: normalizeIndexes(text, Object.assign(Object.assign({}, options), {}, {
  12037. cursorOffset,
  12038. rangeStart,
  12039. rangeEnd,
  12040. endOfLine
  12041. }))
  12042. };
  12043. }
  12044. function hasPragma$5(text, options) {
  12045. const selectedParser = parser$1.resolveParser(options);
  12046. return !selectedParser.hasPragma || selectedParser.hasPragma(text);
  12047. }
  12048. function formatWithCursor$1(originalText, originalOptions) {
  12049. let {
  12050. hasBOM,
  12051. text,
  12052. options
  12053. } = normalizeInputAndOptions(originalText, normalizeOptions$4(originalOptions));
  12054. if (options.rangeStart >= options.rangeEnd && text !== "" || options.requirePragma && !hasPragma$5(text, options)) {
  12055. return {
  12056. formatted: originalText,
  12057. cursorOffset: originalOptions.cursorOffset,
  12058. comments: []
  12059. };
  12060. }
  12061. let result;
  12062. if (options.rangeStart > 0 || options.rangeEnd < text.length) {
  12063. result = formatRange(text, options);
  12064. } else {
  12065. if (!options.requirePragma && options.insertPragma && options.printer.insertPragma && !hasPragma$5(text, options)) {
  12066. text = options.printer.insertPragma(text);
  12067. }
  12068. result = coreFormat(text, options);
  12069. }
  12070. if (hasBOM) {
  12071. result.formatted = BOM + result.formatted;
  12072. if (result.cursorOffset >= 0) {
  12073. result.cursorOffset++;
  12074. }
  12075. }
  12076. return result;
  12077. }
  12078. var core$2 = {
  12079. formatWithCursor: formatWithCursor$1,
  12080. parse(originalText, originalOptions, massage) {
  12081. const {
  12082. text,
  12083. options
  12084. } = normalizeInputAndOptions(originalText, normalizeOptions$4(originalOptions));
  12085. const parsed = parser$1.parse(text, options);
  12086. if (massage) {
  12087. parsed.ast = massageAST(parsed.ast, options);
  12088. }
  12089. return parsed;
  12090. },
  12091. formatAST(ast, options) {
  12092. options = normalizeOptions$4(options);
  12093. const doc = printAstToDoc(ast, options);
  12094. return printDocToString$2(doc, options);
  12095. },
  12096. // Doesn't handle shebang for now
  12097. formatDoc(doc, options) {
  12098. return formatWithCursor$1(printDocToDebug(doc), Object.assign(Object.assign({}, options), {}, {
  12099. parser: "__js_expression"
  12100. })).formatted;
  12101. },
  12102. printToDoc(originalText, options) {
  12103. options = normalizeOptions$4(options);
  12104. const {
  12105. ast,
  12106. text
  12107. } = parser$1.parse(originalText, options);
  12108. attachComments(text, ast, options);
  12109. return printAstToDoc(ast, options);
  12110. },
  12111. printDocToString(doc, options) {
  12112. return printDocToString$2(doc, normalizeOptions$4(options));
  12113. }
  12114. };
  12115. var concatMap$1 = function (xs, fn) {
  12116. var res = [];
  12117. for (var i = 0; i < xs.length; i++) {
  12118. var x = fn(xs[i], i);
  12119. if (isArray$a(x)) res.push.apply(res, x);else res.push(x);
  12120. }
  12121. return res;
  12122. };
  12123. var isArray$a = Array.isArray || function (xs) {
  12124. return Object.prototype.toString.call(xs) === '[object Array]';
  12125. };
  12126. var balancedMatch = balanced$1;
  12127. function balanced$1(a, b, str) {
  12128. if (a instanceof RegExp) a = maybeMatch(a, str);
  12129. if (b instanceof RegExp) b = maybeMatch(b, str);
  12130. var r = range(a, b, str);
  12131. return r && {
  12132. start: r[0],
  12133. end: r[1],
  12134. pre: str.slice(0, r[0]),
  12135. body: str.slice(r[0] + a.length, r[1]),
  12136. post: str.slice(r[1] + b.length)
  12137. };
  12138. }
  12139. function maybeMatch(reg, str) {
  12140. var m = str.match(reg);
  12141. return m ? m[0] : null;
  12142. }
  12143. balanced$1.range = range;
  12144. function range(a, b, str) {
  12145. var begs, beg, left, right, result;
  12146. var ai = str.indexOf(a);
  12147. var bi = str.indexOf(b, ai + 1);
  12148. var i = ai;
  12149. if (ai >= 0 && bi > 0) {
  12150. if (a === b) {
  12151. return [ai, bi];
  12152. }
  12153. begs = [];
  12154. left = str.length;
  12155. while (i >= 0 && !result) {
  12156. if (i == ai) {
  12157. begs.push(i);
  12158. ai = str.indexOf(a, i + 1);
  12159. } else if (begs.length == 1) {
  12160. result = [begs.pop(), bi];
  12161. } else {
  12162. beg = begs.pop();
  12163. if (beg < left) {
  12164. left = beg;
  12165. right = bi;
  12166. }
  12167. bi = str.indexOf(b, i + 1);
  12168. }
  12169. i = ai < bi && ai >= 0 ? ai : bi;
  12170. }
  12171. if (begs.length) {
  12172. result = [left, right];
  12173. }
  12174. }
  12175. return result;
  12176. }
  12177. var concatMap = concatMap$1;
  12178. var balanced = balancedMatch;
  12179. var braceExpansion = expandTop;
  12180. var escSlash = '\0SLASH' + Math.random() + '\0';
  12181. var escOpen = '\0OPEN' + Math.random() + '\0';
  12182. var escClose = '\0CLOSE' + Math.random() + '\0';
  12183. var escComma = '\0COMMA' + Math.random() + '\0';
  12184. var escPeriod = '\0PERIOD' + Math.random() + '\0';
  12185. function numeric(str) {
  12186. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  12187. }
  12188. function escapeBraces(str) {
  12189. return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
  12190. }
  12191. function unescapeBraces(str) {
  12192. return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
  12193. } // Basically just str.split(","), but handling cases
  12194. // where we have nested braced sections, which should be
  12195. // treated as individual members, like {a,{b,c},d}
  12196. function parseCommaParts(str) {
  12197. if (!str) return [''];
  12198. var parts = [];
  12199. var m = balanced('{', '}', str);
  12200. if (!m) return str.split(',');
  12201. var pre = m.pre;
  12202. var body = m.body;
  12203. var post = m.post;
  12204. var p = pre.split(',');
  12205. p[p.length - 1] += '{' + body + '}';
  12206. var postParts = parseCommaParts(post);
  12207. if (post.length) {
  12208. p[p.length - 1] += postParts.shift();
  12209. p.push.apply(p, postParts);
  12210. }
  12211. parts.push.apply(parts, p);
  12212. return parts;
  12213. }
  12214. function expandTop(str) {
  12215. if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
  12216. // Anything starting with {} will have the first two bytes preserved
  12217. // but *only* at the top level, so {},a}b will not expand to anything,
  12218. // but a{},b}c will be expanded to [a}c,abc].
  12219. // One could argue that this is a bug in Bash, but since the goal of
  12220. // this module is to match Bash's rules, we escape a leading {}
  12221. if (str.substr(0, 2) === '{}') {
  12222. str = '\\{\\}' + str.substr(2);
  12223. }
  12224. return expand$3(escapeBraces(str), true).map(unescapeBraces);
  12225. }
  12226. function embrace(str) {
  12227. return '{' + str + '}';
  12228. }
  12229. function isPadded(el) {
  12230. return /^-?0\d/.test(el);
  12231. }
  12232. function lte(i, y) {
  12233. return i <= y;
  12234. }
  12235. function gte(i, y) {
  12236. return i >= y;
  12237. }
  12238. function expand$3(str, isTop) {
  12239. var expansions = [];
  12240. var m = balanced('{', '}', str);
  12241. if (!m || /\$$/.test(m.pre)) return [str];
  12242. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  12243. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  12244. var isSequence = isNumericSequence || isAlphaSequence;
  12245. var isOptions = m.body.indexOf(',') >= 0;
  12246. if (!isSequence && !isOptions) {
  12247. // {a},b}
  12248. if (m.post.match(/,.*\}/)) {
  12249. str = m.pre + '{' + m.body + escClose + m.post;
  12250. return expand$3(str);
  12251. }
  12252. return [str];
  12253. }
  12254. var n;
  12255. if (isSequence) {
  12256. n = m.body.split(/\.\./);
  12257. } else {
  12258. n = parseCommaParts(m.body);
  12259. if (n.length === 1) {
  12260. // x{{a,b}}y ==> x{a}y x{b}y
  12261. n = expand$3(n[0], false).map(embrace);
  12262. if (n.length === 1) {
  12263. var post = m.post.length ? expand$3(m.post, false) : [''];
  12264. return post.map(function (p) {
  12265. return m.pre + n[0] + p;
  12266. });
  12267. }
  12268. }
  12269. } // at this point, n is the parts, and we know it's not a comma set
  12270. // with a single entry.
  12271. // no need to expand pre, since it is guaranteed to be free of brace-sets
  12272. var pre = m.pre;
  12273. var post = m.post.length ? expand$3(m.post, false) : [''];
  12274. var N;
  12275. if (isSequence) {
  12276. var x = numeric(n[0]);
  12277. var y = numeric(n[1]);
  12278. var width = Math.max(n[0].length, n[1].length);
  12279. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  12280. var test = lte;
  12281. var reverse = y < x;
  12282. if (reverse) {
  12283. incr *= -1;
  12284. test = gte;
  12285. }
  12286. var pad = n.some(isPadded);
  12287. N = [];
  12288. for (var i = x; test(i, y); i += incr) {
  12289. var c;
  12290. if (isAlphaSequence) {
  12291. c = String.fromCharCode(i);
  12292. if (c === '\\') c = '';
  12293. } else {
  12294. c = String(i);
  12295. if (pad) {
  12296. var need = width - c.length;
  12297. if (need > 0) {
  12298. var z = new Array(need + 1).join('0');
  12299. if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
  12300. }
  12301. }
  12302. }
  12303. N.push(c);
  12304. }
  12305. } else {
  12306. N = concatMap(n, function (el) {
  12307. return expand$3(el, false);
  12308. });
  12309. }
  12310. for (var j = 0; j < N.length; j++) {
  12311. for (var k = 0; k < post.length; k++) {
  12312. var expansion = pre + N[j] + post[k];
  12313. if (!isTop || isSequence || expansion) expansions.push(expansion);
  12314. }
  12315. }
  12316. return expansions;
  12317. }
  12318. var minimatch_1 = minimatch$1;
  12319. minimatch$1.Minimatch = Minimatch;
  12320. var path$o = {
  12321. sep: '/'
  12322. };
  12323. try {
  12324. path$o = require('path');
  12325. } catch (er) {}
  12326. var GLOBSTAR$1 = minimatch$1.GLOBSTAR = Minimatch.GLOBSTAR = {};
  12327. var expand$2 = braceExpansion;
  12328. var plTypes = {
  12329. '!': {
  12330. open: '(?:(?!(?:',
  12331. close: '))[^/]*?)'
  12332. },
  12333. '?': {
  12334. open: '(?:',
  12335. close: ')?'
  12336. },
  12337. '+': {
  12338. open: '(?:',
  12339. close: ')+'
  12340. },
  12341. '*': {
  12342. open: '(?:',
  12343. close: ')*'
  12344. },
  12345. '@': {
  12346. open: '(?:',
  12347. close: ')'
  12348. }
  12349. }; // any single thing other than /
  12350. // don't need to escape / when using new RegExp()
  12351. var qmark = '[^/]'; // * => any number of characters
  12352. var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
  12353. // not (^ or / followed by one or two dots followed by $ or /),
  12354. // followed by anything, any number of times.
  12355. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
  12356. // followed by anything, any number of times.
  12357. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
  12358. var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
  12359. function charSet(s) {
  12360. return s.split('').reduce(function (set, c) {
  12361. set[c] = true;
  12362. return set;
  12363. }, {});
  12364. } // normalizes slashes.
  12365. var slashSplit = /\/+/;
  12366. minimatch$1.filter = filter;
  12367. function filter(pattern, options) {
  12368. options = options || {};
  12369. return function (p, i, list) {
  12370. return minimatch$1(p, pattern, options);
  12371. };
  12372. }
  12373. function ext(a, b) {
  12374. a = a || {};
  12375. b = b || {};
  12376. var t = {};
  12377. Object.keys(b).forEach(function (k) {
  12378. t[k] = b[k];
  12379. });
  12380. Object.keys(a).forEach(function (k) {
  12381. t[k] = a[k];
  12382. });
  12383. return t;
  12384. }
  12385. minimatch$1.defaults = function (def) {
  12386. if (!def || !Object.keys(def).length) return minimatch$1;
  12387. var orig = minimatch$1;
  12388. var m = function minimatch(p, pattern, options) {
  12389. return orig.minimatch(p, pattern, ext(def, options));
  12390. };
  12391. m.Minimatch = function Minimatch(pattern, options) {
  12392. return new orig.Minimatch(pattern, ext(def, options));
  12393. };
  12394. return m;
  12395. };
  12396. Minimatch.defaults = function (def) {
  12397. if (!def || !Object.keys(def).length) return Minimatch;
  12398. return minimatch$1.defaults(def).Minimatch;
  12399. };
  12400. function minimatch$1(p, pattern, options) {
  12401. if (typeof pattern !== 'string') {
  12402. throw new TypeError('glob pattern string required');
  12403. }
  12404. if (!options) options = {}; // shortcut: comments match nothing.
  12405. if (!options.nocomment && pattern.charAt(0) === '#') {
  12406. return false;
  12407. } // "" only matches ""
  12408. if (pattern.trim() === '') return p === '';
  12409. return new Minimatch(pattern, options).match(p);
  12410. }
  12411. function Minimatch(pattern, options) {
  12412. if (!(this instanceof Minimatch)) {
  12413. return new Minimatch(pattern, options);
  12414. }
  12415. if (typeof pattern !== 'string') {
  12416. throw new TypeError('glob pattern string required');
  12417. }
  12418. if (!options) options = {};
  12419. pattern = pattern.trim(); // windows support: need to use /, not \
  12420. if (path$o.sep !== '/') {
  12421. pattern = pattern.split(path$o.sep).join('/');
  12422. }
  12423. this.options = options;
  12424. this.set = [];
  12425. this.pattern = pattern;
  12426. this.regexp = null;
  12427. this.negate = false;
  12428. this.comment = false;
  12429. this.empty = false; // make the set of regexps etc.
  12430. this.make();
  12431. }
  12432. Minimatch.prototype.debug = function () {};
  12433. Minimatch.prototype.make = make;
  12434. function make() {
  12435. // don't do it more than once.
  12436. if (this._made) return;
  12437. var pattern = this.pattern;
  12438. var options = this.options; // empty patterns and comments match nothing.
  12439. if (!options.nocomment && pattern.charAt(0) === '#') {
  12440. this.comment = true;
  12441. return;
  12442. }
  12443. if (!pattern) {
  12444. this.empty = true;
  12445. return;
  12446. } // step 1: figure out negation, etc.
  12447. this.parseNegate(); // step 2: expand braces
  12448. var set = this.globSet = this.braceExpand();
  12449. if (options.debug) this.debug = console.error;
  12450. this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  12451. // matching patterns.
  12452. // These will be regexps, except in the case of "**", which is
  12453. // set to the GLOBSTAR object for globstar behavior,
  12454. // and will not contain any / characters
  12455. set = this.globParts = set.map(function (s) {
  12456. return s.split(slashSplit);
  12457. });
  12458. this.debug(this.pattern, set); // glob --> regexps
  12459. set = set.map(function (s, si, set) {
  12460. return s.map(this.parse, this);
  12461. }, this);
  12462. this.debug(this.pattern, set); // filter out everything that didn't compile properly.
  12463. set = set.filter(function (s) {
  12464. return s.indexOf(false) === -1;
  12465. });
  12466. this.debug(this.pattern, set);
  12467. this.set = set;
  12468. }
  12469. Minimatch.prototype.parseNegate = parseNegate;
  12470. function parseNegate() {
  12471. var pattern = this.pattern;
  12472. var negate = false;
  12473. var options = this.options;
  12474. var negateOffset = 0;
  12475. if (options.nonegate) return;
  12476. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
  12477. negate = !negate;
  12478. negateOffset++;
  12479. }
  12480. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  12481. this.negate = negate;
  12482. } // Brace expansion:
  12483. // a{b,c}d -> abd acd
  12484. // a{b,}c -> abc ac
  12485. // a{0..3}d -> a0d a1d a2d a3d
  12486. // a{b,c{d,e}f}g -> abg acdfg acefg
  12487. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  12488. //
  12489. // Invalid sets are not expanded.
  12490. // a{2..}b -> a{2..}b
  12491. // a{b}c -> a{b}c
  12492. minimatch$1.braceExpand = function (pattern, options) {
  12493. return braceExpand(pattern, options);
  12494. };
  12495. Minimatch.prototype.braceExpand = braceExpand;
  12496. function braceExpand(pattern, options) {
  12497. if (!options) {
  12498. if (this instanceof Minimatch) {
  12499. options = this.options;
  12500. } else {
  12501. options = {};
  12502. }
  12503. }
  12504. pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
  12505. if (typeof pattern === 'undefined') {
  12506. throw new TypeError('undefined pattern');
  12507. }
  12508. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  12509. // shortcut. no need to expand.
  12510. return [pattern];
  12511. }
  12512. return expand$2(pattern);
  12513. } // parse a component of the expanded set.
  12514. // At this point, no pattern may contain "/" in it
  12515. // so we're going to return a 2d array, where each entry is the full
  12516. // pattern, split on '/', and then turned into a regular expression.
  12517. // A regexp is made at the end which joins each array with an
  12518. // escaped /, and another full one which joins each regexp with |.
  12519. //
  12520. // Following the lead of Bash 4.1, note that "**" only has special meaning
  12521. // when it is the *only* thing in a path portion. Otherwise, any series
  12522. // of * is equivalent to a single *. Globstar behavior is enabled by
  12523. // default, and can be disabled by setting options.noglobstar.
  12524. Minimatch.prototype.parse = parse$c;
  12525. var SUBPARSE = {};
  12526. function parse$c(pattern, isSub) {
  12527. if (pattern.length > 1024 * 64) {
  12528. throw new TypeError('pattern is too long');
  12529. }
  12530. var options = this.options; // shortcuts
  12531. if (!options.noglobstar && pattern === '**') return GLOBSTAR$1;
  12532. if (pattern === '') return '';
  12533. var re = '';
  12534. var hasMagic = !!options.nocase;
  12535. var escaping = false; // ? => one single character
  12536. var patternListStack = [];
  12537. var negativeLists = [];
  12538. var stateChar;
  12539. var inClass = false;
  12540. var reClassStart = -1;
  12541. var classStart = -1; // . and .. never match anything that doesn't start with .,
  12542. // even when options.dot is set.
  12543. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  12544. // not (start or / followed by . or .. followed by / or end)
  12545. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
  12546. var self = this;
  12547. function clearStateChar() {
  12548. if (stateChar) {
  12549. // we had some state-tracking character
  12550. // that wasn't consumed by this pass.
  12551. switch (stateChar) {
  12552. case '*':
  12553. re += star;
  12554. hasMagic = true;
  12555. break;
  12556. case '?':
  12557. re += qmark;
  12558. hasMagic = true;
  12559. break;
  12560. default:
  12561. re += '\\' + stateChar;
  12562. break;
  12563. }
  12564. self.debug('clearStateChar %j %j', stateChar, re);
  12565. stateChar = false;
  12566. }
  12567. }
  12568. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  12569. this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
  12570. if (escaping && reSpecials[c]) {
  12571. re += '\\' + c;
  12572. escaping = false;
  12573. continue;
  12574. }
  12575. switch (c) {
  12576. case '/':
  12577. // completely not allowed, even escaped.
  12578. // Should already be path-split by now.
  12579. return false;
  12580. case '\\':
  12581. clearStateChar();
  12582. escaping = true;
  12583. continue;
  12584. // the various stateChar values
  12585. // for the "extglob" stuff.
  12586. case '?':
  12587. case '*':
  12588. case '+':
  12589. case '@':
  12590. case '!':
  12591. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
  12592. // the glob [!a] means [^a] in regexp
  12593. if (inClass) {
  12594. this.debug(' in class');
  12595. if (c === '!' && i === classStart + 1) c = '^';
  12596. re += c;
  12597. continue;
  12598. } // if we already have a stateChar, then it means
  12599. // that there was something like ** or +? in there.
  12600. // Handle the stateChar, then proceed with this one.
  12601. self.debug('call clearStateChar %j', stateChar);
  12602. clearStateChar();
  12603. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  12604. // just clear the statechar *now*, rather than even diving into
  12605. // the patternList stuff.
  12606. if (options.noext) clearStateChar();
  12607. continue;
  12608. case '(':
  12609. if (inClass) {
  12610. re += '(';
  12611. continue;
  12612. }
  12613. if (!stateChar) {
  12614. re += '\\(';
  12615. continue;
  12616. }
  12617. patternListStack.push({
  12618. type: stateChar,
  12619. start: i - 1,
  12620. reStart: re.length,
  12621. open: plTypes[stateChar].open,
  12622. close: plTypes[stateChar].close
  12623. }); // negation is (?:(?!js)[^/]*)
  12624. re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
  12625. this.debug('plType %j %j', stateChar, re);
  12626. stateChar = false;
  12627. continue;
  12628. case ')':
  12629. if (inClass || !patternListStack.length) {
  12630. re += '\\)';
  12631. continue;
  12632. }
  12633. clearStateChar();
  12634. hasMagic = true;
  12635. var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
  12636. // The others are (?:<pattern>)<type>
  12637. re += pl.close;
  12638. if (pl.type === '!') {
  12639. negativeLists.push(pl);
  12640. }
  12641. pl.reEnd = re.length;
  12642. continue;
  12643. case '|':
  12644. if (inClass || !patternListStack.length || escaping) {
  12645. re += '\\|';
  12646. escaping = false;
  12647. continue;
  12648. }
  12649. clearStateChar();
  12650. re += '|';
  12651. continue;
  12652. // these are mostly the same in regexp and glob
  12653. case '[':
  12654. // swallow any state-tracking char before the [
  12655. clearStateChar();
  12656. if (inClass) {
  12657. re += '\\' + c;
  12658. continue;
  12659. }
  12660. inClass = true;
  12661. classStart = i;
  12662. reClassStart = re.length;
  12663. re += c;
  12664. continue;
  12665. case ']':
  12666. // a right bracket shall lose its special
  12667. // meaning and represent itself in
  12668. // a bracket expression if it occurs
  12669. // first in the list. -- POSIX.2 2.8.3.2
  12670. if (i === classStart + 1 || !inClass) {
  12671. re += '\\' + c;
  12672. escaping = false;
  12673. continue;
  12674. } // handle the case where we left a class open.
  12675. // "[z-a]" is valid, equivalent to "\[z-a\]"
  12676. if (inClass) {
  12677. // split where the last [ was, make sure we don't have
  12678. // an invalid re. if so, re-walk the contents of the
  12679. // would-be class to re-translate any characters that
  12680. // were passed through as-is
  12681. // TODO: It would probably be faster to determine this
  12682. // without a try/catch and a new RegExp, but it's tricky
  12683. // to do safely. For now, this is safe and works.
  12684. var cs = pattern.substring(classStart + 1, i);
  12685. try {
  12686. RegExp('[' + cs + ']');
  12687. } catch (er) {
  12688. // not a valid class!
  12689. var sp = this.parse(cs, SUBPARSE);
  12690. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
  12691. hasMagic = hasMagic || sp[1];
  12692. inClass = false;
  12693. continue;
  12694. }
  12695. } // finish up the class.
  12696. hasMagic = true;
  12697. inClass = false;
  12698. re += c;
  12699. continue;
  12700. default:
  12701. // swallow any state char that wasn't consumed
  12702. clearStateChar();
  12703. if (escaping) {
  12704. // no need
  12705. escaping = false;
  12706. } else if (reSpecials[c] && !(c === '^' && inClass)) {
  12707. re += '\\';
  12708. }
  12709. re += c;
  12710. } // switch
  12711. } // for
  12712. // handle the case where we left a class open.
  12713. // "[abc" is valid, equivalent to "\[abc"
  12714. if (inClass) {
  12715. // split where the last [ was, and escape it
  12716. // this is a huge pita. We now have to re-walk
  12717. // the contents of the would-be class to re-translate
  12718. // any characters that were passed through as-is
  12719. cs = pattern.substr(classStart + 1);
  12720. sp = this.parse(cs, SUBPARSE);
  12721. re = re.substr(0, reClassStart) + '\\[' + sp[0];
  12722. hasMagic = hasMagic || sp[1];
  12723. } // handle the case where we had a +( thing at the *end*
  12724. // of the pattern.
  12725. // each pattern list stack adds 3 chars, and we need to go through
  12726. // and escape any | chars that were passed through as-is for the regexp.
  12727. // Go through and escape them, taking care not to double-escape any
  12728. // | chars that were already escaped.
  12729. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  12730. var tail = re.slice(pl.reStart + pl.open.length);
  12731. this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
  12732. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  12733. if (!$2) {
  12734. // the | isn't already escaped, so escape it.
  12735. $2 = '\\';
  12736. } // need to escape all those slashes *again*, without escaping the
  12737. // one that we need for escaping the | character. As it works out,
  12738. // escaping an even number of slashes can be done by simply repeating
  12739. // it exactly after itself. That's why this trick works.
  12740. //
  12741. // I am sorry that you have to see this.
  12742. return $1 + $1 + $2 + '|';
  12743. });
  12744. this.debug('tail=%j\n %s', tail, tail, pl, re);
  12745. var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
  12746. hasMagic = true;
  12747. re = re.slice(0, pl.reStart) + t + '\\(' + tail;
  12748. } // handle trailing things that only matter at the very end.
  12749. clearStateChar();
  12750. if (escaping) {
  12751. // trailing \\
  12752. re += '\\\\';
  12753. } // only need to apply the nodot start if the re starts with
  12754. // something that could conceivably capture a dot
  12755. var addPatternStart = false;
  12756. switch (re.charAt(0)) {
  12757. case '.':
  12758. case '[':
  12759. case '(':
  12760. addPatternStart = true;
  12761. } // Hack to work around lack of negative lookbehind in JS
  12762. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  12763. // like 'a.xyz.yz' doesn't match. So, the first negative
  12764. // lookahead, has to look ALL the way ahead, to the end of
  12765. // the pattern.
  12766. for (var n = negativeLists.length - 1; n > -1; n--) {
  12767. var nl = negativeLists[n];
  12768. var nlBefore = re.slice(0, nl.reStart);
  12769. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  12770. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  12771. var nlAfter = re.slice(nl.reEnd);
  12772. nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
  12773. // mean that we should *not* include the ) in the bit that is considered
  12774. // "after" the negated section.
  12775. var openParensBefore = nlBefore.split('(').length - 1;
  12776. var cleanAfter = nlAfter;
  12777. for (i = 0; i < openParensBefore; i++) {
  12778. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
  12779. }
  12780. nlAfter = cleanAfter;
  12781. var dollar = '';
  12782. if (nlAfter === '' && isSub !== SUBPARSE) {
  12783. dollar = '$';
  12784. }
  12785. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  12786. re = newRe;
  12787. } // if the re is not "" at this point, then we need to make sure
  12788. // it doesn't match against an empty path part.
  12789. // Otherwise a/* will match a/, which it should not.
  12790. if (re !== '' && hasMagic) {
  12791. re = '(?=.)' + re;
  12792. }
  12793. if (addPatternStart) {
  12794. re = patternStart + re;
  12795. } // parsing just a piece of a larger pattern.
  12796. if (isSub === SUBPARSE) {
  12797. return [re, hasMagic];
  12798. } // skip the regexp for non-magical patterns
  12799. // unescape anything in it, though, so that it'll be
  12800. // an exact match against a file etc.
  12801. if (!hasMagic) {
  12802. return globUnescape(pattern);
  12803. }
  12804. var flags = options.nocase ? 'i' : '';
  12805. try {
  12806. var regExp = new RegExp('^' + re + '$', flags);
  12807. } catch (er) {
  12808. // If it was an invalid regular expression, then it can't match
  12809. // anything. This trick looks for a character after the end of
  12810. // the string, which is of course impossible, except in multi-line
  12811. // mode, but it's not a /m regex.
  12812. return new RegExp('$.');
  12813. }
  12814. regExp._glob = pattern;
  12815. regExp._src = re;
  12816. return regExp;
  12817. }
  12818. minimatch$1.makeRe = function (pattern, options) {
  12819. return new Minimatch(pattern, options || {}).makeRe();
  12820. };
  12821. Minimatch.prototype.makeRe = makeRe$1;
  12822. function makeRe$1() {
  12823. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  12824. // pattern strings, or "**".
  12825. //
  12826. // It's better to use .match(). This function shouldn't
  12827. // be used, really, but it's pretty convenient sometimes,
  12828. // when you just want to work with a regex.
  12829. var set = this.set;
  12830. if (!set.length) {
  12831. this.regexp = false;
  12832. return this.regexp;
  12833. }
  12834. var options = this.options;
  12835. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  12836. var flags = options.nocase ? 'i' : '';
  12837. var re = set.map(function (pattern) {
  12838. return pattern.map(function (p) {
  12839. return p === GLOBSTAR$1 ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
  12840. }).join('\\\/');
  12841. }).join('|'); // must match entire pattern
  12842. // ending in a * or ** will make it less strict.
  12843. re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
  12844. if (this.negate) re = '^(?!' + re + ').*$';
  12845. try {
  12846. this.regexp = new RegExp(re, flags);
  12847. } catch (ex) {
  12848. this.regexp = false;
  12849. }
  12850. return this.regexp;
  12851. }
  12852. minimatch$1.match = function (list, pattern, options) {
  12853. options = options || {};
  12854. var mm = new Minimatch(pattern, options);
  12855. list = list.filter(function (f) {
  12856. return mm.match(f);
  12857. });
  12858. if (mm.options.nonull && !list.length) {
  12859. list.push(pattern);
  12860. }
  12861. return list;
  12862. };
  12863. Minimatch.prototype.match = match;
  12864. function match(f, partial) {
  12865. this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
  12866. // comments, etc.
  12867. if (this.comment) return false;
  12868. if (this.empty) return f === '';
  12869. if (f === '/' && partial) return true;
  12870. var options = this.options; // windows: need to use /, not \
  12871. if (path$o.sep !== '/') {
  12872. f = f.split(path$o.sep).join('/');
  12873. } // treat the test path as a set of pathparts.
  12874. f = f.split(slashSplit);
  12875. this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
  12876. // in order for it to be valid. If negating, then just one
  12877. // match means that we have failed.
  12878. // Either way, return on the first hit.
  12879. var set = this.set;
  12880. this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
  12881. var filename;
  12882. var i;
  12883. for (i = f.length - 1; i >= 0; i--) {
  12884. filename = f[i];
  12885. if (filename) break;
  12886. }
  12887. for (i = 0; i < set.length; i++) {
  12888. var pattern = set[i];
  12889. var file = f;
  12890. if (options.matchBase && pattern.length === 1) {
  12891. file = [filename];
  12892. }
  12893. var hit = this.matchOne(file, pattern, partial);
  12894. if (hit) {
  12895. if (options.flipNegate) return true;
  12896. return !this.negate;
  12897. }
  12898. } // didn't get any hits. this is success if it's a negative
  12899. // pattern, failure otherwise.
  12900. if (options.flipNegate) return false;
  12901. return this.negate;
  12902. } // set partial to true to test if, for example,
  12903. // "/a/b" matches the start of "/*/b/*/d"
  12904. // Partial means, if you run out of file before you run
  12905. // out of pattern, then that's fine, as long as all
  12906. // the parts match.
  12907. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  12908. var options = this.options;
  12909. this.debug('matchOne', {
  12910. 'this': this,
  12911. file: file,
  12912. pattern: pattern
  12913. });
  12914. this.debug('matchOne', file.length, pattern.length);
  12915. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  12916. this.debug('matchOne loop');
  12917. var p = pattern[pi];
  12918. var f = file[fi];
  12919. this.debug(pattern, p, f); // should be impossible.
  12920. // some invalid regexp stuff in the set.
  12921. if (p === false) return false;
  12922. if (p === GLOBSTAR$1) {
  12923. this.debug('GLOBSTAR', [pattern, p, f]); // "**"
  12924. // a/**/b/**/c would match the following:
  12925. // a/b/x/y/z/c
  12926. // a/x/y/z/b/c
  12927. // a/b/x/b/x/c
  12928. // a/b/c
  12929. // To do this, take the rest of the pattern after
  12930. // the **, and see if it would match the file remainder.
  12931. // If so, return success.
  12932. // If not, the ** "swallows" a segment, and try again.
  12933. // This is recursively awful.
  12934. //
  12935. // a/**/b/**/c matching a/b/x/y/z/c
  12936. // - a matches a
  12937. // - doublestar
  12938. // - matchOne(b/x/y/z/c, b/**/c)
  12939. // - b matches b
  12940. // - doublestar
  12941. // - matchOne(x/y/z/c, c) -> no
  12942. // - matchOne(y/z/c, c) -> no
  12943. // - matchOne(z/c, c) -> no
  12944. // - matchOne(c, c) yes, hit
  12945. var fr = fi;
  12946. var pr = pi + 1;
  12947. if (pr === pl) {
  12948. this.debug('** at the end'); // a ** at the end will just swallow the rest.
  12949. // We have found a match.
  12950. // however, it will not swallow /.x, unless
  12951. // options.dot is set.
  12952. // . and .. are *never* matched by **, for explosively
  12953. // exponential reasons.
  12954. for (; fi < fl; fi++) {
  12955. if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
  12956. }
  12957. return true;
  12958. } // ok, let's see if we can swallow whatever we can.
  12959. while (fr < fl) {
  12960. var swallowee = file[fr];
  12961. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
  12962. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  12963. this.debug('globstar found match!', fr, fl, swallowee); // found a match.
  12964. return true;
  12965. } else {
  12966. // can't swallow "." or ".." ever.
  12967. // can only swallow ".foo" when explicitly asked.
  12968. if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
  12969. this.debug('dot detected!', file, fr, pattern, pr);
  12970. break;
  12971. } // ** swallows a segment, and continue.
  12972. this.debug('globstar swallow a segment, and continue');
  12973. fr++;
  12974. }
  12975. } // no match was found.
  12976. // However, in partial mode, we can't say this is necessarily over.
  12977. // If there's more *pattern* left, then
  12978. if (partial) {
  12979. // ran out of file
  12980. this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
  12981. if (fr === fl) return true;
  12982. }
  12983. return false;
  12984. } // something other than **
  12985. // non-magic patterns just have to match exactly
  12986. // patterns with magic have been turned into regexps.
  12987. var hit;
  12988. if (typeof p === 'string') {
  12989. if (options.nocase) {
  12990. hit = f.toLowerCase() === p.toLowerCase();
  12991. } else {
  12992. hit = f === p;
  12993. }
  12994. this.debug('string match', p, f, hit);
  12995. } else {
  12996. hit = f.match(p);
  12997. this.debug('pattern match', p, f, hit);
  12998. }
  12999. if (!hit) return false;
  13000. } // Note: ending in / means that we'll get a final ""
  13001. // at the end of the pattern. This can only match a
  13002. // corresponding "" at the end of the file.
  13003. // If the file ends in /, then it can only match a
  13004. // a pattern that ends in /, unless the pattern just
  13005. // doesn't have any more for it. But, a/b/ should *not*
  13006. // match "a/b/*", even though "" matches against the
  13007. // [^/]*? pattern, except in partial mode, where it might
  13008. // simply not be reached yet.
  13009. // However, a/b/ should still satisfy a/*
  13010. // now either we fell off the end of the pattern, or we're done.
  13011. if (fi === fl && pi === pl) {
  13012. // ran out of pattern and filename at the same time.
  13013. // an exact hit!
  13014. return true;
  13015. } else if (fi === fl) {
  13016. // ran out of file, but still had pattern left.
  13017. // this is ok if we're doing the match as part of
  13018. // a glob fs traversal.
  13019. return partial;
  13020. } else if (pi === pl) {
  13021. // ran out of pattern, still have file left.
  13022. // this is only acceptable if we're on the very last
  13023. // empty segment of a file with a trailing slash.
  13024. // a/* should match a/b/
  13025. var emptyFileEnd = fi === fl - 1 && file[fi] === '';
  13026. return emptyFileEnd;
  13027. } // should be unreachable.
  13028. throw new Error('wtf?');
  13029. }; // replace stuff like \* with *
  13030. function globUnescape(s) {
  13031. return s.replace(/\\(.)/g, '$1');
  13032. }
  13033. function regExpEscape(s) {
  13034. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  13035. }
  13036. const copyProperty = (to, from, property, ignoreNonConfigurable) => {
  13037. // `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
  13038. // `Function#prototype` is non-writable and non-configurable so can never be modified.
  13039. if (property === 'length' || property === 'prototype') {
  13040. return;
  13041. } // `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
  13042. if (property === 'arguments' || property === 'caller') {
  13043. return;
  13044. }
  13045. const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
  13046. const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
  13047. if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
  13048. return;
  13049. }
  13050. Object.defineProperty(to, property, fromDescriptor);
  13051. }; // `Object.defineProperty()` throws if the property exists, is not configurable and either:
  13052. // - one its descriptors is changed
  13053. // - it is non-writable and its value is changed
  13054. const canCopyProperty = function (toDescriptor, fromDescriptor) {
  13055. return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
  13056. };
  13057. const changePrototype = (to, from) => {
  13058. const fromPrototype = Object.getPrototypeOf(from);
  13059. if (fromPrototype === Object.getPrototypeOf(to)) {
  13060. return;
  13061. }
  13062. Object.setPrototypeOf(to, fromPrototype);
  13063. };
  13064. const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
  13065. const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
  13066. const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name'); // We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
  13067. // We use `bind()` instead of a closure for the same reason.
  13068. // Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
  13069. const changeToString = (to, from, name) => {
  13070. const withName = name === '' ? '' : `with ${name.trim()}() `;
  13071. const newToString = wrappedToString.bind(null, withName, from.toString()); // Ensure `to.toString.toString` is non-enumerable and has the same `same`
  13072. Object.defineProperty(newToString, 'name', toStringName);
  13073. Object.defineProperty(to, 'toString', Object.assign(Object.assign({}, toStringDescriptor), {}, {
  13074. value: newToString
  13075. }));
  13076. };
  13077. const mimicFn$1 = (to, from, {
  13078. ignoreNonConfigurable = false
  13079. } = {}) => {
  13080. const {
  13081. name
  13082. } = to;
  13083. for (const property of Reflect.ownKeys(from)) {
  13084. copyProperty(to, from, property, ignoreNonConfigurable);
  13085. }
  13086. changePrototype(to, from);
  13087. changeToString(to, from, name);
  13088. return to;
  13089. };
  13090. var mimicFn_1 = mimicFn$1;
  13091. var dist$2 = {exports: {}};
  13092. var pDefer = () => {
  13093. const ret = {};
  13094. ret.promise = new Promise((resolve, reject) => {
  13095. ret.resolve = resolve;
  13096. ret.reject = reject;
  13097. });
  13098. return ret;
  13099. };
  13100. (function (module, exports) {
  13101. var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
  13102. return new (P || (P = Promise))(function (resolve, reject) {
  13103. function fulfilled(value) {
  13104. try {
  13105. step(generator.next(value));
  13106. } catch (e) {
  13107. reject(e);
  13108. }
  13109. }
  13110. function rejected(value) {
  13111. try {
  13112. step(generator["throw"](value));
  13113. } catch (e) {
  13114. reject(e);
  13115. }
  13116. }
  13117. function step(result) {
  13118. result.done ? resolve(result.value) : new P(function (resolve) {
  13119. resolve(result.value);
  13120. }).then(fulfilled, rejected);
  13121. }
  13122. step((generator = generator.apply(thisArg, _arguments || [])).next());
  13123. });
  13124. };
  13125. var __importDefault = this && this.__importDefault || function (mod) {
  13126. return mod && mod.__esModule ? mod : {
  13127. "default": mod
  13128. };
  13129. };
  13130. Object.defineProperty(exports, "__esModule", {
  13131. value: true
  13132. });
  13133. const p_defer_1 = __importDefault(pDefer);
  13134. function mapAgeCleaner(map, property = 'maxAge') {
  13135. let processingKey;
  13136. let processingTimer;
  13137. let processingDeferred;
  13138. const cleanup = () => __awaiter(this, void 0, void 0, function* () {
  13139. if (processingKey !== undefined) {
  13140. // If we are already processing an item, we can safely exit
  13141. return;
  13142. }
  13143. const setupTimer = item => __awaiter(this, void 0, void 0, function* () {
  13144. processingDeferred = p_defer_1.default();
  13145. const delay = item[1][property] - Date.now();
  13146. if (delay <= 0) {
  13147. // Remove the item immediately if the delay is equal to or below 0
  13148. map.delete(item[0]);
  13149. processingDeferred.resolve();
  13150. return;
  13151. } // Keep track of the current processed key
  13152. processingKey = item[0];
  13153. processingTimer = setTimeout(() => {
  13154. // Remove the item when the timeout fires
  13155. map.delete(item[0]);
  13156. if (processingDeferred) {
  13157. processingDeferred.resolve();
  13158. }
  13159. }, delay); // tslint:disable-next-line:strict-type-predicates
  13160. if (typeof processingTimer.unref === 'function') {
  13161. // Don't hold up the process from exiting
  13162. processingTimer.unref();
  13163. }
  13164. return processingDeferred.promise;
  13165. });
  13166. try {
  13167. for (const entry of map) {
  13168. yield setupTimer(entry);
  13169. }
  13170. } catch (_a) {// Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing
  13171. }
  13172. processingKey = undefined;
  13173. });
  13174. const reset = () => {
  13175. processingKey = undefined;
  13176. if (processingTimer !== undefined) {
  13177. clearTimeout(processingTimer);
  13178. processingTimer = undefined;
  13179. }
  13180. if (processingDeferred !== undefined) {
  13181. // tslint:disable-line:early-exit
  13182. processingDeferred.reject(undefined);
  13183. processingDeferred = undefined;
  13184. }
  13185. };
  13186. const originalSet = map.set.bind(map);
  13187. map.set = (key, value) => {
  13188. if (map.has(key)) {
  13189. // If the key already exist, remove it so we can add it back at the end of the map.
  13190. map.delete(key);
  13191. } // Call the original `map.set`
  13192. const result = originalSet(key, value); // If we are already processing a key and the key added is the current processed key, stop processing it
  13193. if (processingKey && processingKey === key) {
  13194. reset();
  13195. } // Always run the cleanup method in case it wasn't started yet
  13196. cleanup(); // tslint:disable-line:no-floating-promises
  13197. return result;
  13198. };
  13199. cleanup(); // tslint:disable-line:no-floating-promises
  13200. return map;
  13201. }
  13202. exports.default = mapAgeCleaner; // Add support for CJS
  13203. module.exports = mapAgeCleaner;
  13204. module.exports.default = mapAgeCleaner;
  13205. })(dist$2, dist$2.exports);
  13206. const mimicFn = mimicFn_1;
  13207. const mapAgeCleaner = dist$2.exports;
  13208. const decoratorInstanceMap = new WeakMap();
  13209. const cacheStore = new WeakMap();
  13210. /**
  13211. [Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
  13212. @param fn - Function to be memoized.
  13213. @example
  13214. ```
  13215. import mem = require('mem');
  13216. let i = 0;
  13217. const counter = () => ++i;
  13218. const memoized = mem(counter);
  13219. memoized('foo');
  13220. //=> 1
  13221. // Cached as it's the same arguments
  13222. memoized('foo');
  13223. //=> 1
  13224. // Not cached anymore as the arguments changed
  13225. memoized('bar');
  13226. //=> 2
  13227. memoized('bar');
  13228. //=> 2
  13229. ```
  13230. */
  13231. const mem$3 = (fn, {
  13232. cacheKey,
  13233. cache = new Map(),
  13234. maxAge
  13235. } = {}) => {
  13236. if (typeof maxAge === 'number') {
  13237. // TODO: Drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
  13238. // @ts-expect-error
  13239. mapAgeCleaner(cache);
  13240. }
  13241. const memoized = function (...arguments_) {
  13242. const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
  13243. const cacheItem = cache.get(key);
  13244. if (cacheItem) {
  13245. return cacheItem.data;
  13246. }
  13247. const result = fn.apply(this, arguments_);
  13248. cache.set(key, {
  13249. data: result,
  13250. maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY
  13251. });
  13252. return result;
  13253. };
  13254. mimicFn(memoized, fn, {
  13255. ignoreNonConfigurable: true
  13256. });
  13257. cacheStore.set(memoized, cache);
  13258. return memoized;
  13259. };
  13260. /**
  13261. @returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
  13262. @example
  13263. ```
  13264. import mem = require('mem');
  13265. class Example {
  13266. index = 0
  13267. @mem.decorator()
  13268. counter() {
  13269. return ++this.index;
  13270. }
  13271. }
  13272. class ExampleWithOptions {
  13273. index = 0
  13274. @mem.decorator({maxAge: 1000})
  13275. counter() {
  13276. return ++this.index;
  13277. }
  13278. }
  13279. ```
  13280. */
  13281. mem$3.decorator = (options = {}) => (target, propertyKey, descriptor) => {
  13282. const input = target[propertyKey];
  13283. if (typeof input !== 'function') {
  13284. throw new TypeError('The decorated value must be a function');
  13285. }
  13286. delete descriptor.value;
  13287. delete descriptor.writable;
  13288. descriptor.get = function () {
  13289. if (!decoratorInstanceMap.has(this)) {
  13290. const value = mem$3(input, options);
  13291. decoratorInstanceMap.set(this, value);
  13292. return value;
  13293. }
  13294. return decoratorInstanceMap.get(this);
  13295. };
  13296. };
  13297. /**
  13298. Clear all cached data of a memoized function.
  13299. @param fn - Memoized function.
  13300. */
  13301. mem$3.clear = fn => {
  13302. const cache = cacheStore.get(fn);
  13303. if (!cache) {
  13304. throw new TypeError('Can\'t clear a function that was not memoized!');
  13305. }
  13306. if (typeof cache.clear !== 'function') {
  13307. throw new TypeError('The cache Map can\'t be cleared!');
  13308. }
  13309. cache.clear();
  13310. };
  13311. var dist$1 = mem$3;
  13312. var require$$7$2 = require("./third-party.js");
  13313. var tomlParser = {exports: {}};
  13314. const ParserEND = 0x110000;
  13315. class ParserError extends Error {
  13316. /* istanbul ignore next */
  13317. constructor(msg, filename, linenumber) {
  13318. super('[ParserError] ' + msg, filename, linenumber);
  13319. this.name = 'ParserError';
  13320. this.code = 'ParserError';
  13321. if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError);
  13322. }
  13323. }
  13324. class State {
  13325. constructor(parser) {
  13326. this.parser = parser;
  13327. this.buf = '';
  13328. this.returned = null;
  13329. this.result = null;
  13330. this.resultTable = null;
  13331. this.resultArr = null;
  13332. }
  13333. }
  13334. class Parser {
  13335. constructor() {
  13336. this.pos = 0;
  13337. this.col = 0;
  13338. this.line = 0;
  13339. this.obj = {};
  13340. this.ctx = this.obj;
  13341. this.stack = [];
  13342. this._buf = '';
  13343. this.char = null;
  13344. this.ii = 0;
  13345. this.state = new State(this.parseStart);
  13346. }
  13347. parse(str) {
  13348. /* istanbul ignore next */
  13349. if (str.length === 0 || str.length == null) return;
  13350. this._buf = String(str);
  13351. this.ii = -1;
  13352. this.char = -1;
  13353. let getNext;
  13354. while (getNext === false || this.nextChar()) {
  13355. getNext = this.runOne();
  13356. }
  13357. this._buf = null;
  13358. }
  13359. nextChar() {
  13360. if (this.char === 0x0A) {
  13361. ++this.line;
  13362. this.col = -1;
  13363. }
  13364. ++this.ii;
  13365. this.char = this._buf.codePointAt(this.ii);
  13366. ++this.pos;
  13367. ++this.col;
  13368. return this.haveBuffer();
  13369. }
  13370. haveBuffer() {
  13371. return this.ii < this._buf.length;
  13372. }
  13373. runOne() {
  13374. return this.state.parser.call(this, this.state.returned);
  13375. }
  13376. finish() {
  13377. this.char = ParserEND;
  13378. let last;
  13379. do {
  13380. last = this.state.parser;
  13381. this.runOne();
  13382. } while (this.state.parser !== last);
  13383. this.ctx = null;
  13384. this.state = null;
  13385. this._buf = null;
  13386. return this.obj;
  13387. }
  13388. next(fn) {
  13389. /* istanbul ignore next */
  13390. if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
  13391. this.state.parser = fn;
  13392. }
  13393. goto(fn) {
  13394. this.next(fn);
  13395. return this.runOne();
  13396. }
  13397. call(fn, returnWith) {
  13398. if (returnWith) this.next(returnWith);
  13399. this.stack.push(this.state);
  13400. this.state = new State(fn);
  13401. }
  13402. callNow(fn, returnWith) {
  13403. this.call(fn, returnWith);
  13404. return this.runOne();
  13405. }
  13406. return(value) {
  13407. /* istanbul ignore next */
  13408. if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'));
  13409. if (value === undefined) value = this.state.buf;
  13410. this.state = this.stack.pop();
  13411. this.state.returned = value;
  13412. }
  13413. returnNow(value) {
  13414. this.return(value);
  13415. return this.runOne();
  13416. }
  13417. consume() {
  13418. /* istanbul ignore next */
  13419. if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
  13420. this.state.buf += this._buf[this.ii];
  13421. }
  13422. error(err) {
  13423. err.line = this.line;
  13424. err.col = this.col;
  13425. err.pos = this.pos;
  13426. return err;
  13427. }
  13428. /* istanbul ignore next */
  13429. parseStart() {
  13430. throw new ParserError('Must declare a parseStart method');
  13431. }
  13432. }
  13433. Parser.END = ParserEND;
  13434. Parser.Error = ParserError;
  13435. var parser = Parser;
  13436. var createDatetime = value => {
  13437. const date = new Date(value);
  13438. /* istanbul ignore if */
  13439. if (isNaN(date)) {
  13440. throw new TypeError('Invalid Datetime');
  13441. } else {
  13442. return date;
  13443. }
  13444. };
  13445. var formatNum = (d, num) => {
  13446. num = String(num);
  13447. while (num.length < d) num = '0' + num;
  13448. return num;
  13449. };
  13450. const f$2 = formatNum;
  13451. class FloatingDateTime extends Date {
  13452. constructor(value) {
  13453. super(value + 'Z');
  13454. this.isFloating = true;
  13455. }
  13456. toISOString() {
  13457. const date = `${this.getUTCFullYear()}-${f$2(2, this.getUTCMonth() + 1)}-${f$2(2, this.getUTCDate())}`;
  13458. const time = `${f$2(2, this.getUTCHours())}:${f$2(2, this.getUTCMinutes())}:${f$2(2, this.getUTCSeconds())}.${f$2(3, this.getUTCMilliseconds())}`;
  13459. return `${date}T${time}`;
  13460. }
  13461. }
  13462. var createDatetimeFloat = value => {
  13463. const date = new FloatingDateTime(value);
  13464. /* istanbul ignore if */
  13465. if (isNaN(date)) {
  13466. throw new TypeError('Invalid Datetime');
  13467. } else {
  13468. return date;
  13469. }
  13470. };
  13471. const f$1 = formatNum;
  13472. const DateTime = global.Date;
  13473. class Date$1 extends DateTime {
  13474. constructor(value) {
  13475. super(value);
  13476. this.isDate = true;
  13477. }
  13478. toISOString() {
  13479. return `${this.getUTCFullYear()}-${f$1(2, this.getUTCMonth() + 1)}-${f$1(2, this.getUTCDate())}`;
  13480. }
  13481. }
  13482. var createDate$1 = value => {
  13483. const date = new Date$1(value);
  13484. /* istanbul ignore if */
  13485. if (isNaN(date)) {
  13486. throw new TypeError('Invalid Datetime');
  13487. } else {
  13488. return date;
  13489. }
  13490. };
  13491. const f = formatNum;
  13492. class Time extends Date {
  13493. constructor(value) {
  13494. super(`0000-01-01T${value}Z`);
  13495. this.isTime = true;
  13496. }
  13497. toISOString() {
  13498. return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
  13499. }
  13500. }
  13501. var createTime$1 = value => {
  13502. const date = new Time(value);
  13503. /* istanbul ignore if */
  13504. if (isNaN(date)) {
  13505. throw new TypeError('Invalid Datetime');
  13506. } else {
  13507. return date;
  13508. }
  13509. };
  13510. /* eslint-disable no-new-wrappers, no-eval, camelcase, operator-linebreak */
  13511. tomlParser.exports = makeParserClass(parser);
  13512. tomlParser.exports.makeParserClass = makeParserClass;
  13513. class TomlError extends Error {
  13514. constructor(msg) {
  13515. super(msg);
  13516. this.name = 'TomlError';
  13517. /* istanbul ignore next */
  13518. if (Error.captureStackTrace) Error.captureStackTrace(this, TomlError);
  13519. this.fromTOML = true;
  13520. this.wrapped = null;
  13521. }
  13522. }
  13523. TomlError.wrap = err => {
  13524. const terr = new TomlError(err.message);
  13525. terr.code = err.code;
  13526. terr.wrapped = err;
  13527. return terr;
  13528. };
  13529. tomlParser.exports.TomlError = TomlError;
  13530. const createDateTime = createDatetime;
  13531. const createDateTimeFloat = createDatetimeFloat;
  13532. const createDate = createDate$1;
  13533. const createTime = createTime$1;
  13534. const CTRL_I = 0x09;
  13535. const CTRL_J = 0x0A;
  13536. const CTRL_M = 0x0D;
  13537. const CTRL_CHAR_BOUNDARY = 0x1F; // the last non-character in the latin1 region of unicode, except DEL
  13538. const CHAR_SP = 0x20;
  13539. const CHAR_QUOT = 0x22;
  13540. const CHAR_NUM = 0x23;
  13541. const CHAR_APOS = 0x27;
  13542. const CHAR_PLUS$1 = 0x2B;
  13543. const CHAR_COMMA$2 = 0x2C;
  13544. const CHAR_HYPHEN = 0x2D;
  13545. const CHAR_PERIOD = 0x2E;
  13546. const CHAR_0 = 0x30;
  13547. const CHAR_1 = 0x31;
  13548. const CHAR_7 = 0x37;
  13549. const CHAR_9 = 0x39;
  13550. const CHAR_COLON = 0x3A;
  13551. const CHAR_EQUALS = 0x3D;
  13552. const CHAR_A = 0x41;
  13553. const CHAR_E = 0x45;
  13554. const CHAR_F = 0x46;
  13555. const CHAR_T = 0x54;
  13556. const CHAR_U = 0x55;
  13557. const CHAR_Z = 0x5A;
  13558. const CHAR_LOWBAR = 0x5F;
  13559. const CHAR_a = 0x61;
  13560. const CHAR_b = 0x62;
  13561. const CHAR_e = 0x65;
  13562. const CHAR_f = 0x66;
  13563. const CHAR_i = 0x69;
  13564. const CHAR_l = 0x6C;
  13565. const CHAR_n = 0x6E;
  13566. const CHAR_o = 0x6F;
  13567. const CHAR_r = 0x72;
  13568. const CHAR_s = 0x73;
  13569. const CHAR_t = 0x74;
  13570. const CHAR_u = 0x75;
  13571. const CHAR_x = 0x78;
  13572. const CHAR_z = 0x7A;
  13573. const CHAR_LCUB = 0x7B;
  13574. const CHAR_RCUB = 0x7D;
  13575. const CHAR_LSQB = 0x5B;
  13576. const CHAR_BSOL = 0x5C;
  13577. const CHAR_RSQB = 0x5D;
  13578. const CHAR_DEL = 0x7F;
  13579. const SURROGATE_FIRST = 0xD800;
  13580. const SURROGATE_LAST = 0xDFFF;
  13581. const escapes = {
  13582. [CHAR_b]: '\u0008',
  13583. [CHAR_t]: '\u0009',
  13584. [CHAR_n]: '\u000A',
  13585. [CHAR_f]: '\u000C',
  13586. [CHAR_r]: '\u000D',
  13587. [CHAR_QUOT]: '\u0022',
  13588. [CHAR_BSOL]: '\u005C'
  13589. };
  13590. function isDigit(cp) {
  13591. return cp >= CHAR_0 && cp <= CHAR_9;
  13592. }
  13593. function isHexit(cp) {
  13594. return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
  13595. }
  13596. function isBit(cp) {
  13597. return cp === CHAR_1 || cp === CHAR_0;
  13598. }
  13599. function isOctit(cp) {
  13600. return cp >= CHAR_0 && cp <= CHAR_7;
  13601. }
  13602. function isAlphaNumQuoteHyphen(cp) {
  13603. 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;
  13604. }
  13605. function isAlphaNumHyphen(cp) {
  13606. 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;
  13607. }
  13608. const _type = Symbol('type');
  13609. const _declared = Symbol('declared');
  13610. const hasOwnProperty$a = Object.prototype.hasOwnProperty;
  13611. const defineProperty = Object.defineProperty;
  13612. const descriptor = {
  13613. configurable: true,
  13614. enumerable: true,
  13615. writable: true,
  13616. value: undefined
  13617. };
  13618. function hasKey(obj, key) {
  13619. if (hasOwnProperty$a.call(obj, key)) return true;
  13620. if (key === '__proto__') defineProperty(obj, '__proto__', descriptor);
  13621. return false;
  13622. }
  13623. const INLINE_TABLE = Symbol('inline-table');
  13624. function InlineTable() {
  13625. return Object.defineProperties({}, {
  13626. [_type]: {
  13627. value: INLINE_TABLE
  13628. }
  13629. });
  13630. }
  13631. function isInlineTable(obj) {
  13632. if (obj === null || typeof obj !== 'object') return false;
  13633. return obj[_type] === INLINE_TABLE;
  13634. }
  13635. const TABLE = Symbol('table');
  13636. function Table() {
  13637. return Object.defineProperties({}, {
  13638. [_type]: {
  13639. value: TABLE
  13640. },
  13641. [_declared]: {
  13642. value: false,
  13643. writable: true
  13644. }
  13645. });
  13646. }
  13647. function isTable(obj) {
  13648. if (obj === null || typeof obj !== 'object') return false;
  13649. return obj[_type] === TABLE;
  13650. }
  13651. const _contentType = Symbol('content-type');
  13652. const INLINE_LIST = Symbol('inline-list');
  13653. function InlineList(type) {
  13654. return Object.defineProperties([], {
  13655. [_type]: {
  13656. value: INLINE_LIST
  13657. },
  13658. [_contentType]: {
  13659. value: type
  13660. }
  13661. });
  13662. }
  13663. function isInlineList(obj) {
  13664. if (obj === null || typeof obj !== 'object') return false;
  13665. return obj[_type] === INLINE_LIST;
  13666. }
  13667. const LIST = Symbol('list');
  13668. function List() {
  13669. return Object.defineProperties([], {
  13670. [_type]: {
  13671. value: LIST
  13672. }
  13673. });
  13674. }
  13675. function isList(obj) {
  13676. if (obj === null || typeof obj !== 'object') return false;
  13677. return obj[_type] === LIST;
  13678. } // in an eval, to let bundlers not slurp in a util proxy
  13679. let _custom;
  13680. try {
  13681. const utilInspect = require('util').inspect;
  13682. _custom = utilInspect.custom;
  13683. } catch (_) {
  13684. /* eval require not available in transpiled bundle */
  13685. }
  13686. /* istanbul ignore next */
  13687. const _inspect = _custom || 'inspect';
  13688. class BoxedBigInt {
  13689. constructor(value) {
  13690. try {
  13691. this.value = global.BigInt.asIntN(64, value);
  13692. } catch (_) {
  13693. /* istanbul ignore next */
  13694. this.value = null;
  13695. }
  13696. Object.defineProperty(this, _type, {
  13697. value: INTEGER
  13698. });
  13699. }
  13700. isNaN() {
  13701. return this.value === null;
  13702. }
  13703. /* istanbul ignore next */
  13704. toString() {
  13705. return String(this.value);
  13706. }
  13707. /* istanbul ignore next */
  13708. [_inspect]() {
  13709. return `[BigInt: ${this.toString()}]}`;
  13710. }
  13711. valueOf() {
  13712. return this.value;
  13713. }
  13714. }
  13715. const INTEGER = Symbol('integer');
  13716. function Integer(value) {
  13717. let num = Number(value); // -0 is a float thing, not an int thing
  13718. if (Object.is(num, -0)) num = 0;
  13719. /* istanbul ignore else */
  13720. if (global.BigInt && !Number.isSafeInteger(num)) {
  13721. return new BoxedBigInt(value);
  13722. } else {
  13723. /* istanbul ignore next */
  13724. return Object.defineProperties(new Number(num), {
  13725. isNaN: {
  13726. value: function () {
  13727. return isNaN(this);
  13728. }
  13729. },
  13730. [_type]: {
  13731. value: INTEGER
  13732. },
  13733. [_inspect]: {
  13734. value: () => `[Integer: ${value}]`
  13735. }
  13736. });
  13737. }
  13738. }
  13739. function isInteger(obj) {
  13740. if (obj === null || typeof obj !== 'object') return false;
  13741. return obj[_type] === INTEGER;
  13742. }
  13743. const FLOAT = Symbol('float');
  13744. function Float(value) {
  13745. /* istanbul ignore next */
  13746. return Object.defineProperties(new Number(value), {
  13747. [_type]: {
  13748. value: FLOAT
  13749. },
  13750. [_inspect]: {
  13751. value: () => `[Float: ${value}]`
  13752. }
  13753. });
  13754. }
  13755. function isFloat(obj) {
  13756. if (obj === null || typeof obj !== 'object') return false;
  13757. return obj[_type] === FLOAT;
  13758. }
  13759. function tomlType(value) {
  13760. const type = typeof value;
  13761. if (type === 'object') {
  13762. /* istanbul ignore if */
  13763. if (value === null) return 'null';
  13764. if (value instanceof Date) return 'datetime';
  13765. /* istanbul ignore else */
  13766. if (_type in value) {
  13767. switch (value[_type]) {
  13768. case INLINE_TABLE:
  13769. return 'inline-table';
  13770. case INLINE_LIST:
  13771. return 'inline-list';
  13772. /* istanbul ignore next */
  13773. case TABLE:
  13774. return 'table';
  13775. /* istanbul ignore next */
  13776. case LIST:
  13777. return 'list';
  13778. case FLOAT:
  13779. return 'float';
  13780. case INTEGER:
  13781. return 'integer';
  13782. }
  13783. }
  13784. }
  13785. return type;
  13786. }
  13787. function makeParserClass(Parser) {
  13788. class TOMLParser extends Parser {
  13789. constructor() {
  13790. super();
  13791. this.ctx = this.obj = Table();
  13792. }
  13793. /* MATCH HELPER */
  13794. atEndOfWord() {
  13795. return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
  13796. }
  13797. atEndOfLine() {
  13798. return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
  13799. }
  13800. parseStart() {
  13801. if (this.char === Parser.END) {
  13802. return null;
  13803. } else if (this.char === CHAR_LSQB) {
  13804. return this.call(this.parseTableOrList);
  13805. } else if (this.char === CHAR_NUM) {
  13806. return this.call(this.parseComment);
  13807. } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  13808. return null;
  13809. } else if (isAlphaNumQuoteHyphen(this.char)) {
  13810. return this.callNow(this.parseAssignStatement);
  13811. } else {
  13812. throw this.error(new TomlError(`Unknown character "${this.char}"`));
  13813. }
  13814. } // HELPER, this strips any whitespace and comments to the end of the line
  13815. // then RETURNS. Last state in a production.
  13816. parseWhitespaceToEOL() {
  13817. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  13818. return null;
  13819. } else if (this.char === CHAR_NUM) {
  13820. return this.goto(this.parseComment);
  13821. } else if (this.char === Parser.END || this.char === CTRL_J) {
  13822. return this.return();
  13823. } else {
  13824. throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
  13825. }
  13826. }
  13827. /* ASSIGNMENT: key = value */
  13828. parseAssignStatement() {
  13829. return this.callNow(this.parseAssign, this.recordAssignStatement);
  13830. }
  13831. recordAssignStatement(kv) {
  13832. let target = this.ctx;
  13833. let finalKey = kv.key.pop();
  13834. for (let kw of kv.key) {
  13835. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  13836. throw this.error(new TomlError("Can't redefine existing key"));
  13837. }
  13838. target = target[kw] = target[kw] || Table();
  13839. }
  13840. if (hasKey(target, finalKey)) {
  13841. throw this.error(new TomlError("Can't redefine existing key"));
  13842. } // unbox our numbers
  13843. if (isInteger(kv.value) || isFloat(kv.value)) {
  13844. target[finalKey] = kv.value.valueOf();
  13845. } else {
  13846. target[finalKey] = kv.value;
  13847. }
  13848. return this.goto(this.parseWhitespaceToEOL);
  13849. }
  13850. /* ASSSIGNMENT expression, key = value possibly inside an inline table */
  13851. parseAssign() {
  13852. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  13853. }
  13854. recordAssignKeyword(key) {
  13855. if (this.state.resultTable) {
  13856. this.state.resultTable.push(key);
  13857. } else {
  13858. this.state.resultTable = [key];
  13859. }
  13860. return this.goto(this.parseAssignKeywordPreDot);
  13861. }
  13862. parseAssignKeywordPreDot() {
  13863. if (this.char === CHAR_PERIOD) {
  13864. return this.next(this.parseAssignKeywordPostDot);
  13865. } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  13866. return this.goto(this.parseAssignEqual);
  13867. }
  13868. }
  13869. parseAssignKeywordPostDot() {
  13870. if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  13871. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  13872. }
  13873. }
  13874. parseAssignEqual() {
  13875. if (this.char === CHAR_EQUALS) {
  13876. return this.next(this.parseAssignPreValue);
  13877. } else {
  13878. throw this.error(new TomlError('Invalid character, expected "="'));
  13879. }
  13880. }
  13881. parseAssignPreValue() {
  13882. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13883. return null;
  13884. } else {
  13885. return this.callNow(this.parseValue, this.recordAssignValue);
  13886. }
  13887. }
  13888. recordAssignValue(value) {
  13889. return this.returnNow({
  13890. key: this.state.resultTable,
  13891. value: value
  13892. });
  13893. }
  13894. /* COMMENTS: #...eol */
  13895. parseComment() {
  13896. do {
  13897. if (this.char === Parser.END || this.char === CTRL_J) {
  13898. return this.return();
  13899. }
  13900. } while (this.nextChar());
  13901. }
  13902. /* TABLES AND LISTS, [foo] and [[foo]] */
  13903. parseTableOrList() {
  13904. if (this.char === CHAR_LSQB) {
  13905. this.next(this.parseList);
  13906. } else {
  13907. return this.goto(this.parseTable);
  13908. }
  13909. }
  13910. /* TABLE [foo.bar.baz] */
  13911. parseTable() {
  13912. this.ctx = this.obj;
  13913. return this.goto(this.parseTableNext);
  13914. }
  13915. parseTableNext() {
  13916. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13917. return null;
  13918. } else {
  13919. return this.callNow(this.parseKeyword, this.parseTableMore);
  13920. }
  13921. }
  13922. parseTableMore(keyword) {
  13923. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13924. return null;
  13925. } else if (this.char === CHAR_RSQB) {
  13926. if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
  13927. throw this.error(new TomlError("Can't redefine existing key"));
  13928. } else {
  13929. this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
  13930. this.ctx[_declared] = true;
  13931. }
  13932. return this.next(this.parseWhitespaceToEOL);
  13933. } else if (this.char === CHAR_PERIOD) {
  13934. if (!hasKey(this.ctx, keyword)) {
  13935. this.ctx = this.ctx[keyword] = Table();
  13936. } else if (isTable(this.ctx[keyword])) {
  13937. this.ctx = this.ctx[keyword];
  13938. } else if (isList(this.ctx[keyword])) {
  13939. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  13940. } else {
  13941. throw this.error(new TomlError("Can't redefine existing key"));
  13942. }
  13943. return this.next(this.parseTableNext);
  13944. } else {
  13945. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  13946. }
  13947. }
  13948. /* LIST [[a.b.c]] */
  13949. parseList() {
  13950. this.ctx = this.obj;
  13951. return this.goto(this.parseListNext);
  13952. }
  13953. parseListNext() {
  13954. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13955. return null;
  13956. } else {
  13957. return this.callNow(this.parseKeyword, this.parseListMore);
  13958. }
  13959. }
  13960. parseListMore(keyword) {
  13961. if (this.char === CHAR_SP || this.char === CTRL_I) {
  13962. return null;
  13963. } else if (this.char === CHAR_RSQB) {
  13964. if (!hasKey(this.ctx, keyword)) {
  13965. this.ctx[keyword] = List();
  13966. }
  13967. if (isInlineList(this.ctx[keyword])) {
  13968. throw this.error(new TomlError("Can't extend an inline array"));
  13969. } else if (isList(this.ctx[keyword])) {
  13970. const next = Table();
  13971. this.ctx[keyword].push(next);
  13972. this.ctx = next;
  13973. } else {
  13974. throw this.error(new TomlError("Can't redefine an existing key"));
  13975. }
  13976. return this.next(this.parseListEnd);
  13977. } else if (this.char === CHAR_PERIOD) {
  13978. if (!hasKey(this.ctx, keyword)) {
  13979. this.ctx = this.ctx[keyword] = Table();
  13980. } else if (isInlineList(this.ctx[keyword])) {
  13981. throw this.error(new TomlError("Can't extend an inline array"));
  13982. } else if (isInlineTable(this.ctx[keyword])) {
  13983. throw this.error(new TomlError("Can't extend an inline table"));
  13984. } else if (isList(this.ctx[keyword])) {
  13985. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  13986. } else if (isTable(this.ctx[keyword])) {
  13987. this.ctx = this.ctx[keyword];
  13988. } else {
  13989. throw this.error(new TomlError("Can't redefine an existing key"));
  13990. }
  13991. return this.next(this.parseListNext);
  13992. } else {
  13993. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  13994. }
  13995. }
  13996. parseListEnd(keyword) {
  13997. if (this.char === CHAR_RSQB) {
  13998. return this.next(this.parseWhitespaceToEOL);
  13999. } else {
  14000. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  14001. }
  14002. }
  14003. /* VALUE string, number, boolean, inline list, inline object */
  14004. parseValue() {
  14005. if (this.char === Parser.END) {
  14006. throw this.error(new TomlError('Key without value'));
  14007. } else if (this.char === CHAR_QUOT) {
  14008. return this.next(this.parseDoubleString);
  14009. }
  14010. if (this.char === CHAR_APOS) {
  14011. return this.next(this.parseSingleString);
  14012. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14013. return this.goto(this.parseNumberSign);
  14014. } else if (this.char === CHAR_i) {
  14015. return this.next(this.parseInf);
  14016. } else if (this.char === CHAR_n) {
  14017. return this.next(this.parseNan);
  14018. } else if (isDigit(this.char)) {
  14019. return this.goto(this.parseNumberOrDateTime);
  14020. } else if (this.char === CHAR_t || this.char === CHAR_f) {
  14021. return this.goto(this.parseBoolean);
  14022. } else if (this.char === CHAR_LSQB) {
  14023. return this.call(this.parseInlineList, this.recordValue);
  14024. } else if (this.char === CHAR_LCUB) {
  14025. return this.call(this.parseInlineTable, this.recordValue);
  14026. } else {
  14027. throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
  14028. }
  14029. }
  14030. recordValue(value) {
  14031. return this.returnNow(value);
  14032. }
  14033. parseInf() {
  14034. if (this.char === CHAR_n) {
  14035. return this.next(this.parseInf2);
  14036. } else {
  14037. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  14038. }
  14039. }
  14040. parseInf2() {
  14041. if (this.char === CHAR_f) {
  14042. if (this.state.buf === '-') {
  14043. return this.return(-Infinity);
  14044. } else {
  14045. return this.return(Infinity);
  14046. }
  14047. } else {
  14048. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  14049. }
  14050. }
  14051. parseNan() {
  14052. if (this.char === CHAR_a) {
  14053. return this.next(this.parseNan2);
  14054. } else {
  14055. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  14056. }
  14057. }
  14058. parseNan2() {
  14059. if (this.char === CHAR_n) {
  14060. return this.return(NaN);
  14061. } else {
  14062. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  14063. }
  14064. }
  14065. /* KEYS, barewords or basic, literal, or dotted */
  14066. parseKeyword() {
  14067. if (this.char === CHAR_QUOT) {
  14068. return this.next(this.parseBasicString);
  14069. } else if (this.char === CHAR_APOS) {
  14070. return this.next(this.parseLiteralString);
  14071. } else {
  14072. return this.goto(this.parseBareKey);
  14073. }
  14074. }
  14075. /* KEYS: barewords */
  14076. parseBareKey() {
  14077. do {
  14078. if (this.char === Parser.END) {
  14079. throw this.error(new TomlError('Key ended without value'));
  14080. } else if (isAlphaNumHyphen(this.char)) {
  14081. this.consume();
  14082. } else if (this.state.buf.length === 0) {
  14083. throw this.error(new TomlError('Empty bare keys are not allowed'));
  14084. } else {
  14085. return this.returnNow();
  14086. }
  14087. } while (this.nextChar());
  14088. }
  14089. /* STRINGS, single quoted (literal) */
  14090. parseSingleString() {
  14091. if (this.char === CHAR_APOS) {
  14092. return this.next(this.parseLiteralMultiStringMaybe);
  14093. } else {
  14094. return this.goto(this.parseLiteralString);
  14095. }
  14096. }
  14097. parseLiteralString() {
  14098. do {
  14099. if (this.char === CHAR_APOS) {
  14100. return this.return();
  14101. } else if (this.atEndOfLine()) {
  14102. throw this.error(new TomlError('Unterminated string'));
  14103. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  14104. throw this.errorControlCharInString();
  14105. } else {
  14106. this.consume();
  14107. }
  14108. } while (this.nextChar());
  14109. }
  14110. parseLiteralMultiStringMaybe() {
  14111. if (this.char === CHAR_APOS) {
  14112. return this.next(this.parseLiteralMultiString);
  14113. } else {
  14114. return this.returnNow();
  14115. }
  14116. }
  14117. parseLiteralMultiString() {
  14118. if (this.char === CTRL_M) {
  14119. return null;
  14120. } else if (this.char === CTRL_J) {
  14121. return this.next(this.parseLiteralMultiStringContent);
  14122. } else {
  14123. return this.goto(this.parseLiteralMultiStringContent);
  14124. }
  14125. }
  14126. parseLiteralMultiStringContent() {
  14127. do {
  14128. if (this.char === CHAR_APOS) {
  14129. return this.next(this.parseLiteralMultiEnd);
  14130. } else if (this.char === Parser.END) {
  14131. throw this.error(new TomlError('Unterminated multi-line string'));
  14132. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  14133. throw this.errorControlCharInString();
  14134. } else {
  14135. this.consume();
  14136. }
  14137. } while (this.nextChar());
  14138. }
  14139. parseLiteralMultiEnd() {
  14140. if (this.char === CHAR_APOS) {
  14141. return this.next(this.parseLiteralMultiEnd2);
  14142. } else {
  14143. this.state.buf += "'";
  14144. return this.goto(this.parseLiteralMultiStringContent);
  14145. }
  14146. }
  14147. parseLiteralMultiEnd2() {
  14148. if (this.char === CHAR_APOS) {
  14149. return this.return();
  14150. } else {
  14151. this.state.buf += "''";
  14152. return this.goto(this.parseLiteralMultiStringContent);
  14153. }
  14154. }
  14155. /* STRINGS double quoted */
  14156. parseDoubleString() {
  14157. if (this.char === CHAR_QUOT) {
  14158. return this.next(this.parseMultiStringMaybe);
  14159. } else {
  14160. return this.goto(this.parseBasicString);
  14161. }
  14162. }
  14163. parseBasicString() {
  14164. do {
  14165. if (this.char === CHAR_BSOL) {
  14166. return this.call(this.parseEscape, this.recordEscapeReplacement);
  14167. } else if (this.char === CHAR_QUOT) {
  14168. return this.return();
  14169. } else if (this.atEndOfLine()) {
  14170. throw this.error(new TomlError('Unterminated string'));
  14171. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  14172. throw this.errorControlCharInString();
  14173. } else {
  14174. this.consume();
  14175. }
  14176. } while (this.nextChar());
  14177. }
  14178. recordEscapeReplacement(replacement) {
  14179. this.state.buf += replacement;
  14180. return this.goto(this.parseBasicString);
  14181. }
  14182. parseMultiStringMaybe() {
  14183. if (this.char === CHAR_QUOT) {
  14184. return this.next(this.parseMultiString);
  14185. } else {
  14186. return this.returnNow();
  14187. }
  14188. }
  14189. parseMultiString() {
  14190. if (this.char === CTRL_M) {
  14191. return null;
  14192. } else if (this.char === CTRL_J) {
  14193. return this.next(this.parseMultiStringContent);
  14194. } else {
  14195. return this.goto(this.parseMultiStringContent);
  14196. }
  14197. }
  14198. parseMultiStringContent() {
  14199. do {
  14200. if (this.char === CHAR_BSOL) {
  14201. return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
  14202. } else if (this.char === CHAR_QUOT) {
  14203. return this.next(this.parseMultiEnd);
  14204. } else if (this.char === Parser.END) {
  14205. throw this.error(new TomlError('Unterminated multi-line string'));
  14206. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  14207. throw this.errorControlCharInString();
  14208. } else {
  14209. this.consume();
  14210. }
  14211. } while (this.nextChar());
  14212. }
  14213. errorControlCharInString() {
  14214. let displayCode = '\\u00';
  14215. if (this.char < 16) {
  14216. displayCode += '0';
  14217. }
  14218. displayCode += this.char.toString(16);
  14219. return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
  14220. }
  14221. recordMultiEscapeReplacement(replacement) {
  14222. this.state.buf += replacement;
  14223. return this.goto(this.parseMultiStringContent);
  14224. }
  14225. parseMultiEnd() {
  14226. if (this.char === CHAR_QUOT) {
  14227. return this.next(this.parseMultiEnd2);
  14228. } else {
  14229. this.state.buf += '"';
  14230. return this.goto(this.parseMultiStringContent);
  14231. }
  14232. }
  14233. parseMultiEnd2() {
  14234. if (this.char === CHAR_QUOT) {
  14235. return this.return();
  14236. } else {
  14237. this.state.buf += '""';
  14238. return this.goto(this.parseMultiStringContent);
  14239. }
  14240. }
  14241. parseMultiEscape() {
  14242. if (this.char === CTRL_M || this.char === CTRL_J) {
  14243. return this.next(this.parseMultiTrim);
  14244. } else if (this.char === CHAR_SP || this.char === CTRL_I) {
  14245. return this.next(this.parsePreMultiTrim);
  14246. } else {
  14247. return this.goto(this.parseEscape);
  14248. }
  14249. }
  14250. parsePreMultiTrim() {
  14251. if (this.char === CHAR_SP || this.char === CTRL_I) {
  14252. return null;
  14253. } else if (this.char === CTRL_M || this.char === CTRL_J) {
  14254. return this.next(this.parseMultiTrim);
  14255. } else {
  14256. throw this.error(new TomlError("Can't escape whitespace"));
  14257. }
  14258. }
  14259. parseMultiTrim() {
  14260. // explicitly whitespace here, END should follow the same path as chars
  14261. if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  14262. return null;
  14263. } else {
  14264. return this.returnNow();
  14265. }
  14266. }
  14267. parseEscape() {
  14268. if (this.char in escapes) {
  14269. return this.return(escapes[this.char]);
  14270. } else if (this.char === CHAR_u) {
  14271. return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
  14272. } else if (this.char === CHAR_U) {
  14273. return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
  14274. } else {
  14275. throw this.error(new TomlError('Unknown escape character: ' + this.char));
  14276. }
  14277. }
  14278. parseUnicodeReturn(char) {
  14279. try {
  14280. const codePoint = parseInt(char, 16);
  14281. if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
  14282. throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
  14283. }
  14284. return this.returnNow(String.fromCodePoint(codePoint));
  14285. } catch (err) {
  14286. throw this.error(TomlError.wrap(err));
  14287. }
  14288. }
  14289. parseSmallUnicode() {
  14290. if (!isHexit(this.char)) {
  14291. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  14292. } else {
  14293. this.consume();
  14294. if (this.state.buf.length >= 4) return this.return();
  14295. }
  14296. }
  14297. parseLargeUnicode() {
  14298. if (!isHexit(this.char)) {
  14299. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  14300. } else {
  14301. this.consume();
  14302. if (this.state.buf.length >= 8) return this.return();
  14303. }
  14304. }
  14305. /* NUMBERS */
  14306. parseNumberSign() {
  14307. this.consume();
  14308. return this.next(this.parseMaybeSignedInfOrNan);
  14309. }
  14310. parseMaybeSignedInfOrNan() {
  14311. if (this.char === CHAR_i) {
  14312. return this.next(this.parseInf);
  14313. } else if (this.char === CHAR_n) {
  14314. return this.next(this.parseNan);
  14315. } else {
  14316. return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
  14317. }
  14318. }
  14319. parseNumberIntegerStart() {
  14320. if (this.char === CHAR_0) {
  14321. this.consume();
  14322. return this.next(this.parseNumberIntegerExponentOrDecimal);
  14323. } else {
  14324. return this.goto(this.parseNumberInteger);
  14325. }
  14326. }
  14327. parseNumberIntegerExponentOrDecimal() {
  14328. if (this.char === CHAR_PERIOD) {
  14329. this.consume();
  14330. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14331. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14332. this.consume();
  14333. return this.next(this.parseNumberExponentSign);
  14334. } else {
  14335. return this.returnNow(Integer(this.state.buf));
  14336. }
  14337. }
  14338. parseNumberInteger() {
  14339. if (isDigit(this.char)) {
  14340. this.consume();
  14341. } else if (this.char === CHAR_LOWBAR) {
  14342. return this.call(this.parseNoUnder);
  14343. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14344. this.consume();
  14345. return this.next(this.parseNumberExponentSign);
  14346. } else if (this.char === CHAR_PERIOD) {
  14347. this.consume();
  14348. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14349. } else {
  14350. const result = Integer(this.state.buf);
  14351. /* istanbul ignore if */
  14352. if (result.isNaN()) {
  14353. throw this.error(new TomlError('Invalid number'));
  14354. } else {
  14355. return this.returnNow(result);
  14356. }
  14357. }
  14358. }
  14359. parseNoUnder() {
  14360. if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
  14361. throw this.error(new TomlError('Unexpected character, expected digit'));
  14362. } else if (this.atEndOfWord()) {
  14363. throw this.error(new TomlError('Incomplete number'));
  14364. }
  14365. return this.returnNow();
  14366. }
  14367. parseNoUnderHexOctBinLiteral() {
  14368. if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) {
  14369. throw this.error(new TomlError('Unexpected character, expected digit'));
  14370. } else if (this.atEndOfWord()) {
  14371. throw this.error(new TomlError('Incomplete number'));
  14372. }
  14373. return this.returnNow();
  14374. }
  14375. parseNumberFloat() {
  14376. if (this.char === CHAR_LOWBAR) {
  14377. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14378. } else if (isDigit(this.char)) {
  14379. this.consume();
  14380. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14381. this.consume();
  14382. return this.next(this.parseNumberExponentSign);
  14383. } else {
  14384. return this.returnNow(Float(this.state.buf));
  14385. }
  14386. }
  14387. parseNumberExponentSign() {
  14388. if (isDigit(this.char)) {
  14389. return this.goto(this.parseNumberExponent);
  14390. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14391. this.consume();
  14392. this.call(this.parseNoUnder, this.parseNumberExponent);
  14393. } else {
  14394. throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
  14395. }
  14396. }
  14397. parseNumberExponent() {
  14398. if (isDigit(this.char)) {
  14399. this.consume();
  14400. } else if (this.char === CHAR_LOWBAR) {
  14401. return this.call(this.parseNoUnder);
  14402. } else {
  14403. return this.returnNow(Float(this.state.buf));
  14404. }
  14405. }
  14406. /* NUMBERS or DATETIMES */
  14407. parseNumberOrDateTime() {
  14408. if (this.char === CHAR_0) {
  14409. this.consume();
  14410. return this.next(this.parseNumberBaseOrDateTime);
  14411. } else {
  14412. return this.goto(this.parseNumberOrDateTimeOnly);
  14413. }
  14414. }
  14415. parseNumberOrDateTimeOnly() {
  14416. // note, if two zeros are in a row then it MUST be a date
  14417. if (this.char === CHAR_LOWBAR) {
  14418. return this.call(this.parseNoUnder, this.parseNumberInteger);
  14419. } else if (isDigit(this.char)) {
  14420. this.consume();
  14421. if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
  14422. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  14423. this.consume();
  14424. return this.next(this.parseNumberExponentSign);
  14425. } else if (this.char === CHAR_PERIOD) {
  14426. this.consume();
  14427. return this.call(this.parseNoUnder, this.parseNumberFloat);
  14428. } else if (this.char === CHAR_HYPHEN) {
  14429. return this.goto(this.parseDateTime);
  14430. } else if (this.char === CHAR_COLON) {
  14431. return this.goto(this.parseOnlyTimeHour);
  14432. } else {
  14433. return this.returnNow(Integer(this.state.buf));
  14434. }
  14435. }
  14436. parseDateTimeOnly() {
  14437. if (this.state.buf.length < 4) {
  14438. if (isDigit(this.char)) {
  14439. return this.consume();
  14440. } else if (this.char === CHAR_COLON) {
  14441. return this.goto(this.parseOnlyTimeHour);
  14442. } else {
  14443. throw this.error(new TomlError('Expected digit while parsing year part of a date'));
  14444. }
  14445. } else {
  14446. if (this.char === CHAR_HYPHEN) {
  14447. return this.goto(this.parseDateTime);
  14448. } else {
  14449. throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
  14450. }
  14451. }
  14452. }
  14453. parseNumberBaseOrDateTime() {
  14454. if (this.char === CHAR_b) {
  14455. this.consume();
  14456. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin);
  14457. } else if (this.char === CHAR_o) {
  14458. this.consume();
  14459. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct);
  14460. } else if (this.char === CHAR_x) {
  14461. this.consume();
  14462. return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex);
  14463. } else if (this.char === CHAR_PERIOD) {
  14464. return this.goto(this.parseNumberInteger);
  14465. } else if (isDigit(this.char)) {
  14466. return this.goto(this.parseDateTimeOnly);
  14467. } else {
  14468. return this.returnNow(Integer(this.state.buf));
  14469. }
  14470. }
  14471. parseIntegerHex() {
  14472. if (isHexit(this.char)) {
  14473. this.consume();
  14474. } else if (this.char === CHAR_LOWBAR) {
  14475. return this.call(this.parseNoUnderHexOctBinLiteral);
  14476. } else {
  14477. const result = Integer(this.state.buf);
  14478. /* istanbul ignore if */
  14479. if (result.isNaN()) {
  14480. throw this.error(new TomlError('Invalid number'));
  14481. } else {
  14482. return this.returnNow(result);
  14483. }
  14484. }
  14485. }
  14486. parseIntegerOct() {
  14487. if (isOctit(this.char)) {
  14488. this.consume();
  14489. } else if (this.char === CHAR_LOWBAR) {
  14490. return this.call(this.parseNoUnderHexOctBinLiteral);
  14491. } else {
  14492. const result = Integer(this.state.buf);
  14493. /* istanbul ignore if */
  14494. if (result.isNaN()) {
  14495. throw this.error(new TomlError('Invalid number'));
  14496. } else {
  14497. return this.returnNow(result);
  14498. }
  14499. }
  14500. }
  14501. parseIntegerBin() {
  14502. if (isBit(this.char)) {
  14503. this.consume();
  14504. } else if (this.char === CHAR_LOWBAR) {
  14505. return this.call(this.parseNoUnderHexOctBinLiteral);
  14506. } else {
  14507. const result = Integer(this.state.buf);
  14508. /* istanbul ignore if */
  14509. if (result.isNaN()) {
  14510. throw this.error(new TomlError('Invalid number'));
  14511. } else {
  14512. return this.returnNow(result);
  14513. }
  14514. }
  14515. }
  14516. /* DATETIME */
  14517. parseDateTime() {
  14518. // we enter here having just consumed the year and about to consume the hyphen
  14519. if (this.state.buf.length < 4) {
  14520. throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
  14521. }
  14522. this.state.result = this.state.buf;
  14523. this.state.buf = '';
  14524. return this.next(this.parseDateMonth);
  14525. }
  14526. parseDateMonth() {
  14527. if (this.char === CHAR_HYPHEN) {
  14528. if (this.state.buf.length < 2) {
  14529. throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
  14530. }
  14531. this.state.result += '-' + this.state.buf;
  14532. this.state.buf = '';
  14533. return this.next(this.parseDateDay);
  14534. } else if (isDigit(this.char)) {
  14535. this.consume();
  14536. } else {
  14537. throw this.error(new TomlError('Incomplete datetime'));
  14538. }
  14539. }
  14540. parseDateDay() {
  14541. if (this.char === CHAR_T || this.char === CHAR_SP) {
  14542. if (this.state.buf.length < 2) {
  14543. throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
  14544. }
  14545. this.state.result += '-' + this.state.buf;
  14546. this.state.buf = '';
  14547. return this.next(this.parseStartTimeHour);
  14548. } else if (this.atEndOfWord()) {
  14549. return this.returnNow(createDate(this.state.result + '-' + this.state.buf));
  14550. } else if (isDigit(this.char)) {
  14551. this.consume();
  14552. } else {
  14553. throw this.error(new TomlError('Incomplete datetime'));
  14554. }
  14555. }
  14556. parseStartTimeHour() {
  14557. if (this.atEndOfWord()) {
  14558. return this.returnNow(createDate(this.state.result));
  14559. } else {
  14560. return this.goto(this.parseTimeHour);
  14561. }
  14562. }
  14563. parseTimeHour() {
  14564. if (this.char === CHAR_COLON) {
  14565. if (this.state.buf.length < 2) {
  14566. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  14567. }
  14568. this.state.result += 'T' + this.state.buf;
  14569. this.state.buf = '';
  14570. return this.next(this.parseTimeMin);
  14571. } else if (isDigit(this.char)) {
  14572. this.consume();
  14573. } else {
  14574. throw this.error(new TomlError('Incomplete datetime'));
  14575. }
  14576. }
  14577. parseTimeMin() {
  14578. if (this.state.buf.length < 2 && isDigit(this.char)) {
  14579. this.consume();
  14580. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  14581. this.state.result += ':' + this.state.buf;
  14582. this.state.buf = '';
  14583. return this.next(this.parseTimeSec);
  14584. } else {
  14585. throw this.error(new TomlError('Incomplete datetime'));
  14586. }
  14587. }
  14588. parseTimeSec() {
  14589. if (isDigit(this.char)) {
  14590. this.consume();
  14591. if (this.state.buf.length === 2) {
  14592. this.state.result += ':' + this.state.buf;
  14593. this.state.buf = '';
  14594. return this.next(this.parseTimeZoneOrFraction);
  14595. }
  14596. } else {
  14597. throw this.error(new TomlError('Incomplete datetime'));
  14598. }
  14599. }
  14600. parseOnlyTimeHour() {
  14601. /* istanbul ignore else */
  14602. if (this.char === CHAR_COLON) {
  14603. if (this.state.buf.length < 2) {
  14604. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  14605. }
  14606. this.state.result = this.state.buf;
  14607. this.state.buf = '';
  14608. return this.next(this.parseOnlyTimeMin);
  14609. } else {
  14610. throw this.error(new TomlError('Incomplete time'));
  14611. }
  14612. }
  14613. parseOnlyTimeMin() {
  14614. if (this.state.buf.length < 2 && isDigit(this.char)) {
  14615. this.consume();
  14616. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  14617. this.state.result += ':' + this.state.buf;
  14618. this.state.buf = '';
  14619. return this.next(this.parseOnlyTimeSec);
  14620. } else {
  14621. throw this.error(new TomlError('Incomplete time'));
  14622. }
  14623. }
  14624. parseOnlyTimeSec() {
  14625. if (isDigit(this.char)) {
  14626. this.consume();
  14627. if (this.state.buf.length === 2) {
  14628. return this.next(this.parseOnlyTimeFractionMaybe);
  14629. }
  14630. } else {
  14631. throw this.error(new TomlError('Incomplete time'));
  14632. }
  14633. }
  14634. parseOnlyTimeFractionMaybe() {
  14635. this.state.result += ':' + this.state.buf;
  14636. if (this.char === CHAR_PERIOD) {
  14637. this.state.buf = '';
  14638. this.next(this.parseOnlyTimeFraction);
  14639. } else {
  14640. return this.return(createTime(this.state.result));
  14641. }
  14642. }
  14643. parseOnlyTimeFraction() {
  14644. if (isDigit(this.char)) {
  14645. this.consume();
  14646. } else if (this.atEndOfWord()) {
  14647. if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
  14648. return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
  14649. } else {
  14650. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14651. }
  14652. }
  14653. parseTimeZoneOrFraction() {
  14654. if (this.char === CHAR_PERIOD) {
  14655. this.consume();
  14656. this.next(this.parseDateTimeFraction);
  14657. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14658. this.consume();
  14659. this.next(this.parseTimeZoneHour);
  14660. } else if (this.char === CHAR_Z) {
  14661. this.consume();
  14662. return this.return(createDateTime(this.state.result + this.state.buf));
  14663. } else if (this.atEndOfWord()) {
  14664. return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
  14665. } else {
  14666. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14667. }
  14668. }
  14669. parseDateTimeFraction() {
  14670. if (isDigit(this.char)) {
  14671. this.consume();
  14672. } else if (this.state.buf.length === 1) {
  14673. throw this.error(new TomlError('Expected digit in milliseconds'));
  14674. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS$1) {
  14675. this.consume();
  14676. this.next(this.parseTimeZoneHour);
  14677. } else if (this.char === CHAR_Z) {
  14678. this.consume();
  14679. return this.return(createDateTime(this.state.result + this.state.buf));
  14680. } else if (this.atEndOfWord()) {
  14681. return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
  14682. } else {
  14683. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  14684. }
  14685. }
  14686. parseTimeZoneHour() {
  14687. if (isDigit(this.char)) {
  14688. this.consume(); // FIXME: No more regexps
  14689. if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
  14690. } else {
  14691. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  14692. }
  14693. }
  14694. parseTimeZoneSep() {
  14695. if (this.char === CHAR_COLON) {
  14696. this.consume();
  14697. this.next(this.parseTimeZoneMin);
  14698. } else {
  14699. throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
  14700. }
  14701. }
  14702. parseTimeZoneMin() {
  14703. if (isDigit(this.char)) {
  14704. this.consume();
  14705. if (/\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf));
  14706. } else {
  14707. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  14708. }
  14709. }
  14710. /* BOOLEAN */
  14711. parseBoolean() {
  14712. /* istanbul ignore else */
  14713. if (this.char === CHAR_t) {
  14714. this.consume();
  14715. return this.next(this.parseTrue_r);
  14716. } else if (this.char === CHAR_f) {
  14717. this.consume();
  14718. return this.next(this.parseFalse_a);
  14719. }
  14720. }
  14721. parseTrue_r() {
  14722. if (this.char === CHAR_r) {
  14723. this.consume();
  14724. return this.next(this.parseTrue_u);
  14725. } else {
  14726. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14727. }
  14728. }
  14729. parseTrue_u() {
  14730. if (this.char === CHAR_u) {
  14731. this.consume();
  14732. return this.next(this.parseTrue_e);
  14733. } else {
  14734. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14735. }
  14736. }
  14737. parseTrue_e() {
  14738. if (this.char === CHAR_e) {
  14739. return this.return(true);
  14740. } else {
  14741. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14742. }
  14743. }
  14744. parseFalse_a() {
  14745. if (this.char === CHAR_a) {
  14746. this.consume();
  14747. return this.next(this.parseFalse_l);
  14748. } else {
  14749. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14750. }
  14751. }
  14752. parseFalse_l() {
  14753. if (this.char === CHAR_l) {
  14754. this.consume();
  14755. return this.next(this.parseFalse_s);
  14756. } else {
  14757. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14758. }
  14759. }
  14760. parseFalse_s() {
  14761. if (this.char === CHAR_s) {
  14762. this.consume();
  14763. return this.next(this.parseFalse_e);
  14764. } else {
  14765. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14766. }
  14767. }
  14768. parseFalse_e() {
  14769. if (this.char === CHAR_e) {
  14770. return this.return(false);
  14771. } else {
  14772. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  14773. }
  14774. }
  14775. /* INLINE LISTS */
  14776. parseInlineList() {
  14777. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  14778. return null;
  14779. } else if (this.char === Parser.END) {
  14780. throw this.error(new TomlError('Unterminated inline array'));
  14781. } else if (this.char === CHAR_NUM) {
  14782. return this.call(this.parseComment);
  14783. } else if (this.char === CHAR_RSQB) {
  14784. return this.return(this.state.resultArr || InlineList());
  14785. } else {
  14786. return this.callNow(this.parseValue, this.recordInlineListValue);
  14787. }
  14788. }
  14789. recordInlineListValue(value) {
  14790. if (this.state.resultArr) {
  14791. const listType = this.state.resultArr[_contentType];
  14792. const valueType = tomlType(value);
  14793. if (listType !== valueType) {
  14794. throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
  14795. }
  14796. } else {
  14797. this.state.resultArr = InlineList(tomlType(value));
  14798. }
  14799. if (isFloat(value) || isInteger(value)) {
  14800. // unbox now that we've verified they're ok
  14801. this.state.resultArr.push(value.valueOf());
  14802. } else {
  14803. this.state.resultArr.push(value);
  14804. }
  14805. return this.goto(this.parseInlineListNext);
  14806. }
  14807. parseInlineListNext() {
  14808. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  14809. return null;
  14810. } else if (this.char === CHAR_NUM) {
  14811. return this.call(this.parseComment);
  14812. } else if (this.char === CHAR_COMMA$2) {
  14813. return this.next(this.parseInlineList);
  14814. } else if (this.char === CHAR_RSQB) {
  14815. return this.goto(this.parseInlineList);
  14816. } else {
  14817. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  14818. }
  14819. }
  14820. /* INLINE TABLE */
  14821. parseInlineTable() {
  14822. if (this.char === CHAR_SP || this.char === CTRL_I) {
  14823. return null;
  14824. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  14825. throw this.error(new TomlError('Unterminated inline array'));
  14826. } else if (this.char === CHAR_RCUB) {
  14827. return this.return(this.state.resultTable || InlineTable());
  14828. } else {
  14829. if (!this.state.resultTable) this.state.resultTable = InlineTable();
  14830. return this.callNow(this.parseAssign, this.recordInlineTableValue);
  14831. }
  14832. }
  14833. recordInlineTableValue(kv) {
  14834. let target = this.state.resultTable;
  14835. let finalKey = kv.key.pop();
  14836. for (let kw of kv.key) {
  14837. if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
  14838. throw this.error(new TomlError("Can't redefine existing key"));
  14839. }
  14840. target = target[kw] = target[kw] || Table();
  14841. }
  14842. if (hasKey(target, finalKey)) {
  14843. throw this.error(new TomlError("Can't redefine existing key"));
  14844. }
  14845. if (isInteger(kv.value) || isFloat(kv.value)) {
  14846. target[finalKey] = kv.value.valueOf();
  14847. } else {
  14848. target[finalKey] = kv.value;
  14849. }
  14850. return this.goto(this.parseInlineTableNext);
  14851. }
  14852. parseInlineTableNext() {
  14853. if (this.char === CHAR_SP || this.char === CTRL_I) {
  14854. return null;
  14855. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  14856. throw this.error(new TomlError('Unterminated inline array'));
  14857. } else if (this.char === CHAR_COMMA$2) {
  14858. return this.next(this.parseInlineTable);
  14859. } else if (this.char === CHAR_RCUB) {
  14860. return this.goto(this.parseInlineTable);
  14861. } else {
  14862. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  14863. }
  14864. }
  14865. }
  14866. return TOMLParser;
  14867. }
  14868. var parsePrettyError = prettyError$1;
  14869. function prettyError$1(err, buf) {
  14870. /* istanbul ignore if */
  14871. if (err.pos == null || err.line == null) return err;
  14872. let msg = err.message;
  14873. msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
  14874. /* istanbul ignore else */
  14875. if (buf && buf.split) {
  14876. const lines = buf.split(/\n/);
  14877. const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
  14878. let linePadding = ' ';
  14879. while (linePadding.length < lineNumWidth) linePadding += ' ';
  14880. for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
  14881. let lineNum = String(ii + 1);
  14882. if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
  14883. if (err.line === ii) {
  14884. msg += lineNum + '> ' + lines[ii] + '\n';
  14885. msg += linePadding + ' ';
  14886. for (let hh = 0; hh < err.col; ++hh) {
  14887. msg += ' ';
  14888. }
  14889. msg += '^\n';
  14890. } else {
  14891. msg += lineNum + ': ' + lines[ii] + '\n';
  14892. }
  14893. }
  14894. }
  14895. err.message = msg + '\n';
  14896. return err;
  14897. }
  14898. var parseString_1 = parseString$1;
  14899. const TOMLParser = tomlParser.exports;
  14900. const prettyError = parsePrettyError;
  14901. function parseString$1(str) {
  14902. if (global.Buffer && global.Buffer.isBuffer(str)) {
  14903. str = str.toString('utf8');
  14904. }
  14905. const parser = new TOMLParser();
  14906. try {
  14907. parser.parse(str);
  14908. return parser.finish();
  14909. } catch (err) {
  14910. throw prettyError(err, str);
  14911. }
  14912. }
  14913. const parse$b = parseString_1;
  14914. var loadToml$1 = function (filePath, content) {
  14915. try {
  14916. return parse$b(content);
  14917. } catch (error) {
  14918. error.message = `TOML Error in ${filePath}:\n${error.message}`;
  14919. throw error;
  14920. }
  14921. };
  14922. // This is a generated file. Do not edit.
  14923. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  14924. var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
  14925. var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
  14926. var unicode = {
  14927. Space_Separator: Space_Separator,
  14928. ID_Start: ID_Start,
  14929. ID_Continue: ID_Continue
  14930. };
  14931. var util$6 = {
  14932. isSpaceSeparator(c) {
  14933. return typeof c === 'string' && unicode.Space_Separator.test(c);
  14934. },
  14935. isIdStartChar(c) {
  14936. return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c === '$' || c === '_' || unicode.ID_Start.test(c));
  14937. },
  14938. isIdContinueChar(c) {
  14939. return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '$' || c === '_' || c === '\u200C' || c === '\u200D' || unicode.ID_Continue.test(c));
  14940. },
  14941. isDigit(c) {
  14942. return typeof c === 'string' && /[0-9]/.test(c);
  14943. },
  14944. isHexDigit(c) {
  14945. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c);
  14946. }
  14947. };
  14948. let source$1;
  14949. let parseState;
  14950. let stack;
  14951. let pos;
  14952. let line$z;
  14953. let column;
  14954. let token;
  14955. let key;
  14956. let root$9;
  14957. var parse$a = function parse(text, reviver) {
  14958. source$1 = String(text);
  14959. parseState = 'start';
  14960. stack = [];
  14961. pos = 0;
  14962. line$z = 1;
  14963. column = 0;
  14964. token = undefined;
  14965. key = undefined;
  14966. root$9 = undefined;
  14967. do {
  14968. token = lex(); // This code is unreachable.
  14969. // if (!parseStates[parseState]) {
  14970. // throw invalidParseState()
  14971. // }
  14972. parseStates[parseState]();
  14973. } while (token.type !== 'eof');
  14974. if (typeof reviver === 'function') {
  14975. return internalize({
  14976. '': root$9
  14977. }, '', reviver);
  14978. }
  14979. return root$9;
  14980. };
  14981. function internalize(holder, name, reviver) {
  14982. const value = holder[name];
  14983. if (value != null && typeof value === 'object') {
  14984. for (const key in value) {
  14985. const replacement = internalize(value, key, reviver);
  14986. if (replacement === undefined) {
  14987. delete value[key];
  14988. } else {
  14989. value[key] = replacement;
  14990. }
  14991. }
  14992. }
  14993. return reviver.call(holder, name, value);
  14994. }
  14995. let lexState;
  14996. let buffer$2;
  14997. let doubleQuote;
  14998. let sign;
  14999. let c;
  15000. function lex() {
  15001. lexState = 'default';
  15002. buffer$2 = '';
  15003. doubleQuote = false;
  15004. sign = 1;
  15005. for (;;) {
  15006. c = peek(); // This code is unreachable.
  15007. // if (!lexStates[lexState]) {
  15008. // throw invalidLexState(lexState)
  15009. // }
  15010. const token = lexStates[lexState]();
  15011. if (token) {
  15012. return token;
  15013. }
  15014. }
  15015. }
  15016. function peek() {
  15017. if (source$1[pos]) {
  15018. return String.fromCodePoint(source$1.codePointAt(pos));
  15019. }
  15020. }
  15021. function read$4() {
  15022. const c = peek();
  15023. if (c === '\n') {
  15024. line$z++;
  15025. column = 0;
  15026. } else if (c) {
  15027. column += c.length;
  15028. } else {
  15029. column++;
  15030. }
  15031. if (c) {
  15032. pos += c.length;
  15033. }
  15034. return c;
  15035. }
  15036. const lexStates = {
  15037. default() {
  15038. switch (c) {
  15039. case '\t':
  15040. case '\v':
  15041. case '\f':
  15042. case ' ':
  15043. case '\u00A0':
  15044. case '\uFEFF':
  15045. case '\n':
  15046. case '\r':
  15047. case '\u2028':
  15048. case '\u2029':
  15049. read$4();
  15050. return;
  15051. case '/':
  15052. read$4();
  15053. lexState = 'comment';
  15054. return;
  15055. case undefined:
  15056. read$4();
  15057. return newToken('eof');
  15058. }
  15059. if (util$6.isSpaceSeparator(c)) {
  15060. read$4();
  15061. return;
  15062. } // This code is unreachable.
  15063. // if (!lexStates[parseState]) {
  15064. // throw invalidLexState(parseState)
  15065. // }
  15066. return lexStates[parseState]();
  15067. },
  15068. comment() {
  15069. switch (c) {
  15070. case '*':
  15071. read$4();
  15072. lexState = 'multiLineComment';
  15073. return;
  15074. case '/':
  15075. read$4();
  15076. lexState = 'singleLineComment';
  15077. return;
  15078. }
  15079. throw invalidChar(read$4());
  15080. },
  15081. multiLineComment() {
  15082. switch (c) {
  15083. case '*':
  15084. read$4();
  15085. lexState = 'multiLineCommentAsterisk';
  15086. return;
  15087. case undefined:
  15088. throw invalidChar(read$4());
  15089. }
  15090. read$4();
  15091. },
  15092. multiLineCommentAsterisk() {
  15093. switch (c) {
  15094. case '*':
  15095. read$4();
  15096. return;
  15097. case '/':
  15098. read$4();
  15099. lexState = 'default';
  15100. return;
  15101. case undefined:
  15102. throw invalidChar(read$4());
  15103. }
  15104. read$4();
  15105. lexState = 'multiLineComment';
  15106. },
  15107. singleLineComment() {
  15108. switch (c) {
  15109. case '\n':
  15110. case '\r':
  15111. case '\u2028':
  15112. case '\u2029':
  15113. read$4();
  15114. lexState = 'default';
  15115. return;
  15116. case undefined:
  15117. read$4();
  15118. return newToken('eof');
  15119. }
  15120. read$4();
  15121. },
  15122. value() {
  15123. switch (c) {
  15124. case '{':
  15125. case '[':
  15126. return newToken('punctuator', read$4());
  15127. case 'n':
  15128. read$4();
  15129. literal$1('ull');
  15130. return newToken('null', null);
  15131. case 't':
  15132. read$4();
  15133. literal$1('rue');
  15134. return newToken('boolean', true);
  15135. case 'f':
  15136. read$4();
  15137. literal$1('alse');
  15138. return newToken('boolean', false);
  15139. case '-':
  15140. case '+':
  15141. if (read$4() === '-') {
  15142. sign = -1;
  15143. }
  15144. lexState = 'sign';
  15145. return;
  15146. case '.':
  15147. buffer$2 = read$4();
  15148. lexState = 'decimalPointLeading';
  15149. return;
  15150. case '0':
  15151. buffer$2 = read$4();
  15152. lexState = 'zero';
  15153. return;
  15154. case '1':
  15155. case '2':
  15156. case '3':
  15157. case '4':
  15158. case '5':
  15159. case '6':
  15160. case '7':
  15161. case '8':
  15162. case '9':
  15163. buffer$2 = read$4();
  15164. lexState = 'decimalInteger';
  15165. return;
  15166. case 'I':
  15167. read$4();
  15168. literal$1('nfinity');
  15169. return newToken('numeric', Infinity);
  15170. case 'N':
  15171. read$4();
  15172. literal$1('aN');
  15173. return newToken('numeric', NaN);
  15174. case '"':
  15175. case "'":
  15176. doubleQuote = read$4() === '"';
  15177. buffer$2 = '';
  15178. lexState = 'string';
  15179. return;
  15180. }
  15181. throw invalidChar(read$4());
  15182. },
  15183. identifierNameStartEscape() {
  15184. if (c !== 'u') {
  15185. throw invalidChar(read$4());
  15186. }
  15187. read$4();
  15188. const u = unicodeEscape();
  15189. switch (u) {
  15190. case '$':
  15191. case '_':
  15192. break;
  15193. default:
  15194. if (!util$6.isIdStartChar(u)) {
  15195. throw invalidIdentifier();
  15196. }
  15197. break;
  15198. }
  15199. buffer$2 += u;
  15200. lexState = 'identifierName';
  15201. },
  15202. identifierName() {
  15203. switch (c) {
  15204. case '$':
  15205. case '_':
  15206. case '\u200C':
  15207. case '\u200D':
  15208. buffer$2 += read$4();
  15209. return;
  15210. case '\\':
  15211. read$4();
  15212. lexState = 'identifierNameEscape';
  15213. return;
  15214. }
  15215. if (util$6.isIdContinueChar(c)) {
  15216. buffer$2 += read$4();
  15217. return;
  15218. }
  15219. return newToken('identifier', buffer$2);
  15220. },
  15221. identifierNameEscape() {
  15222. if (c !== 'u') {
  15223. throw invalidChar(read$4());
  15224. }
  15225. read$4();
  15226. const u = unicodeEscape();
  15227. switch (u) {
  15228. case '$':
  15229. case '_':
  15230. case '\u200C':
  15231. case '\u200D':
  15232. break;
  15233. default:
  15234. if (!util$6.isIdContinueChar(u)) {
  15235. throw invalidIdentifier();
  15236. }
  15237. break;
  15238. }
  15239. buffer$2 += u;
  15240. lexState = 'identifierName';
  15241. },
  15242. sign() {
  15243. switch (c) {
  15244. case '.':
  15245. buffer$2 = read$4();
  15246. lexState = 'decimalPointLeading';
  15247. return;
  15248. case '0':
  15249. buffer$2 = read$4();
  15250. lexState = 'zero';
  15251. return;
  15252. case '1':
  15253. case '2':
  15254. case '3':
  15255. case '4':
  15256. case '5':
  15257. case '6':
  15258. case '7':
  15259. case '8':
  15260. case '9':
  15261. buffer$2 = read$4();
  15262. lexState = 'decimalInteger';
  15263. return;
  15264. case 'I':
  15265. read$4();
  15266. literal$1('nfinity');
  15267. return newToken('numeric', sign * Infinity);
  15268. case 'N':
  15269. read$4();
  15270. literal$1('aN');
  15271. return newToken('numeric', NaN);
  15272. }
  15273. throw invalidChar(read$4());
  15274. },
  15275. zero() {
  15276. switch (c) {
  15277. case '.':
  15278. buffer$2 += read$4();
  15279. lexState = 'decimalPoint';
  15280. return;
  15281. case 'e':
  15282. case 'E':
  15283. buffer$2 += read$4();
  15284. lexState = 'decimalExponent';
  15285. return;
  15286. case 'x':
  15287. case 'X':
  15288. buffer$2 += read$4();
  15289. lexState = 'hexadecimal';
  15290. return;
  15291. }
  15292. return newToken('numeric', sign * 0);
  15293. },
  15294. decimalInteger() {
  15295. switch (c) {
  15296. case '.':
  15297. buffer$2 += read$4();
  15298. lexState = 'decimalPoint';
  15299. return;
  15300. case 'e':
  15301. case 'E':
  15302. buffer$2 += read$4();
  15303. lexState = 'decimalExponent';
  15304. return;
  15305. }
  15306. if (util$6.isDigit(c)) {
  15307. buffer$2 += read$4();
  15308. return;
  15309. }
  15310. return newToken('numeric', sign * Number(buffer$2));
  15311. },
  15312. decimalPointLeading() {
  15313. if (util$6.isDigit(c)) {
  15314. buffer$2 += read$4();
  15315. lexState = 'decimalFraction';
  15316. return;
  15317. }
  15318. throw invalidChar(read$4());
  15319. },
  15320. decimalPoint() {
  15321. switch (c) {
  15322. case 'e':
  15323. case 'E':
  15324. buffer$2 += read$4();
  15325. lexState = 'decimalExponent';
  15326. return;
  15327. }
  15328. if (util$6.isDigit(c)) {
  15329. buffer$2 += read$4();
  15330. lexState = 'decimalFraction';
  15331. return;
  15332. }
  15333. return newToken('numeric', sign * Number(buffer$2));
  15334. },
  15335. decimalFraction() {
  15336. switch (c) {
  15337. case 'e':
  15338. case 'E':
  15339. buffer$2 += read$4();
  15340. lexState = 'decimalExponent';
  15341. return;
  15342. }
  15343. if (util$6.isDigit(c)) {
  15344. buffer$2 += read$4();
  15345. return;
  15346. }
  15347. return newToken('numeric', sign * Number(buffer$2));
  15348. },
  15349. decimalExponent() {
  15350. switch (c) {
  15351. case '+':
  15352. case '-':
  15353. buffer$2 += read$4();
  15354. lexState = 'decimalExponentSign';
  15355. return;
  15356. }
  15357. if (util$6.isDigit(c)) {
  15358. buffer$2 += read$4();
  15359. lexState = 'decimalExponentInteger';
  15360. return;
  15361. }
  15362. throw invalidChar(read$4());
  15363. },
  15364. decimalExponentSign() {
  15365. if (util$6.isDigit(c)) {
  15366. buffer$2 += read$4();
  15367. lexState = 'decimalExponentInteger';
  15368. return;
  15369. }
  15370. throw invalidChar(read$4());
  15371. },
  15372. decimalExponentInteger() {
  15373. if (util$6.isDigit(c)) {
  15374. buffer$2 += read$4();
  15375. return;
  15376. }
  15377. return newToken('numeric', sign * Number(buffer$2));
  15378. },
  15379. hexadecimal() {
  15380. if (util$6.isHexDigit(c)) {
  15381. buffer$2 += read$4();
  15382. lexState = 'hexadecimalInteger';
  15383. return;
  15384. }
  15385. throw invalidChar(read$4());
  15386. },
  15387. hexadecimalInteger() {
  15388. if (util$6.isHexDigit(c)) {
  15389. buffer$2 += read$4();
  15390. return;
  15391. }
  15392. return newToken('numeric', sign * Number(buffer$2));
  15393. },
  15394. string() {
  15395. switch (c) {
  15396. case '\\':
  15397. read$4();
  15398. buffer$2 += escape$1();
  15399. return;
  15400. case '"':
  15401. if (doubleQuote) {
  15402. read$4();
  15403. return newToken('string', buffer$2);
  15404. }
  15405. buffer$2 += read$4();
  15406. return;
  15407. case "'":
  15408. if (!doubleQuote) {
  15409. read$4();
  15410. return newToken('string', buffer$2);
  15411. }
  15412. buffer$2 += read$4();
  15413. return;
  15414. case '\n':
  15415. case '\r':
  15416. throw invalidChar(read$4());
  15417. case '\u2028':
  15418. case '\u2029':
  15419. separatorChar(c);
  15420. break;
  15421. case undefined:
  15422. throw invalidChar(read$4());
  15423. }
  15424. buffer$2 += read$4();
  15425. },
  15426. start() {
  15427. switch (c) {
  15428. case '{':
  15429. case '[':
  15430. return newToken('punctuator', read$4());
  15431. // This code is unreachable since the default lexState handles eof.
  15432. // case undefined:
  15433. // return newToken('eof')
  15434. }
  15435. lexState = 'value';
  15436. },
  15437. beforePropertyName() {
  15438. switch (c) {
  15439. case '$':
  15440. case '_':
  15441. buffer$2 = read$4();
  15442. lexState = 'identifierName';
  15443. return;
  15444. case '\\':
  15445. read$4();
  15446. lexState = 'identifierNameStartEscape';
  15447. return;
  15448. case '}':
  15449. return newToken('punctuator', read$4());
  15450. case '"':
  15451. case "'":
  15452. doubleQuote = read$4() === '"';
  15453. lexState = 'string';
  15454. return;
  15455. }
  15456. if (util$6.isIdStartChar(c)) {
  15457. buffer$2 += read$4();
  15458. lexState = 'identifierName';
  15459. return;
  15460. }
  15461. throw invalidChar(read$4());
  15462. },
  15463. afterPropertyName() {
  15464. if (c === ':') {
  15465. return newToken('punctuator', read$4());
  15466. }
  15467. throw invalidChar(read$4());
  15468. },
  15469. beforePropertyValue() {
  15470. lexState = 'value';
  15471. },
  15472. afterPropertyValue() {
  15473. switch (c) {
  15474. case ',':
  15475. case '}':
  15476. return newToken('punctuator', read$4());
  15477. }
  15478. throw invalidChar(read$4());
  15479. },
  15480. beforeArrayValue() {
  15481. if (c === ']') {
  15482. return newToken('punctuator', read$4());
  15483. }
  15484. lexState = 'value';
  15485. },
  15486. afterArrayValue() {
  15487. switch (c) {
  15488. case ',':
  15489. case ']':
  15490. return newToken('punctuator', read$4());
  15491. }
  15492. throw invalidChar(read$4());
  15493. },
  15494. end() {
  15495. // This code is unreachable since it's handled by the default lexState.
  15496. // if (c === undefined) {
  15497. // read()
  15498. // return newToken('eof')
  15499. // }
  15500. throw invalidChar(read$4());
  15501. }
  15502. };
  15503. function newToken(type, value) {
  15504. return {
  15505. type,
  15506. value,
  15507. line: line$z,
  15508. column
  15509. };
  15510. }
  15511. function literal$1(s) {
  15512. for (const c of s) {
  15513. const p = peek();
  15514. if (p !== c) {
  15515. throw invalidChar(read$4());
  15516. }
  15517. read$4();
  15518. }
  15519. }
  15520. function escape$1() {
  15521. const c = peek();
  15522. switch (c) {
  15523. case 'b':
  15524. read$4();
  15525. return '\b';
  15526. case 'f':
  15527. read$4();
  15528. return '\f';
  15529. case 'n':
  15530. read$4();
  15531. return '\n';
  15532. case 'r':
  15533. read$4();
  15534. return '\r';
  15535. case 't':
  15536. read$4();
  15537. return '\t';
  15538. case 'v':
  15539. read$4();
  15540. return '\v';
  15541. case '0':
  15542. read$4();
  15543. if (util$6.isDigit(peek())) {
  15544. throw invalidChar(read$4());
  15545. }
  15546. return '\0';
  15547. case 'x':
  15548. read$4();
  15549. return hexEscape();
  15550. case 'u':
  15551. read$4();
  15552. return unicodeEscape();
  15553. case '\n':
  15554. case '\u2028':
  15555. case '\u2029':
  15556. read$4();
  15557. return '';
  15558. case '\r':
  15559. read$4();
  15560. if (peek() === '\n') {
  15561. read$4();
  15562. }
  15563. return '';
  15564. case '1':
  15565. case '2':
  15566. case '3':
  15567. case '4':
  15568. case '5':
  15569. case '6':
  15570. case '7':
  15571. case '8':
  15572. case '9':
  15573. throw invalidChar(read$4());
  15574. case undefined:
  15575. throw invalidChar(read$4());
  15576. }
  15577. return read$4();
  15578. }
  15579. function hexEscape() {
  15580. let buffer = '';
  15581. let c = peek();
  15582. if (!util$6.isHexDigit(c)) {
  15583. throw invalidChar(read$4());
  15584. }
  15585. buffer += read$4();
  15586. c = peek();
  15587. if (!util$6.isHexDigit(c)) {
  15588. throw invalidChar(read$4());
  15589. }
  15590. buffer += read$4();
  15591. return String.fromCodePoint(parseInt(buffer, 16));
  15592. }
  15593. function unicodeEscape() {
  15594. let buffer = '';
  15595. let count = 4;
  15596. while (count-- > 0) {
  15597. const c = peek();
  15598. if (!util$6.isHexDigit(c)) {
  15599. throw invalidChar(read$4());
  15600. }
  15601. buffer += read$4();
  15602. }
  15603. return String.fromCodePoint(parseInt(buffer, 16));
  15604. }
  15605. const parseStates = {
  15606. start() {
  15607. if (token.type === 'eof') {
  15608. throw invalidEOF();
  15609. }
  15610. push$1();
  15611. },
  15612. beforePropertyName() {
  15613. switch (token.type) {
  15614. case 'identifier':
  15615. case 'string':
  15616. key = token.value;
  15617. parseState = 'afterPropertyName';
  15618. return;
  15619. case 'punctuator':
  15620. // This code is unreachable since it's handled by the lexState.
  15621. // if (token.value !== '}') {
  15622. // throw invalidToken()
  15623. // }
  15624. pop();
  15625. return;
  15626. case 'eof':
  15627. throw invalidEOF();
  15628. } // This code is unreachable since it's handled by the lexState.
  15629. // throw invalidToken()
  15630. },
  15631. afterPropertyName() {
  15632. // This code is unreachable since it's handled by the lexState.
  15633. // if (token.type !== 'punctuator' || token.value !== ':') {
  15634. // throw invalidToken()
  15635. // }
  15636. if (token.type === 'eof') {
  15637. throw invalidEOF();
  15638. }
  15639. parseState = 'beforePropertyValue';
  15640. },
  15641. beforePropertyValue() {
  15642. if (token.type === 'eof') {
  15643. throw invalidEOF();
  15644. }
  15645. push$1();
  15646. },
  15647. beforeArrayValue() {
  15648. if (token.type === 'eof') {
  15649. throw invalidEOF();
  15650. }
  15651. if (token.type === 'punctuator' && token.value === ']') {
  15652. pop();
  15653. return;
  15654. }
  15655. push$1();
  15656. },
  15657. afterPropertyValue() {
  15658. // This code is unreachable since it's handled by the lexState.
  15659. // if (token.type !== 'punctuator') {
  15660. // throw invalidToken()
  15661. // }
  15662. if (token.type === 'eof') {
  15663. throw invalidEOF();
  15664. }
  15665. switch (token.value) {
  15666. case ',':
  15667. parseState = 'beforePropertyName';
  15668. return;
  15669. case '}':
  15670. pop();
  15671. } // This code is unreachable since it's handled by the lexState.
  15672. // throw invalidToken()
  15673. },
  15674. afterArrayValue() {
  15675. // This code is unreachable since it's handled by the lexState.
  15676. // if (token.type !== 'punctuator') {
  15677. // throw invalidToken()
  15678. // }
  15679. if (token.type === 'eof') {
  15680. throw invalidEOF();
  15681. }
  15682. switch (token.value) {
  15683. case ',':
  15684. parseState = 'beforeArrayValue';
  15685. return;
  15686. case ']':
  15687. pop();
  15688. } // This code is unreachable since it's handled by the lexState.
  15689. // throw invalidToken()
  15690. },
  15691. end() {// This code is unreachable since it's handled by the lexState.
  15692. // if (token.type !== 'eof') {
  15693. // throw invalidToken()
  15694. // }
  15695. }
  15696. };
  15697. function push$1() {
  15698. let value;
  15699. switch (token.type) {
  15700. case 'punctuator':
  15701. switch (token.value) {
  15702. case '{':
  15703. value = {};
  15704. break;
  15705. case '[':
  15706. value = [];
  15707. break;
  15708. }
  15709. break;
  15710. case 'null':
  15711. case 'boolean':
  15712. case 'numeric':
  15713. case 'string':
  15714. value = token.value;
  15715. break;
  15716. // This code is unreachable.
  15717. // default:
  15718. // throw invalidToken()
  15719. }
  15720. if (root$9 === undefined) {
  15721. root$9 = value;
  15722. } else {
  15723. const parent = stack[stack.length - 1];
  15724. if (Array.isArray(parent)) {
  15725. parent.push(value);
  15726. } else {
  15727. parent[key] = value;
  15728. }
  15729. }
  15730. if (value !== null && typeof value === 'object') {
  15731. stack.push(value);
  15732. if (Array.isArray(value)) {
  15733. parseState = 'beforeArrayValue';
  15734. } else {
  15735. parseState = 'beforePropertyName';
  15736. }
  15737. } else {
  15738. const current = stack[stack.length - 1];
  15739. if (current == null) {
  15740. parseState = 'end';
  15741. } else if (Array.isArray(current)) {
  15742. parseState = 'afterArrayValue';
  15743. } else {
  15744. parseState = 'afterPropertyValue';
  15745. }
  15746. }
  15747. }
  15748. function pop() {
  15749. stack.pop();
  15750. const current = stack[stack.length - 1];
  15751. if (current == null) {
  15752. parseState = 'end';
  15753. } else if (Array.isArray(current)) {
  15754. parseState = 'afterArrayValue';
  15755. } else {
  15756. parseState = 'afterPropertyValue';
  15757. }
  15758. } // This code is unreachable.
  15759. // function invalidParseState () {
  15760. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  15761. // }
  15762. // This code is unreachable.
  15763. // function invalidLexState (state) {
  15764. // return new Error(`JSON5: invalid lex state '${state}'`)
  15765. // }
  15766. function invalidChar(c) {
  15767. if (c === undefined) {
  15768. return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
  15769. }
  15770. return syntaxError$2(`JSON5: invalid character '${formatChar(c)}' at ${line$z}:${column}`);
  15771. }
  15772. function invalidEOF() {
  15773. return syntaxError$2(`JSON5: invalid end of input at ${line$z}:${column}`);
  15774. } // This code is unreachable.
  15775. // function invalidToken () {
  15776. // if (token.type === 'eof') {
  15777. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  15778. // }
  15779. // const c = String.fromCodePoint(token.value.codePointAt(0))
  15780. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  15781. // }
  15782. function invalidIdentifier() {
  15783. column -= 5;
  15784. return syntaxError$2(`JSON5: invalid identifier character at ${line$z}:${column}`);
  15785. }
  15786. function separatorChar(c) {
  15787. console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`);
  15788. }
  15789. function formatChar(c) {
  15790. const replacements = {
  15791. "'": "\\'",
  15792. '"': '\\"',
  15793. '\\': '\\\\',
  15794. '\b': '\\b',
  15795. '\f': '\\f',
  15796. '\n': '\\n',
  15797. '\r': '\\r',
  15798. '\t': '\\t',
  15799. '\v': '\\v',
  15800. '\0': '\\0',
  15801. '\u2028': '\\u2028',
  15802. '\u2029': '\\u2029'
  15803. };
  15804. if (replacements[c]) {
  15805. return replacements[c];
  15806. }
  15807. if (c < ' ') {
  15808. const hexString = c.charCodeAt(0).toString(16);
  15809. return '\\x' + ('00' + hexString).substring(hexString.length);
  15810. }
  15811. return c;
  15812. }
  15813. function syntaxError$2(message) {
  15814. const err = new SyntaxError(message);
  15815. err.lineNumber = line$z;
  15816. err.columnNumber = column;
  15817. return err;
  15818. }
  15819. var stringify$6 = function stringify(value, replacer, space) {
  15820. const stack = [];
  15821. let indent = '';
  15822. let propertyList;
  15823. let replacerFunc;
  15824. let gap = '';
  15825. let quote;
  15826. if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
  15827. space = replacer.space;
  15828. quote = replacer.quote;
  15829. replacer = replacer.replacer;
  15830. }
  15831. if (typeof replacer === 'function') {
  15832. replacerFunc = replacer;
  15833. } else if (Array.isArray(replacer)) {
  15834. propertyList = [];
  15835. for (const v of replacer) {
  15836. let item;
  15837. if (typeof v === 'string') {
  15838. item = v;
  15839. } else if (typeof v === 'number' || v instanceof String || v instanceof Number) {
  15840. item = String(v);
  15841. }
  15842. if (item !== undefined && propertyList.indexOf(item) < 0) {
  15843. propertyList.push(item);
  15844. }
  15845. }
  15846. }
  15847. if (space instanceof Number) {
  15848. space = Number(space);
  15849. } else if (space instanceof String) {
  15850. space = String(space);
  15851. }
  15852. if (typeof space === 'number') {
  15853. if (space > 0) {
  15854. space = Math.min(10, Math.floor(space));
  15855. gap = ' '.substr(0, space);
  15856. }
  15857. } else if (typeof space === 'string') {
  15858. gap = space.substr(0, 10);
  15859. }
  15860. return serializeProperty('', {
  15861. '': value
  15862. });
  15863. function serializeProperty(key, holder) {
  15864. let value = holder[key];
  15865. if (value != null) {
  15866. if (typeof value.toJSON5 === 'function') {
  15867. value = value.toJSON5(key);
  15868. } else if (typeof value.toJSON === 'function') {
  15869. value = value.toJSON(key);
  15870. }
  15871. }
  15872. if (replacerFunc) {
  15873. value = replacerFunc.call(holder, key, value);
  15874. }
  15875. if (value instanceof Number) {
  15876. value = Number(value);
  15877. } else if (value instanceof String) {
  15878. value = String(value);
  15879. } else if (value instanceof Boolean) {
  15880. value = value.valueOf();
  15881. }
  15882. switch (value) {
  15883. case null:
  15884. return 'null';
  15885. case true:
  15886. return 'true';
  15887. case false:
  15888. return 'false';
  15889. }
  15890. if (typeof value === 'string') {
  15891. return quoteString(value);
  15892. }
  15893. if (typeof value === 'number') {
  15894. return String(value);
  15895. }
  15896. if (typeof value === 'object') {
  15897. return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
  15898. }
  15899. return undefined;
  15900. }
  15901. function quoteString(value) {
  15902. const quotes = {
  15903. "'": 0.1,
  15904. '"': 0.2
  15905. };
  15906. const replacements = {
  15907. "'": "\\'",
  15908. '"': '\\"',
  15909. '\\': '\\\\',
  15910. '\b': '\\b',
  15911. '\f': '\\f',
  15912. '\n': '\\n',
  15913. '\r': '\\r',
  15914. '\t': '\\t',
  15915. '\v': '\\v',
  15916. '\0': '\\0',
  15917. '\u2028': '\\u2028',
  15918. '\u2029': '\\u2029'
  15919. };
  15920. let product = '';
  15921. for (let i = 0; i < value.length; i++) {
  15922. const c = value[i];
  15923. switch (c) {
  15924. case "'":
  15925. case '"':
  15926. quotes[c]++;
  15927. product += c;
  15928. continue;
  15929. case '\0':
  15930. if (util$6.isDigit(value[i + 1])) {
  15931. product += '\\x00';
  15932. continue;
  15933. }
  15934. }
  15935. if (replacements[c]) {
  15936. product += replacements[c];
  15937. continue;
  15938. }
  15939. if (c < ' ') {
  15940. let hexString = c.charCodeAt(0).toString(16);
  15941. product += '\\x' + ('00' + hexString).substring(hexString.length);
  15942. continue;
  15943. }
  15944. product += c;
  15945. }
  15946. const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
  15947. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  15948. return quoteChar + product + quoteChar;
  15949. }
  15950. function serializeObject(value) {
  15951. if (stack.indexOf(value) >= 0) {
  15952. throw TypeError('Converting circular structure to JSON5');
  15953. }
  15954. stack.push(value);
  15955. let stepback = indent;
  15956. indent = indent + gap;
  15957. let keys = propertyList || Object.keys(value);
  15958. let partial = [];
  15959. for (const key of keys) {
  15960. const propertyString = serializeProperty(key, value);
  15961. if (propertyString !== undefined) {
  15962. let member = serializeKey(key) + ':';
  15963. if (gap !== '') {
  15964. member += ' ';
  15965. }
  15966. member += propertyString;
  15967. partial.push(member);
  15968. }
  15969. }
  15970. let final;
  15971. if (partial.length === 0) {
  15972. final = '{}';
  15973. } else {
  15974. let properties;
  15975. if (gap === '') {
  15976. properties = partial.join(',');
  15977. final = '{' + properties + '}';
  15978. } else {
  15979. let separator = ',\n' + indent;
  15980. properties = partial.join(separator);
  15981. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  15982. }
  15983. }
  15984. stack.pop();
  15985. indent = stepback;
  15986. return final;
  15987. }
  15988. function serializeKey(key) {
  15989. if (key.length === 0) {
  15990. return quoteString(key);
  15991. }
  15992. const firstChar = String.fromCodePoint(key.codePointAt(0));
  15993. if (!util$6.isIdStartChar(firstChar)) {
  15994. return quoteString(key);
  15995. }
  15996. for (let i = firstChar.length; i < key.length; i++) {
  15997. if (!util$6.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  15998. return quoteString(key);
  15999. }
  16000. }
  16001. return key;
  16002. }
  16003. function serializeArray(value) {
  16004. if (stack.indexOf(value) >= 0) {
  16005. throw TypeError('Converting circular structure to JSON5');
  16006. }
  16007. stack.push(value);
  16008. let stepback = indent;
  16009. indent = indent + gap;
  16010. let partial = [];
  16011. for (let i = 0; i < value.length; i++) {
  16012. const propertyString = serializeProperty(String(i), value);
  16013. partial.push(propertyString !== undefined ? propertyString : 'null');
  16014. }
  16015. let final;
  16016. if (partial.length === 0) {
  16017. final = '[]';
  16018. } else {
  16019. if (gap === '') {
  16020. let properties = partial.join(',');
  16021. final = '[' + properties + ']';
  16022. } else {
  16023. let separator = ',\n' + indent;
  16024. let properties = partial.join(separator);
  16025. final = '[\n' + indent + properties + ',\n' + stepback + ']';
  16026. }
  16027. }
  16028. stack.pop();
  16029. indent = stepback;
  16030. return final;
  16031. }
  16032. };
  16033. const JSON5 = {
  16034. parse: parse$a,
  16035. stringify: stringify$6
  16036. };
  16037. var lib = JSON5;
  16038. var dist = /*#__PURE__*/Object.freeze({
  16039. __proto__: null,
  16040. 'default': lib
  16041. });
  16042. var require$$0$4 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(dist);
  16043. const {
  16044. parse: parse$9
  16045. } = require$$0$4;
  16046. var loadJson5$1 = function (filePath, content) {
  16047. try {
  16048. return parse$9(content);
  16049. } catch (error) {
  16050. error.message = `JSON5 Error in ${filePath}:\n${error.message}`;
  16051. throw error;
  16052. }
  16053. };
  16054. var caller$2 = function () {
  16055. // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  16056. var origPrepareStackTrace = Error.prepareStackTrace;
  16057. Error.prepareStackTrace = function (_, stack) {
  16058. return stack;
  16059. };
  16060. var stack = new Error().stack;
  16061. Error.prepareStackTrace = origPrepareStackTrace;
  16062. return stack[2].getFileName();
  16063. };
  16064. var pathParse = {exports: {}};
  16065. var isWindows = process.platform === 'win32'; // Regex to split a windows path into into [dir, root, basename, name, ext]
  16066. var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
  16067. var win32 = {};
  16068. function win32SplitPath(filename) {
  16069. return splitWindowsRe.exec(filename).slice(1);
  16070. }
  16071. win32.parse = function (pathString) {
  16072. if (typeof pathString !== 'string') {
  16073. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  16074. }
  16075. var allParts = win32SplitPath(pathString);
  16076. if (!allParts || allParts.length !== 5) {
  16077. throw new TypeError("Invalid path '" + pathString + "'");
  16078. }
  16079. return {
  16080. root: allParts[1],
  16081. dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
  16082. base: allParts[2],
  16083. ext: allParts[4],
  16084. name: allParts[3]
  16085. };
  16086. }; // Split a filename into [dir, root, basename, name, ext], unix version
  16087. // 'root' is just a slash, or nothing.
  16088. var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
  16089. var posix = {};
  16090. function posixSplitPath(filename) {
  16091. return splitPathRe.exec(filename).slice(1);
  16092. }
  16093. posix.parse = function (pathString) {
  16094. if (typeof pathString !== 'string') {
  16095. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  16096. }
  16097. var allParts = posixSplitPath(pathString);
  16098. if (!allParts || allParts.length !== 5) {
  16099. throw new TypeError("Invalid path '" + pathString + "'");
  16100. }
  16101. return {
  16102. root: allParts[1],
  16103. dir: allParts[0].slice(0, -1),
  16104. base: allParts[2],
  16105. ext: allParts[4],
  16106. name: allParts[3]
  16107. };
  16108. };
  16109. if (isWindows) pathParse.exports = win32.parse;else
  16110. /* posix */
  16111. pathParse.exports = posix.parse;
  16112. pathParse.exports.posix = posix.parse;
  16113. pathParse.exports.win32 = win32.parse;
  16114. var path$n = require$$0__default$2["default"];
  16115. var parse$8 = path$n.parse || pathParse.exports;
  16116. var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
  16117. var prefix = '/';
  16118. if (/^([A-Za-z]:)/.test(absoluteStart)) {
  16119. prefix = '';
  16120. } else if (/^\\\\/.test(absoluteStart)) {
  16121. prefix = '\\\\';
  16122. }
  16123. var paths = [absoluteStart];
  16124. var parsed = parse$8(absoluteStart);
  16125. while (parsed.dir !== paths[paths.length - 1]) {
  16126. paths.push(parsed.dir);
  16127. parsed = parse$8(parsed.dir);
  16128. }
  16129. return paths.reduce(function (dirs, aPath) {
  16130. return dirs.concat(modules.map(function (moduleDir) {
  16131. return path$n.resolve(prefix, aPath, moduleDir);
  16132. }));
  16133. }, []);
  16134. };
  16135. var nodeModulesPaths$2 = function nodeModulesPaths(start, opts, request) {
  16136. var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules'];
  16137. if (opts && typeof opts.paths === 'function') {
  16138. return opts.paths(request, start, function () {
  16139. return getNodeModulesDirs(start, modules);
  16140. }, opts);
  16141. }
  16142. var dirs = getNodeModulesDirs(start, modules);
  16143. return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
  16144. };
  16145. var normalizeOptions$3 = function (x, opts) {
  16146. /**
  16147. * This file is purposefully a passthrough. It's expected that third-party
  16148. * environments will override it at runtime in order to inject special logic
  16149. * into `resolve` (by manipulating the options). One such example is the PnP
  16150. * code path in Yarn.
  16151. */
  16152. return opts || {};
  16153. };
  16154. /* eslint no-invalid-this: 1 */
  16155. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  16156. var slice$1 = Array.prototype.slice;
  16157. var toStr = Object.prototype.toString;
  16158. var funcType = '[object Function]';
  16159. var implementation$1 = function bind(that) {
  16160. var target = this;
  16161. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  16162. throw new TypeError(ERROR_MESSAGE + target);
  16163. }
  16164. var args = slice$1.call(arguments, 1);
  16165. var bound;
  16166. var binder = function () {
  16167. if (this instanceof bound) {
  16168. var result = target.apply(this, args.concat(slice$1.call(arguments)));
  16169. if (Object(result) === result) {
  16170. return result;
  16171. }
  16172. return this;
  16173. } else {
  16174. return target.apply(that, args.concat(slice$1.call(arguments)));
  16175. }
  16176. };
  16177. var boundLength = Math.max(0, target.length - args.length);
  16178. var boundArgs = [];
  16179. for (var i = 0; i < boundLength; i++) {
  16180. boundArgs.push('$' + i);
  16181. }
  16182. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  16183. if (target.prototype) {
  16184. var Empty = function Empty() {};
  16185. Empty.prototype = target.prototype;
  16186. bound.prototype = new Empty();
  16187. Empty.prototype = null;
  16188. }
  16189. return bound;
  16190. };
  16191. var implementation = implementation$1;
  16192. var functionBind = Function.prototype.bind || implementation;
  16193. var bind = functionBind;
  16194. var src$2 = bind.call(Function.call, Object.prototype.hasOwnProperty);
  16195. var assert$4 = true;
  16196. var async_hooks$1 = ">= 8";
  16197. var buffer_ieee754$1 = "< 0.9.7";
  16198. var buffer$1 = true;
  16199. var child_process$1 = true;
  16200. var cluster$1 = true;
  16201. var console$2 = true;
  16202. var constants$6 = true;
  16203. var crypto$1 = true;
  16204. var _debug_agent$1 = ">= 1 && < 8";
  16205. var _debugger$1 = "< 8";
  16206. var dgram$1 = true;
  16207. var diagnostics_channel$1 = [
  16208. ">= 14.17 && < 15",
  16209. ">= 15.1"
  16210. ];
  16211. var dns$1 = true;
  16212. var domain$1 = ">= 0.7.12";
  16213. var events$1 = true;
  16214. var freelist$1 = "< 6";
  16215. var fs$j = true;
  16216. var _http_agent$1 = ">= 0.11.1";
  16217. var _http_client$1 = ">= 0.11.1";
  16218. var _http_common$1 = ">= 0.11.1";
  16219. var _http_incoming$1 = ">= 0.11.1";
  16220. var _http_outgoing$1 = ">= 0.11.1";
  16221. var _http_server$1 = ">= 0.11.1";
  16222. var http$1 = true;
  16223. var http2$1 = ">= 8.8";
  16224. var https$1 = true;
  16225. var inspector$1 = ">= 8";
  16226. var _linklist$1 = "< 8";
  16227. var module$3 = true;
  16228. var net$1 = true;
  16229. var os$1 = true;
  16230. var path$m = true;
  16231. var perf_hooks$1 = ">= 8.5";
  16232. var process$2 = ">= 1";
  16233. var punycode$1 = true;
  16234. var querystring$1 = true;
  16235. var readline$1 = true;
  16236. var repl$1 = true;
  16237. var smalloc$1 = ">= 0.11.5 && < 3";
  16238. var _stream_duplex$1 = ">= 0.9.4";
  16239. var _stream_transform$1 = ">= 0.9.4";
  16240. var _stream_wrap$1 = ">= 1.4.1";
  16241. var _stream_passthrough$1 = ">= 0.9.4";
  16242. var _stream_readable$1 = ">= 0.9.4";
  16243. var _stream_writable$1 = ">= 0.9.4";
  16244. var stream$6 = true;
  16245. var string_decoder$1 = true;
  16246. var sys$1 = [
  16247. ">= 0.6 && < 0.7",
  16248. ">= 0.8"
  16249. ];
  16250. var timers$1 = true;
  16251. var _tls_common$1 = ">= 0.11.13";
  16252. var _tls_legacy$1 = ">= 0.11.3 && < 10";
  16253. var _tls_wrap$1 = ">= 0.11.3";
  16254. var tls$1 = true;
  16255. var trace_events$1 = ">= 10";
  16256. var tty$1 = true;
  16257. var url$1 = true;
  16258. var util$5 = true;
  16259. var v8$1 = ">= 1";
  16260. var vm$1 = true;
  16261. var wasi$1 = ">= 13.4 && < 13.5";
  16262. var worker_threads$1 = ">= 11.7";
  16263. var zlib$1 = true;
  16264. var require$$1$2 = {
  16265. assert: assert$4,
  16266. "node:assert": [
  16267. ">= 14.18 && < 15",
  16268. ">= 16"
  16269. ],
  16270. "assert/strict": ">= 15",
  16271. "node:assert/strict": ">= 16",
  16272. async_hooks: async_hooks$1,
  16273. "node:async_hooks": [
  16274. ">= 14.18 && < 15",
  16275. ">= 16"
  16276. ],
  16277. buffer_ieee754: buffer_ieee754$1,
  16278. buffer: buffer$1,
  16279. "node:buffer": [
  16280. ">= 14.18 && < 15",
  16281. ">= 16"
  16282. ],
  16283. child_process: child_process$1,
  16284. "node:child_process": [
  16285. ">= 14.18 && < 15",
  16286. ">= 16"
  16287. ],
  16288. cluster: cluster$1,
  16289. "node:cluster": [
  16290. ">= 14.18 && < 15",
  16291. ">= 16"
  16292. ],
  16293. console: console$2,
  16294. "node:console": [
  16295. ">= 14.18 && < 15",
  16296. ">= 16"
  16297. ],
  16298. constants: constants$6,
  16299. "node:constants": [
  16300. ">= 14.18 && < 15",
  16301. ">= 16"
  16302. ],
  16303. crypto: crypto$1,
  16304. "node:crypto": [
  16305. ">= 14.18 && < 15",
  16306. ">= 16"
  16307. ],
  16308. _debug_agent: _debug_agent$1,
  16309. _debugger: _debugger$1,
  16310. dgram: dgram$1,
  16311. "node:dgram": [
  16312. ">= 14.18 && < 15",
  16313. ">= 16"
  16314. ],
  16315. diagnostics_channel: diagnostics_channel$1,
  16316. "node:diagnostics_channel": [
  16317. ">= 14.18 && < 15",
  16318. ">= 16"
  16319. ],
  16320. dns: dns$1,
  16321. "node:dns": [
  16322. ">= 14.18 && < 15",
  16323. ">= 16"
  16324. ],
  16325. "dns/promises": ">= 15",
  16326. "node:dns/promises": ">= 16",
  16327. domain: domain$1,
  16328. "node:domain": [
  16329. ">= 14.18 && < 15",
  16330. ">= 16"
  16331. ],
  16332. events: events$1,
  16333. "node:events": [
  16334. ">= 14.18 && < 15",
  16335. ">= 16"
  16336. ],
  16337. freelist: freelist$1,
  16338. fs: fs$j,
  16339. "node:fs": [
  16340. ">= 14.18 && < 15",
  16341. ">= 16"
  16342. ],
  16343. "fs/promises": [
  16344. ">= 10 && < 10.1",
  16345. ">= 14"
  16346. ],
  16347. "node:fs/promises": [
  16348. ">= 14.18 && < 15",
  16349. ">= 16"
  16350. ],
  16351. _http_agent: _http_agent$1,
  16352. "node:_http_agent": [
  16353. ">= 14.18 && < 15",
  16354. ">= 16"
  16355. ],
  16356. _http_client: _http_client$1,
  16357. "node:_http_client": [
  16358. ">= 14.18 && < 15",
  16359. ">= 16"
  16360. ],
  16361. _http_common: _http_common$1,
  16362. "node:_http_common": [
  16363. ">= 14.18 && < 15",
  16364. ">= 16"
  16365. ],
  16366. _http_incoming: _http_incoming$1,
  16367. "node:_http_incoming": [
  16368. ">= 14.18 && < 15",
  16369. ">= 16"
  16370. ],
  16371. _http_outgoing: _http_outgoing$1,
  16372. "node:_http_outgoing": [
  16373. ">= 14.18 && < 15",
  16374. ">= 16"
  16375. ],
  16376. _http_server: _http_server$1,
  16377. "node:_http_server": [
  16378. ">= 14.18 && < 15",
  16379. ">= 16"
  16380. ],
  16381. http: http$1,
  16382. "node:http": [
  16383. ">= 14.18 && < 15",
  16384. ">= 16"
  16385. ],
  16386. http2: http2$1,
  16387. "node:http2": [
  16388. ">= 14.18 && < 15",
  16389. ">= 16"
  16390. ],
  16391. https: https$1,
  16392. "node:https": [
  16393. ">= 14.18 && < 15",
  16394. ">= 16"
  16395. ],
  16396. inspector: inspector$1,
  16397. "node:inspector": [
  16398. ">= 14.18 && < 15",
  16399. ">= 16"
  16400. ],
  16401. _linklist: _linklist$1,
  16402. module: module$3,
  16403. "node:module": [
  16404. ">= 14.18 && < 15",
  16405. ">= 16"
  16406. ],
  16407. net: net$1,
  16408. "node:net": [
  16409. ">= 14.18 && < 15",
  16410. ">= 16"
  16411. ],
  16412. "node-inspect/lib/_inspect": ">= 7.6 && < 12",
  16413. "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
  16414. "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
  16415. os: os$1,
  16416. "node:os": [
  16417. ">= 14.18 && < 15",
  16418. ">= 16"
  16419. ],
  16420. path: path$m,
  16421. "node:path": [
  16422. ">= 14.18 && < 15",
  16423. ">= 16"
  16424. ],
  16425. "path/posix": ">= 15.3",
  16426. "node:path/posix": ">= 16",
  16427. "path/win32": ">= 15.3",
  16428. "node:path/win32": ">= 16",
  16429. perf_hooks: perf_hooks$1,
  16430. "node:perf_hooks": [
  16431. ">= 14.18 && < 15",
  16432. ">= 16"
  16433. ],
  16434. process: process$2,
  16435. "node:process": [
  16436. ">= 14.18 && < 15",
  16437. ">= 16"
  16438. ],
  16439. punycode: punycode$1,
  16440. "node:punycode": [
  16441. ">= 14.18 && < 15",
  16442. ">= 16"
  16443. ],
  16444. querystring: querystring$1,
  16445. "node:querystring": [
  16446. ">= 14.18 && < 15",
  16447. ">= 16"
  16448. ],
  16449. readline: readline$1,
  16450. "node:readline": [
  16451. ">= 14.18 && < 15",
  16452. ">= 16"
  16453. ],
  16454. "readline/promises": ">= 17",
  16455. "node:readline/promises": ">= 17",
  16456. repl: repl$1,
  16457. "node:repl": [
  16458. ">= 14.18 && < 15",
  16459. ">= 16"
  16460. ],
  16461. smalloc: smalloc$1,
  16462. _stream_duplex: _stream_duplex$1,
  16463. "node:_stream_duplex": [
  16464. ">= 14.18 && < 15",
  16465. ">= 16"
  16466. ],
  16467. _stream_transform: _stream_transform$1,
  16468. "node:_stream_transform": [
  16469. ">= 14.18 && < 15",
  16470. ">= 16"
  16471. ],
  16472. _stream_wrap: _stream_wrap$1,
  16473. "node:_stream_wrap": [
  16474. ">= 14.18 && < 15",
  16475. ">= 16"
  16476. ],
  16477. _stream_passthrough: _stream_passthrough$1,
  16478. "node:_stream_passthrough": [
  16479. ">= 14.18 && < 15",
  16480. ">= 16"
  16481. ],
  16482. _stream_readable: _stream_readable$1,
  16483. "node:_stream_readable": [
  16484. ">= 14.18 && < 15",
  16485. ">= 16"
  16486. ],
  16487. _stream_writable: _stream_writable$1,
  16488. "node:_stream_writable": [
  16489. ">= 14.18 && < 15",
  16490. ">= 16"
  16491. ],
  16492. stream: stream$6,
  16493. "node:stream": [
  16494. ">= 14.18 && < 15",
  16495. ">= 16"
  16496. ],
  16497. "stream/consumers": ">= 16.7",
  16498. "node:stream/consumers": ">= 16.7",
  16499. "stream/promises": ">= 15",
  16500. "node:stream/promises": ">= 16",
  16501. "stream/web": ">= 16.5",
  16502. "node:stream/web": ">= 16.5",
  16503. string_decoder: string_decoder$1,
  16504. "node:string_decoder": [
  16505. ">= 14.18 && < 15",
  16506. ">= 16"
  16507. ],
  16508. sys: sys$1,
  16509. "node:sys": [
  16510. ">= 14.18 && < 15",
  16511. ">= 16"
  16512. ],
  16513. timers: timers$1,
  16514. "node:timers": [
  16515. ">= 14.18 && < 15",
  16516. ">= 16"
  16517. ],
  16518. "timers/promises": ">= 15",
  16519. "node:timers/promises": ">= 16",
  16520. _tls_common: _tls_common$1,
  16521. "node:_tls_common": [
  16522. ">= 14.18 && < 15",
  16523. ">= 16"
  16524. ],
  16525. _tls_legacy: _tls_legacy$1,
  16526. _tls_wrap: _tls_wrap$1,
  16527. "node:_tls_wrap": [
  16528. ">= 14.18 && < 15",
  16529. ">= 16"
  16530. ],
  16531. tls: tls$1,
  16532. "node:tls": [
  16533. ">= 14.18 && < 15",
  16534. ">= 16"
  16535. ],
  16536. trace_events: trace_events$1,
  16537. "node:trace_events": [
  16538. ">= 14.18 && < 15",
  16539. ">= 16"
  16540. ],
  16541. tty: tty$1,
  16542. "node:tty": [
  16543. ">= 14.18 && < 15",
  16544. ">= 16"
  16545. ],
  16546. url: url$1,
  16547. "node:url": [
  16548. ">= 14.18 && < 15",
  16549. ">= 16"
  16550. ],
  16551. util: util$5,
  16552. "node:util": [
  16553. ">= 14.18 && < 15",
  16554. ">= 16"
  16555. ],
  16556. "util/types": ">= 15.3",
  16557. "node:util/types": ">= 16",
  16558. "v8/tools/arguments": ">= 10 && < 12",
  16559. "v8/tools/codemap": [
  16560. ">= 4.4 && < 5",
  16561. ">= 5.2 && < 12"
  16562. ],
  16563. "v8/tools/consarray": [
  16564. ">= 4.4 && < 5",
  16565. ">= 5.2 && < 12"
  16566. ],
  16567. "v8/tools/csvparser": [
  16568. ">= 4.4 && < 5",
  16569. ">= 5.2 && < 12"
  16570. ],
  16571. "v8/tools/logreader": [
  16572. ">= 4.4 && < 5",
  16573. ">= 5.2 && < 12"
  16574. ],
  16575. "v8/tools/profile_view": [
  16576. ">= 4.4 && < 5",
  16577. ">= 5.2 && < 12"
  16578. ],
  16579. "v8/tools/splaytree": [
  16580. ">= 4.4 && < 5",
  16581. ">= 5.2 && < 12"
  16582. ],
  16583. v8: v8$1,
  16584. "node:v8": [
  16585. ">= 14.18 && < 15",
  16586. ">= 16"
  16587. ],
  16588. vm: vm$1,
  16589. "node:vm": [
  16590. ">= 14.18 && < 15",
  16591. ">= 16"
  16592. ],
  16593. wasi: wasi$1,
  16594. worker_threads: worker_threads$1,
  16595. "node:worker_threads": [
  16596. ">= 14.18 && < 15",
  16597. ">= 16"
  16598. ],
  16599. zlib: zlib$1,
  16600. "node:zlib": [
  16601. ">= 14.18 && < 15",
  16602. ">= 16"
  16603. ]
  16604. };
  16605. var has = src$2;
  16606. function specifierIncluded$1(current, specifier) {
  16607. var nodeParts = current.split('.');
  16608. var parts = specifier.split(' ');
  16609. var op = parts.length > 1 ? parts[0] : '=';
  16610. var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
  16611. for (var i = 0; i < 3; ++i) {
  16612. var cur = parseInt(nodeParts[i] || 0, 10);
  16613. var ver = parseInt(versionParts[i] || 0, 10);
  16614. if (cur === ver) {
  16615. continue; // eslint-disable-line no-restricted-syntax, no-continue
  16616. }
  16617. if (op === '<') {
  16618. return cur < ver;
  16619. }
  16620. if (op === '>=') {
  16621. return cur >= ver;
  16622. }
  16623. return false;
  16624. }
  16625. return op === '>=';
  16626. }
  16627. function matchesRange$1(current, range) {
  16628. var specifiers = range.split(/ ?&& ?/);
  16629. if (specifiers.length === 0) {
  16630. return false;
  16631. }
  16632. for (var i = 0; i < specifiers.length; ++i) {
  16633. if (!specifierIncluded$1(current, specifiers[i])) {
  16634. return false;
  16635. }
  16636. }
  16637. return true;
  16638. }
  16639. function versionIncluded$1(nodeVersion, specifierValue) {
  16640. if (typeof specifierValue === 'boolean') {
  16641. return specifierValue;
  16642. }
  16643. var current = typeof nodeVersion === 'undefined' ? process.versions && process.versions.node : nodeVersion;
  16644. if (typeof current !== 'string') {
  16645. throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
  16646. }
  16647. if (specifierValue && typeof specifierValue === 'object') {
  16648. for (var i = 0; i < specifierValue.length; ++i) {
  16649. if (matchesRange$1(current, specifierValue[i])) {
  16650. return true;
  16651. }
  16652. }
  16653. return false;
  16654. }
  16655. return matchesRange$1(current, specifierValue);
  16656. }
  16657. var data$2 = require$$1$2;
  16658. var isCoreModule$1 = function isCore(x, nodeVersion) {
  16659. return has(data$2, x) && versionIncluded$1(nodeVersion, data$2[x]);
  16660. };
  16661. var fs$i = require$$0__default["default"];
  16662. var path$l = require$$0__default$2["default"];
  16663. var caller$1 = caller$2;
  16664. var nodeModulesPaths$1 = nodeModulesPaths$2;
  16665. var normalizeOptions$2 = normalizeOptions$3;
  16666. var isCore$2 = isCoreModule$1;
  16667. var realpathFS$1 = fs$i.realpath && typeof fs$i.realpath.native === 'function' ? fs$i.realpath.native : fs$i.realpath;
  16668. var defaultIsFile$1 = function isFile(file, cb) {
  16669. fs$i.stat(file, function (err, stat) {
  16670. if (!err) {
  16671. return cb(null, stat.isFile() || stat.isFIFO());
  16672. }
  16673. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  16674. return cb(err);
  16675. });
  16676. };
  16677. var defaultIsDir$1 = function isDirectory(dir, cb) {
  16678. fs$i.stat(dir, function (err, stat) {
  16679. if (!err) {
  16680. return cb(null, stat.isDirectory());
  16681. }
  16682. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  16683. return cb(err);
  16684. });
  16685. };
  16686. var defaultRealpath = function realpath(x, cb) {
  16687. realpathFS$1(x, function (realpathErr, realPath) {
  16688. if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);else cb(null, realpathErr ? x : realPath);
  16689. });
  16690. };
  16691. var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
  16692. if (opts && opts.preserveSymlinks === false) {
  16693. realpath(x, cb);
  16694. } else {
  16695. cb(null, x);
  16696. }
  16697. };
  16698. var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) {
  16699. readFile(pkgfile, function (readFileErr, body) {
  16700. if (readFileErr) cb(readFileErr);else {
  16701. try {
  16702. var pkg = JSON.parse(body);
  16703. cb(null, pkg);
  16704. } catch (jsonErr) {
  16705. cb(null);
  16706. }
  16707. }
  16708. });
  16709. };
  16710. var getPackageCandidates$1 = function getPackageCandidates(x, start, opts) {
  16711. var dirs = nodeModulesPaths$1(start, opts, x);
  16712. for (var i = 0; i < dirs.length; i++) {
  16713. dirs[i] = path$l.join(dirs[i], x);
  16714. }
  16715. return dirs;
  16716. };
  16717. var async$8 = function resolve(x, options, callback) {
  16718. var cb = callback;
  16719. var opts = options;
  16720. if (typeof options === 'function') {
  16721. cb = opts;
  16722. opts = {};
  16723. }
  16724. if (typeof x !== 'string') {
  16725. var err = new TypeError('Path must be a string.');
  16726. return process.nextTick(function () {
  16727. cb(err);
  16728. });
  16729. }
  16730. opts = normalizeOptions$2(x, opts);
  16731. var isFile = opts.isFile || defaultIsFile$1;
  16732. var isDirectory = opts.isDirectory || defaultIsDir$1;
  16733. var readFile = opts.readFile || fs$i.readFile;
  16734. var realpath = opts.realpath || defaultRealpath;
  16735. var readPackage = opts.readPackage || defaultReadPackage;
  16736. if (opts.readFile && opts.readPackage) {
  16737. var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.');
  16738. return process.nextTick(function () {
  16739. cb(conflictErr);
  16740. });
  16741. }
  16742. var packageIterator = opts.packageIterator;
  16743. var extensions = opts.extensions || ['.js'];
  16744. var includeCoreModules = opts.includeCoreModules !== false;
  16745. var basedir = opts.basedir || path$l.dirname(caller$1());
  16746. var parent = opts.filename || basedir;
  16747. opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
  16748. var absoluteStart = path$l.resolve(basedir);
  16749. maybeRealpath(realpath, absoluteStart, opts, function (err, realStart) {
  16750. if (err) cb(err);else init(realStart);
  16751. });
  16752. var res;
  16753. function init(basedir) {
  16754. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  16755. res = path$l.resolve(basedir, x);
  16756. if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
  16757. if (/\/$/.test(x) && res === basedir) {
  16758. loadAsDirectory(res, opts.package, onfile);
  16759. } else loadAsFile(res, opts.package, onfile);
  16760. } else if (includeCoreModules && isCore$2(x)) {
  16761. return cb(null, x);
  16762. } else loadNodeModules(x, basedir, function (err, n, pkg) {
  16763. if (err) cb(err);else if (n) {
  16764. return maybeRealpath(realpath, n, opts, function (err, realN) {
  16765. if (err) {
  16766. cb(err);
  16767. } else {
  16768. cb(null, realN, pkg);
  16769. }
  16770. });
  16771. } else {
  16772. var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  16773. moduleError.code = 'MODULE_NOT_FOUND';
  16774. cb(moduleError);
  16775. }
  16776. });
  16777. }
  16778. function onfile(err, m, pkg) {
  16779. if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
  16780. if (err) cb(err);else if (d) {
  16781. maybeRealpath(realpath, d, opts, function (err, realD) {
  16782. if (err) {
  16783. cb(err);
  16784. } else {
  16785. cb(null, realD, pkg);
  16786. }
  16787. });
  16788. } else {
  16789. var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  16790. moduleError.code = 'MODULE_NOT_FOUND';
  16791. cb(moduleError);
  16792. }
  16793. });
  16794. }
  16795. function loadAsFile(x, thePackage, callback) {
  16796. var loadAsFilePackage = thePackage;
  16797. var cb = callback;
  16798. if (typeof loadAsFilePackage === 'function') {
  16799. cb = loadAsFilePackage;
  16800. loadAsFilePackage = undefined;
  16801. }
  16802. var exts = [''].concat(extensions);
  16803. load(exts, x, loadAsFilePackage);
  16804. function load(exts, x, loadPackage) {
  16805. if (exts.length === 0) return cb(null, undefined, loadPackage);
  16806. var file = x + exts[0];
  16807. var pkg = loadPackage;
  16808. if (pkg) onpkg(null, pkg);else loadpkg(path$l.dirname(file), onpkg);
  16809. function onpkg(err, pkg_, dir) {
  16810. pkg = pkg_;
  16811. if (err) return cb(err);
  16812. if (dir && pkg && opts.pathFilter) {
  16813. var rfile = path$l.relative(dir, file);
  16814. var rel = rfile.slice(0, rfile.length - exts[0].length);
  16815. var r = opts.pathFilter(pkg, x, rel);
  16816. if (r) return load([''].concat(extensions.slice()), path$l.resolve(dir, r), pkg);
  16817. }
  16818. isFile(file, onex);
  16819. }
  16820. function onex(err, ex) {
  16821. if (err) return cb(err);
  16822. if (ex) return cb(null, file, pkg);
  16823. load(exts.slice(1), x, pkg);
  16824. }
  16825. }
  16826. }
  16827. function loadpkg(dir, cb) {
  16828. if (dir === '' || dir === '/') return cb(null);
  16829. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  16830. return cb(null);
  16831. }
  16832. if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
  16833. maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
  16834. if (unwrapErr) return loadpkg(path$l.dirname(dir), cb);
  16835. var pkgfile = path$l.join(pkgdir, 'package.json');
  16836. isFile(pkgfile, function (err, ex) {
  16837. // on err, ex is false
  16838. if (!ex) return loadpkg(path$l.dirname(dir), cb);
  16839. readPackage(readFile, pkgfile, function (err, pkgParam) {
  16840. if (err) cb(err);
  16841. var pkg = pkgParam;
  16842. if (pkg && opts.packageFilter) {
  16843. pkg = opts.packageFilter(pkg, pkgfile);
  16844. }
  16845. cb(null, pkg, dir);
  16846. });
  16847. });
  16848. });
  16849. }
  16850. function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
  16851. var cb = callback;
  16852. var fpkg = loadAsDirectoryPackage;
  16853. if (typeof fpkg === 'function') {
  16854. cb = fpkg;
  16855. fpkg = opts.package;
  16856. }
  16857. maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
  16858. if (unwrapErr) return cb(unwrapErr);
  16859. var pkgfile = path$l.join(pkgdir, 'package.json');
  16860. isFile(pkgfile, function (err, ex) {
  16861. if (err) return cb(err);
  16862. if (!ex) return loadAsFile(path$l.join(x, 'index'), fpkg, cb);
  16863. readPackage(readFile, pkgfile, function (err, pkgParam) {
  16864. if (err) return cb(err);
  16865. var pkg = pkgParam;
  16866. if (pkg && opts.packageFilter) {
  16867. pkg = opts.packageFilter(pkg, pkgfile);
  16868. }
  16869. if (pkg && pkg.main) {
  16870. if (typeof pkg.main !== 'string') {
  16871. var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
  16872. mainError.code = 'INVALID_PACKAGE_MAIN';
  16873. return cb(mainError);
  16874. }
  16875. if (pkg.main === '.' || pkg.main === './') {
  16876. pkg.main = 'index';
  16877. }
  16878. loadAsFile(path$l.resolve(x, pkg.main), pkg, function (err, m, pkg) {
  16879. if (err) return cb(err);
  16880. if (m) return cb(null, m, pkg);
  16881. if (!pkg) return loadAsFile(path$l.join(x, 'index'), pkg, cb);
  16882. var dir = path$l.resolve(x, pkg.main);
  16883. loadAsDirectory(dir, pkg, function (err, n, pkg) {
  16884. if (err) return cb(err);
  16885. if (n) return cb(null, n, pkg);
  16886. loadAsFile(path$l.join(x, 'index'), pkg, cb);
  16887. });
  16888. });
  16889. return;
  16890. }
  16891. loadAsFile(path$l.join(x, '/index'), pkg, cb);
  16892. });
  16893. });
  16894. });
  16895. }
  16896. function processDirs(cb, dirs) {
  16897. if (dirs.length === 0) return cb(null, undefined);
  16898. var dir = dirs[0];
  16899. isDirectory(path$l.dirname(dir), isdir);
  16900. function isdir(err, isdir) {
  16901. if (err) return cb(err);
  16902. if (!isdir) return processDirs(cb, dirs.slice(1));
  16903. loadAsFile(dir, opts.package, onfile);
  16904. }
  16905. function onfile(err, m, pkg) {
  16906. if (err) return cb(err);
  16907. if (m) return cb(null, m, pkg);
  16908. loadAsDirectory(dir, opts.package, ondir);
  16909. }
  16910. function ondir(err, n, pkg) {
  16911. if (err) return cb(err);
  16912. if (n) return cb(null, n, pkg);
  16913. processDirs(cb, dirs.slice(1));
  16914. }
  16915. }
  16916. function loadNodeModules(x, start, cb) {
  16917. var thunk = function () {
  16918. return getPackageCandidates$1(x, start, opts);
  16919. };
  16920. processDirs(cb, packageIterator ? packageIterator(x, start, thunk, opts) : thunk());
  16921. }
  16922. };
  16923. var assert$3 = true;
  16924. var async_hooks = ">= 8";
  16925. var buffer_ieee754 = "< 0.9.7";
  16926. var buffer = true;
  16927. var child_process = true;
  16928. var cluster = true;
  16929. var console$1 = true;
  16930. var constants$5 = true;
  16931. var crypto = true;
  16932. var _debug_agent = ">= 1 && < 8";
  16933. var _debugger = "< 8";
  16934. var dgram = true;
  16935. var diagnostics_channel = ">= 15.1";
  16936. var dns = true;
  16937. var domain = ">= 0.7.12";
  16938. var events = true;
  16939. var freelist = "< 6";
  16940. var fs$h = true;
  16941. var _http_agent = ">= 0.11.1";
  16942. var _http_client = ">= 0.11.1";
  16943. var _http_common = ">= 0.11.1";
  16944. var _http_incoming = ">= 0.11.1";
  16945. var _http_outgoing = ">= 0.11.1";
  16946. var _http_server = ">= 0.11.1";
  16947. var http = true;
  16948. var http2 = ">= 8.8";
  16949. var https = true;
  16950. var inspector = ">= 8.0.0";
  16951. var _linklist = "< 8";
  16952. var module$2 = true;
  16953. var net = true;
  16954. var os = true;
  16955. var path$k = true;
  16956. var perf_hooks = ">= 8.5";
  16957. var process$1 = ">= 1";
  16958. var punycode = true;
  16959. var querystring = true;
  16960. var readline = true;
  16961. var repl = true;
  16962. var smalloc = ">= 0.11.5 && < 3";
  16963. var _stream_duplex = ">= 0.9.4";
  16964. var _stream_transform = ">= 0.9.4";
  16965. var _stream_wrap = ">= 1.4.1";
  16966. var _stream_passthrough = ">= 0.9.4";
  16967. var _stream_readable = ">= 0.9.4";
  16968. var _stream_writable = ">= 0.9.4";
  16969. var stream$5 = true;
  16970. var string_decoder = true;
  16971. var sys = [
  16972. ">= 0.6 && < 0.7",
  16973. ">= 0.8"
  16974. ];
  16975. var timers = true;
  16976. var _tls_common = ">= 0.11.13";
  16977. var _tls_legacy = ">= 0.11.3 && < 10";
  16978. var _tls_wrap = ">= 0.11.3";
  16979. var tls = true;
  16980. var trace_events = ">= 10";
  16981. var tty = true;
  16982. var url = true;
  16983. var util$4 = true;
  16984. var v8 = ">= 1";
  16985. var vm = true;
  16986. var wasi = ">= 13.4 && < 13.5";
  16987. var worker_threads = ">= 11.7";
  16988. var zlib = true;
  16989. var require$$0$3 = {
  16990. assert: assert$3,
  16991. "assert/strict": ">= 15",
  16992. async_hooks: async_hooks,
  16993. buffer_ieee754: buffer_ieee754,
  16994. buffer: buffer,
  16995. child_process: child_process,
  16996. cluster: cluster,
  16997. console: console$1,
  16998. constants: constants$5,
  16999. crypto: crypto,
  17000. _debug_agent: _debug_agent,
  17001. _debugger: _debugger,
  17002. dgram: dgram,
  17003. diagnostics_channel: diagnostics_channel,
  17004. dns: dns,
  17005. "dns/promises": ">= 15",
  17006. domain: domain,
  17007. events: events,
  17008. freelist: freelist,
  17009. fs: fs$h,
  17010. "fs/promises": [
  17011. ">= 10 && < 10.1",
  17012. ">= 14"
  17013. ],
  17014. _http_agent: _http_agent,
  17015. _http_client: _http_client,
  17016. _http_common: _http_common,
  17017. _http_incoming: _http_incoming,
  17018. _http_outgoing: _http_outgoing,
  17019. _http_server: _http_server,
  17020. http: http,
  17021. http2: http2,
  17022. https: https,
  17023. inspector: inspector,
  17024. _linklist: _linklist,
  17025. module: module$2,
  17026. net: net,
  17027. "node-inspect/lib/_inspect": ">= 7.6.0 && < 12",
  17028. "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12",
  17029. "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12",
  17030. os: os,
  17031. path: path$k,
  17032. "path/posix": ">= 15.3",
  17033. "path/win32": ">= 15.3",
  17034. perf_hooks: perf_hooks,
  17035. process: process$1,
  17036. punycode: punycode,
  17037. querystring: querystring,
  17038. readline: readline,
  17039. repl: repl,
  17040. smalloc: smalloc,
  17041. _stream_duplex: _stream_duplex,
  17042. _stream_transform: _stream_transform,
  17043. _stream_wrap: _stream_wrap,
  17044. _stream_passthrough: _stream_passthrough,
  17045. _stream_readable: _stream_readable,
  17046. _stream_writable: _stream_writable,
  17047. stream: stream$5,
  17048. "stream/promises": ">= 15",
  17049. string_decoder: string_decoder,
  17050. sys: sys,
  17051. timers: timers,
  17052. "timers/promises": ">= 15",
  17053. _tls_common: _tls_common,
  17054. _tls_legacy: _tls_legacy,
  17055. _tls_wrap: _tls_wrap,
  17056. tls: tls,
  17057. trace_events: trace_events,
  17058. tty: tty,
  17059. url: url,
  17060. util: util$4,
  17061. "util/types": ">= 15.3",
  17062. "v8/tools/arguments": ">= 10 && < 12",
  17063. "v8/tools/codemap": [
  17064. ">= 4.4.0 && < 5",
  17065. ">= 5.2.0 && < 12"
  17066. ],
  17067. "v8/tools/consarray": [
  17068. ">= 4.4.0 && < 5",
  17069. ">= 5.2.0 && < 12"
  17070. ],
  17071. "v8/tools/csvparser": [
  17072. ">= 4.4.0 && < 5",
  17073. ">= 5.2.0 && < 12"
  17074. ],
  17075. "v8/tools/logreader": [
  17076. ">= 4.4.0 && < 5",
  17077. ">= 5.2.0 && < 12"
  17078. ],
  17079. "v8/tools/profile_view": [
  17080. ">= 4.4.0 && < 5",
  17081. ">= 5.2.0 && < 12"
  17082. ],
  17083. "v8/tools/splaytree": [
  17084. ">= 4.4.0 && < 5",
  17085. ">= 5.2.0 && < 12"
  17086. ],
  17087. v8: v8,
  17088. vm: vm,
  17089. wasi: wasi,
  17090. worker_threads: worker_threads,
  17091. zlib: zlib
  17092. };
  17093. var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
  17094. function specifierIncluded(specifier) {
  17095. var parts = specifier.split(' ');
  17096. var op = parts.length > 1 ? parts[0] : '=';
  17097. var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
  17098. for (var i = 0; i < 3; ++i) {
  17099. var cur = parseInt(current[i] || 0, 10);
  17100. var ver = parseInt(versionParts[i] || 0, 10);
  17101. if (cur === ver) {
  17102. continue; // eslint-disable-line no-restricted-syntax, no-continue
  17103. }
  17104. if (op === '<') {
  17105. return cur < ver;
  17106. } else if (op === '>=') {
  17107. return cur >= ver;
  17108. } else {
  17109. return false;
  17110. }
  17111. }
  17112. return op === '>=';
  17113. }
  17114. function matchesRange(range) {
  17115. var specifiers = range.split(/ ?&& ?/);
  17116. if (specifiers.length === 0) {
  17117. return false;
  17118. }
  17119. for (var i = 0; i < specifiers.length; ++i) {
  17120. if (!specifierIncluded(specifiers[i])) {
  17121. return false;
  17122. }
  17123. }
  17124. return true;
  17125. }
  17126. function versionIncluded(specifierValue) {
  17127. if (typeof specifierValue === 'boolean') {
  17128. return specifierValue;
  17129. }
  17130. if (specifierValue && typeof specifierValue === 'object') {
  17131. for (var i = 0; i < specifierValue.length; ++i) {
  17132. if (matchesRange(specifierValue[i])) {
  17133. return true;
  17134. }
  17135. }
  17136. return false;
  17137. }
  17138. return matchesRange(specifierValue);
  17139. }
  17140. var data$1 = require$$0$3;
  17141. var core$1 = {};
  17142. for (var mod in data$1) {
  17143. // eslint-disable-line no-restricted-syntax
  17144. if (Object.prototype.hasOwnProperty.call(data$1, mod)) {
  17145. core$1[mod] = versionIncluded(data$1[mod]);
  17146. }
  17147. }
  17148. var core_1 = core$1;
  17149. var isCoreModule = isCoreModule$1;
  17150. var isCore$1 = function isCore(x) {
  17151. return isCoreModule(x);
  17152. };
  17153. var isCore = isCoreModule$1;
  17154. var fs$g = require$$0__default["default"];
  17155. var path$j = require$$0__default$2["default"];
  17156. var caller = caller$2;
  17157. var nodeModulesPaths = nodeModulesPaths$2;
  17158. var normalizeOptions$1 = normalizeOptions$3;
  17159. var realpathFS = fs$g.realpathSync && typeof fs$g.realpathSync.native === 'function' ? fs$g.realpathSync.native : fs$g.realpathSync;
  17160. var defaultIsFile = function isFile(file) {
  17161. try {
  17162. var stat = fs$g.statSync(file);
  17163. } catch (e) {
  17164. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  17165. throw e;
  17166. }
  17167. return stat.isFile() || stat.isFIFO();
  17168. };
  17169. var defaultIsDir = function isDirectory(dir) {
  17170. try {
  17171. var stat = fs$g.statSync(dir);
  17172. } catch (e) {
  17173. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  17174. throw e;
  17175. }
  17176. return stat.isDirectory();
  17177. };
  17178. var defaultRealpathSync = function realpathSync(x) {
  17179. try {
  17180. return realpathFS(x);
  17181. } catch (realpathErr) {
  17182. if (realpathErr.code !== 'ENOENT') {
  17183. throw realpathErr;
  17184. }
  17185. }
  17186. return x;
  17187. };
  17188. var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
  17189. if (opts && opts.preserveSymlinks === false) {
  17190. return realpathSync(x);
  17191. }
  17192. return x;
  17193. };
  17194. var defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) {
  17195. var body = readFileSync(pkgfile);
  17196. try {
  17197. var pkg = JSON.parse(body);
  17198. return pkg;
  17199. } catch (jsonErr) {}
  17200. };
  17201. var getPackageCandidates = function getPackageCandidates(x, start, opts) {
  17202. var dirs = nodeModulesPaths(start, opts, x);
  17203. for (var i = 0; i < dirs.length; i++) {
  17204. dirs[i] = path$j.join(dirs[i], x);
  17205. }
  17206. return dirs;
  17207. };
  17208. var sync$8 = function resolveSync(x, options) {
  17209. if (typeof x !== 'string') {
  17210. throw new TypeError('Path must be a string.');
  17211. }
  17212. var opts = normalizeOptions$1(x, options);
  17213. var isFile = opts.isFile || defaultIsFile;
  17214. var readFileSync = opts.readFileSync || fs$g.readFileSync;
  17215. var isDirectory = opts.isDirectory || defaultIsDir;
  17216. var realpathSync = opts.realpathSync || defaultRealpathSync;
  17217. var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
  17218. if (opts.readFileSync && opts.readPackageSync) {
  17219. throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.');
  17220. }
  17221. var packageIterator = opts.packageIterator;
  17222. var extensions = opts.extensions || ['.js'];
  17223. var includeCoreModules = opts.includeCoreModules !== false;
  17224. var basedir = opts.basedir || path$j.dirname(caller());
  17225. var parent = opts.filename || basedir;
  17226. opts.paths = opts.paths || []; // ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
  17227. var absoluteStart = maybeRealpathSync(realpathSync, path$j.resolve(basedir), opts);
  17228. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  17229. var res = path$j.resolve(absoluteStart, x);
  17230. if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
  17231. var m = loadAsFileSync(res) || loadAsDirectorySync(res);
  17232. if (m) return maybeRealpathSync(realpathSync, m, opts);
  17233. } else if (includeCoreModules && isCore(x)) {
  17234. return x;
  17235. } else {
  17236. var n = loadNodeModulesSync(x, absoluteStart);
  17237. if (n) return maybeRealpathSync(realpathSync, n, opts);
  17238. }
  17239. var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
  17240. err.code = 'MODULE_NOT_FOUND';
  17241. throw err;
  17242. function loadAsFileSync(x) {
  17243. var pkg = loadpkg(path$j.dirname(x));
  17244. if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
  17245. var rfile = path$j.relative(pkg.dir, x);
  17246. var r = opts.pathFilter(pkg.pkg, x, rfile);
  17247. if (r) {
  17248. x = path$j.resolve(pkg.dir, r); // eslint-disable-line no-param-reassign
  17249. }
  17250. }
  17251. if (isFile(x)) {
  17252. return x;
  17253. }
  17254. for (var i = 0; i < extensions.length; i++) {
  17255. var file = x + extensions[i];
  17256. if (isFile(file)) {
  17257. return file;
  17258. }
  17259. }
  17260. }
  17261. function loadpkg(dir) {
  17262. if (dir === '' || dir === '/') return;
  17263. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  17264. return;
  17265. }
  17266. if (/[/\\]node_modules[/\\]*$/.test(dir)) return;
  17267. var pkgfile = path$j.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
  17268. if (!isFile(pkgfile)) {
  17269. return loadpkg(path$j.dirname(dir));
  17270. }
  17271. var pkg = readPackageSync(readFileSync, pkgfile);
  17272. if (pkg && opts.packageFilter) {
  17273. // v2 will pass pkgfile
  17274. pkg = opts.packageFilter(pkg,
  17275. /*pkgfile,*/
  17276. dir); // eslint-disable-line spaced-comment
  17277. }
  17278. return {
  17279. pkg: pkg,
  17280. dir: dir
  17281. };
  17282. }
  17283. function loadAsDirectorySync(x) {
  17284. var pkgfile = path$j.join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
  17285. if (isFile(pkgfile)) {
  17286. try {
  17287. var pkg = readPackageSync(readFileSync, pkgfile);
  17288. } catch (e) {}
  17289. if (pkg && opts.packageFilter) {
  17290. // v2 will pass pkgfile
  17291. pkg = opts.packageFilter(pkg,
  17292. /*pkgfile,*/
  17293. x); // eslint-disable-line spaced-comment
  17294. }
  17295. if (pkg && pkg.main) {
  17296. if (typeof pkg.main !== 'string') {
  17297. var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
  17298. mainError.code = 'INVALID_PACKAGE_MAIN';
  17299. throw mainError;
  17300. }
  17301. if (pkg.main === '.' || pkg.main === './') {
  17302. pkg.main = 'index';
  17303. }
  17304. try {
  17305. var m = loadAsFileSync(path$j.resolve(x, pkg.main));
  17306. if (m) return m;
  17307. var n = loadAsDirectorySync(path$j.resolve(x, pkg.main));
  17308. if (n) return n;
  17309. } catch (e) {}
  17310. }
  17311. }
  17312. return loadAsFileSync(path$j.join(x, '/index'));
  17313. }
  17314. function loadNodeModulesSync(x, start) {
  17315. var thunk = function () {
  17316. return getPackageCandidates(x, start, opts);
  17317. };
  17318. var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
  17319. for (var i = 0; i < dirs.length; i++) {
  17320. var dir = dirs[i];
  17321. if (isDirectory(path$j.dirname(dir))) {
  17322. var m = loadAsFileSync(dir);
  17323. if (m) return m;
  17324. var n = loadAsDirectorySync(dir);
  17325. if (n) return n;
  17326. }
  17327. }
  17328. }
  17329. };
  17330. var async$7 = async$8;
  17331. async$7.core = core_1;
  17332. async$7.isCore = isCore$1;
  17333. async$7.sync = sync$8;
  17334. var resolve$3 = async$7;
  17335. let {
  17336. resolve: resolve$2
  17337. } = require; // In the VS Code and Atom extensions `require` is overridden and `require.resolve` doesn't support the 2nd argument.
  17338. if (resolve$2.length === 1 || process.env.PRETTIER_FALLBACK_RESOLVE) {
  17339. // @ts-expect-error
  17340. resolve$2 = (id, options) => {
  17341. let basedir;
  17342. if (options && options.paths && options.paths.length === 1) {
  17343. basedir = options.paths[0];
  17344. }
  17345. return resolve$3.sync(id, {
  17346. basedir
  17347. });
  17348. };
  17349. }
  17350. var resolve_1 = resolve$2;
  17351. var src$1 = {};
  17352. var semver$1 = {exports: {}};
  17353. (function (module, exports) {
  17354. exports = module.exports = SemVer;
  17355. var debug;
  17356. /* istanbul ignore next */
  17357. if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
  17358. debug = function () {
  17359. var args = Array.prototype.slice.call(arguments, 0);
  17360. args.unshift('SEMVER');
  17361. console.log.apply(console, args);
  17362. };
  17363. } else {
  17364. debug = function () {};
  17365. } // Note: this is the semver.org version of the spec that it implements
  17366. // Not necessarily the package version of this code.
  17367. exports.SEMVER_SPEC_VERSION = '2.0.0';
  17368. var MAX_LENGTH = 256;
  17369. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  17370. /* istanbul ignore next */
  17371. 9007199254740991; // Max safe segment length for coercion.
  17372. var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
  17373. var re = exports.re = [];
  17374. var src = exports.src = [];
  17375. var R = 0; // The following Regular Expressions can be used for tokenizing,
  17376. // validating, and parsing SemVer version strings.
  17377. // ## Numeric Identifier
  17378. // A single `0`, or a non-zero digit followed by zero or more digits.
  17379. var NUMERICIDENTIFIER = R++;
  17380. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  17381. var NUMERICIDENTIFIERLOOSE = R++;
  17382. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  17383. // Zero or more digits, followed by a letter or hyphen, and then zero or
  17384. // more letters, digits, or hyphens.
  17385. var NONNUMERICIDENTIFIER = R++;
  17386. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  17387. // Three dot-separated numeric identifiers.
  17388. var MAINVERSION = R++;
  17389. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  17390. var MAINVERSIONLOOSE = R++;
  17391. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  17392. // A numeric identifier, or a non-numeric identifier.
  17393. var PRERELEASEIDENTIFIER = R++;
  17394. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  17395. var PRERELEASEIDENTIFIERLOOSE = R++;
  17396. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  17397. // Hyphen, followed by one or more dot-separated pre-release version
  17398. // identifiers.
  17399. var PRERELEASE = R++;
  17400. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  17401. var PRERELEASELOOSE = R++;
  17402. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  17403. // Any combination of digits, letters, or hyphens.
  17404. var BUILDIDENTIFIER = R++;
  17405. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  17406. // Plus sign, followed by one or more period-separated build metadata
  17407. // identifiers.
  17408. var BUILD = R++;
  17409. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  17410. // A main version, followed optionally by a pre-release version and
  17411. // build metadata.
  17412. // Note that the only major, minor, patch, and pre-release sections of
  17413. // the version string are capturing groups. The build metadata is not a
  17414. // capturing group, because it should not ever be used in version
  17415. // comparison.
  17416. var FULL = R++;
  17417. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  17418. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  17419. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  17420. // common in the npm registry.
  17421. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  17422. var LOOSE = R++;
  17423. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  17424. var GTLT = R++;
  17425. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  17426. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  17427. // Only the first item is strictly required.
  17428. var XRANGEIDENTIFIERLOOSE = R++;
  17429. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  17430. var XRANGEIDENTIFIER = R++;
  17431. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  17432. var XRANGEPLAIN = R++;
  17433. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  17434. var XRANGEPLAINLOOSE = R++;
  17435. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  17436. var XRANGE = R++;
  17437. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  17438. var XRANGELOOSE = R++;
  17439. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Coercion.
  17440. // Extract anything that could conceivably be a part of a valid semver
  17441. var COERCE = R++;
  17442. src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; // Tilde ranges.
  17443. // Meaning is "reasonably at or greater than"
  17444. var LONETILDE = R++;
  17445. src[LONETILDE] = '(?:~>?)';
  17446. var TILDETRIM = R++;
  17447. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  17448. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  17449. var tildeTrimReplace = '$1~';
  17450. var TILDE = R++;
  17451. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  17452. var TILDELOOSE = R++;
  17453. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  17454. // Meaning is "at least and backwards compatible with"
  17455. var LONECARET = R++;
  17456. src[LONECARET] = '(?:\\^)';
  17457. var CARETTRIM = R++;
  17458. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  17459. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  17460. var caretTrimReplace = '$1^';
  17461. var CARET = R++;
  17462. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  17463. var CARETLOOSE = R++;
  17464. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  17465. var COMPARATORLOOSE = R++;
  17466. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  17467. var COMPARATOR = R++;
  17468. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  17469. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  17470. var COMPARATORTRIM = R++;
  17471. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  17472. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  17473. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  17474. // Note that these all use the loose form, because they'll be
  17475. // checked against either the strict or loose comparator form
  17476. // later.
  17477. var HYPHENRANGE = R++;
  17478. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  17479. var HYPHENRANGELOOSE = R++;
  17480. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  17481. var STAR = R++;
  17482. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  17483. // All are flag-free, unless they were created above with a flag.
  17484. for (var i = 0; i < R; i++) {
  17485. debug(i, src[i]);
  17486. if (!re[i]) {
  17487. re[i] = new RegExp(src[i]);
  17488. }
  17489. }
  17490. exports.parse = parse;
  17491. function parse(version, options) {
  17492. if (!options || typeof options !== 'object') {
  17493. options = {
  17494. loose: !!options,
  17495. includePrerelease: false
  17496. };
  17497. }
  17498. if (version instanceof SemVer) {
  17499. return version;
  17500. }
  17501. if (typeof version !== 'string') {
  17502. return null;
  17503. }
  17504. if (version.length > MAX_LENGTH) {
  17505. return null;
  17506. }
  17507. var r = options.loose ? re[LOOSE] : re[FULL];
  17508. if (!r.test(version)) {
  17509. return null;
  17510. }
  17511. try {
  17512. return new SemVer(version, options);
  17513. } catch (er) {
  17514. return null;
  17515. }
  17516. }
  17517. exports.valid = valid;
  17518. function valid(version, options) {
  17519. var v = parse(version, options);
  17520. return v ? v.version : null;
  17521. }
  17522. exports.clean = clean;
  17523. function clean(version, options) {
  17524. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  17525. return s ? s.version : null;
  17526. }
  17527. exports.SemVer = SemVer;
  17528. function SemVer(version, options) {
  17529. if (!options || typeof options !== 'object') {
  17530. options = {
  17531. loose: !!options,
  17532. includePrerelease: false
  17533. };
  17534. }
  17535. if (version instanceof SemVer) {
  17536. if (version.loose === options.loose) {
  17537. return version;
  17538. } else {
  17539. version = version.version;
  17540. }
  17541. } else if (typeof version !== 'string') {
  17542. throw new TypeError('Invalid Version: ' + version);
  17543. }
  17544. if (version.length > MAX_LENGTH) {
  17545. throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  17546. }
  17547. if (!(this instanceof SemVer)) {
  17548. return new SemVer(version, options);
  17549. }
  17550. debug('SemVer', version, options);
  17551. this.options = options;
  17552. this.loose = !!options.loose;
  17553. var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
  17554. if (!m) {
  17555. throw new TypeError('Invalid Version: ' + version);
  17556. }
  17557. this.raw = version; // these are actually numbers
  17558. this.major = +m[1];
  17559. this.minor = +m[2];
  17560. this.patch = +m[3];
  17561. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  17562. throw new TypeError('Invalid major version');
  17563. }
  17564. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  17565. throw new TypeError('Invalid minor version');
  17566. }
  17567. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  17568. throw new TypeError('Invalid patch version');
  17569. } // numberify any prerelease numeric ids
  17570. if (!m[4]) {
  17571. this.prerelease = [];
  17572. } else {
  17573. this.prerelease = m[4].split('.').map(function (id) {
  17574. if (/^[0-9]+$/.test(id)) {
  17575. var num = +id;
  17576. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  17577. return num;
  17578. }
  17579. }
  17580. return id;
  17581. });
  17582. }
  17583. this.build = m[5] ? m[5].split('.') : [];
  17584. this.format();
  17585. }
  17586. SemVer.prototype.format = function () {
  17587. this.version = this.major + '.' + this.minor + '.' + this.patch;
  17588. if (this.prerelease.length) {
  17589. this.version += '-' + this.prerelease.join('.');
  17590. }
  17591. return this.version;
  17592. };
  17593. SemVer.prototype.toString = function () {
  17594. return this.version;
  17595. };
  17596. SemVer.prototype.compare = function (other) {
  17597. debug('SemVer.compare', this.version, this.options, other);
  17598. if (!(other instanceof SemVer)) {
  17599. other = new SemVer(other, this.options);
  17600. }
  17601. return this.compareMain(other) || this.comparePre(other);
  17602. };
  17603. SemVer.prototype.compareMain = function (other) {
  17604. if (!(other instanceof SemVer)) {
  17605. other = new SemVer(other, this.options);
  17606. }
  17607. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  17608. };
  17609. SemVer.prototype.comparePre = function (other) {
  17610. if (!(other instanceof SemVer)) {
  17611. other = new SemVer(other, this.options);
  17612. } // NOT having a prerelease is > having one
  17613. if (this.prerelease.length && !other.prerelease.length) {
  17614. return -1;
  17615. } else if (!this.prerelease.length && other.prerelease.length) {
  17616. return 1;
  17617. } else if (!this.prerelease.length && !other.prerelease.length) {
  17618. return 0;
  17619. }
  17620. var i = 0;
  17621. do {
  17622. var a = this.prerelease[i];
  17623. var b = other.prerelease[i];
  17624. debug('prerelease compare', i, a, b);
  17625. if (a === undefined && b === undefined) {
  17626. return 0;
  17627. } else if (b === undefined) {
  17628. return 1;
  17629. } else if (a === undefined) {
  17630. return -1;
  17631. } else if (a === b) {
  17632. continue;
  17633. } else {
  17634. return compareIdentifiers(a, b);
  17635. }
  17636. } while (++i);
  17637. }; // preminor will bump the version up to the next minor release, and immediately
  17638. // down to pre-release. premajor and prepatch work the same way.
  17639. SemVer.prototype.inc = function (release, identifier) {
  17640. switch (release) {
  17641. case 'premajor':
  17642. this.prerelease.length = 0;
  17643. this.patch = 0;
  17644. this.minor = 0;
  17645. this.major++;
  17646. this.inc('pre', identifier);
  17647. break;
  17648. case 'preminor':
  17649. this.prerelease.length = 0;
  17650. this.patch = 0;
  17651. this.minor++;
  17652. this.inc('pre', identifier);
  17653. break;
  17654. case 'prepatch':
  17655. // If this is already a prerelease, it will bump to the next version
  17656. // drop any prereleases that might already exist, since they are not
  17657. // relevant at this point.
  17658. this.prerelease.length = 0;
  17659. this.inc('patch', identifier);
  17660. this.inc('pre', identifier);
  17661. break;
  17662. // If the input is a non-prerelease version, this acts the same as
  17663. // prepatch.
  17664. case 'prerelease':
  17665. if (this.prerelease.length === 0) {
  17666. this.inc('patch', identifier);
  17667. }
  17668. this.inc('pre', identifier);
  17669. break;
  17670. case 'major':
  17671. // If this is a pre-major version, bump up to the same major version.
  17672. // Otherwise increment major.
  17673. // 1.0.0-5 bumps to 1.0.0
  17674. // 1.1.0 bumps to 2.0.0
  17675. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
  17676. this.major++;
  17677. }
  17678. this.minor = 0;
  17679. this.patch = 0;
  17680. this.prerelease = [];
  17681. break;
  17682. case 'minor':
  17683. // If this is a pre-minor version, bump up to the same minor version.
  17684. // Otherwise increment minor.
  17685. // 1.2.0-5 bumps to 1.2.0
  17686. // 1.2.1 bumps to 1.3.0
  17687. if (this.patch !== 0 || this.prerelease.length === 0) {
  17688. this.minor++;
  17689. }
  17690. this.patch = 0;
  17691. this.prerelease = [];
  17692. break;
  17693. case 'patch':
  17694. // If this is not a pre-release version, it will increment the patch.
  17695. // If it is a pre-release it will bump up to the same patch version.
  17696. // 1.2.0-5 patches to 1.2.0
  17697. // 1.2.0 patches to 1.2.1
  17698. if (this.prerelease.length === 0) {
  17699. this.patch++;
  17700. }
  17701. this.prerelease = [];
  17702. break;
  17703. // This probably shouldn't be used publicly.
  17704. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  17705. case 'pre':
  17706. if (this.prerelease.length === 0) {
  17707. this.prerelease = [0];
  17708. } else {
  17709. var i = this.prerelease.length;
  17710. while (--i >= 0) {
  17711. if (typeof this.prerelease[i] === 'number') {
  17712. this.prerelease[i]++;
  17713. i = -2;
  17714. }
  17715. }
  17716. if (i === -1) {
  17717. // didn't increment anything
  17718. this.prerelease.push(0);
  17719. }
  17720. }
  17721. if (identifier) {
  17722. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  17723. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  17724. if (this.prerelease[0] === identifier) {
  17725. if (isNaN(this.prerelease[1])) {
  17726. this.prerelease = [identifier, 0];
  17727. }
  17728. } else {
  17729. this.prerelease = [identifier, 0];
  17730. }
  17731. }
  17732. break;
  17733. default:
  17734. throw new Error('invalid increment argument: ' + release);
  17735. }
  17736. this.format();
  17737. this.raw = this.version;
  17738. return this;
  17739. };
  17740. exports.inc = inc;
  17741. function inc(version, release, loose, identifier) {
  17742. if (typeof loose === 'string') {
  17743. identifier = loose;
  17744. loose = undefined;
  17745. }
  17746. try {
  17747. return new SemVer(version, loose).inc(release, identifier).version;
  17748. } catch (er) {
  17749. return null;
  17750. }
  17751. }
  17752. exports.diff = diff;
  17753. function diff(version1, version2) {
  17754. if (eq(version1, version2)) {
  17755. return null;
  17756. } else {
  17757. var v1 = parse(version1);
  17758. var v2 = parse(version2);
  17759. var prefix = '';
  17760. if (v1.prerelease.length || v2.prerelease.length) {
  17761. prefix = 'pre';
  17762. var defaultResult = 'prerelease';
  17763. }
  17764. for (var key in v1) {
  17765. if (key === 'major' || key === 'minor' || key === 'patch') {
  17766. if (v1[key] !== v2[key]) {
  17767. return prefix + key;
  17768. }
  17769. }
  17770. }
  17771. return defaultResult; // may be undefined
  17772. }
  17773. }
  17774. exports.compareIdentifiers = compareIdentifiers;
  17775. var numeric = /^[0-9]+$/;
  17776. function compareIdentifiers(a, b) {
  17777. var anum = numeric.test(a);
  17778. var bnum = numeric.test(b);
  17779. if (anum && bnum) {
  17780. a = +a;
  17781. b = +b;
  17782. }
  17783. return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
  17784. }
  17785. exports.rcompareIdentifiers = rcompareIdentifiers;
  17786. function rcompareIdentifiers(a, b) {
  17787. return compareIdentifiers(b, a);
  17788. }
  17789. exports.major = major;
  17790. function major(a, loose) {
  17791. return new SemVer(a, loose).major;
  17792. }
  17793. exports.minor = minor;
  17794. function minor(a, loose) {
  17795. return new SemVer(a, loose).minor;
  17796. }
  17797. exports.patch = patch;
  17798. function patch(a, loose) {
  17799. return new SemVer(a, loose).patch;
  17800. }
  17801. exports.compare = compare;
  17802. function compare(a, b, loose) {
  17803. return new SemVer(a, loose).compare(new SemVer(b, loose));
  17804. }
  17805. exports.compareLoose = compareLoose;
  17806. function compareLoose(a, b) {
  17807. return compare(a, b, true);
  17808. }
  17809. exports.rcompare = rcompare;
  17810. function rcompare(a, b, loose) {
  17811. return compare(b, a, loose);
  17812. }
  17813. exports.sort = sort;
  17814. function sort(list, loose) {
  17815. return list.sort(function (a, b) {
  17816. return exports.compare(a, b, loose);
  17817. });
  17818. }
  17819. exports.rsort = rsort;
  17820. function rsort(list, loose) {
  17821. return list.sort(function (a, b) {
  17822. return exports.rcompare(a, b, loose);
  17823. });
  17824. }
  17825. exports.gt = gt;
  17826. function gt(a, b, loose) {
  17827. return compare(a, b, loose) > 0;
  17828. }
  17829. exports.lt = lt;
  17830. function lt(a, b, loose) {
  17831. return compare(a, b, loose) < 0;
  17832. }
  17833. exports.eq = eq;
  17834. function eq(a, b, loose) {
  17835. return compare(a, b, loose) === 0;
  17836. }
  17837. exports.neq = neq;
  17838. function neq(a, b, loose) {
  17839. return compare(a, b, loose) !== 0;
  17840. }
  17841. exports.gte = gte;
  17842. function gte(a, b, loose) {
  17843. return compare(a, b, loose) >= 0;
  17844. }
  17845. exports.lte = lte;
  17846. function lte(a, b, loose) {
  17847. return compare(a, b, loose) <= 0;
  17848. }
  17849. exports.cmp = cmp;
  17850. function cmp(a, op, b, loose) {
  17851. switch (op) {
  17852. case '===':
  17853. if (typeof a === 'object') a = a.version;
  17854. if (typeof b === 'object') b = b.version;
  17855. return a === b;
  17856. case '!==':
  17857. if (typeof a === 'object') a = a.version;
  17858. if (typeof b === 'object') b = b.version;
  17859. return a !== b;
  17860. case '':
  17861. case '=':
  17862. case '==':
  17863. return eq(a, b, loose);
  17864. case '!=':
  17865. return neq(a, b, loose);
  17866. case '>':
  17867. return gt(a, b, loose);
  17868. case '>=':
  17869. return gte(a, b, loose);
  17870. case '<':
  17871. return lt(a, b, loose);
  17872. case '<=':
  17873. return lte(a, b, loose);
  17874. default:
  17875. throw new TypeError('Invalid operator: ' + op);
  17876. }
  17877. }
  17878. exports.Comparator = Comparator;
  17879. function Comparator(comp, options) {
  17880. if (!options || typeof options !== 'object') {
  17881. options = {
  17882. loose: !!options,
  17883. includePrerelease: false
  17884. };
  17885. }
  17886. if (comp instanceof Comparator) {
  17887. if (comp.loose === !!options.loose) {
  17888. return comp;
  17889. } else {
  17890. comp = comp.value;
  17891. }
  17892. }
  17893. if (!(this instanceof Comparator)) {
  17894. return new Comparator(comp, options);
  17895. }
  17896. debug('comparator', comp, options);
  17897. this.options = options;
  17898. this.loose = !!options.loose;
  17899. this.parse(comp);
  17900. if (this.semver === ANY) {
  17901. this.value = '';
  17902. } else {
  17903. this.value = this.operator + this.semver.version;
  17904. }
  17905. debug('comp', this);
  17906. }
  17907. var ANY = {};
  17908. Comparator.prototype.parse = function (comp) {
  17909. var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  17910. var m = comp.match(r);
  17911. if (!m) {
  17912. throw new TypeError('Invalid comparator: ' + comp);
  17913. }
  17914. this.operator = m[1];
  17915. if (this.operator === '=') {
  17916. this.operator = '';
  17917. } // if it literally is just '>' or '' then allow anything.
  17918. if (!m[2]) {
  17919. this.semver = ANY;
  17920. } else {
  17921. this.semver = new SemVer(m[2], this.options.loose);
  17922. }
  17923. };
  17924. Comparator.prototype.toString = function () {
  17925. return this.value;
  17926. };
  17927. Comparator.prototype.test = function (version) {
  17928. debug('Comparator.test', version, this.options.loose);
  17929. if (this.semver === ANY) {
  17930. return true;
  17931. }
  17932. if (typeof version === 'string') {
  17933. version = new SemVer(version, this.options);
  17934. }
  17935. return cmp(version, this.operator, this.semver, this.options);
  17936. };
  17937. Comparator.prototype.intersects = function (comp, options) {
  17938. if (!(comp instanceof Comparator)) {
  17939. throw new TypeError('a Comparator is required');
  17940. }
  17941. if (!options || typeof options !== 'object') {
  17942. options = {
  17943. loose: !!options,
  17944. includePrerelease: false
  17945. };
  17946. }
  17947. var rangeTmp;
  17948. if (this.operator === '') {
  17949. rangeTmp = new Range(comp.value, options);
  17950. return satisfies(this.value, rangeTmp, options);
  17951. } else if (comp.operator === '') {
  17952. rangeTmp = new Range(this.value, options);
  17953. return satisfies(comp.semver, rangeTmp, options);
  17954. }
  17955. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  17956. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  17957. var sameSemVer = this.semver.version === comp.semver.version;
  17958. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  17959. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  17960. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  17961. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  17962. };
  17963. exports.Range = Range;
  17964. function Range(range, options) {
  17965. if (!options || typeof options !== 'object') {
  17966. options = {
  17967. loose: !!options,
  17968. includePrerelease: false
  17969. };
  17970. }
  17971. if (range instanceof Range) {
  17972. if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
  17973. return range;
  17974. } else {
  17975. return new Range(range.raw, options);
  17976. }
  17977. }
  17978. if (range instanceof Comparator) {
  17979. return new Range(range.value, options);
  17980. }
  17981. if (!(this instanceof Range)) {
  17982. return new Range(range, options);
  17983. }
  17984. this.options = options;
  17985. this.loose = !!options.loose;
  17986. this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
  17987. this.raw = range;
  17988. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  17989. return this.parseRange(range.trim());
  17990. }, this).filter(function (c) {
  17991. // throw out any that are not relevant for whatever reason
  17992. return c.length;
  17993. });
  17994. if (!this.set.length) {
  17995. throw new TypeError('Invalid SemVer Range: ' + range);
  17996. }
  17997. this.format();
  17998. }
  17999. Range.prototype.format = function () {
  18000. this.range = this.set.map(function (comps) {
  18001. return comps.join(' ').trim();
  18002. }).join('||').trim();
  18003. return this.range;
  18004. };
  18005. Range.prototype.toString = function () {
  18006. return this.range;
  18007. };
  18008. Range.prototype.parseRange = function (range) {
  18009. var loose = this.options.loose;
  18010. range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  18011. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  18012. range = range.replace(hr, hyphenReplace);
  18013. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  18014. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  18015. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  18016. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  18017. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  18018. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  18019. // ready to be split into comparators.
  18020. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  18021. var set = range.split(' ').map(function (comp) {
  18022. return parseComparator(comp, this.options);
  18023. }, this).join(' ').split(/\s+/);
  18024. if (this.options.loose) {
  18025. // in loose mode, throw out any that are not valid comparators
  18026. set = set.filter(function (comp) {
  18027. return !!comp.match(compRe);
  18028. });
  18029. }
  18030. set = set.map(function (comp) {
  18031. return new Comparator(comp, this.options);
  18032. }, this);
  18033. return set;
  18034. };
  18035. Range.prototype.intersects = function (range, options) {
  18036. if (!(range instanceof Range)) {
  18037. throw new TypeError('a Range is required');
  18038. }
  18039. return this.set.some(function (thisComparators) {
  18040. return thisComparators.every(function (thisComparator) {
  18041. return range.set.some(function (rangeComparators) {
  18042. return rangeComparators.every(function (rangeComparator) {
  18043. return thisComparator.intersects(rangeComparator, options);
  18044. });
  18045. });
  18046. });
  18047. });
  18048. }; // Mostly just for testing and legacy API reasons
  18049. exports.toComparators = toComparators;
  18050. function toComparators(range, options) {
  18051. return new Range(range, options).set.map(function (comp) {
  18052. return comp.map(function (c) {
  18053. return c.value;
  18054. }).join(' ').trim().split(' ');
  18055. });
  18056. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  18057. // already replaced the hyphen ranges
  18058. // turn into a set of JUST comparators.
  18059. function parseComparator(comp, options) {
  18060. debug('comp', comp, options);
  18061. comp = replaceCarets(comp, options);
  18062. debug('caret', comp);
  18063. comp = replaceTildes(comp, options);
  18064. debug('tildes', comp);
  18065. comp = replaceXRanges(comp, options);
  18066. debug('xrange', comp);
  18067. comp = replaceStars(comp, options);
  18068. debug('stars', comp);
  18069. return comp;
  18070. }
  18071. function isX(id) {
  18072. return !id || id.toLowerCase() === 'x' || id === '*';
  18073. } // ~, ~> --> * (any, kinda silly)
  18074. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  18075. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  18076. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  18077. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  18078. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  18079. function replaceTildes(comp, options) {
  18080. return comp.trim().split(/\s+/).map(function (comp) {
  18081. return replaceTilde(comp, options);
  18082. }).join(' ');
  18083. }
  18084. function replaceTilde(comp, options) {
  18085. var r = options.loose ? re[TILDELOOSE] : re[TILDE];
  18086. return comp.replace(r, function (_, M, m, p, pr) {
  18087. debug('tilde', comp, _, M, m, p, pr);
  18088. var ret;
  18089. if (isX(M)) {
  18090. ret = '';
  18091. } else if (isX(m)) {
  18092. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  18093. } else if (isX(p)) {
  18094. // ~1.2 == >=1.2.0 <1.3.0
  18095. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  18096. } else if (pr) {
  18097. debug('replaceTilde pr', pr);
  18098. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
  18099. } else {
  18100. // ~1.2.3 == >=1.2.3 <1.3.0
  18101. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  18102. }
  18103. debug('tilde return', ret);
  18104. return ret;
  18105. });
  18106. } // ^ --> * (any, kinda silly)
  18107. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  18108. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  18109. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  18110. // ^1.2.3 --> >=1.2.3 <2.0.0
  18111. // ^1.2.0 --> >=1.2.0 <2.0.0
  18112. function replaceCarets(comp, options) {
  18113. return comp.trim().split(/\s+/).map(function (comp) {
  18114. return replaceCaret(comp, options);
  18115. }).join(' ');
  18116. }
  18117. function replaceCaret(comp, options) {
  18118. debug('caret', comp, options);
  18119. var r = options.loose ? re[CARETLOOSE] : re[CARET];
  18120. return comp.replace(r, function (_, M, m, p, pr) {
  18121. debug('caret', comp, _, M, m, p, pr);
  18122. var ret;
  18123. if (isX(M)) {
  18124. ret = '';
  18125. } else if (isX(m)) {
  18126. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  18127. } else if (isX(p)) {
  18128. if (M === '0') {
  18129. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  18130. } else {
  18131. ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  18132. }
  18133. } else if (pr) {
  18134. debug('replaceCaret pr', pr);
  18135. if (M === '0') {
  18136. if (m === '0') {
  18137. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
  18138. } else {
  18139. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
  18140. }
  18141. } else {
  18142. ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
  18143. }
  18144. } else {
  18145. debug('no pr');
  18146. if (M === '0') {
  18147. if (m === '0') {
  18148. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
  18149. } else {
  18150. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  18151. }
  18152. } else {
  18153. ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  18154. }
  18155. }
  18156. debug('caret return', ret);
  18157. return ret;
  18158. });
  18159. }
  18160. function replaceXRanges(comp, options) {
  18161. debug('replaceXRanges', comp, options);
  18162. return comp.split(/\s+/).map(function (comp) {
  18163. return replaceXRange(comp, options);
  18164. }).join(' ');
  18165. }
  18166. function replaceXRange(comp, options) {
  18167. comp = comp.trim();
  18168. var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
  18169. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  18170. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  18171. var xM = isX(M);
  18172. var xm = xM || isX(m);
  18173. var xp = xm || isX(p);
  18174. var anyX = xp;
  18175. if (gtlt === '=' && anyX) {
  18176. gtlt = '';
  18177. }
  18178. if (xM) {
  18179. if (gtlt === '>' || gtlt === '<') {
  18180. // nothing is allowed
  18181. ret = '<0.0.0';
  18182. } else {
  18183. // nothing is forbidden
  18184. ret = '*';
  18185. }
  18186. } else if (gtlt && anyX) {
  18187. // we know patch is an x, because we have any x at all.
  18188. // replace X with 0
  18189. if (xm) {
  18190. m = 0;
  18191. }
  18192. p = 0;
  18193. if (gtlt === '>') {
  18194. // >1 => >=2.0.0
  18195. // >1.2 => >=1.3.0
  18196. // >1.2.3 => >= 1.2.4
  18197. gtlt = '>=';
  18198. if (xm) {
  18199. M = +M + 1;
  18200. m = 0;
  18201. p = 0;
  18202. } else {
  18203. m = +m + 1;
  18204. p = 0;
  18205. }
  18206. } else if (gtlt === '<=') {
  18207. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  18208. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  18209. gtlt = '<';
  18210. if (xm) {
  18211. M = +M + 1;
  18212. } else {
  18213. m = +m + 1;
  18214. }
  18215. }
  18216. ret = gtlt + M + '.' + m + '.' + p;
  18217. } else if (xm) {
  18218. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  18219. } else if (xp) {
  18220. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  18221. }
  18222. debug('xRange return', ret);
  18223. return ret;
  18224. });
  18225. } // Because * is AND-ed with everything else in the comparator,
  18226. // and '' means "any version", just remove the *s entirely.
  18227. function replaceStars(comp, options) {
  18228. debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
  18229. return comp.trim().replace(re[STAR], '');
  18230. } // This function is passed to string.replace(re[HYPHENRANGE])
  18231. // M, m, patch, prerelease, build
  18232. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  18233. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  18234. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  18235. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  18236. if (isX(fM)) {
  18237. from = '';
  18238. } else if (isX(fm)) {
  18239. from = '>=' + fM + '.0.0';
  18240. } else if (isX(fp)) {
  18241. from = '>=' + fM + '.' + fm + '.0';
  18242. } else {
  18243. from = '>=' + from;
  18244. }
  18245. if (isX(tM)) {
  18246. to = '';
  18247. } else if (isX(tm)) {
  18248. to = '<' + (+tM + 1) + '.0.0';
  18249. } else if (isX(tp)) {
  18250. to = '<' + tM + '.' + (+tm + 1) + '.0';
  18251. } else if (tpr) {
  18252. to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
  18253. } else {
  18254. to = '<=' + to;
  18255. }
  18256. return (from + ' ' + to).trim();
  18257. } // if ANY of the sets match ALL of its comparators, then pass
  18258. Range.prototype.test = function (version) {
  18259. if (!version) {
  18260. return false;
  18261. }
  18262. if (typeof version === 'string') {
  18263. version = new SemVer(version, this.options);
  18264. }
  18265. for (var i = 0; i < this.set.length; i++) {
  18266. if (testSet(this.set[i], version, this.options)) {
  18267. return true;
  18268. }
  18269. }
  18270. return false;
  18271. };
  18272. function testSet(set, version, options) {
  18273. for (var i = 0; i < set.length; i++) {
  18274. if (!set[i].test(version)) {
  18275. return false;
  18276. }
  18277. }
  18278. if (version.prerelease.length && !options.includePrerelease) {
  18279. // Find the set of versions that are allowed to have prereleases
  18280. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  18281. // That should allow `1.2.3-pr.2` to pass.
  18282. // However, `1.2.4-alpha.notready` should NOT be allowed,
  18283. // even though it's within the range set by the comparators.
  18284. for (i = 0; i < set.length; i++) {
  18285. debug(set[i].semver);
  18286. if (set[i].semver === ANY) {
  18287. continue;
  18288. }
  18289. if (set[i].semver.prerelease.length > 0) {
  18290. var allowed = set[i].semver;
  18291. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
  18292. return true;
  18293. }
  18294. }
  18295. } // Version has a -pre, but it's not one of the ones we like.
  18296. return false;
  18297. }
  18298. return true;
  18299. }
  18300. exports.satisfies = satisfies;
  18301. function satisfies(version, range, options) {
  18302. try {
  18303. range = new Range(range, options);
  18304. } catch (er) {
  18305. return false;
  18306. }
  18307. return range.test(version);
  18308. }
  18309. exports.maxSatisfying = maxSatisfying;
  18310. function maxSatisfying(versions, range, options) {
  18311. var max = null;
  18312. var maxSV = null;
  18313. try {
  18314. var rangeObj = new Range(range, options);
  18315. } catch (er) {
  18316. return null;
  18317. }
  18318. versions.forEach(function (v) {
  18319. if (rangeObj.test(v)) {
  18320. // satisfies(v, range, options)
  18321. if (!max || maxSV.compare(v) === -1) {
  18322. // compare(max, v, true)
  18323. max = v;
  18324. maxSV = new SemVer(max, options);
  18325. }
  18326. }
  18327. });
  18328. return max;
  18329. }
  18330. exports.minSatisfying = minSatisfying;
  18331. function minSatisfying(versions, range, options) {
  18332. var min = null;
  18333. var minSV = null;
  18334. try {
  18335. var rangeObj = new Range(range, options);
  18336. } catch (er) {
  18337. return null;
  18338. }
  18339. versions.forEach(function (v) {
  18340. if (rangeObj.test(v)) {
  18341. // satisfies(v, range, options)
  18342. if (!min || minSV.compare(v) === 1) {
  18343. // compare(min, v, true)
  18344. min = v;
  18345. minSV = new SemVer(min, options);
  18346. }
  18347. }
  18348. });
  18349. return min;
  18350. }
  18351. exports.minVersion = minVersion;
  18352. function minVersion(range, loose) {
  18353. range = new Range(range, loose);
  18354. var minver = new SemVer('0.0.0');
  18355. if (range.test(minver)) {
  18356. return minver;
  18357. }
  18358. minver = new SemVer('0.0.0-0');
  18359. if (range.test(minver)) {
  18360. return minver;
  18361. }
  18362. minver = null;
  18363. for (var i = 0; i < range.set.length; ++i) {
  18364. var comparators = range.set[i];
  18365. comparators.forEach(function (comparator) {
  18366. // Clone to avoid manipulating the comparator's semver object.
  18367. var compver = new SemVer(comparator.semver.version);
  18368. switch (comparator.operator) {
  18369. case '>':
  18370. if (compver.prerelease.length === 0) {
  18371. compver.patch++;
  18372. } else {
  18373. compver.prerelease.push(0);
  18374. }
  18375. compver.raw = compver.format();
  18376. /* fallthrough */
  18377. case '':
  18378. case '>=':
  18379. if (!minver || gt(minver, compver)) {
  18380. minver = compver;
  18381. }
  18382. break;
  18383. case '<':
  18384. case '<=':
  18385. /* Ignore maximum versions */
  18386. break;
  18387. /* istanbul ignore next */
  18388. default:
  18389. throw new Error('Unexpected operation: ' + comparator.operator);
  18390. }
  18391. });
  18392. }
  18393. if (minver && range.test(minver)) {
  18394. return minver;
  18395. }
  18396. return null;
  18397. }
  18398. exports.validRange = validRange;
  18399. function validRange(range, options) {
  18400. try {
  18401. // Return '*' instead of '' so that truthiness works.
  18402. // This will throw if it's invalid anyway
  18403. return new Range(range, options).range || '*';
  18404. } catch (er) {
  18405. return null;
  18406. }
  18407. } // Determine if version is less than all the versions possible in the range
  18408. exports.ltr = ltr;
  18409. function ltr(version, range, options) {
  18410. return outside(version, range, '<', options);
  18411. } // Determine if version is greater than all the versions possible in the range.
  18412. exports.gtr = gtr;
  18413. function gtr(version, range, options) {
  18414. return outside(version, range, '>', options);
  18415. }
  18416. exports.outside = outside;
  18417. function outside(version, range, hilo, options) {
  18418. version = new SemVer(version, options);
  18419. range = new Range(range, options);
  18420. var gtfn, ltefn, ltfn, comp, ecomp;
  18421. switch (hilo) {
  18422. case '>':
  18423. gtfn = gt;
  18424. ltefn = lte;
  18425. ltfn = lt;
  18426. comp = '>';
  18427. ecomp = '>=';
  18428. break;
  18429. case '<':
  18430. gtfn = lt;
  18431. ltefn = gte;
  18432. ltfn = gt;
  18433. comp = '<';
  18434. ecomp = '<=';
  18435. break;
  18436. default:
  18437. throw new TypeError('Must provide a hilo val of "<" or ">"');
  18438. } // If it satisifes the range it is not outside
  18439. if (satisfies(version, range, options)) {
  18440. return false;
  18441. } // From now on, variable terms are as if we're in "gtr" mode.
  18442. // but note that everything is flipped for the "ltr" function.
  18443. for (var i = 0; i < range.set.length; ++i) {
  18444. var comparators = range.set[i];
  18445. var high = null;
  18446. var low = null;
  18447. comparators.forEach(function (comparator) {
  18448. if (comparator.semver === ANY) {
  18449. comparator = new Comparator('>=0.0.0');
  18450. }
  18451. high = high || comparator;
  18452. low = low || comparator;
  18453. if (gtfn(comparator.semver, high.semver, options)) {
  18454. high = comparator;
  18455. } else if (ltfn(comparator.semver, low.semver, options)) {
  18456. low = comparator;
  18457. }
  18458. }); // If the edge version comparator has a operator then our version
  18459. // isn't outside it
  18460. if (high.operator === comp || high.operator === ecomp) {
  18461. return false;
  18462. } // If the lowest version comparator has an operator and our version
  18463. // is less than it then it isn't higher than the range
  18464. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  18465. return false;
  18466. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  18467. return false;
  18468. }
  18469. }
  18470. return true;
  18471. }
  18472. exports.prerelease = prerelease;
  18473. function prerelease(version, options) {
  18474. var parsed = parse(version, options);
  18475. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  18476. }
  18477. exports.intersects = intersects;
  18478. function intersects(r1, r2, options) {
  18479. r1 = new Range(r1, options);
  18480. r2 = new Range(r2, options);
  18481. return r1.intersects(r2);
  18482. }
  18483. exports.coerce = coerce;
  18484. function coerce(version) {
  18485. if (version instanceof SemVer) {
  18486. return version;
  18487. }
  18488. if (typeof version !== 'string') {
  18489. return null;
  18490. }
  18491. var match = version.match(re[COERCE]);
  18492. if (match == null) {
  18493. return null;
  18494. }
  18495. return parse(match[1] + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
  18496. }
  18497. })(semver$1, semver$1.exports);
  18498. var fnmatch$1 = {exports: {}};
  18499. var map$1 = {exports: {}};
  18500. var hasOwnProperty$9 = Object.prototype.hasOwnProperty;
  18501. var pseudomap = PseudoMap;
  18502. function PseudoMap(set) {
  18503. if (!(this instanceof PseudoMap)) // whyyyyyyy
  18504. throw new TypeError("Constructor PseudoMap requires 'new'");
  18505. this.clear();
  18506. if (set) {
  18507. if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
  18508. this.set(key, value);
  18509. }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
  18510. this.set(kv[0], kv[1]);
  18511. }, this);else throw new TypeError('invalid argument');
  18512. }
  18513. }
  18514. PseudoMap.prototype.forEach = function (fn, thisp) {
  18515. thisp = thisp || this;
  18516. Object.keys(this._data).forEach(function (k) {
  18517. if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
  18518. }, this);
  18519. };
  18520. PseudoMap.prototype.has = function (k) {
  18521. return !!find(this._data, k);
  18522. };
  18523. PseudoMap.prototype.get = function (k) {
  18524. var res = find(this._data, k);
  18525. return res && res.value;
  18526. };
  18527. PseudoMap.prototype.set = function (k, v) {
  18528. set(this._data, k, v);
  18529. };
  18530. PseudoMap.prototype.delete = function (k) {
  18531. var res = find(this._data, k);
  18532. if (res) {
  18533. delete this._data[res._index];
  18534. this._data.size--;
  18535. }
  18536. };
  18537. PseudoMap.prototype.clear = function () {
  18538. var data = Object.create(null);
  18539. data.size = 0;
  18540. Object.defineProperty(this, '_data', {
  18541. value: data,
  18542. enumerable: false,
  18543. configurable: true,
  18544. writable: false
  18545. });
  18546. };
  18547. Object.defineProperty(PseudoMap.prototype, 'size', {
  18548. get: function () {
  18549. return this._data.size;
  18550. },
  18551. set: function (n) {},
  18552. enumerable: true,
  18553. configurable: true
  18554. });
  18555. PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
  18556. throw new Error('iterators are not implemented in this version');
  18557. }; // Either identical, or both NaN
  18558. function same(a, b) {
  18559. return a === b || a !== a && b !== b;
  18560. }
  18561. function Entry$1(k, v, i) {
  18562. this.key = k;
  18563. this.value = v;
  18564. this._index = i;
  18565. }
  18566. function find(data, k) {
  18567. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
  18568. if (same(data[key].key, k)) return data[key];
  18569. }
  18570. }
  18571. function set(data, k, v) {
  18572. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$9.call(data, key); key = s + i++) {
  18573. if (same(data[key].key, k)) {
  18574. data[key].value = v;
  18575. return;
  18576. }
  18577. }
  18578. data.size++;
  18579. data[key] = new Entry$1(k, v, key);
  18580. }
  18581. if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
  18582. if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
  18583. map$1.exports = Map;
  18584. } else {
  18585. map$1.exports = pseudomap;
  18586. }
  18587. var yallist = Yallist$1;
  18588. Yallist$1.Node = Node;
  18589. Yallist$1.create = Yallist$1;
  18590. function Yallist$1(list) {
  18591. var self = this;
  18592. if (!(self instanceof Yallist$1)) {
  18593. self = new Yallist$1();
  18594. }
  18595. self.tail = null;
  18596. self.head = null;
  18597. self.length = 0;
  18598. if (list && typeof list.forEach === 'function') {
  18599. list.forEach(function (item) {
  18600. self.push(item);
  18601. });
  18602. } else if (arguments.length > 0) {
  18603. for (var i = 0, l = arguments.length; i < l; i++) {
  18604. self.push(arguments[i]);
  18605. }
  18606. }
  18607. return self;
  18608. }
  18609. Yallist$1.prototype.removeNode = function (node) {
  18610. if (node.list !== this) {
  18611. throw new Error('removing node which does not belong to this list');
  18612. }
  18613. var next = node.next;
  18614. var prev = node.prev;
  18615. if (next) {
  18616. next.prev = prev;
  18617. }
  18618. if (prev) {
  18619. prev.next = next;
  18620. }
  18621. if (node === this.head) {
  18622. this.head = next;
  18623. }
  18624. if (node === this.tail) {
  18625. this.tail = prev;
  18626. }
  18627. node.list.length--;
  18628. node.next = null;
  18629. node.prev = null;
  18630. node.list = null;
  18631. };
  18632. Yallist$1.prototype.unshiftNode = function (node) {
  18633. if (node === this.head) {
  18634. return;
  18635. }
  18636. if (node.list) {
  18637. node.list.removeNode(node);
  18638. }
  18639. var head = this.head;
  18640. node.list = this;
  18641. node.next = head;
  18642. if (head) {
  18643. head.prev = node;
  18644. }
  18645. this.head = node;
  18646. if (!this.tail) {
  18647. this.tail = node;
  18648. }
  18649. this.length++;
  18650. };
  18651. Yallist$1.prototype.pushNode = function (node) {
  18652. if (node === this.tail) {
  18653. return;
  18654. }
  18655. if (node.list) {
  18656. node.list.removeNode(node);
  18657. }
  18658. var tail = this.tail;
  18659. node.list = this;
  18660. node.prev = tail;
  18661. if (tail) {
  18662. tail.next = node;
  18663. }
  18664. this.tail = node;
  18665. if (!this.head) {
  18666. this.head = node;
  18667. }
  18668. this.length++;
  18669. };
  18670. Yallist$1.prototype.push = function () {
  18671. for (var i = 0, l = arguments.length; i < l; i++) {
  18672. push(this, arguments[i]);
  18673. }
  18674. return this.length;
  18675. };
  18676. Yallist$1.prototype.unshift = function () {
  18677. for (var i = 0, l = arguments.length; i < l; i++) {
  18678. unshift(this, arguments[i]);
  18679. }
  18680. return this.length;
  18681. };
  18682. Yallist$1.prototype.pop = function () {
  18683. if (!this.tail) {
  18684. return undefined;
  18685. }
  18686. var res = this.tail.value;
  18687. this.tail = this.tail.prev;
  18688. if (this.tail) {
  18689. this.tail.next = null;
  18690. } else {
  18691. this.head = null;
  18692. }
  18693. this.length--;
  18694. return res;
  18695. };
  18696. Yallist$1.prototype.shift = function () {
  18697. if (!this.head) {
  18698. return undefined;
  18699. }
  18700. var res = this.head.value;
  18701. this.head = this.head.next;
  18702. if (this.head) {
  18703. this.head.prev = null;
  18704. } else {
  18705. this.tail = null;
  18706. }
  18707. this.length--;
  18708. return res;
  18709. };
  18710. Yallist$1.prototype.forEach = function (fn, thisp) {
  18711. thisp = thisp || this;
  18712. for (var walker = this.head, i = 0; walker !== null; i++) {
  18713. fn.call(thisp, walker.value, i, this);
  18714. walker = walker.next;
  18715. }
  18716. };
  18717. Yallist$1.prototype.forEachReverse = function (fn, thisp) {
  18718. thisp = thisp || this;
  18719. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  18720. fn.call(thisp, walker.value, i, this);
  18721. walker = walker.prev;
  18722. }
  18723. };
  18724. Yallist$1.prototype.get = function (n) {
  18725. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  18726. // abort out of the list early if we hit a cycle
  18727. walker = walker.next;
  18728. }
  18729. if (i === n && walker !== null) {
  18730. return walker.value;
  18731. }
  18732. };
  18733. Yallist$1.prototype.getReverse = function (n) {
  18734. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  18735. // abort out of the list early if we hit a cycle
  18736. walker = walker.prev;
  18737. }
  18738. if (i === n && walker !== null) {
  18739. return walker.value;
  18740. }
  18741. };
  18742. Yallist$1.prototype.map = function (fn, thisp) {
  18743. thisp = thisp || this;
  18744. var res = new Yallist$1();
  18745. for (var walker = this.head; walker !== null;) {
  18746. res.push(fn.call(thisp, walker.value, this));
  18747. walker = walker.next;
  18748. }
  18749. return res;
  18750. };
  18751. Yallist$1.prototype.mapReverse = function (fn, thisp) {
  18752. thisp = thisp || this;
  18753. var res = new Yallist$1();
  18754. for (var walker = this.tail; walker !== null;) {
  18755. res.push(fn.call(thisp, walker.value, this));
  18756. walker = walker.prev;
  18757. }
  18758. return res;
  18759. };
  18760. Yallist$1.prototype.reduce = function (fn, initial) {
  18761. var acc;
  18762. var walker = this.head;
  18763. if (arguments.length > 1) {
  18764. acc = initial;
  18765. } else if (this.head) {
  18766. walker = this.head.next;
  18767. acc = this.head.value;
  18768. } else {
  18769. throw new TypeError('Reduce of empty list with no initial value');
  18770. }
  18771. for (var i = 0; walker !== null; i++) {
  18772. acc = fn(acc, walker.value, i);
  18773. walker = walker.next;
  18774. }
  18775. return acc;
  18776. };
  18777. Yallist$1.prototype.reduceReverse = function (fn, initial) {
  18778. var acc;
  18779. var walker = this.tail;
  18780. if (arguments.length > 1) {
  18781. acc = initial;
  18782. } else if (this.tail) {
  18783. walker = this.tail.prev;
  18784. acc = this.tail.value;
  18785. } else {
  18786. throw new TypeError('Reduce of empty list with no initial value');
  18787. }
  18788. for (var i = this.length - 1; walker !== null; i--) {
  18789. acc = fn(acc, walker.value, i);
  18790. walker = walker.prev;
  18791. }
  18792. return acc;
  18793. };
  18794. Yallist$1.prototype.toArray = function () {
  18795. var arr = new Array(this.length);
  18796. for (var i = 0, walker = this.head; walker !== null; i++) {
  18797. arr[i] = walker.value;
  18798. walker = walker.next;
  18799. }
  18800. return arr;
  18801. };
  18802. Yallist$1.prototype.toArrayReverse = function () {
  18803. var arr = new Array(this.length);
  18804. for (var i = 0, walker = this.tail; walker !== null; i++) {
  18805. arr[i] = walker.value;
  18806. walker = walker.prev;
  18807. }
  18808. return arr;
  18809. };
  18810. Yallist$1.prototype.slice = function (from, to) {
  18811. to = to || this.length;
  18812. if (to < 0) {
  18813. to += this.length;
  18814. }
  18815. from = from || 0;
  18816. if (from < 0) {
  18817. from += this.length;
  18818. }
  18819. var ret = new Yallist$1();
  18820. if (to < from || to < 0) {
  18821. return ret;
  18822. }
  18823. if (from < 0) {
  18824. from = 0;
  18825. }
  18826. if (to > this.length) {
  18827. to = this.length;
  18828. }
  18829. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  18830. walker = walker.next;
  18831. }
  18832. for (; walker !== null && i < to; i++, walker = walker.next) {
  18833. ret.push(walker.value);
  18834. }
  18835. return ret;
  18836. };
  18837. Yallist$1.prototype.sliceReverse = function (from, to) {
  18838. to = to || this.length;
  18839. if (to < 0) {
  18840. to += this.length;
  18841. }
  18842. from = from || 0;
  18843. if (from < 0) {
  18844. from += this.length;
  18845. }
  18846. var ret = new Yallist$1();
  18847. if (to < from || to < 0) {
  18848. return ret;
  18849. }
  18850. if (from < 0) {
  18851. from = 0;
  18852. }
  18853. if (to > this.length) {
  18854. to = this.length;
  18855. }
  18856. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  18857. walker = walker.prev;
  18858. }
  18859. for (; walker !== null && i > from; i--, walker = walker.prev) {
  18860. ret.push(walker.value);
  18861. }
  18862. return ret;
  18863. };
  18864. Yallist$1.prototype.reverse = function () {
  18865. var head = this.head;
  18866. var tail = this.tail;
  18867. for (var walker = head; walker !== null; walker = walker.prev) {
  18868. var p = walker.prev;
  18869. walker.prev = walker.next;
  18870. walker.next = p;
  18871. }
  18872. this.head = tail;
  18873. this.tail = head;
  18874. return this;
  18875. };
  18876. function push(self, item) {
  18877. self.tail = new Node(item, self.tail, null, self);
  18878. if (!self.head) {
  18879. self.head = self.tail;
  18880. }
  18881. self.length++;
  18882. }
  18883. function unshift(self, item) {
  18884. self.head = new Node(item, null, self.head, self);
  18885. if (!self.tail) {
  18886. self.tail = self.head;
  18887. }
  18888. self.length++;
  18889. }
  18890. function Node(value, prev, next, list) {
  18891. if (!(this instanceof Node)) {
  18892. return new Node(value, prev, next, list);
  18893. }
  18894. this.list = list;
  18895. this.value = value;
  18896. if (prev) {
  18897. prev.next = this;
  18898. this.prev = prev;
  18899. } else {
  18900. this.prev = null;
  18901. }
  18902. if (next) {
  18903. next.prev = this;
  18904. this.next = next;
  18905. } else {
  18906. this.next = null;
  18907. }
  18908. }
  18909. var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
  18910. // or a fakey-fake PseudoMap in older versions.
  18911. var Map$5 = map$1.exports;
  18912. var util$3 = require$$0__default$4["default"]; // A linked list to keep track of recently-used-ness
  18913. var Yallist = yallist; // use symbols if possible, otherwise just _props
  18914. var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1';
  18915. var makeSymbol;
  18916. if (hasSymbol) {
  18917. makeSymbol = function (key) {
  18918. return Symbol(key);
  18919. };
  18920. } else {
  18921. makeSymbol = function (key) {
  18922. return '_' + key;
  18923. };
  18924. }
  18925. var MAX = makeSymbol('max');
  18926. var LENGTH = makeSymbol('length');
  18927. var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
  18928. var ALLOW_STALE = makeSymbol('allowStale');
  18929. var MAX_AGE = makeSymbol('maxAge');
  18930. var DISPOSE = makeSymbol('dispose');
  18931. var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
  18932. var LRU_LIST = makeSymbol('lruList');
  18933. var CACHE = makeSymbol('cache');
  18934. function naiveLength() {
  18935. return 1;
  18936. } // lruList is a yallist where the head is the youngest
  18937. // item, and the tail is the oldest. the list contains the Hit
  18938. // objects as the entries.
  18939. // Each Hit object has a reference to its Yallist.Node. This
  18940. // never changes.
  18941. //
  18942. // cache is a Map (or PseudoMap) that matches the keys to
  18943. // the Yallist.Node object.
  18944. function LRUCache(options) {
  18945. if (!(this instanceof LRUCache)) {
  18946. return new LRUCache(options);
  18947. }
  18948. if (typeof options === 'number') {
  18949. options = {
  18950. max: options
  18951. };
  18952. }
  18953. if (!options) {
  18954. options = {};
  18955. }
  18956. var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
  18957. if (!max || !(typeof max === 'number') || max <= 0) {
  18958. this[MAX] = Infinity;
  18959. }
  18960. var lc = options.length || naiveLength;
  18961. if (typeof lc !== 'function') {
  18962. lc = naiveLength;
  18963. }
  18964. this[LENGTH_CALCULATOR] = lc;
  18965. this[ALLOW_STALE] = options.stale || false;
  18966. this[MAX_AGE] = options.maxAge || 0;
  18967. this[DISPOSE] = options.dispose;
  18968. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  18969. this.reset();
  18970. } // resize the cache when the max changes.
  18971. Object.defineProperty(LRUCache.prototype, 'max', {
  18972. set: function (mL) {
  18973. if (!mL || !(typeof mL === 'number') || mL <= 0) {
  18974. mL = Infinity;
  18975. }
  18976. this[MAX] = mL;
  18977. trim(this);
  18978. },
  18979. get: function () {
  18980. return this[MAX];
  18981. },
  18982. enumerable: true
  18983. });
  18984. Object.defineProperty(LRUCache.prototype, 'allowStale', {
  18985. set: function (allowStale) {
  18986. this[ALLOW_STALE] = !!allowStale;
  18987. },
  18988. get: function () {
  18989. return this[ALLOW_STALE];
  18990. },
  18991. enumerable: true
  18992. });
  18993. Object.defineProperty(LRUCache.prototype, 'maxAge', {
  18994. set: function (mA) {
  18995. if (!mA || !(typeof mA === 'number') || mA < 0) {
  18996. mA = 0;
  18997. }
  18998. this[MAX_AGE] = mA;
  18999. trim(this);
  19000. },
  19001. get: function () {
  19002. return this[MAX_AGE];
  19003. },
  19004. enumerable: true
  19005. }); // resize the cache when the lengthCalculator changes.
  19006. Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
  19007. set: function (lC) {
  19008. if (typeof lC !== 'function') {
  19009. lC = naiveLength;
  19010. }
  19011. if (lC !== this[LENGTH_CALCULATOR]) {
  19012. this[LENGTH_CALCULATOR] = lC;
  19013. this[LENGTH] = 0;
  19014. this[LRU_LIST].forEach(function (hit) {
  19015. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  19016. this[LENGTH] += hit.length;
  19017. }, this);
  19018. }
  19019. trim(this);
  19020. },
  19021. get: function () {
  19022. return this[LENGTH_CALCULATOR];
  19023. },
  19024. enumerable: true
  19025. });
  19026. Object.defineProperty(LRUCache.prototype, 'length', {
  19027. get: function () {
  19028. return this[LENGTH];
  19029. },
  19030. enumerable: true
  19031. });
  19032. Object.defineProperty(LRUCache.prototype, 'itemCount', {
  19033. get: function () {
  19034. return this[LRU_LIST].length;
  19035. },
  19036. enumerable: true
  19037. });
  19038. LRUCache.prototype.rforEach = function (fn, thisp) {
  19039. thisp = thisp || this;
  19040. for (var walker = this[LRU_LIST].tail; walker !== null;) {
  19041. var prev = walker.prev;
  19042. forEachStep(this, fn, walker, thisp);
  19043. walker = prev;
  19044. }
  19045. };
  19046. function forEachStep(self, fn, node, thisp) {
  19047. var hit = node.value;
  19048. if (isStale(self, hit)) {
  19049. del$1(self, node);
  19050. if (!self[ALLOW_STALE]) {
  19051. hit = undefined;
  19052. }
  19053. }
  19054. if (hit) {
  19055. fn.call(thisp, hit.value, hit.key, self);
  19056. }
  19057. }
  19058. LRUCache.prototype.forEach = function (fn, thisp) {
  19059. thisp = thisp || this;
  19060. for (var walker = this[LRU_LIST].head; walker !== null;) {
  19061. var next = walker.next;
  19062. forEachStep(this, fn, walker, thisp);
  19063. walker = next;
  19064. }
  19065. };
  19066. LRUCache.prototype.keys = function () {
  19067. return this[LRU_LIST].toArray().map(function (k) {
  19068. return k.key;
  19069. }, this);
  19070. };
  19071. LRUCache.prototype.values = function () {
  19072. return this[LRU_LIST].toArray().map(function (k) {
  19073. return k.value;
  19074. }, this);
  19075. };
  19076. LRUCache.prototype.reset = function () {
  19077. if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
  19078. this[LRU_LIST].forEach(function (hit) {
  19079. this[DISPOSE](hit.key, hit.value);
  19080. }, this);
  19081. }
  19082. this[CACHE] = new Map$5(); // hash of items by key
  19083. this[LRU_LIST] = new Yallist(); // list of items in order of use recency
  19084. this[LENGTH] = 0; // length of items in the list
  19085. };
  19086. LRUCache.prototype.dump = function () {
  19087. return this[LRU_LIST].map(function (hit) {
  19088. if (!isStale(this, hit)) {
  19089. return {
  19090. k: hit.key,
  19091. v: hit.value,
  19092. e: hit.now + (hit.maxAge || 0)
  19093. };
  19094. }
  19095. }, this).toArray().filter(function (h) {
  19096. return h;
  19097. });
  19098. };
  19099. LRUCache.prototype.dumpLru = function () {
  19100. return this[LRU_LIST];
  19101. };
  19102. /* istanbul ignore next */
  19103. LRUCache.prototype.inspect = function (n, opts) {
  19104. var str = 'LRUCache {';
  19105. var extras = false;
  19106. var as = this[ALLOW_STALE];
  19107. if (as) {
  19108. str += '\n allowStale: true';
  19109. extras = true;
  19110. }
  19111. var max = this[MAX];
  19112. if (max && max !== Infinity) {
  19113. if (extras) {
  19114. str += ',';
  19115. }
  19116. str += '\n max: ' + util$3.inspect(max, opts);
  19117. extras = true;
  19118. }
  19119. var maxAge = this[MAX_AGE];
  19120. if (maxAge) {
  19121. if (extras) {
  19122. str += ',';
  19123. }
  19124. str += '\n maxAge: ' + util$3.inspect(maxAge, opts);
  19125. extras = true;
  19126. }
  19127. var lc = this[LENGTH_CALCULATOR];
  19128. if (lc && lc !== naiveLength) {
  19129. if (extras) {
  19130. str += ',';
  19131. }
  19132. str += '\n length: ' + util$3.inspect(this[LENGTH], opts);
  19133. extras = true;
  19134. }
  19135. var didFirst = false;
  19136. this[LRU_LIST].forEach(function (item) {
  19137. if (didFirst) {
  19138. str += ',\n ';
  19139. } else {
  19140. if (extras) {
  19141. str += ',\n';
  19142. }
  19143. didFirst = true;
  19144. str += '\n ';
  19145. }
  19146. var key = util$3.inspect(item.key).split('\n').join('\n ');
  19147. var val = {
  19148. value: item.value
  19149. };
  19150. if (item.maxAge !== maxAge) {
  19151. val.maxAge = item.maxAge;
  19152. }
  19153. if (lc !== naiveLength) {
  19154. val.length = item.length;
  19155. }
  19156. if (isStale(this, item)) {
  19157. val.stale = true;
  19158. }
  19159. val = util$3.inspect(val, opts).split('\n').join('\n ');
  19160. str += key + ' => ' + val;
  19161. });
  19162. if (didFirst || extras) {
  19163. str += '\n';
  19164. }
  19165. str += '}';
  19166. return str;
  19167. };
  19168. LRUCache.prototype.set = function (key, value, maxAge) {
  19169. maxAge = maxAge || this[MAX_AGE];
  19170. var now = maxAge ? Date.now() : 0;
  19171. var len = this[LENGTH_CALCULATOR](value, key);
  19172. if (this[CACHE].has(key)) {
  19173. if (len > this[MAX]) {
  19174. del$1(this, this[CACHE].get(key));
  19175. return false;
  19176. }
  19177. var node = this[CACHE].get(key);
  19178. var item = node.value; // dispose of the old one before overwriting
  19179. // split out into 2 ifs for better coverage tracking
  19180. if (this[DISPOSE]) {
  19181. if (!this[NO_DISPOSE_ON_SET]) {
  19182. this[DISPOSE](key, item.value);
  19183. }
  19184. }
  19185. item.now = now;
  19186. item.maxAge = maxAge;
  19187. item.value = value;
  19188. this[LENGTH] += len - item.length;
  19189. item.length = len;
  19190. this.get(key);
  19191. trim(this);
  19192. return true;
  19193. }
  19194. var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
  19195. if (hit.length > this[MAX]) {
  19196. if (this[DISPOSE]) {
  19197. this[DISPOSE](key, value);
  19198. }
  19199. return false;
  19200. }
  19201. this[LENGTH] += hit.length;
  19202. this[LRU_LIST].unshift(hit);
  19203. this[CACHE].set(key, this[LRU_LIST].head);
  19204. trim(this);
  19205. return true;
  19206. };
  19207. LRUCache.prototype.has = function (key) {
  19208. if (!this[CACHE].has(key)) return false;
  19209. var hit = this[CACHE].get(key).value;
  19210. if (isStale(this, hit)) {
  19211. return false;
  19212. }
  19213. return true;
  19214. };
  19215. LRUCache.prototype.get = function (key) {
  19216. return get$2(this, key, true);
  19217. };
  19218. LRUCache.prototype.peek = function (key) {
  19219. return get$2(this, key, false);
  19220. };
  19221. LRUCache.prototype.pop = function () {
  19222. var node = this[LRU_LIST].tail;
  19223. if (!node) return null;
  19224. del$1(this, node);
  19225. return node.value;
  19226. };
  19227. LRUCache.prototype.del = function (key) {
  19228. del$1(this, this[CACHE].get(key));
  19229. };
  19230. LRUCache.prototype.load = function (arr) {
  19231. // reset the cache
  19232. this.reset();
  19233. var now = Date.now(); // A previous serialized cache has the most recent items first
  19234. for (var l = arr.length - 1; l >= 0; l--) {
  19235. var hit = arr[l];
  19236. var expiresAt = hit.e || 0;
  19237. if (expiresAt === 0) {
  19238. // the item was created without expiration in a non aged cache
  19239. this.set(hit.k, hit.v);
  19240. } else {
  19241. var maxAge = expiresAt - now; // dont add already expired items
  19242. if (maxAge > 0) {
  19243. this.set(hit.k, hit.v, maxAge);
  19244. }
  19245. }
  19246. }
  19247. };
  19248. LRUCache.prototype.prune = function () {
  19249. var self = this;
  19250. this[CACHE].forEach(function (value, key) {
  19251. get$2(self, key, false);
  19252. });
  19253. };
  19254. function get$2(self, key, doUse) {
  19255. var node = self[CACHE].get(key);
  19256. if (node) {
  19257. var hit = node.value;
  19258. if (isStale(self, hit)) {
  19259. del$1(self, node);
  19260. if (!self[ALLOW_STALE]) hit = undefined;
  19261. } else {
  19262. if (doUse) {
  19263. self[LRU_LIST].unshiftNode(node);
  19264. }
  19265. }
  19266. if (hit) hit = hit.value;
  19267. }
  19268. return hit;
  19269. }
  19270. function isStale(self, hit) {
  19271. if (!hit || !hit.maxAge && !self[MAX_AGE]) {
  19272. return false;
  19273. }
  19274. var stale = false;
  19275. var diff = Date.now() - hit.now;
  19276. if (hit.maxAge) {
  19277. stale = diff > hit.maxAge;
  19278. } else {
  19279. stale = self[MAX_AGE] && diff > self[MAX_AGE];
  19280. }
  19281. return stale;
  19282. }
  19283. function trim(self) {
  19284. if (self[LENGTH] > self[MAX]) {
  19285. for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
  19286. // We know that we're about to delete this one, and also
  19287. // what the next least recently used key will be, so just
  19288. // go ahead and set it now.
  19289. var prev = walker.prev;
  19290. del$1(self, walker);
  19291. walker = prev;
  19292. }
  19293. }
  19294. }
  19295. function del$1(self, node) {
  19296. if (node) {
  19297. var hit = node.value;
  19298. if (self[DISPOSE]) {
  19299. self[DISPOSE](hit.key, hit.value);
  19300. }
  19301. self[LENGTH] -= hit.length;
  19302. self[CACHE].delete(hit.key);
  19303. self[LRU_LIST].removeNode(node);
  19304. }
  19305. } // classy, since V8 prefers predictable objects.
  19306. function Entry(key, value, length, now, maxAge) {
  19307. this.key = key;
  19308. this.value = value;
  19309. this.length = length;
  19310. this.now = now;
  19311. this.maxAge = maxAge || 0;
  19312. }
  19313. var sigmund_1 = sigmund;
  19314. function sigmund(subject, maxSessions) {
  19315. maxSessions = maxSessions || 10;
  19316. var notes = [];
  19317. var analysis = '';
  19318. var RE = RegExp;
  19319. function psychoAnalyze(subject, session) {
  19320. if (session > maxSessions) return;
  19321. if (typeof subject === 'function' || typeof subject === 'undefined') {
  19322. return;
  19323. }
  19324. if (typeof subject !== 'object' || !subject || subject instanceof RE) {
  19325. analysis += subject;
  19326. return;
  19327. }
  19328. if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
  19329. notes.push(subject);
  19330. analysis += '{';
  19331. Object.keys(subject).forEach(function (issue, _, __) {
  19332. // pseudo-private values. skip those.
  19333. if (issue.charAt(0) === '_') return;
  19334. var to = typeof subject[issue];
  19335. if (to === 'function' || to === 'undefined') return;
  19336. analysis += issue;
  19337. psychoAnalyze(subject[issue], session + 1);
  19338. });
  19339. }
  19340. psychoAnalyze(subject, 0);
  19341. return analysis;
  19342. } // vim: set softtabstop=4 shiftwidth=4:
  19343. (function (module, exports) {
  19344. // Based on minimatch.js by isaacs <https://npmjs.org/package/minimatch>
  19345. var platform = typeof process === "object" ? process.platform : "win32";
  19346. if (module) module.exports = minimatch;else exports.minimatch = minimatch;
  19347. minimatch.Minimatch = Minimatch;
  19348. var LRU = lruCache,
  19349. cache = minimatch.cache = new LRU({
  19350. max: 100
  19351. }),
  19352. GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {},
  19353. sigmund = sigmund_1;
  19354. var path = require$$0__default$2["default"] // any single thing other than /
  19355. // don't need to escape / when using new RegExp()
  19356. ,
  19357. qmark = "[^/]" // * => any number of characters
  19358. ,
  19359. star = qmark + "*?" // ** when dots are allowed. Anything goes, except .. and .
  19360. // not (^ or / followed by one or two dots followed by $ or /),
  19361. // followed by anything, any number of times.
  19362. ,
  19363. twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" // not a ^ or / followed by a dot,
  19364. // followed by anything, any number of times.
  19365. ,
  19366. twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" // characters that need to be escaped in RegExp.
  19367. ,
  19368. reSpecials = charSet("().*{}+?[]^$\\!"); // "abc" -> { a:true, b:true, c:true }
  19369. function charSet(s) {
  19370. return s.split("").reduce(function (set, c) {
  19371. set[c] = true;
  19372. return set;
  19373. }, {});
  19374. } // normalizes slashes.
  19375. var slashSplit = /\/+/;
  19376. minimatch.monkeyPatch = monkeyPatch;
  19377. function monkeyPatch() {
  19378. var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
  19379. var orig = desc.value;
  19380. desc.value = function (p) {
  19381. if (p instanceof Minimatch) return p.match(this);
  19382. return orig.call(this, p);
  19383. };
  19384. Object.defineProperty(String.prototype, desc);
  19385. }
  19386. minimatch.filter = filter;
  19387. function filter(pattern, options) {
  19388. options = options || {};
  19389. return function (p, i, list) {
  19390. return minimatch(p, pattern, options);
  19391. };
  19392. }
  19393. function ext(a, b) {
  19394. a = a || {};
  19395. b = b || {};
  19396. var t = {};
  19397. Object.keys(b).forEach(function (k) {
  19398. t[k] = b[k];
  19399. });
  19400. Object.keys(a).forEach(function (k) {
  19401. t[k] = a[k];
  19402. });
  19403. return t;
  19404. }
  19405. minimatch.defaults = function (def) {
  19406. if (!def || !Object.keys(def).length) return minimatch;
  19407. var orig = minimatch;
  19408. var m = function minimatch(p, pattern, options) {
  19409. return orig.minimatch(p, pattern, ext(def, options));
  19410. };
  19411. m.Minimatch = function Minimatch(pattern, options) {
  19412. return new orig.Minimatch(pattern, ext(def, options));
  19413. };
  19414. return m;
  19415. };
  19416. Minimatch.defaults = function (def) {
  19417. if (!def || !Object.keys(def).length) return Minimatch;
  19418. return minimatch.defaults(def).Minimatch;
  19419. };
  19420. function minimatch(p, pattern, options) {
  19421. if (typeof pattern !== "string") {
  19422. throw new TypeError("glob pattern string required");
  19423. }
  19424. if (!options) options = {}; // shortcut: comments match nothing.
  19425. if (!options.nocomment && pattern.charAt(0) === "#") {
  19426. return false;
  19427. } // "" only matches ""
  19428. if (pattern.trim() === "") return p === "";
  19429. return new Minimatch(pattern, options).match(p);
  19430. }
  19431. function Minimatch(pattern, options) {
  19432. if (!(this instanceof Minimatch)) {
  19433. return new Minimatch(pattern, options, cache);
  19434. }
  19435. if (typeof pattern !== "string") {
  19436. throw new TypeError("glob pattern string required");
  19437. }
  19438. if (!options) options = {}; // windows: need to use /, not \
  19439. // On other platforms, \ is a valid (albeit bad) filename char.
  19440. if (platform === "win32") {
  19441. pattern = pattern.split("\\").join("/");
  19442. } // lru storage.
  19443. // these things aren't particularly big, but walking down the string
  19444. // and turning it into a regexp can get pretty costly.
  19445. var cacheKey = pattern + "\n" + sigmund(options);
  19446. var cached = minimatch.cache.get(cacheKey);
  19447. if (cached) return cached;
  19448. minimatch.cache.set(cacheKey, this);
  19449. this.options = options;
  19450. this.set = [];
  19451. this.pattern = pattern;
  19452. this.regexp = null;
  19453. this.negate = false;
  19454. this.comment = false;
  19455. this.empty = false; // make the set of regexps etc.
  19456. this.make();
  19457. }
  19458. Minimatch.prototype.make = make;
  19459. function make() {
  19460. // don't do it more than once.
  19461. if (this._made) return;
  19462. var pattern = this.pattern;
  19463. var options = this.options; // empty patterns and comments match nothing.
  19464. if (!options.nocomment && pattern.charAt(0) === "#") {
  19465. this.comment = true;
  19466. return;
  19467. }
  19468. if (!pattern) {
  19469. this.empty = true;
  19470. return;
  19471. } // step 1: figure out negation, etc.
  19472. this.parseNegate(); // step 2: expand braces
  19473. var set = this.globSet = this.braceExpand();
  19474. 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
  19475. // matching patterns.
  19476. // These will be regexps, except in the case of "**", which is
  19477. // set to the GLOBSTAR object for globstar behavior,
  19478. // and will not contain any / characters
  19479. set = this.globParts = set.map(function (s) {
  19480. return s.split(slashSplit);
  19481. });
  19482. if (options.debug) console.error(this.pattern, set); // glob --> regexps
  19483. set = set.map(function (s, si, set) {
  19484. return s.map(this.parse, this);
  19485. }, this);
  19486. if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
  19487. set = set.filter(function (s) {
  19488. return -1 === s.indexOf(false);
  19489. });
  19490. if (options.debug) console.error(this.pattern, set);
  19491. this.set = set;
  19492. }
  19493. Minimatch.prototype.parseNegate = parseNegate;
  19494. function parseNegate() {
  19495. var pattern = this.pattern,
  19496. negate = false,
  19497. options = this.options,
  19498. negateOffset = 0;
  19499. if (options.nonegate) return;
  19500. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
  19501. negate = !negate;
  19502. negateOffset++;
  19503. }
  19504. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  19505. this.negate = negate;
  19506. } // Brace expansion:
  19507. // a{b,c}d -> abd acd
  19508. // a{b,}c -> abc ac
  19509. // a{0..3}d -> a0d a1d a2d a3d
  19510. // a{b,c{d,e}f}g -> abg acdfg acefg
  19511. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  19512. //
  19513. // Invalid sets are not expanded.
  19514. // a{2..}b -> a{2..}b
  19515. // a{b}c -> a{b}c
  19516. minimatch.braceExpand = function (pattern, options) {
  19517. return new Minimatch(pattern, options).braceExpand();
  19518. };
  19519. Minimatch.prototype.braceExpand = braceExpand;
  19520. function braceExpand(pattern, options) {
  19521. options = options || this.options;
  19522. pattern = typeof pattern === "undefined" ? this.pattern : pattern;
  19523. if (typeof pattern === "undefined") {
  19524. throw new Error("undefined pattern");
  19525. }
  19526. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  19527. // shortcut. no need to expand.
  19528. return [pattern];
  19529. }
  19530. var escaping = false; // examples and comments refer to this crazy pattern:
  19531. // a{b,c{d,e},{f,g}h}x{y,z}
  19532. // expected:
  19533. // abxy
  19534. // abxz
  19535. // acdxy
  19536. // acdxz
  19537. // acexy
  19538. // acexz
  19539. // afhxy
  19540. // afhxz
  19541. // aghxy
  19542. // aghxz
  19543. // everything before the first \{ is just a prefix.
  19544. // So, we pluck that off, and work with the rest,
  19545. // and then prepend it to everything we find.
  19546. if (pattern.charAt(0) !== "{") {
  19547. // console.error(pattern)
  19548. var prefix = null;
  19549. for (var i = 0, l = pattern.length; i < l; i++) {
  19550. var c = pattern.charAt(i); // console.error(i, c)
  19551. if (c === "\\") {
  19552. escaping = !escaping;
  19553. } else if (c === "{" && !escaping) {
  19554. prefix = pattern.substr(0, i);
  19555. break;
  19556. }
  19557. } // actually no sets, all { were escaped.
  19558. if (prefix === null) {
  19559. // console.error("no sets")
  19560. return [pattern];
  19561. }
  19562. var tail = braceExpand(pattern.substr(i), options);
  19563. return tail.map(function (t) {
  19564. return prefix + t;
  19565. });
  19566. } // now we have something like:
  19567. // {b,c{d,e},{f,g}h}x{y,z}
  19568. // walk through the set, expanding each part, until
  19569. // the set ends. then, we'll expand the suffix.
  19570. // If the set only has a single member, then'll put the {} back
  19571. // first, handle numeric sets, since they're easier
  19572. var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
  19573. if (numset) {
  19574. // console.error("numset", numset[1], numset[2])
  19575. var suf = braceExpand(pattern.substr(numset[0].length), options),
  19576. start = +numset[1],
  19577. end = +numset[2],
  19578. inc = start > end ? -1 : 1,
  19579. set = [];
  19580. for (var i = start; i != end + inc; i += inc) {
  19581. // append all the suffixes
  19582. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  19583. set.push(i + suf[ii]);
  19584. }
  19585. }
  19586. return set;
  19587. } // ok, walk through the set
  19588. // We hope, somewhat optimistically, that there
  19589. // will be a } at the end.
  19590. // If the closing brace isn't found, then the pattern is
  19591. // interpreted as braceExpand("\\" + pattern) so that
  19592. // the leading \{ will be interpreted literally.
  19593. var i = 1 // skip the \{
  19594. ,
  19595. depth = 1,
  19596. set = [],
  19597. member = "",
  19598. escaping = false;
  19599. function addMember() {
  19600. set.push(member);
  19601. member = "";
  19602. } // console.error("Entering for")
  19603. FOR: for (i = 1, l = pattern.length; i < l; i++) {
  19604. var c = pattern.charAt(i); // console.error("", i, c)
  19605. if (escaping) {
  19606. escaping = false;
  19607. member += "\\" + c;
  19608. } else {
  19609. switch (c) {
  19610. case "\\":
  19611. escaping = true;
  19612. continue;
  19613. case "{":
  19614. depth++;
  19615. member += "{";
  19616. continue;
  19617. case "}":
  19618. depth--; // if this closes the actual set, then we're done
  19619. if (depth === 0) {
  19620. addMember(); // pluck off the close-brace
  19621. i++;
  19622. break FOR;
  19623. } else {
  19624. member += c;
  19625. continue;
  19626. }
  19627. case ",":
  19628. if (depth === 1) {
  19629. addMember();
  19630. } else {
  19631. member += c;
  19632. }
  19633. continue;
  19634. default:
  19635. member += c;
  19636. continue;
  19637. } // switch
  19638. } // else
  19639. } // for
  19640. // now we've either finished the set, and the suffix is
  19641. // pattern.substr(i), or we have *not* closed the set,
  19642. // and need to escape the leading brace
  19643. if (depth !== 0) {
  19644. // console.error("didn't close", pattern)
  19645. return braceExpand("\\" + pattern, options);
  19646. } // x{y,z} -> ["xy", "xz"]
  19647. // console.error("set", set)
  19648. // console.error("suffix", pattern.substr(i))
  19649. var suf = braceExpand(pattern.substr(i), options); // ["b", "c{d,e}","{f,g}h"] ->
  19650. // [["b"], ["cd", "ce"], ["fh", "gh"]]
  19651. var addBraces = set.length === 1; // console.error("set pre-expanded", set)
  19652. set = set.map(function (p) {
  19653. return braceExpand(p, options);
  19654. }); // console.error("set expanded", set)
  19655. // [["b"], ["cd", "ce"], ["fh", "gh"]] ->
  19656. // ["b", "cd", "ce", "fh", "gh"]
  19657. set = set.reduce(function (l, r) {
  19658. return l.concat(r);
  19659. });
  19660. if (addBraces) {
  19661. set = set.map(function (s) {
  19662. return "{" + s + "}";
  19663. });
  19664. } // now attach the suffixes.
  19665. var ret = [];
  19666. for (var i = 0, l = set.length; i < l; i++) {
  19667. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  19668. ret.push(set[i] + suf[ii]);
  19669. }
  19670. }
  19671. return ret;
  19672. } // parse a component of the expanded set.
  19673. // At this point, no pattern may contain "/" in it
  19674. // so we're going to return a 2d array, where each entry is the full
  19675. // pattern, split on '/', and then turned into a regular expression.
  19676. // A regexp is made at the end which joins each array with an
  19677. // escaped /, and another full one which joins each regexp with |.
  19678. //
  19679. // Following the lead of Bash 4.1, note that "**" only has special meaning
  19680. // when it is the *only* thing in a path portion. Otherwise, any series
  19681. // of * is equivalent to a single *. Globstar behavior is enabled by
  19682. // default, and can be disabled by setting options.noglobstar.
  19683. Minimatch.prototype.parse = parse;
  19684. var SUBPARSE = {};
  19685. function parse(pattern, isSub) {
  19686. var options = this.options; // shortcuts
  19687. if (!options.noglobstar && pattern === "**") return GLOBSTAR;
  19688. if (pattern === "") return "";
  19689. var re = "",
  19690. hasMagic = !!options.nocase,
  19691. escaping = false // ? => one single character
  19692. ,
  19693. patternListStack = [],
  19694. plType,
  19695. stateChar,
  19696. inClass = false,
  19697. reClassStart = -1,
  19698. classStart = -1 // . and .. never match anything that doesn't start with .,
  19699. // even when options.dot is set.
  19700. ,
  19701. patternStart = pattern.charAt(0) === "." ? "" // anything
  19702. // not (start or / followed by . or .. followed by / or end)
  19703. : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
  19704. function clearStateChar() {
  19705. if (stateChar) {
  19706. // we had some state-tracking character
  19707. // that wasn't consumed by this pass.
  19708. switch (stateChar) {
  19709. case "*":
  19710. re += star;
  19711. hasMagic = true;
  19712. break;
  19713. case "?":
  19714. re += qmark;
  19715. hasMagic = true;
  19716. break;
  19717. default:
  19718. re += "\\" + stateChar;
  19719. break;
  19720. }
  19721. stateChar = false;
  19722. }
  19723. }
  19724. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  19725. if (options.debug) {
  19726. console.error("%s\t%s %s %j", pattern, i, re, c);
  19727. } // skip over any that are escaped.
  19728. if (escaping && reSpecials[c]) {
  19729. re += "\\" + c;
  19730. escaping = false;
  19731. continue;
  19732. }
  19733. switch (c) {
  19734. case "/":
  19735. // completely not allowed, even escaped.
  19736. // Should already be path-split by now.
  19737. return false;
  19738. case "\\":
  19739. clearStateChar();
  19740. escaping = true;
  19741. continue;
  19742. // the various stateChar values
  19743. // for the "extglob" stuff.
  19744. case "?":
  19745. case "*":
  19746. case "+":
  19747. case "@":
  19748. case "!":
  19749. if (options.debug) {
  19750. console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
  19751. } // all of those are literals inside a class, except that
  19752. // the glob [!a] means [^a] in regexp
  19753. if (inClass) {
  19754. if (c === "!" && i === classStart + 1) c = "^";
  19755. re += c;
  19756. continue;
  19757. } // if we already have a stateChar, then it means
  19758. // that there was something like ** or +? in there.
  19759. // Handle the stateChar, then proceed with this one.
  19760. clearStateChar();
  19761. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  19762. // just clear the statechar *now*, rather than even diving into
  19763. // the patternList stuff.
  19764. if (options.noext) clearStateChar();
  19765. continue;
  19766. case "(":
  19767. if (inClass) {
  19768. re += "(";
  19769. continue;
  19770. }
  19771. if (!stateChar) {
  19772. re += "\\(";
  19773. continue;
  19774. }
  19775. plType = stateChar;
  19776. patternListStack.push({
  19777. type: plType,
  19778. start: i - 1,
  19779. reStart: re.length
  19780. }); // negation is (?:(?!js)[^/]*)
  19781. re += stateChar === "!" ? "(?:(?!" : "(?:";
  19782. stateChar = false;
  19783. continue;
  19784. case ")":
  19785. if (inClass || !patternListStack.length) {
  19786. re += "\\)";
  19787. continue;
  19788. }
  19789. hasMagic = true;
  19790. re += ")";
  19791. plType = patternListStack.pop().type; // negation is (?:(?!js)[^/]*)
  19792. // The others are (?:<pattern>)<type>
  19793. switch (plType) {
  19794. case "!":
  19795. re += "[^/]*?)";
  19796. break;
  19797. case "?":
  19798. case "+":
  19799. case "*":
  19800. re += plType;
  19801. // the default anyway
  19802. }
  19803. continue;
  19804. case "|":
  19805. if (inClass || !patternListStack.length || escaping) {
  19806. re += "\\|";
  19807. escaping = false;
  19808. continue;
  19809. }
  19810. re += "|";
  19811. continue;
  19812. // these are mostly the same in regexp and glob
  19813. case "[":
  19814. // swallow any state-tracking char before the [
  19815. clearStateChar();
  19816. if (inClass) {
  19817. re += "\\" + c;
  19818. continue;
  19819. }
  19820. inClass = true;
  19821. classStart = i;
  19822. reClassStart = re.length;
  19823. re += c;
  19824. continue;
  19825. case "]":
  19826. // a right bracket shall lose its special
  19827. // meaning and represent itself in
  19828. // a bracket expression if it occurs
  19829. // first in the list. -- POSIX.2 2.8.3.2
  19830. if (i === classStart + 1 || !inClass) {
  19831. re += "\\" + c;
  19832. escaping = false;
  19833. continue;
  19834. } // finish up the class.
  19835. hasMagic = true;
  19836. inClass = false;
  19837. re += c;
  19838. continue;
  19839. default:
  19840. // swallow any state char that wasn't consumed
  19841. clearStateChar();
  19842. if (escaping) {
  19843. // no need
  19844. escaping = false;
  19845. } else if (reSpecials[c] && !(c === "^" && inClass)) {
  19846. re += "\\";
  19847. }
  19848. re += c;
  19849. } // switch
  19850. } // for
  19851. // handle the case where we left a class open.
  19852. // "[abc" is valid, equivalent to "\[abc"
  19853. if (inClass) {
  19854. // split where the last [ was, and escape it
  19855. // this is a huge pita. We now have to re-walk
  19856. // the contents of the would-be class to re-translate
  19857. // any characters that were passed through as-is
  19858. var cs = pattern.substr(classStart + 1),
  19859. sp = this.parse(cs, SUBPARSE);
  19860. re = re.substr(0, reClassStart) + "\\[" + sp[0];
  19861. hasMagic = hasMagic || sp[1];
  19862. } // handle the case where we had a +( thing at the *end*
  19863. // of the pattern.
  19864. // each pattern list stack adds 3 chars, and we need to go through
  19865. // and escape any | chars that were passed through as-is for the regexp.
  19866. // Go through and escape them, taking care not to double-escape any
  19867. // | chars that were already escaped.
  19868. var pl;
  19869. while (pl = patternListStack.pop()) {
  19870. var tail = re.slice(pl.reStart + 3); // maybe some even number of \, then maybe 1 \, followed by a |
  19871. tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
  19872. if (!$2) {
  19873. // the | isn't already escaped, so escape it.
  19874. $2 = "\\";
  19875. } // need to escape all those slashes *again*, without escaping the
  19876. // one that we need for escaping the | character. As it works out,
  19877. // escaping an even number of slashes can be done by simply repeating
  19878. // it exactly after itself. That's why this trick works.
  19879. //
  19880. // I am sorry that you have to see this.
  19881. return $1 + $1 + $2 + "|";
  19882. }); // console.error("tail=%j\n %s", tail, tail)
  19883. var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
  19884. hasMagic = true;
  19885. re = re.slice(0, pl.reStart) + t + "\\(" + tail;
  19886. } // handle trailing things that only matter at the very end.
  19887. clearStateChar();
  19888. if (escaping) {
  19889. // trailing \\
  19890. re += "\\\\";
  19891. } // only need to apply the nodot start if the re starts with
  19892. // something that could conceivably capture a dot
  19893. var addPatternStart = false;
  19894. switch (re.charAt(0)) {
  19895. case ".":
  19896. case "[":
  19897. case "(":
  19898. addPatternStart = true;
  19899. } // if the re is not "" at this point, then we need to make sure
  19900. // it doesn't match against an empty path part.
  19901. // Otherwise a/* will match a/, which it should not.
  19902. if (re !== "" && hasMagic) re = "(?=.)" + re;
  19903. if (addPatternStart) re = patternStart + re; // parsing just a piece of a larger pattern.
  19904. if (isSub === SUBPARSE) {
  19905. return [re, hasMagic];
  19906. } // skip the regexp for non-magical patterns
  19907. // unescape anything in it, though, so that it'll be
  19908. // an exact match against a file etc.
  19909. if (!hasMagic) {
  19910. return globUnescape(pattern);
  19911. }
  19912. var flags = options.nocase ? "i" : "",
  19913. regExp = new RegExp("^" + re + "$", flags);
  19914. regExp._glob = pattern;
  19915. regExp._src = re;
  19916. return regExp;
  19917. }
  19918. minimatch.makeRe = function (pattern, options) {
  19919. return new Minimatch(pattern, options || {}).makeRe();
  19920. };
  19921. Minimatch.prototype.makeRe = makeRe;
  19922. function makeRe() {
  19923. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  19924. // pattern strings, or "**".
  19925. //
  19926. // It's better to use .match(). This function shouldn't
  19927. // be used, really, but it's pretty convenient sometimes,
  19928. // when you just want to work with a regex.
  19929. var set = this.set;
  19930. if (!set.length) return this.regexp = false;
  19931. var options = this.options;
  19932. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
  19933. flags = options.nocase ? "i" : "";
  19934. var re = set.map(function (pattern) {
  19935. return pattern.map(function (p) {
  19936. return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
  19937. }).join("\\\/");
  19938. }).join("|"); // must match entire pattern
  19939. // ending in a * or ** will make it less strict.
  19940. re = "^(?:" + re + ")$"; // can match anything, as long as it's not this.
  19941. if (this.negate) re = "^(?!" + re + ").*$";
  19942. try {
  19943. return this.regexp = new RegExp(re, flags);
  19944. } catch (ex) {
  19945. return this.regexp = false;
  19946. }
  19947. }
  19948. minimatch.match = function (list, pattern, options) {
  19949. var mm = new Minimatch(pattern, options);
  19950. list = list.filter(function (f) {
  19951. return mm.match(f);
  19952. });
  19953. if (options.nonull && !list.length) {
  19954. list.push(pattern);
  19955. }
  19956. return list;
  19957. };
  19958. Minimatch.prototype.match = match;
  19959. function match(f, partial) {
  19960. // console.error("match", f, this.pattern)
  19961. // short-circuit in the case of busted things.
  19962. // comments, etc.
  19963. if (this.comment) return false;
  19964. if (this.empty) return f === "";
  19965. if (f === "/" && partial) return true;
  19966. var options = this.options; // windows: need to use /, not \
  19967. // On other platforms, \ is a valid (albeit bad) filename char.
  19968. if (platform === "win32") {
  19969. f = f.split("\\").join("/");
  19970. } // treat the test path as a set of pathparts.
  19971. f = f.split(slashSplit);
  19972. if (options.debug) {
  19973. console.error(this.pattern, "split", f);
  19974. } // just ONE of the pattern sets in this.set needs to match
  19975. // in order for it to be valid. If negating, then just one
  19976. // match means that we have failed.
  19977. // Either way, return on the first hit.
  19978. var set = this.set; // console.error(this.pattern, "set", set)
  19979. for (var i = 0, l = set.length; i < l; i++) {
  19980. var pattern = set[i];
  19981. var hit = this.matchOne(f, pattern, partial);
  19982. if (hit) {
  19983. if (options.flipNegate) return true;
  19984. return !this.negate;
  19985. }
  19986. } // didn't get any hits. this is success if it's a negative
  19987. // pattern, failure otherwise.
  19988. if (options.flipNegate) return false;
  19989. return this.negate;
  19990. } // set partial to true to test if, for example,
  19991. // "/a/b" matches the start of "/*/b/*/d"
  19992. // Partial means, if you run out of file before you run
  19993. // out of pattern, then that's fine, as long as all
  19994. // the parts match.
  19995. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  19996. var options = this.options;
  19997. if (options.debug) {
  19998. console.error("matchOne", {
  19999. "this": this,
  20000. file: file,
  20001. pattern: pattern
  20002. });
  20003. }
  20004. if (options.matchBase && pattern.length === 1) {
  20005. file = path.basename(file.join("/")).split("/");
  20006. }
  20007. if (options.debug) {
  20008. console.error("matchOne", file.length, pattern.length);
  20009. }
  20010. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  20011. if (options.debug) {
  20012. console.error("matchOne loop");
  20013. }
  20014. var p = pattern[pi],
  20015. f = file[fi];
  20016. if (options.debug) {
  20017. console.error(pattern, p, f);
  20018. } // should be impossible.
  20019. // some invalid regexp stuff in the set.
  20020. if (p === false) return false;
  20021. if (p === GLOBSTAR) {
  20022. if (options.debug) console.error('GLOBSTAR', [pattern, p, f]); // "**"
  20023. // a/**/b/**/c would match the following:
  20024. // a/b/x/y/z/c
  20025. // a/x/y/z/b/c
  20026. // a/b/x/b/x/c
  20027. // a/b/c
  20028. // To do this, take the rest of the pattern after
  20029. // the **, and see if it would match the file remainder.
  20030. // If so, return success.
  20031. // If not, the ** "swallows" a segment, and try again.
  20032. // This is recursively awful.
  20033. //
  20034. // a/**/b/**/c matching a/b/x/y/z/c
  20035. // - a matches a
  20036. // - doublestar
  20037. // - matchOne(b/x/y/z/c, b/**/c)
  20038. // - b matches b
  20039. // - doublestar
  20040. // - matchOne(x/y/z/c, c) -> no
  20041. // - matchOne(y/z/c, c) -> no
  20042. // - matchOne(z/c, c) -> no
  20043. // - matchOne(c, c) yes, hit
  20044. var fr = fi,
  20045. pr = pi + 1;
  20046. if (pr === pl) {
  20047. if (options.debug) console.error('** at the end'); // a ** at the end will just swallow the rest.
  20048. // We have found a match.
  20049. // however, it will not swallow /.x, unless
  20050. // options.dot is set.
  20051. // . and .. are *never* matched by **, for explosively
  20052. // exponential reasons.
  20053. for (; fi < fl; fi++) {
  20054. if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
  20055. }
  20056. return true;
  20057. } // ok, let's see if we can swallow whatever we can.
  20058. WHILE: while (fr < fl) {
  20059. var swallowee = file[fr];
  20060. if (options.debug) {
  20061. console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
  20062. } // XXX remove this slice. Just pass the start index.
  20063. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  20064. if (options.debug) console.error('globstar found match!', fr, fl, swallowee); // found a match.
  20065. return true;
  20066. } else {
  20067. // can't swallow "." or ".." ever.
  20068. // can only swallow ".foo" when explicitly asked.
  20069. if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
  20070. if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
  20071. break WHILE;
  20072. } // ** swallows a segment, and continue.
  20073. if (options.debug) console.error('globstar swallow a segment, and continue');
  20074. fr++;
  20075. }
  20076. } // no match was found.
  20077. // However, in partial mode, we can't say this is necessarily over.
  20078. // If there's more *pattern* left, then
  20079. if (partial) {
  20080. // ran out of file
  20081. // console.error("\n>>> no match, partial?", file, fr, pattern, pr)
  20082. if (fr === fl) return true;
  20083. }
  20084. return false;
  20085. } // something other than **
  20086. // non-magic patterns just have to match exactly
  20087. // patterns with magic have been turned into regexps.
  20088. var hit;
  20089. if (typeof p === "string") {
  20090. if (options.nocase) {
  20091. hit = f.toLowerCase() === p.toLowerCase();
  20092. } else {
  20093. hit = f === p;
  20094. }
  20095. if (options.debug) {
  20096. console.error("string match", p, f, hit);
  20097. }
  20098. } else {
  20099. hit = f.match(p);
  20100. if (options.debug) {
  20101. console.error("pattern match", p, f, hit);
  20102. }
  20103. }
  20104. if (!hit) return false;
  20105. } // Note: ending in / means that we'll get a final ""
  20106. // at the end of the pattern. This can only match a
  20107. // corresponding "" at the end of the file.
  20108. // If the file ends in /, then it can only match a
  20109. // a pattern that ends in /, unless the pattern just
  20110. // doesn't have any more for it. But, a/b/ should *not*
  20111. // match "a/b/*", even though "" matches against the
  20112. // [^/]*? pattern, except in partial mode, where it might
  20113. // simply not be reached yet.
  20114. // However, a/b/ should still satisfy a/*
  20115. // now either we fell off the end of the pattern, or we're done.
  20116. if (fi === fl && pi === pl) {
  20117. // ran out of pattern and filename at the same time.
  20118. // an exact hit!
  20119. return true;
  20120. } else if (fi === fl) {
  20121. // ran out of file, but still had pattern left.
  20122. // this is ok if we're doing the match as part of
  20123. // a glob fs traversal.
  20124. return partial;
  20125. } else if (pi === pl) {
  20126. // ran out of pattern, still have file left.
  20127. // this is only acceptable if we're on the very last
  20128. // empty segment of a file with a trailing slash.
  20129. // a/* should match a/b/
  20130. var emptyFileEnd = fi === fl - 1 && file[fi] === "";
  20131. return emptyFileEnd;
  20132. } // should be unreachable.
  20133. throw new Error("wtf?");
  20134. }; // replace stuff like \* with *
  20135. function globUnescape(s) {
  20136. return s.replace(/\\(.)/g, "$1");
  20137. }
  20138. function regExpEscape(s) {
  20139. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  20140. }
  20141. })(fnmatch$1, fnmatch$1.exports);
  20142. var ini = {};
  20143. var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
  20144. return new (P || (P = Promise))(function (resolve, reject) {
  20145. function fulfilled(value) {
  20146. try {
  20147. step(generator.next(value));
  20148. } catch (e) {
  20149. reject(e);
  20150. }
  20151. }
  20152. function rejected(value) {
  20153. try {
  20154. step(generator["throw"](value));
  20155. } catch (e) {
  20156. reject(e);
  20157. }
  20158. }
  20159. function step(result) {
  20160. result.done ? resolve(result.value) : new P(function (resolve) {
  20161. resolve(result.value);
  20162. }).then(fulfilled, rejected);
  20163. }
  20164. step((generator = generator.apply(thisArg, _arguments || [])).next());
  20165. });
  20166. };
  20167. var __generator$1 = undefined && undefined.__generator || function (thisArg, body) {
  20168. var _ = {
  20169. label: 0,
  20170. sent: function () {
  20171. if (t[0] & 1) throw t[1];
  20172. return t[1];
  20173. },
  20174. trys: [],
  20175. ops: []
  20176. },
  20177. f,
  20178. y,
  20179. t,
  20180. g;
  20181. return g = {
  20182. next: verb(0),
  20183. "throw": verb(1),
  20184. "return": verb(2)
  20185. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  20186. return this;
  20187. }), g;
  20188. function verb(n) {
  20189. return function (v) {
  20190. return step([n, v]);
  20191. };
  20192. }
  20193. function step(op) {
  20194. if (f) throw new TypeError("Generator is already executing.");
  20195. while (_) try {
  20196. 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;
  20197. if (y = 0, t) op = [op[0] & 2, t.value];
  20198. switch (op[0]) {
  20199. case 0:
  20200. case 1:
  20201. t = op;
  20202. break;
  20203. case 4:
  20204. _.label++;
  20205. return {
  20206. value: op[1],
  20207. done: false
  20208. };
  20209. case 5:
  20210. _.label++;
  20211. y = op[1];
  20212. op = [0];
  20213. continue;
  20214. case 7:
  20215. op = _.ops.pop();
  20216. _.trys.pop();
  20217. continue;
  20218. default:
  20219. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  20220. _ = 0;
  20221. continue;
  20222. }
  20223. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  20224. _.label = op[1];
  20225. break;
  20226. }
  20227. if (op[0] === 6 && _.label < t[1]) {
  20228. _.label = t[1];
  20229. t = op;
  20230. break;
  20231. }
  20232. if (t && _.label < t[2]) {
  20233. _.label = t[2];
  20234. _.ops.push(op);
  20235. break;
  20236. }
  20237. if (t[2]) _.ops.pop();
  20238. _.trys.pop();
  20239. continue;
  20240. }
  20241. op = body.call(thisArg, _);
  20242. } catch (e) {
  20243. op = [6, e];
  20244. y = 0;
  20245. } finally {
  20246. f = t = 0;
  20247. }
  20248. if (op[0] & 5) throw op[1];
  20249. return {
  20250. value: op[0] ? op[1] : void 0,
  20251. done: true
  20252. };
  20253. }
  20254. };
  20255. var __importStar$1 = undefined && undefined.__importStar || function (mod) {
  20256. if (mod && mod.__esModule) return mod;
  20257. var result = {};
  20258. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  20259. result["default"] = mod;
  20260. return result;
  20261. };
  20262. Object.defineProperty(ini, "__esModule", {
  20263. value: true
  20264. });
  20265. var fs$f = __importStar$1(require$$0__default["default"]);
  20266. /**
  20267. * define the possible values:
  20268. * section: [section]
  20269. * param: key=value
  20270. * comment: ;this is a comment
  20271. */
  20272. var regex = {
  20273. section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
  20274. param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
  20275. comment: /^\s*[#;].*$/
  20276. };
  20277. /**
  20278. * Parses an .ini file
  20279. * @param file The location of the .ini file
  20280. */
  20281. function parse$7(file) {
  20282. return __awaiter$1(this, void 0, void 0, function () {
  20283. return __generator$1(this, function (_a) {
  20284. return [2
  20285. /*return*/
  20286. , new Promise(function (resolve, reject) {
  20287. fs$f.readFile(file, 'utf8', function (err, data) {
  20288. if (err) {
  20289. reject(err);
  20290. return;
  20291. }
  20292. resolve(parseString(data));
  20293. });
  20294. })];
  20295. });
  20296. });
  20297. }
  20298. ini.parse = parse$7;
  20299. function parseSync$1(file) {
  20300. return parseString(fs$f.readFileSync(file, 'utf8'));
  20301. }
  20302. ini.parseSync = parseSync$1;
  20303. function parseString(data) {
  20304. var sectionBody = {};
  20305. var sectionName = null;
  20306. var value = [[sectionName, sectionBody]];
  20307. var lines = data.split(/\r\n|\r|\n/);
  20308. lines.forEach(function (line) {
  20309. var match;
  20310. if (regex.comment.test(line)) {
  20311. return;
  20312. }
  20313. if (regex.param.test(line)) {
  20314. match = line.match(regex.param);
  20315. sectionBody[match[1]] = match[2];
  20316. } else if (regex.section.test(line)) {
  20317. match = line.match(regex.section);
  20318. sectionName = match[1];
  20319. sectionBody = {};
  20320. value.push([sectionName, sectionBody]);
  20321. }
  20322. });
  20323. return value;
  20324. }
  20325. ini.parseString = parseString;
  20326. var name$g = "editorconfig";
  20327. var version$1 = "0.15.3";
  20328. var description = "EditorConfig File Locator and Interpreter for Node.js";
  20329. var keywords = [
  20330. "editorconfig",
  20331. "core"
  20332. ];
  20333. var main = "src/index.js";
  20334. var contributors = [
  20335. "Hong Xu (topbug.net)",
  20336. "Jed Mao (https://github.com/jedmao/)",
  20337. "Trey Hunner (http://treyhunner.com)"
  20338. ];
  20339. var directories = {
  20340. bin: "./bin",
  20341. lib: "./lib"
  20342. };
  20343. var scripts = {
  20344. clean: "rimraf dist",
  20345. prebuild: "npm run clean",
  20346. build: "tsc",
  20347. pretest: "npm run lint && npm run build && npm run copy && cmake .",
  20348. test: "ctest .",
  20349. "pretest:ci": "npm run pretest",
  20350. "test:ci": "ctest -VV --output-on-failure .",
  20351. lint: "npm run eclint && npm run tslint",
  20352. eclint: "eclint check --indent_size ignore \"src/**\"",
  20353. tslint: "tslint --project tsconfig.json --exclude package.json",
  20354. copy: "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
  20355. prepub: "npm run lint && npm run build && npm run copy",
  20356. pub: "npm publish ./dist"
  20357. };
  20358. var repository = {
  20359. type: "git",
  20360. url: "git://github.com/editorconfig/editorconfig-core-js.git"
  20361. };
  20362. var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
  20363. var author = "EditorConfig Team";
  20364. var license = "MIT";
  20365. var dependencies = {
  20366. commander: "^2.19.0",
  20367. "lru-cache": "^4.1.5",
  20368. semver: "^5.6.0",
  20369. sigmund: "^1.0.1"
  20370. };
  20371. var devDependencies = {
  20372. "@types/mocha": "^5.2.6",
  20373. "@types/node": "^10.12.29",
  20374. "@types/semver": "^5.5.0",
  20375. "cpy-cli": "^2.0.0",
  20376. eclint: "^2.8.1",
  20377. mocha: "^5.2.0",
  20378. rimraf: "^2.6.3",
  20379. should: "^13.2.3",
  20380. tslint: "^5.13.1",
  20381. typescript: "^3.3.3333"
  20382. };
  20383. var require$$5$4 = {
  20384. name: name$g,
  20385. version: version$1,
  20386. description: description,
  20387. keywords: keywords,
  20388. main: main,
  20389. contributors: contributors,
  20390. directories: directories,
  20391. scripts: scripts,
  20392. repository: repository,
  20393. bugs: bugs,
  20394. author: author,
  20395. license: license,
  20396. dependencies: dependencies,
  20397. devDependencies: devDependencies
  20398. };
  20399. var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
  20400. return new (P || (P = Promise))(function (resolve, reject) {
  20401. function fulfilled(value) {
  20402. try {
  20403. step(generator.next(value));
  20404. } catch (e) {
  20405. reject(e);
  20406. }
  20407. }
  20408. function rejected(value) {
  20409. try {
  20410. step(generator["throw"](value));
  20411. } catch (e) {
  20412. reject(e);
  20413. }
  20414. }
  20415. function step(result) {
  20416. result.done ? resolve(result.value) : new P(function (resolve) {
  20417. resolve(result.value);
  20418. }).then(fulfilled, rejected);
  20419. }
  20420. step((generator = generator.apply(thisArg, _arguments || [])).next());
  20421. });
  20422. };
  20423. var __generator = undefined && undefined.__generator || function (thisArg, body) {
  20424. var _ = {
  20425. label: 0,
  20426. sent: function () {
  20427. if (t[0] & 1) throw t[1];
  20428. return t[1];
  20429. },
  20430. trys: [],
  20431. ops: []
  20432. },
  20433. f,
  20434. y,
  20435. t,
  20436. g;
  20437. return g = {
  20438. next: verb(0),
  20439. "throw": verb(1),
  20440. "return": verb(2)
  20441. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  20442. return this;
  20443. }), g;
  20444. function verb(n) {
  20445. return function (v) {
  20446. return step([n, v]);
  20447. };
  20448. }
  20449. function step(op) {
  20450. if (f) throw new TypeError("Generator is already executing.");
  20451. while (_) try {
  20452. 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;
  20453. if (y = 0, t) op = [op[0] & 2, t.value];
  20454. switch (op[0]) {
  20455. case 0:
  20456. case 1:
  20457. t = op;
  20458. break;
  20459. case 4:
  20460. _.label++;
  20461. return {
  20462. value: op[1],
  20463. done: false
  20464. };
  20465. case 5:
  20466. _.label++;
  20467. y = op[1];
  20468. op = [0];
  20469. continue;
  20470. case 7:
  20471. op = _.ops.pop();
  20472. _.trys.pop();
  20473. continue;
  20474. default:
  20475. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  20476. _ = 0;
  20477. continue;
  20478. }
  20479. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  20480. _.label = op[1];
  20481. break;
  20482. }
  20483. if (op[0] === 6 && _.label < t[1]) {
  20484. _.label = t[1];
  20485. t = op;
  20486. break;
  20487. }
  20488. if (t && _.label < t[2]) {
  20489. _.label = t[2];
  20490. _.ops.push(op);
  20491. break;
  20492. }
  20493. if (t[2]) _.ops.pop();
  20494. _.trys.pop();
  20495. continue;
  20496. }
  20497. op = body.call(thisArg, _);
  20498. } catch (e) {
  20499. op = [6, e];
  20500. y = 0;
  20501. } finally {
  20502. f = t = 0;
  20503. }
  20504. if (op[0] & 5) throw op[1];
  20505. return {
  20506. value: op[0] ? op[1] : void 0,
  20507. done: true
  20508. };
  20509. }
  20510. };
  20511. var __importStar = undefined && undefined.__importStar || function (mod) {
  20512. if (mod && mod.__esModule) return mod;
  20513. var result = {};
  20514. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  20515. result["default"] = mod;
  20516. return result;
  20517. };
  20518. var __importDefault = undefined && undefined.__importDefault || function (mod) {
  20519. return mod && mod.__esModule ? mod : {
  20520. "default": mod
  20521. };
  20522. };
  20523. Object.defineProperty(src$1, "__esModule", {
  20524. value: true
  20525. });
  20526. var fs$e = __importStar(require$$0__default["default"]);
  20527. var path$i = __importStar(require$$0__default$2["default"]);
  20528. var semver = __importStar(semver$1.exports);
  20529. var fnmatch_1 = __importDefault(fnmatch$1.exports);
  20530. var ini_1 = ini;
  20531. src$1.parseString = ini_1.parseString;
  20532. var package_json_1 = __importDefault(require$$5$4);
  20533. var knownProps = {
  20534. end_of_line: true,
  20535. indent_style: true,
  20536. indent_size: true,
  20537. insert_final_newline: true,
  20538. trim_trailing_whitespace: true,
  20539. charset: true
  20540. };
  20541. function fnmatch(filepath, glob) {
  20542. var matchOptions = {
  20543. matchBase: true,
  20544. dot: true,
  20545. noext: true
  20546. };
  20547. glob = glob.replace(/\*\*/g, '{*,**/**/**}');
  20548. return fnmatch_1.default(filepath, glob, matchOptions);
  20549. }
  20550. function getConfigFileNames(filepath, options) {
  20551. var paths = [];
  20552. do {
  20553. filepath = path$i.dirname(filepath);
  20554. paths.push(path$i.join(filepath, options.config));
  20555. } while (filepath !== options.root);
  20556. return paths;
  20557. }
  20558. function processMatches(matches, version) {
  20559. // Set indent_size to 'tab' if indent_size is unspecified and
  20560. // indent_style is set to 'tab'.
  20561. if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
  20562. matches.indent_size = 'tab';
  20563. } // Set tab_width to indent_size if indent_size is specified and
  20564. // tab_width is unspecified
  20565. if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
  20566. matches.tab_width = matches.indent_size;
  20567. } // Set indent_size to tab_width if indent_size is 'tab'
  20568. if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
  20569. matches.indent_size = matches.tab_width;
  20570. }
  20571. return matches;
  20572. }
  20573. function processOptions(options, filepath) {
  20574. if (options === void 0) {
  20575. options = {};
  20576. }
  20577. return {
  20578. config: options.config || '.editorconfig',
  20579. version: options.version || package_json_1.default.version,
  20580. root: path$i.resolve(options.root || path$i.parse(filepath).root)
  20581. };
  20582. }
  20583. function buildFullGlob(pathPrefix, glob) {
  20584. switch (glob.indexOf('/')) {
  20585. case -1:
  20586. glob = '**/' + glob;
  20587. break;
  20588. case 0:
  20589. glob = glob.substring(1);
  20590. break;
  20591. }
  20592. return path$i.join(pathPrefix, glob);
  20593. }
  20594. function extendProps(props, options) {
  20595. if (props === void 0) {
  20596. props = {};
  20597. }
  20598. if (options === void 0) {
  20599. options = {};
  20600. }
  20601. for (var key in options) {
  20602. if (options.hasOwnProperty(key)) {
  20603. var value = options[key];
  20604. var key2 = key.toLowerCase();
  20605. var value2 = value;
  20606. if (knownProps[key2]) {
  20607. value2 = value.toLowerCase();
  20608. }
  20609. try {
  20610. value2 = JSON.parse(value);
  20611. } catch (e) {}
  20612. if (typeof value === 'undefined' || value === null) {
  20613. // null and undefined are values specific to JSON (no special meaning
  20614. // in editorconfig) & should just be returned as regular strings.
  20615. value2 = String(value);
  20616. }
  20617. props[key2] = value2;
  20618. }
  20619. }
  20620. return props;
  20621. }
  20622. function parseFromConfigs(configs, filepath, options) {
  20623. return processMatches(configs.reverse().reduce(function (matches, file) {
  20624. var pathPrefix = path$i.dirname(file.name);
  20625. file.contents.forEach(function (section) {
  20626. var glob = section[0];
  20627. var options2 = section[1];
  20628. if (!glob) {
  20629. return;
  20630. }
  20631. var fullGlob = buildFullGlob(pathPrefix, glob);
  20632. if (!fnmatch(filepath, fullGlob)) {
  20633. return;
  20634. }
  20635. matches = extendProps(matches, options2);
  20636. });
  20637. return matches;
  20638. }, {}), options.version);
  20639. }
  20640. function getConfigsForFiles(files) {
  20641. var configs = [];
  20642. for (var i in files) {
  20643. if (files.hasOwnProperty(i)) {
  20644. var file = files[i];
  20645. var contents = ini_1.parseString(file.contents);
  20646. configs.push({
  20647. name: file.name,
  20648. contents: contents
  20649. });
  20650. if ((contents[0][1].root || '').toLowerCase() === 'true') {
  20651. break;
  20652. }
  20653. }
  20654. }
  20655. return configs;
  20656. }
  20657. function readConfigFiles(filepaths) {
  20658. return __awaiter(this, void 0, void 0, function () {
  20659. return __generator(this, function (_a) {
  20660. return [2
  20661. /*return*/
  20662. , Promise.all(filepaths.map(function (name) {
  20663. return new Promise(function (resolve) {
  20664. fs$e.readFile(name, 'utf8', function (err, data) {
  20665. resolve({
  20666. name: name,
  20667. contents: err ? '' : data
  20668. });
  20669. });
  20670. });
  20671. }))];
  20672. });
  20673. });
  20674. }
  20675. function readConfigFilesSync(filepaths) {
  20676. var files = [];
  20677. var file;
  20678. filepaths.forEach(function (filepath) {
  20679. try {
  20680. file = fs$e.readFileSync(filepath, 'utf8');
  20681. } catch (e) {
  20682. file = '';
  20683. }
  20684. files.push({
  20685. name: filepath,
  20686. contents: file
  20687. });
  20688. });
  20689. return files;
  20690. }
  20691. function opts(filepath, options) {
  20692. if (options === void 0) {
  20693. options = {};
  20694. }
  20695. var resolvedFilePath = path$i.resolve(filepath);
  20696. return [resolvedFilePath, processOptions(options, resolvedFilePath)];
  20697. }
  20698. function parseFromFiles(filepath, files, options) {
  20699. if (options === void 0) {
  20700. options = {};
  20701. }
  20702. return __awaiter(this, void 0, void 0, function () {
  20703. var _a, resolvedFilePath, processedOptions;
  20704. return __generator(this, function (_b) {
  20705. _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
  20706. return [2
  20707. /*return*/
  20708. , files.then(getConfigsForFiles).then(function (configs) {
  20709. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  20710. })];
  20711. });
  20712. });
  20713. }
  20714. src$1.parseFromFiles = parseFromFiles;
  20715. function parseFromFilesSync(filepath, files, options) {
  20716. if (options === void 0) {
  20717. options = {};
  20718. }
  20719. var _a = opts(filepath, options),
  20720. resolvedFilePath = _a[0],
  20721. processedOptions = _a[1];
  20722. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  20723. }
  20724. src$1.parseFromFilesSync = parseFromFilesSync;
  20725. function parse$6(_filepath, _options) {
  20726. if (_options === void 0) {
  20727. _options = {};
  20728. }
  20729. return __awaiter(this, void 0, void 0, function () {
  20730. var _a, resolvedFilePath, processedOptions, filepaths;
  20731. return __generator(this, function (_b) {
  20732. _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
  20733. filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  20734. return [2
  20735. /*return*/
  20736. , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
  20737. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  20738. })];
  20739. });
  20740. });
  20741. }
  20742. src$1.parse = parse$6;
  20743. function parseSync(_filepath, _options) {
  20744. if (_options === void 0) {
  20745. _options = {};
  20746. }
  20747. var _a = opts(_filepath, _options),
  20748. resolvedFilePath = _a[0],
  20749. processedOptions = _a[1];
  20750. var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  20751. var files = readConfigFilesSync(filepaths);
  20752. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  20753. }
  20754. src$1.parseSync = parseSync;
  20755. var editorconfigToPrettier = editorConfigToPrettier$1;
  20756. function removeUnset(editorConfig) {
  20757. const result = {};
  20758. const keys = Object.keys(editorConfig);
  20759. for (let i = 0; i < keys.length; i++) {
  20760. const key = keys[i];
  20761. if (editorConfig[key] === "unset") {
  20762. continue;
  20763. }
  20764. result[key] = editorConfig[key];
  20765. }
  20766. return result;
  20767. }
  20768. function editorConfigToPrettier$1(editorConfig) {
  20769. if (!editorConfig) {
  20770. return null;
  20771. }
  20772. editorConfig = removeUnset(editorConfig);
  20773. if (Object.keys(editorConfig).length === 0) {
  20774. return null;
  20775. }
  20776. const result = {};
  20777. if (editorConfig.indent_style) {
  20778. result.useTabs = editorConfig.indent_style === "tab";
  20779. }
  20780. if (editorConfig.indent_size === "tab") {
  20781. result.useTabs = true;
  20782. }
  20783. if (result.useTabs && editorConfig.tab_width) {
  20784. result.tabWidth = editorConfig.tab_width;
  20785. } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
  20786. result.tabWidth = editorConfig.indent_size;
  20787. } else if (editorConfig.tab_width !== undefined) {
  20788. result.tabWidth = editorConfig.tab_width;
  20789. }
  20790. if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
  20791. result.printWidth = editorConfig.max_line_length;
  20792. }
  20793. if (editorConfig.quote_type === "single") {
  20794. result.singleQuote = true;
  20795. } else if (editorConfig.quote_type === "double") {
  20796. result.singleQuote = false;
  20797. }
  20798. if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
  20799. result.endOfLine = editorConfig.end_of_line;
  20800. }
  20801. if (editorConfig.insert_final_newline === false || editorConfig.insert_final_newline === true) {
  20802. result.insertFinalNewline = editorConfig.insert_final_newline;
  20803. }
  20804. return result;
  20805. }
  20806. // https://github.com/kirstein/find-project-root/blob/master/index.js
  20807. const fs$d = require$$0__default["default"];
  20808. const path$h = require$$0__default$2["default"];
  20809. const MARKERS = [".git", ".hg"];
  20810. const markerExists = directory => MARKERS.some(mark => fs$d.existsSync(path$h.join(directory, mark)));
  20811. function findProjectRoot$1(directory) {
  20812. while (!markerExists(directory)) {
  20813. const parentDirectory = path$h.resolve(directory, "..");
  20814. if (parentDirectory === directory) {
  20815. break;
  20816. }
  20817. directory = parentDirectory;
  20818. }
  20819. return directory;
  20820. }
  20821. var findProjectRoot_1 = findProjectRoot$1;
  20822. const path$g = require$$0__default$2["default"];
  20823. const editorconfig = src$1;
  20824. const mem$2 = dist$1;
  20825. const editorConfigToPrettier = editorconfigToPrettier;
  20826. const findProjectRoot = findProjectRoot_1;
  20827. const jsonStringifyMem = fn => mem$2(fn, {
  20828. cacheKey: JSON.stringify
  20829. });
  20830. const maybeParse = (filePath, parse) => filePath && parse(filePath, {
  20831. root: findProjectRoot(path$g.dirname(path$g.resolve(filePath)))
  20832. });
  20833. const editorconfigAsyncNoCache = async filePath => editorConfigToPrettier(await maybeParse(filePath, editorconfig.parse));
  20834. const editorconfigAsyncWithCache = jsonStringifyMem(editorconfigAsyncNoCache);
  20835. const editorconfigSyncNoCache = filePath => editorConfigToPrettier(maybeParse(filePath, editorconfig.parseSync));
  20836. const editorconfigSyncWithCache = jsonStringifyMem(editorconfigSyncNoCache);
  20837. function getLoadFunction(opts) {
  20838. if (!opts.editorconfig) {
  20839. return () => null;
  20840. }
  20841. if (opts.sync) {
  20842. return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
  20843. }
  20844. return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
  20845. }
  20846. function clearCache$2() {
  20847. mem$2.clear(editorconfigSyncWithCache);
  20848. mem$2.clear(editorconfigAsyncWithCache);
  20849. }
  20850. var resolveConfigEditorconfig = {
  20851. getLoadFunction,
  20852. clearCache: clearCache$2
  20853. };
  20854. const _excluded$1 = ["overrides"];
  20855. const path$f = require$$0__default$2["default"];
  20856. const minimatch = minimatch_1;
  20857. const mem$1 = dist$1;
  20858. const thirdParty$1 = require$$7$2;
  20859. const loadToml = loadToml$1;
  20860. const loadJson5 = loadJson5$1;
  20861. const resolve$1 = resolve_1;
  20862. const resolveEditorConfig = resolveConfigEditorconfig;
  20863. /**
  20864. * @typedef {import("cosmiconfig/dist/Explorer").Explorer} Explorer
  20865. * @typedef {{sync: boolean; cache: boolean }} Options
  20866. */
  20867. /**
  20868. * @type {(opts: Options) => Explorer}
  20869. */
  20870. const getExplorerMemoized = mem$1(opts => {
  20871. const cosmiconfig = thirdParty$1["cosmiconfig" + (opts.sync ? "Sync" : "")];
  20872. const explorer = cosmiconfig("prettier", {
  20873. cache: opts.cache,
  20874. transform: result => {
  20875. if (result && result.config) {
  20876. if (typeof result.config === "string") {
  20877. const dir = path$f.dirname(result.filepath);
  20878. const modulePath = resolve$1(result.config, {
  20879. paths: [dir]
  20880. });
  20881. result.config = require(modulePath);
  20882. }
  20883. if (typeof result.config !== "object") {
  20884. throw new TypeError("Config is only allowed to be an object, " + `but received ${typeof result.config} in "${result.filepath}"`);
  20885. }
  20886. delete result.config.$schema;
  20887. }
  20888. return result;
  20889. },
  20890. searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.json5", ".prettierrc.js", ".prettierrc.cjs", "prettier.config.js", "prettier.config.cjs", ".prettierrc.toml"],
  20891. loaders: {
  20892. ".toml": loadToml,
  20893. ".json5": loadJson5
  20894. }
  20895. });
  20896. return explorer;
  20897. }, {
  20898. cacheKey: JSON.stringify
  20899. });
  20900. /**
  20901. * @param {Options} opts
  20902. * @return {Explorer}
  20903. */
  20904. function getExplorer(opts) {
  20905. // Normalize opts before passing to a memoized function
  20906. opts = Object.assign({
  20907. sync: false,
  20908. cache: false
  20909. }, opts);
  20910. return getExplorerMemoized(opts);
  20911. }
  20912. function _resolveConfig(filePath, opts, sync) {
  20913. opts = Object.assign({
  20914. useCache: true
  20915. }, opts);
  20916. const loadOpts = {
  20917. cache: Boolean(opts.useCache),
  20918. sync: Boolean(sync),
  20919. editorconfig: Boolean(opts.editorconfig)
  20920. };
  20921. const {
  20922. load,
  20923. search
  20924. } = getExplorer(loadOpts);
  20925. const loadEditorConfig = resolveEditorConfig.getLoadFunction(loadOpts);
  20926. const arr = [opts.config ? load(opts.config) : search(filePath), loadEditorConfig(filePath)];
  20927. const unwrapAndMerge = ([result, editorConfigured]) => {
  20928. const merged = Object.assign(Object.assign({}, editorConfigured), mergeOverrides(result, filePath));
  20929. for (const optionName of ["plugins", "pluginSearchDirs"]) {
  20930. if (Array.isArray(merged[optionName])) {
  20931. merged[optionName] = merged[optionName].map(value => typeof value === "string" && value.startsWith(".") // relative path
  20932. ? path$f.resolve(path$f.dirname(result.filepath), value) : value);
  20933. }
  20934. }
  20935. if (!result && !editorConfigured) {
  20936. return null;
  20937. } // We are not using this option
  20938. delete merged.insertFinalNewline;
  20939. return merged;
  20940. };
  20941. if (loadOpts.sync) {
  20942. return unwrapAndMerge(arr);
  20943. }
  20944. return Promise.all(arr).then(unwrapAndMerge);
  20945. }
  20946. const resolveConfig = (filePath, opts) => _resolveConfig(filePath, opts, false);
  20947. resolveConfig.sync = (filePath, opts) => _resolveConfig(filePath, opts, true);
  20948. function clearCache$1() {
  20949. mem$1.clear(getExplorerMemoized);
  20950. resolveEditorConfig.clearCache();
  20951. }
  20952. async function resolveConfigFile(filePath) {
  20953. const {
  20954. search
  20955. } = getExplorer({
  20956. sync: false
  20957. });
  20958. const result = await search(filePath);
  20959. return result ? result.filepath : null;
  20960. }
  20961. resolveConfigFile.sync = filePath => {
  20962. const {
  20963. search
  20964. } = getExplorer({
  20965. sync: true
  20966. });
  20967. const result = search(filePath);
  20968. return result ? result.filepath : null;
  20969. };
  20970. function mergeOverrides(configResult, filePath) {
  20971. const {
  20972. config,
  20973. filepath: configPath
  20974. } = configResult || {};
  20975. const _ref = config || {},
  20976. {
  20977. overrides
  20978. } = _ref,
  20979. options = _objectWithoutProperties(_ref, _excluded$1);
  20980. if (filePath && overrides) {
  20981. const relativeFilePath = path$f.relative(path$f.dirname(configPath), filePath);
  20982. for (const override of overrides) {
  20983. if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
  20984. Object.assign(options, override.options);
  20985. }
  20986. }
  20987. }
  20988. return options;
  20989. } // Based on eslint: https://github.com/eslint/eslint/blob/master/lib/config/config-ops.js
  20990. function pathMatchesGlobs(filePath, patterns, excludedPatterns = []) {
  20991. const patternList = Array.isArray(patterns) ? patterns : [patterns];
  20992. const excludedPatternList = Array.isArray(excludedPatterns) ? excludedPatterns : [excludedPatterns];
  20993. const opts = {
  20994. matchBase: true,
  20995. dot: true
  20996. };
  20997. return patternList.some(pattern => minimatch(filePath, pattern, opts)) && !excludedPatternList.some(excludedPattern => minimatch(filePath, excludedPattern, opts));
  20998. }
  20999. var resolveConfig_1 = {
  21000. resolveConfig,
  21001. resolveConfigFile,
  21002. clearCache: clearCache$1
  21003. };
  21004. function make_array(subject) {
  21005. return Array.isArray(subject) ? subject : [subject];
  21006. }
  21007. const REGEX_BLANK_LINE = /^\s+$/;
  21008. const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  21009. const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
  21010. const SLASH$1 = '/';
  21011. const KEY_IGNORE$1 = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  21012. /* istanbul ignore next */
  21013. : 'node-ignore';
  21014. const define$1 = (object, key, value) => Object.defineProperty(object, key, {
  21015. value
  21016. });
  21017. const REGEX_REGEXP_RANGE$1 = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
  21018. // The cases are complicated, see test cases for details
  21019. const sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
  21020. // fatal for JavaScript regular expression, so eliminate it.
  21021. : ''); // > If the pattern ends with a slash,
  21022. // > it is removed for the purpose of the following description,
  21023. // > but it would only find a match with a directory.
  21024. // > In other words, foo/ will match a directory foo and paths underneath it,
  21025. // > but will not match a regular file or a symbolic link foo
  21026. // > (this is consistent with the way how pathspec works in general in Git).
  21027. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  21028. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  21029. // you could use option `mark: true` with `glob`
  21030. // '`foo/`' should not continue with the '`..`'
  21031. const DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  21032. [// (a\ ) -> (a )
  21033. // (a ) -> (a)
  21034. // (a \ ) -> (a )
  21035. /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''], // replace (\ ) with ' '
  21036. [/\\\s/g, () => ' '], // Escape metacharacters
  21037. // which is written down by users but means special for regular expressions.
  21038. // > There are 12 characters with special meanings:
  21039. // > - the backslash \,
  21040. // > - the caret ^,
  21041. // > - the dollar sign $,
  21042. // > - the period or dot .,
  21043. // > - the vertical bar or pipe symbol |,
  21044. // > - the question mark ?,
  21045. // > - the asterisk or star *,
  21046. // > - the plus sign +,
  21047. // > - the opening parenthesis (,
  21048. // > - the closing parenthesis ),
  21049. // > - and the opening square bracket [,
  21050. // > - the opening curly brace {,
  21051. // > These special characters are often called "metacharacters".
  21052. [/[\\^$.|*+(){]/g, match => `\\${match}`], [// > [abc] matches any character inside the brackets
  21053. // > (in this case a, b, or c);
  21054. /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? `[${sanitizeRange$1(p1)}]` : `\\${match}`], [// > a question mark (?) matches a single character
  21055. /(?!\\)\?/g, () => '[^/]'], // leading slash
  21056. [// > A leading slash matches the beginning of the pathname.
  21057. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  21058. // A leading slash matches the beginning of the pathname
  21059. /^\//, () => '^'], // replace special metacharacter slash after the leading slash
  21060. [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
  21061. // > For example, "**/foo" matches file or directory "foo" anywhere,
  21062. // > the same as pattern "foo".
  21063. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  21064. // > under directory "foo".
  21065. // Notice that the '*'s have been replaced as '\\*'
  21066. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  21067. () => '^(?:.*\\/)?']];
  21068. const DEFAULT_REPLACER_SUFFIX = [// starting
  21069. [// there will be no leading '/'
  21070. // (which has been replaced by section "leading slash")
  21071. // If starts with '**', adding a '^' to the regular expression also works
  21072. /^(?=[^^])/, function startingReplacer() {
  21073. return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
  21074. // > Git treats it as a shell glob pattern
  21075. // Actually, if there is only a trailing slash,
  21076. // git also treats it as a shell glob pattern
  21077. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
  21078. // > consumption by fnmatch(3)
  21079. : '^';
  21080. }], // two globstars
  21081. [// Use lookahead assertions so that we could match more than one `'/**'`
  21082. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  21083. // should not use '*', or it will be replaced by the next replacer
  21084. // Check if it is not the last `'/**'`
  21085. (match, index, str) => index + 6 < str.length // case: /**/
  21086. // > A slash followed by two consecutive asterisks then a slash matches
  21087. // > zero or more directories.
  21088. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  21089. // '/**/'
  21090. ? '(?:\\/[^\\/]+)*' // case: /**
  21091. // > A trailing `"/**"` matches everything inside.
  21092. // #21: everything inside but it should not include the current folder
  21093. : '\\/.+'], // intermediate wildcards
  21094. [// Never replace escaped '*'
  21095. // ignore rule '\*' will match the path '*'
  21096. // 'abc.*/' -> go
  21097. // 'abc.*' -> skip this rule
  21098. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  21099. // '*.js' doesn't match 'abc'
  21100. (match, p1) => `${p1}[^\\/]*`], // trailing wildcard
  21101. [/(\^|\\\/)?\\\*$/, (match, p1) => {
  21102. const prefix = p1 // '\^':
  21103. // '/*' does not match ''
  21104. // '/*' does not match everything
  21105. // '\\\/':
  21106. // 'abc/*' does not match 'abc/'
  21107. ? `${p1}[^/]+` // 'a*' matches 'a'
  21108. // 'a*' matches 'aa'
  21109. : '[^/]*';
  21110. return `${prefix}(?=$|\\/$)`;
  21111. }], [// unescape
  21112. /\\\\\\/g, () => '\\']];
  21113. const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // 'f'
  21114. // matches
  21115. // - /f(end)
  21116. // - /f/
  21117. // - (start)f(end)
  21118. // - (start)f/
  21119. // doesn't match
  21120. // - oof
  21121. // - foo
  21122. // pseudo:
  21123. // -> (^|/)f(/|$)
  21124. // ending
  21125. [// 'js' will not match 'js.'
  21126. // 'ab' will not match 'abc'
  21127. /(?:[^*/])$/, // 'js*' will not match 'a.js'
  21128. // 'js/' will not match 'a.js'
  21129. // 'js' will match 'a.js' and 'a.js/'
  21130. match => `${match}(?=$|\\/)`], ...DEFAULT_REPLACER_SUFFIX];
  21131. const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // #24, #38
  21132. // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
  21133. // A negative pattern without a trailing wildcard should not
  21134. // re-include the things inside that directory.
  21135. // eg:
  21136. // ['node_modules/*', '!node_modules']
  21137. // should ignore `node_modules/a.js`
  21138. [/(?:[^*])$/, match => `${match}(?=$|\\/$)`], ...DEFAULT_REPLACER_SUFFIX]; // A simple cache, because an ignore rule only has only one certain meaning
  21139. const cache = Object.create(null); // @param {pattern}
  21140. const make_regex = (pattern, negative, ignorecase) => {
  21141. const r = cache[pattern];
  21142. if (r) {
  21143. return r;
  21144. }
  21145. const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
  21146. const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
  21147. return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  21148. }; // > A blank line matches no files, so it can serve as a separator for readability.
  21149. const checkPattern$1 = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  21150. && pattern.indexOf('#') !== 0;
  21151. const createRule$1 = (pattern, ignorecase) => {
  21152. const origin = pattern;
  21153. let negative = false; // > An optional prefix "!" which negates the pattern;
  21154. if (pattern.indexOf('!') === 0) {
  21155. negative = true;
  21156. pattern = pattern.substr(1);
  21157. }
  21158. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
  21159. // > begin with a literal "!", for example, `"\!important!.txt"`.
  21160. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
  21161. // > begin with a hash.
  21162. .replace(REGEX_LEADING_EXCAPED_HASH, '#');
  21163. const regex = make_regex(pattern, negative, ignorecase);
  21164. return {
  21165. origin,
  21166. pattern,
  21167. negative,
  21168. regex
  21169. };
  21170. };
  21171. class IgnoreBase {
  21172. constructor({
  21173. ignorecase = true
  21174. } = {}) {
  21175. this._rules = [];
  21176. this._ignorecase = ignorecase;
  21177. define$1(this, KEY_IGNORE$1, true);
  21178. this._initCache();
  21179. }
  21180. _initCache() {
  21181. this._cache = Object.create(null);
  21182. } // @param {Array.<string>|string|Ignore} pattern
  21183. add(pattern) {
  21184. this._added = false;
  21185. if (typeof pattern === 'string') {
  21186. pattern = pattern.split(/\r?\n/g);
  21187. }
  21188. make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  21189. // making the behavior changed.
  21190. if (this._added) {
  21191. this._initCache();
  21192. }
  21193. return this;
  21194. } // legacy
  21195. addPattern(pattern) {
  21196. return this.add(pattern);
  21197. }
  21198. _addPattern(pattern) {
  21199. // #32
  21200. if (pattern && pattern[KEY_IGNORE$1]) {
  21201. this._rules = this._rules.concat(pattern._rules);
  21202. this._added = true;
  21203. return;
  21204. }
  21205. if (checkPattern$1(pattern)) {
  21206. const rule = createRule$1(pattern, this._ignorecase);
  21207. this._added = true;
  21208. this._rules.push(rule);
  21209. }
  21210. }
  21211. filter(paths) {
  21212. return make_array(paths).filter(path => this._filter(path));
  21213. }
  21214. createFilter() {
  21215. return path => this._filter(path);
  21216. }
  21217. ignores(path) {
  21218. return !this._filter(path);
  21219. } // @returns `Boolean` true if the `path` is NOT ignored
  21220. _filter(path, slices) {
  21221. if (!path) {
  21222. return false;
  21223. }
  21224. if (path in this._cache) {
  21225. return this._cache[path];
  21226. }
  21227. if (!slices) {
  21228. // path/to/a.js
  21229. // ['path', 'to', 'a.js']
  21230. slices = path.split(SLASH$1);
  21231. }
  21232. slices.pop();
  21233. return this._cache[path] = slices.length // > It is not possible to re-include a file if a parent directory of
  21234. // > that file is excluded.
  21235. // If the path contains a parent directory, check the parent first
  21236. ? this._filter(slices.join(SLASH$1) + SLASH$1, slices) && this._test(path) // Or only test the path
  21237. : this._test(path);
  21238. } // @returns {Boolean} true if a file is NOT ignored
  21239. _test(path) {
  21240. // Explicitly define variable type by setting matched to `0`
  21241. let matched = 0;
  21242. this._rules.forEach(rule => {
  21243. // if matched = true, then we only test negative rules
  21244. // if matched = false, then we test non-negative rules
  21245. if (!(matched ^ rule.negative)) {
  21246. matched = rule.negative ^ rule.regex.test(path);
  21247. }
  21248. });
  21249. return !matched;
  21250. }
  21251. } // Windows
  21252. // --------------------------------------------------------------
  21253. /* istanbul ignore if */
  21254. if ( // Detect `process` so that it can run in browsers.
  21255. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  21256. const filter = IgnoreBase.prototype._filter;
  21257. /* eslint no-control-regex: "off" */
  21258. const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
  21259. IgnoreBase.prototype._filter = function filterWin32(path, slices) {
  21260. path = make_posix(path);
  21261. return filter.call(this, path, slices);
  21262. };
  21263. }
  21264. var ignore$2 = options => new IgnoreBase(options);
  21265. const fs$c = require$$0__default["default"];
  21266. const fsAsync = fs$c.promises;
  21267. /**
  21268. * @param {string} filename
  21269. * @returns {Promise<null | string>}
  21270. */
  21271. async function getFileContentOrNull$1(filename) {
  21272. try {
  21273. return await fsAsync.readFile(filename, "utf8");
  21274. } catch (error) {
  21275. return handleError(filename, error);
  21276. }
  21277. }
  21278. /**
  21279. * @param {string} filename
  21280. * @returns {null | string}
  21281. */
  21282. getFileContentOrNull$1.sync = function (filename) {
  21283. try {
  21284. return fs$c.readFileSync(filename, "utf8");
  21285. } catch (error) {
  21286. return handleError(filename, error);
  21287. }
  21288. };
  21289. function handleError(filename, error) {
  21290. if (error && error.code === "ENOENT") {
  21291. return null;
  21292. }
  21293. throw new Error(`Unable to read ${filename}: ${error.message}`);
  21294. }
  21295. var getFileContentOrNull_1 = getFileContentOrNull$1;
  21296. const path$e = require$$0__default$2["default"];
  21297. const ignore$1 = ignore$2;
  21298. const getFileContentOrNull = getFileContentOrNull_1;
  21299. /**
  21300. * @param {string?} ignorePath
  21301. * @param {boolean?} withNodeModules
  21302. */
  21303. async function createIgnorer$1(ignorePath, withNodeModules) {
  21304. const ignoreContent = ignorePath ? await getFileContentOrNull(path$e.resolve(ignorePath)) : null;
  21305. return _createIgnorer(ignoreContent, withNodeModules);
  21306. }
  21307. /**
  21308. * @param {string?} ignorePath
  21309. * @param {boolean?} withNodeModules
  21310. */
  21311. createIgnorer$1.sync = function (ignorePath, withNodeModules) {
  21312. const ignoreContent = !ignorePath ? null : getFileContentOrNull.sync(path$e.resolve(ignorePath));
  21313. return _createIgnorer(ignoreContent, withNodeModules);
  21314. };
  21315. /**
  21316. * @param {null | string} ignoreContent
  21317. * @param {boolean?} withNodeModules
  21318. */
  21319. function _createIgnorer(ignoreContent, withNodeModules) {
  21320. const ignorer = ignore$1().add(ignoreContent || "");
  21321. if (!withNodeModules) {
  21322. ignorer.add("node_modules");
  21323. }
  21324. return ignorer;
  21325. }
  21326. var createIgnorer_1 = createIgnorer$1;
  21327. const path$d = require$$0__default$2["default"];
  21328. const options$c = options$d;
  21329. const config$1 = resolveConfig_1;
  21330. const createIgnorer = createIgnorer_1;
  21331. /**
  21332. * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
  21333. * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
  21334. */
  21335. /**
  21336. * @param {string} filePath
  21337. * @param {FileInfoOptions} opts
  21338. * @returns {Promise<FileInfoResult>}
  21339. *
  21340. * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
  21341. * not an object. A transformation from this array to an object is automatically done
  21342. * internally by the method wrapper. See withPlugins() in index.js.
  21343. */
  21344. async function getFileInfo$1(filePath, opts) {
  21345. if (typeof filePath !== "string") {
  21346. throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
  21347. }
  21348. const ignorer = await createIgnorer(opts.ignorePath, opts.withNodeModules);
  21349. return _getFileInfo({
  21350. ignorer,
  21351. filePath,
  21352. plugins: opts.plugins,
  21353. resolveConfig: opts.resolveConfig,
  21354. ignorePath: opts.ignorePath,
  21355. sync: false
  21356. });
  21357. }
  21358. /**
  21359. * @param {string} filePath
  21360. * @param {FileInfoOptions} opts
  21361. * @returns {FileInfoResult}
  21362. */
  21363. getFileInfo$1.sync = function (filePath, opts) {
  21364. if (typeof filePath !== "string") {
  21365. throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
  21366. }
  21367. const ignorer = createIgnorer.sync(opts.ignorePath, opts.withNodeModules);
  21368. return _getFileInfo({
  21369. ignorer,
  21370. filePath,
  21371. plugins: opts.plugins,
  21372. resolveConfig: opts.resolveConfig,
  21373. ignorePath: opts.ignorePath,
  21374. sync: true
  21375. });
  21376. };
  21377. function getFileParser(resolvedConfig, filePath, plugins) {
  21378. if (resolvedConfig && resolvedConfig.parser) {
  21379. return resolvedConfig.parser;
  21380. }
  21381. const inferredParser = options$c.inferParser(filePath, plugins);
  21382. if (inferredParser) {
  21383. return inferredParser;
  21384. }
  21385. return null;
  21386. }
  21387. function _getFileInfo({
  21388. ignorer,
  21389. filePath,
  21390. plugins,
  21391. resolveConfig = false,
  21392. ignorePath,
  21393. sync = false
  21394. }) {
  21395. const normalizedFilePath = normalizeFilePath(filePath, ignorePath);
  21396. const fileInfo = {
  21397. ignored: ignorer.ignores(normalizedFilePath),
  21398. inferredParser: null
  21399. };
  21400. if (fileInfo.ignored) {
  21401. return fileInfo;
  21402. }
  21403. let resolvedConfig;
  21404. if (resolveConfig) {
  21405. if (sync) {
  21406. resolvedConfig = config$1.resolveConfig.sync(filePath);
  21407. } else {
  21408. return config$1.resolveConfig(filePath).then(resolvedConfig => {
  21409. fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
  21410. return fileInfo;
  21411. });
  21412. }
  21413. }
  21414. fileInfo.inferredParser = getFileParser(resolvedConfig, filePath, plugins);
  21415. return fileInfo;
  21416. }
  21417. function normalizeFilePath(filePath, ignorePath) {
  21418. return ignorePath ? path$d.relative(path$d.dirname(ignorePath), filePath) : filePath;
  21419. }
  21420. var getFileInfo_1 = getFileInfo$1;
  21421. const {
  21422. getMaxContinuousCount: getMaxContinuousCount$2,
  21423. getStringWidth: getStringWidth$4,
  21424. getAlignmentSize,
  21425. getIndentSize: getIndentSize$1,
  21426. skip,
  21427. skipWhitespace: skipWhitespace$1,
  21428. skipSpaces,
  21429. skipNewline,
  21430. skipToLineEnd,
  21431. skipEverythingButNewLine: skipEverythingButNewLine$1,
  21432. skipInlineComment,
  21433. skipTrailingComment,
  21434. hasNewline: hasNewline$8,
  21435. hasNewlineInRange: hasNewlineInRange$4,
  21436. hasSpaces,
  21437. isNextLineEmpty: isNextLineEmpty$d,
  21438. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
  21439. isPreviousLineEmpty: isPreviousLineEmpty$1,
  21440. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
  21441. makeString,
  21442. addLeadingComment: addLeadingComment$1,
  21443. addDanglingComment: addDanglingComment$1,
  21444. addTrailingComment: addTrailingComment$1
  21445. } = util$8;
  21446. var utilShared = {
  21447. getMaxContinuousCount: getMaxContinuousCount$2,
  21448. getStringWidth: getStringWidth$4,
  21449. getAlignmentSize,
  21450. getIndentSize: getIndentSize$1,
  21451. skip,
  21452. skipWhitespace: skipWhitespace$1,
  21453. skipSpaces,
  21454. skipNewline,
  21455. skipToLineEnd,
  21456. skipEverythingButNewLine: skipEverythingButNewLine$1,
  21457. skipInlineComment,
  21458. skipTrailingComment,
  21459. hasNewline: hasNewline$8,
  21460. hasNewlineInRange: hasNewlineInRange$4,
  21461. hasSpaces,
  21462. isNextLineEmpty: isNextLineEmpty$d,
  21463. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
  21464. isPreviousLineEmpty: isPreviousLineEmpty$1,
  21465. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3,
  21466. makeString,
  21467. addLeadingComment: addLeadingComment$1,
  21468. addDanglingComment: addDanglingComment$1,
  21469. addTrailingComment: addTrailingComment$1
  21470. };
  21471. /**
  21472. * Removes all key-value entries from the list cache.
  21473. *
  21474. * @private
  21475. * @name clear
  21476. * @memberOf ListCache
  21477. */
  21478. function listCacheClear$1() {
  21479. this.__data__ = [];
  21480. this.size = 0;
  21481. }
  21482. var _listCacheClear = listCacheClear$1;
  21483. /**
  21484. * Performs a
  21485. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21486. * comparison between two values to determine if they are equivalent.
  21487. *
  21488. * @static
  21489. * @memberOf _
  21490. * @since 4.0.0
  21491. * @category Lang
  21492. * @param {*} value The value to compare.
  21493. * @param {*} other The other value to compare.
  21494. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  21495. * @example
  21496. *
  21497. * var object = { 'a': 1 };
  21498. * var other = { 'a': 1 };
  21499. *
  21500. * _.eq(object, object);
  21501. * // => true
  21502. *
  21503. * _.eq(object, other);
  21504. * // => false
  21505. *
  21506. * _.eq('a', 'a');
  21507. * // => true
  21508. *
  21509. * _.eq('a', Object('a'));
  21510. * // => false
  21511. *
  21512. * _.eq(NaN, NaN);
  21513. * // => true
  21514. */
  21515. function eq$2(value, other) {
  21516. return value === other || value !== value && other !== other;
  21517. }
  21518. var eq_1 = eq$2;
  21519. var eq$1 = eq_1;
  21520. /**
  21521. * Gets the index at which the `key` is found in `array` of key-value pairs.
  21522. *
  21523. * @private
  21524. * @param {Array} array The array to inspect.
  21525. * @param {*} key The key to search for.
  21526. * @returns {number} Returns the index of the matched value, else `-1`.
  21527. */
  21528. function assocIndexOf$4(array, key) {
  21529. var length = array.length;
  21530. while (length--) {
  21531. if (eq$1(array[length][0], key)) {
  21532. return length;
  21533. }
  21534. }
  21535. return -1;
  21536. }
  21537. var _assocIndexOf = assocIndexOf$4;
  21538. var assocIndexOf$3 = _assocIndexOf;
  21539. /** Used for built-in method references. */
  21540. var arrayProto = Array.prototype;
  21541. /** Built-in value references. */
  21542. var splice = arrayProto.splice;
  21543. /**
  21544. * Removes `key` and its value from the list cache.
  21545. *
  21546. * @private
  21547. * @name delete
  21548. * @memberOf ListCache
  21549. * @param {string} key The key of the value to remove.
  21550. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21551. */
  21552. function listCacheDelete$1(key) {
  21553. var data = this.__data__,
  21554. index = assocIndexOf$3(data, key);
  21555. if (index < 0) {
  21556. return false;
  21557. }
  21558. var lastIndex = data.length - 1;
  21559. if (index == lastIndex) {
  21560. data.pop();
  21561. } else {
  21562. splice.call(data, index, 1);
  21563. }
  21564. --this.size;
  21565. return true;
  21566. }
  21567. var _listCacheDelete = listCacheDelete$1;
  21568. var assocIndexOf$2 = _assocIndexOf;
  21569. /**
  21570. * Gets the list cache value for `key`.
  21571. *
  21572. * @private
  21573. * @name get
  21574. * @memberOf ListCache
  21575. * @param {string} key The key of the value to get.
  21576. * @returns {*} Returns the entry value.
  21577. */
  21578. function listCacheGet$1(key) {
  21579. var data = this.__data__,
  21580. index = assocIndexOf$2(data, key);
  21581. return index < 0 ? undefined : data[index][1];
  21582. }
  21583. var _listCacheGet = listCacheGet$1;
  21584. var assocIndexOf$1 = _assocIndexOf;
  21585. /**
  21586. * Checks if a list cache value for `key` exists.
  21587. *
  21588. * @private
  21589. * @name has
  21590. * @memberOf ListCache
  21591. * @param {string} key The key of the entry to check.
  21592. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21593. */
  21594. function listCacheHas$1(key) {
  21595. return assocIndexOf$1(this.__data__, key) > -1;
  21596. }
  21597. var _listCacheHas = listCacheHas$1;
  21598. var assocIndexOf = _assocIndexOf;
  21599. /**
  21600. * Sets the list cache `key` to `value`.
  21601. *
  21602. * @private
  21603. * @name set
  21604. * @memberOf ListCache
  21605. * @param {string} key The key of the value to set.
  21606. * @param {*} value The value to set.
  21607. * @returns {Object} Returns the list cache instance.
  21608. */
  21609. function listCacheSet$1(key, value) {
  21610. var data = this.__data__,
  21611. index = assocIndexOf(data, key);
  21612. if (index < 0) {
  21613. ++this.size;
  21614. data.push([key, value]);
  21615. } else {
  21616. data[index][1] = value;
  21617. }
  21618. return this;
  21619. }
  21620. var _listCacheSet = listCacheSet$1;
  21621. var listCacheClear = _listCacheClear,
  21622. listCacheDelete = _listCacheDelete,
  21623. listCacheGet = _listCacheGet,
  21624. listCacheHas = _listCacheHas,
  21625. listCacheSet = _listCacheSet;
  21626. /**
  21627. * Creates an list cache object.
  21628. *
  21629. * @private
  21630. * @constructor
  21631. * @param {Array} [entries] The key-value pairs to cache.
  21632. */
  21633. function ListCache$4(entries) {
  21634. var index = -1,
  21635. length = entries == null ? 0 : entries.length;
  21636. this.clear();
  21637. while (++index < length) {
  21638. var entry = entries[index];
  21639. this.set(entry[0], entry[1]);
  21640. }
  21641. } // Add methods to `ListCache`.
  21642. ListCache$4.prototype.clear = listCacheClear;
  21643. ListCache$4.prototype['delete'] = listCacheDelete;
  21644. ListCache$4.prototype.get = listCacheGet;
  21645. ListCache$4.prototype.has = listCacheHas;
  21646. ListCache$4.prototype.set = listCacheSet;
  21647. var _ListCache = ListCache$4;
  21648. var ListCache$3 = _ListCache;
  21649. /**
  21650. * Removes all key-value entries from the stack.
  21651. *
  21652. * @private
  21653. * @name clear
  21654. * @memberOf Stack
  21655. */
  21656. function stackClear$1() {
  21657. this.__data__ = new ListCache$3();
  21658. this.size = 0;
  21659. }
  21660. var _stackClear = stackClear$1;
  21661. /**
  21662. * Removes `key` and its value from the stack.
  21663. *
  21664. * @private
  21665. * @name delete
  21666. * @memberOf Stack
  21667. * @param {string} key The key of the value to remove.
  21668. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21669. */
  21670. function stackDelete$1(key) {
  21671. var data = this.__data__,
  21672. result = data['delete'](key);
  21673. this.size = data.size;
  21674. return result;
  21675. }
  21676. var _stackDelete = stackDelete$1;
  21677. /**
  21678. * Gets the stack value for `key`.
  21679. *
  21680. * @private
  21681. * @name get
  21682. * @memberOf Stack
  21683. * @param {string} key The key of the value to get.
  21684. * @returns {*} Returns the entry value.
  21685. */
  21686. function stackGet$1(key) {
  21687. return this.__data__.get(key);
  21688. }
  21689. var _stackGet = stackGet$1;
  21690. /**
  21691. * Checks if a stack value for `key` exists.
  21692. *
  21693. * @private
  21694. * @name has
  21695. * @memberOf Stack
  21696. * @param {string} key The key of the entry to check.
  21697. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  21698. */
  21699. function stackHas$1(key) {
  21700. return this.__data__.has(key);
  21701. }
  21702. var _stackHas = stackHas$1;
  21703. /** Detect free variable `global` from Node.js. */
  21704. var freeGlobal$1 = typeof global == 'object' && global && global.Object === Object && global;
  21705. var _freeGlobal = freeGlobal$1;
  21706. var freeGlobal = _freeGlobal;
  21707. /** Detect free variable `self`. */
  21708. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  21709. /** Used as a reference to the global object. */
  21710. var root$8 = freeGlobal || freeSelf || Function('return this')();
  21711. var _root = root$8;
  21712. var root$7 = _root;
  21713. /** Built-in value references. */
  21714. var Symbol$5 = root$7.Symbol;
  21715. var _Symbol = Symbol$5;
  21716. var Symbol$4 = _Symbol;
  21717. /** Used for built-in method references. */
  21718. var objectProto$b = Object.prototype;
  21719. /** Used to check objects for own properties. */
  21720. var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
  21721. /**
  21722. * Used to resolve the
  21723. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  21724. * of values.
  21725. */
  21726. var nativeObjectToString$1 = objectProto$b.toString;
  21727. /** Built-in value references. */
  21728. var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : undefined;
  21729. /**
  21730. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  21731. *
  21732. * @private
  21733. * @param {*} value The value to query.
  21734. * @returns {string} Returns the raw `toStringTag`.
  21735. */
  21736. function getRawTag$1(value) {
  21737. var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
  21738. tag = value[symToStringTag$1];
  21739. try {
  21740. value[symToStringTag$1] = undefined;
  21741. var unmasked = true;
  21742. } catch (e) {}
  21743. var result = nativeObjectToString$1.call(value);
  21744. if (unmasked) {
  21745. if (isOwn) {
  21746. value[symToStringTag$1] = tag;
  21747. } else {
  21748. delete value[symToStringTag$1];
  21749. }
  21750. }
  21751. return result;
  21752. }
  21753. var _getRawTag = getRawTag$1;
  21754. /** Used for built-in method references. */
  21755. var objectProto$a = Object.prototype;
  21756. /**
  21757. * Used to resolve the
  21758. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  21759. * of values.
  21760. */
  21761. var nativeObjectToString = objectProto$a.toString;
  21762. /**
  21763. * Converts `value` to a string using `Object.prototype.toString`.
  21764. *
  21765. * @private
  21766. * @param {*} value The value to convert.
  21767. * @returns {string} Returns the converted string.
  21768. */
  21769. function objectToString$1(value) {
  21770. return nativeObjectToString.call(value);
  21771. }
  21772. var _objectToString = objectToString$1;
  21773. var Symbol$3 = _Symbol,
  21774. getRawTag = _getRawTag,
  21775. objectToString = _objectToString;
  21776. /** `Object#toString` result references. */
  21777. var nullTag = '[object Null]',
  21778. undefinedTag = '[object Undefined]';
  21779. /** Built-in value references. */
  21780. var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : undefined;
  21781. /**
  21782. * The base implementation of `getTag` without fallbacks for buggy environments.
  21783. *
  21784. * @private
  21785. * @param {*} value The value to query.
  21786. * @returns {string} Returns the `toStringTag`.
  21787. */
  21788. function baseGetTag$5(value) {
  21789. if (value == null) {
  21790. return value === undefined ? undefinedTag : nullTag;
  21791. }
  21792. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  21793. }
  21794. var _baseGetTag = baseGetTag$5;
  21795. /**
  21796. * Checks if `value` is the
  21797. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  21798. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  21799. *
  21800. * @static
  21801. * @memberOf _
  21802. * @since 0.1.0
  21803. * @category Lang
  21804. * @param {*} value The value to check.
  21805. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  21806. * @example
  21807. *
  21808. * _.isObject({});
  21809. * // => true
  21810. *
  21811. * _.isObject([1, 2, 3]);
  21812. * // => true
  21813. *
  21814. * _.isObject(_.noop);
  21815. * // => true
  21816. *
  21817. * _.isObject(null);
  21818. * // => false
  21819. */
  21820. function isObject$5(value) {
  21821. var type = typeof value;
  21822. return value != null && (type == 'object' || type == 'function');
  21823. }
  21824. var isObject_1 = isObject$5;
  21825. var baseGetTag$4 = _baseGetTag,
  21826. isObject$4 = isObject_1;
  21827. /** `Object#toString` result references. */
  21828. var asyncTag = '[object AsyncFunction]',
  21829. funcTag$1 = '[object Function]',
  21830. genTag = '[object GeneratorFunction]',
  21831. proxyTag = '[object Proxy]';
  21832. /**
  21833. * Checks if `value` is classified as a `Function` object.
  21834. *
  21835. * @static
  21836. * @memberOf _
  21837. * @since 0.1.0
  21838. * @category Lang
  21839. * @param {*} value The value to check.
  21840. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  21841. * @example
  21842. *
  21843. * _.isFunction(_);
  21844. * // => true
  21845. *
  21846. * _.isFunction(/abc/);
  21847. * // => false
  21848. */
  21849. function isFunction$2(value) {
  21850. if (!isObject$4(value)) {
  21851. return false;
  21852. } // The use of `Object#toString` avoids issues with the `typeof` operator
  21853. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  21854. var tag = baseGetTag$4(value);
  21855. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  21856. }
  21857. var isFunction_1 = isFunction$2;
  21858. var root$6 = _root;
  21859. /** Used to detect overreaching core-js shims. */
  21860. var coreJsData$1 = root$6['__core-js_shared__'];
  21861. var _coreJsData = coreJsData$1;
  21862. var coreJsData = _coreJsData;
  21863. /** Used to detect methods masquerading as native. */
  21864. var maskSrcKey = function () {
  21865. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  21866. return uid ? 'Symbol(src)_1.' + uid : '';
  21867. }();
  21868. /**
  21869. * Checks if `func` has its source masked.
  21870. *
  21871. * @private
  21872. * @param {Function} func The function to check.
  21873. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  21874. */
  21875. function isMasked$1(func) {
  21876. return !!maskSrcKey && maskSrcKey in func;
  21877. }
  21878. var _isMasked = isMasked$1;
  21879. /** Used for built-in method references. */
  21880. var funcProto$1 = Function.prototype;
  21881. /** Used to resolve the decompiled source of functions. */
  21882. var funcToString$1 = funcProto$1.toString;
  21883. /**
  21884. * Converts `func` to its source code.
  21885. *
  21886. * @private
  21887. * @param {Function} func The function to convert.
  21888. * @returns {string} Returns the source code.
  21889. */
  21890. function toSource$2(func) {
  21891. if (func != null) {
  21892. try {
  21893. return funcToString$1.call(func);
  21894. } catch (e) {}
  21895. try {
  21896. return func + '';
  21897. } catch (e) {}
  21898. }
  21899. return '';
  21900. }
  21901. var _toSource = toSource$2;
  21902. var isFunction$1 = isFunction_1,
  21903. isMasked = _isMasked,
  21904. isObject$3 = isObject_1,
  21905. toSource$1 = _toSource;
  21906. /**
  21907. * Used to match `RegExp`
  21908. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  21909. */
  21910. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  21911. /** Used to detect host constructors (Safari). */
  21912. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  21913. /** Used for built-in method references. */
  21914. var funcProto = Function.prototype,
  21915. objectProto$9 = Object.prototype;
  21916. /** Used to resolve the decompiled source of functions. */
  21917. var funcToString = funcProto.toString;
  21918. /** Used to check objects for own properties. */
  21919. var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
  21920. /** Used to detect if a method is native. */
  21921. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  21922. /**
  21923. * The base implementation of `_.isNative` without bad shim checks.
  21924. *
  21925. * @private
  21926. * @param {*} value The value to check.
  21927. * @returns {boolean} Returns `true` if `value` is a native function,
  21928. * else `false`.
  21929. */
  21930. function baseIsNative$1(value) {
  21931. if (!isObject$3(value) || isMasked(value)) {
  21932. return false;
  21933. }
  21934. var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
  21935. return pattern.test(toSource$1(value));
  21936. }
  21937. var _baseIsNative = baseIsNative$1;
  21938. /**
  21939. * Gets the value at `key` of `object`.
  21940. *
  21941. * @private
  21942. * @param {Object} [object] The object to query.
  21943. * @param {string} key The key of the property to get.
  21944. * @returns {*} Returns the property value.
  21945. */
  21946. function getValue$1(object, key) {
  21947. return object == null ? undefined : object[key];
  21948. }
  21949. var _getValue = getValue$1;
  21950. var baseIsNative = _baseIsNative,
  21951. getValue = _getValue;
  21952. /**
  21953. * Gets the native function at `key` of `object`.
  21954. *
  21955. * @private
  21956. * @param {Object} object The object to query.
  21957. * @param {string} key The key of the method to get.
  21958. * @returns {*} Returns the function if it's native, else `undefined`.
  21959. */
  21960. function getNative$6(object, key) {
  21961. var value = getValue(object, key);
  21962. return baseIsNative(value) ? value : undefined;
  21963. }
  21964. var _getNative = getNative$6;
  21965. var getNative$5 = _getNative,
  21966. root$5 = _root;
  21967. /* Built-in method references that are verified to be native. */
  21968. var Map$4 = getNative$5(root$5, 'Map');
  21969. var _Map = Map$4;
  21970. var getNative$4 = _getNative;
  21971. /* Built-in method references that are verified to be native. */
  21972. var nativeCreate$4 = getNative$4(Object, 'create');
  21973. var _nativeCreate = nativeCreate$4;
  21974. var nativeCreate$3 = _nativeCreate;
  21975. /**
  21976. * Removes all key-value entries from the hash.
  21977. *
  21978. * @private
  21979. * @name clear
  21980. * @memberOf Hash
  21981. */
  21982. function hashClear$1() {
  21983. this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
  21984. this.size = 0;
  21985. }
  21986. var _hashClear = hashClear$1;
  21987. /**
  21988. * Removes `key` and its value from the hash.
  21989. *
  21990. * @private
  21991. * @name delete
  21992. * @memberOf Hash
  21993. * @param {Object} hash The hash to modify.
  21994. * @param {string} key The key of the value to remove.
  21995. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  21996. */
  21997. function hashDelete$1(key) {
  21998. var result = this.has(key) && delete this.__data__[key];
  21999. this.size -= result ? 1 : 0;
  22000. return result;
  22001. }
  22002. var _hashDelete = hashDelete$1;
  22003. var nativeCreate$2 = _nativeCreate;
  22004. /** Used to stand-in for `undefined` hash values. */
  22005. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  22006. /** Used for built-in method references. */
  22007. var objectProto$8 = Object.prototype;
  22008. /** Used to check objects for own properties. */
  22009. var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
  22010. /**
  22011. * Gets the hash value for `key`.
  22012. *
  22013. * @private
  22014. * @name get
  22015. * @memberOf Hash
  22016. * @param {string} key The key of the value to get.
  22017. * @returns {*} Returns the entry value.
  22018. */
  22019. function hashGet$1(key) {
  22020. var data = this.__data__;
  22021. if (nativeCreate$2) {
  22022. var result = data[key];
  22023. return result === HASH_UNDEFINED$2 ? undefined : result;
  22024. }
  22025. return hasOwnProperty$6.call(data, key) ? data[key] : undefined;
  22026. }
  22027. var _hashGet = hashGet$1;
  22028. var nativeCreate$1 = _nativeCreate;
  22029. /** Used for built-in method references. */
  22030. var objectProto$7 = Object.prototype;
  22031. /** Used to check objects for own properties. */
  22032. var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
  22033. /**
  22034. * Checks if a hash value for `key` exists.
  22035. *
  22036. * @private
  22037. * @name has
  22038. * @memberOf Hash
  22039. * @param {string} key The key of the entry to check.
  22040. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  22041. */
  22042. function hashHas$1(key) {
  22043. var data = this.__data__;
  22044. return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty$5.call(data, key);
  22045. }
  22046. var _hashHas = hashHas$1;
  22047. var nativeCreate = _nativeCreate;
  22048. /** Used to stand-in for `undefined` hash values. */
  22049. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  22050. /**
  22051. * Sets the hash `key` to `value`.
  22052. *
  22053. * @private
  22054. * @name set
  22055. * @memberOf Hash
  22056. * @param {string} key The key of the value to set.
  22057. * @param {*} value The value to set.
  22058. * @returns {Object} Returns the hash instance.
  22059. */
  22060. function hashSet$1(key, value) {
  22061. var data = this.__data__;
  22062. this.size += this.has(key) ? 0 : 1;
  22063. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
  22064. return this;
  22065. }
  22066. var _hashSet = hashSet$1;
  22067. var hashClear = _hashClear,
  22068. hashDelete = _hashDelete,
  22069. hashGet = _hashGet,
  22070. hashHas = _hashHas,
  22071. hashSet = _hashSet;
  22072. /**
  22073. * Creates a hash object.
  22074. *
  22075. * @private
  22076. * @constructor
  22077. * @param {Array} [entries] The key-value pairs to cache.
  22078. */
  22079. function Hash$1(entries) {
  22080. var index = -1,
  22081. length = entries == null ? 0 : entries.length;
  22082. this.clear();
  22083. while (++index < length) {
  22084. var entry = entries[index];
  22085. this.set(entry[0], entry[1]);
  22086. }
  22087. } // Add methods to `Hash`.
  22088. Hash$1.prototype.clear = hashClear;
  22089. Hash$1.prototype['delete'] = hashDelete;
  22090. Hash$1.prototype.get = hashGet;
  22091. Hash$1.prototype.has = hashHas;
  22092. Hash$1.prototype.set = hashSet;
  22093. var _Hash = Hash$1;
  22094. var Hash = _Hash,
  22095. ListCache$2 = _ListCache,
  22096. Map$3 = _Map;
  22097. /**
  22098. * Removes all key-value entries from the map.
  22099. *
  22100. * @private
  22101. * @name clear
  22102. * @memberOf MapCache
  22103. */
  22104. function mapCacheClear$1() {
  22105. this.size = 0;
  22106. this.__data__ = {
  22107. 'hash': new Hash(),
  22108. 'map': new (Map$3 || ListCache$2)(),
  22109. 'string': new Hash()
  22110. };
  22111. }
  22112. var _mapCacheClear = mapCacheClear$1;
  22113. /**
  22114. * Checks if `value` is suitable for use as unique object key.
  22115. *
  22116. * @private
  22117. * @param {*} value The value to check.
  22118. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22119. */
  22120. function isKeyable$1(value) {
  22121. var type = typeof value;
  22122. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  22123. }
  22124. var _isKeyable = isKeyable$1;
  22125. var isKeyable = _isKeyable;
  22126. /**
  22127. * Gets the data for `map`.
  22128. *
  22129. * @private
  22130. * @param {Object} map The map to query.
  22131. * @param {string} key The reference key.
  22132. * @returns {*} Returns the map data.
  22133. */
  22134. function getMapData$4(map, key) {
  22135. var data = map.__data__;
  22136. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  22137. }
  22138. var _getMapData = getMapData$4;
  22139. var getMapData$3 = _getMapData;
  22140. /**
  22141. * Removes `key` and its value from the map.
  22142. *
  22143. * @private
  22144. * @name delete
  22145. * @memberOf MapCache
  22146. * @param {string} key The key of the value to remove.
  22147. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  22148. */
  22149. function mapCacheDelete$1(key) {
  22150. var result = getMapData$3(this, key)['delete'](key);
  22151. this.size -= result ? 1 : 0;
  22152. return result;
  22153. }
  22154. var _mapCacheDelete = mapCacheDelete$1;
  22155. var getMapData$2 = _getMapData;
  22156. /**
  22157. * Gets the map value for `key`.
  22158. *
  22159. * @private
  22160. * @name get
  22161. * @memberOf MapCache
  22162. * @param {string} key The key of the value to get.
  22163. * @returns {*} Returns the entry value.
  22164. */
  22165. function mapCacheGet$1(key) {
  22166. return getMapData$2(this, key).get(key);
  22167. }
  22168. var _mapCacheGet = mapCacheGet$1;
  22169. var getMapData$1 = _getMapData;
  22170. /**
  22171. * Checks if a map value for `key` exists.
  22172. *
  22173. * @private
  22174. * @name has
  22175. * @memberOf MapCache
  22176. * @param {string} key The key of the entry to check.
  22177. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  22178. */
  22179. function mapCacheHas$1(key) {
  22180. return getMapData$1(this, key).has(key);
  22181. }
  22182. var _mapCacheHas = mapCacheHas$1;
  22183. var getMapData = _getMapData;
  22184. /**
  22185. * Sets the map `key` to `value`.
  22186. *
  22187. * @private
  22188. * @name set
  22189. * @memberOf MapCache
  22190. * @param {string} key The key of the value to set.
  22191. * @param {*} value The value to set.
  22192. * @returns {Object} Returns the map cache instance.
  22193. */
  22194. function mapCacheSet$1(key, value) {
  22195. var data = getMapData(this, key),
  22196. size = data.size;
  22197. data.set(key, value);
  22198. this.size += data.size == size ? 0 : 1;
  22199. return this;
  22200. }
  22201. var _mapCacheSet = mapCacheSet$1;
  22202. var mapCacheClear = _mapCacheClear,
  22203. mapCacheDelete = _mapCacheDelete,
  22204. mapCacheGet = _mapCacheGet,
  22205. mapCacheHas = _mapCacheHas,
  22206. mapCacheSet = _mapCacheSet;
  22207. /**
  22208. * Creates a map cache object to store key-value pairs.
  22209. *
  22210. * @private
  22211. * @constructor
  22212. * @param {Array} [entries] The key-value pairs to cache.
  22213. */
  22214. function MapCache$3(entries) {
  22215. var index = -1,
  22216. length = entries == null ? 0 : entries.length;
  22217. this.clear();
  22218. while (++index < length) {
  22219. var entry = entries[index];
  22220. this.set(entry[0], entry[1]);
  22221. }
  22222. } // Add methods to `MapCache`.
  22223. MapCache$3.prototype.clear = mapCacheClear;
  22224. MapCache$3.prototype['delete'] = mapCacheDelete;
  22225. MapCache$3.prototype.get = mapCacheGet;
  22226. MapCache$3.prototype.has = mapCacheHas;
  22227. MapCache$3.prototype.set = mapCacheSet;
  22228. var _MapCache = MapCache$3;
  22229. var ListCache$1 = _ListCache,
  22230. Map$2 = _Map,
  22231. MapCache$2 = _MapCache;
  22232. /** Used as the size to enable large array optimizations. */
  22233. var LARGE_ARRAY_SIZE$1 = 200;
  22234. /**
  22235. * Sets the stack `key` to `value`.
  22236. *
  22237. * @private
  22238. * @name set
  22239. * @memberOf Stack
  22240. * @param {string} key The key of the value to set.
  22241. * @param {*} value The value to set.
  22242. * @returns {Object} Returns the stack cache instance.
  22243. */
  22244. function stackSet$1(key, value) {
  22245. var data = this.__data__;
  22246. if (data instanceof ListCache$1) {
  22247. var pairs = data.__data__;
  22248. if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE$1 - 1) {
  22249. pairs.push([key, value]);
  22250. this.size = ++data.size;
  22251. return this;
  22252. }
  22253. data = this.__data__ = new MapCache$2(pairs);
  22254. }
  22255. data.set(key, value);
  22256. this.size = data.size;
  22257. return this;
  22258. }
  22259. var _stackSet = stackSet$1;
  22260. var ListCache = _ListCache,
  22261. stackClear = _stackClear,
  22262. stackDelete = _stackDelete,
  22263. stackGet = _stackGet,
  22264. stackHas = _stackHas,
  22265. stackSet = _stackSet;
  22266. /**
  22267. * Creates a stack cache object to store key-value pairs.
  22268. *
  22269. * @private
  22270. * @constructor
  22271. * @param {Array} [entries] The key-value pairs to cache.
  22272. */
  22273. function Stack$2(entries) {
  22274. var data = this.__data__ = new ListCache(entries);
  22275. this.size = data.size;
  22276. } // Add methods to `Stack`.
  22277. Stack$2.prototype.clear = stackClear;
  22278. Stack$2.prototype['delete'] = stackDelete;
  22279. Stack$2.prototype.get = stackGet;
  22280. Stack$2.prototype.has = stackHas;
  22281. Stack$2.prototype.set = stackSet;
  22282. var _Stack = Stack$2;
  22283. /** Used to stand-in for `undefined` hash values. */
  22284. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  22285. /**
  22286. * Adds `value` to the array cache.
  22287. *
  22288. * @private
  22289. * @name add
  22290. * @memberOf SetCache
  22291. * @alias push
  22292. * @param {*} value The value to cache.
  22293. * @returns {Object} Returns the cache instance.
  22294. */
  22295. function setCacheAdd$1(value) {
  22296. this.__data__.set(value, HASH_UNDEFINED);
  22297. return this;
  22298. }
  22299. var _setCacheAdd = setCacheAdd$1;
  22300. /**
  22301. * Checks if `value` is in the array cache.
  22302. *
  22303. * @private
  22304. * @name has
  22305. * @memberOf SetCache
  22306. * @param {*} value The value to search for.
  22307. * @returns {number} Returns `true` if `value` is found, else `false`.
  22308. */
  22309. function setCacheHas$1(value) {
  22310. return this.__data__.has(value);
  22311. }
  22312. var _setCacheHas = setCacheHas$1;
  22313. var MapCache$1 = _MapCache,
  22314. setCacheAdd = _setCacheAdd,
  22315. setCacheHas = _setCacheHas;
  22316. /**
  22317. *
  22318. * Creates an array cache object to store unique values.
  22319. *
  22320. * @private
  22321. * @constructor
  22322. * @param {Array} [values] The values to cache.
  22323. */
  22324. function SetCache$2(values) {
  22325. var index = -1,
  22326. length = values == null ? 0 : values.length;
  22327. this.__data__ = new MapCache$1();
  22328. while (++index < length) {
  22329. this.add(values[index]);
  22330. }
  22331. } // Add methods to `SetCache`.
  22332. SetCache$2.prototype.add = SetCache$2.prototype.push = setCacheAdd;
  22333. SetCache$2.prototype.has = setCacheHas;
  22334. var _SetCache = SetCache$2;
  22335. /**
  22336. * A specialized version of `_.some` for arrays without support for iteratee
  22337. * shorthands.
  22338. *
  22339. * @private
  22340. * @param {Array} [array] The array to iterate over.
  22341. * @param {Function} predicate The function invoked per iteration.
  22342. * @returns {boolean} Returns `true` if any element passes the predicate check,
  22343. * else `false`.
  22344. */
  22345. function arraySome$1(array, predicate) {
  22346. var index = -1,
  22347. length = array == null ? 0 : array.length;
  22348. while (++index < length) {
  22349. if (predicate(array[index], index, array)) {
  22350. return true;
  22351. }
  22352. }
  22353. return false;
  22354. }
  22355. var _arraySome = arraySome$1;
  22356. /**
  22357. * Checks if a `cache` value for `key` exists.
  22358. *
  22359. * @private
  22360. * @param {Object} cache The cache to query.
  22361. * @param {string} key The key of the entry to check.
  22362. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  22363. */
  22364. function cacheHas$2(cache, key) {
  22365. return cache.has(key);
  22366. }
  22367. var _cacheHas = cacheHas$2;
  22368. var SetCache$1 = _SetCache,
  22369. arraySome = _arraySome,
  22370. cacheHas$1 = _cacheHas;
  22371. /** Used to compose bitmasks for value comparisons. */
  22372. var COMPARE_PARTIAL_FLAG$5 = 1,
  22373. COMPARE_UNORDERED_FLAG$3 = 2;
  22374. /**
  22375. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22376. * partial deep comparisons.
  22377. *
  22378. * @private
  22379. * @param {Array} array The array to compare.
  22380. * @param {Array} other The other array to compare.
  22381. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22382. * @param {Function} customizer The function to customize comparisons.
  22383. * @param {Function} equalFunc The function to determine equivalents of values.
  22384. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22385. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22386. */
  22387. function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
  22388. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
  22389. arrLength = array.length,
  22390. othLength = other.length;
  22391. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22392. return false;
  22393. } // Check that cyclic values are equal.
  22394. var arrStacked = stack.get(array);
  22395. var othStacked = stack.get(other);
  22396. if (arrStacked && othStacked) {
  22397. return arrStacked == other && othStacked == array;
  22398. }
  22399. var index = -1,
  22400. result = true,
  22401. seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache$1() : undefined;
  22402. stack.set(array, other);
  22403. stack.set(other, array); // Ignore non-index properties.
  22404. while (++index < arrLength) {
  22405. var arrValue = array[index],
  22406. othValue = other[index];
  22407. if (customizer) {
  22408. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  22409. }
  22410. if (compared !== undefined) {
  22411. if (compared) {
  22412. continue;
  22413. }
  22414. result = false;
  22415. break;
  22416. } // Recursively compare arrays (susceptible to call stack limits).
  22417. if (seen) {
  22418. if (!arraySome(other, function (othValue, othIndex) {
  22419. if (!cacheHas$1(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22420. return seen.push(othIndex);
  22421. }
  22422. })) {
  22423. result = false;
  22424. break;
  22425. }
  22426. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22427. result = false;
  22428. break;
  22429. }
  22430. }
  22431. stack['delete'](array);
  22432. stack['delete'](other);
  22433. return result;
  22434. }
  22435. var _equalArrays = equalArrays$2;
  22436. var root$4 = _root;
  22437. /** Built-in value references. */
  22438. var Uint8Array$1 = root$4.Uint8Array;
  22439. var _Uint8Array = Uint8Array$1;
  22440. /**
  22441. * Converts `map` to its key-value pairs.
  22442. *
  22443. * @private
  22444. * @param {Object} map The map to convert.
  22445. * @returns {Array} Returns the key-value pairs.
  22446. */
  22447. function mapToArray$1(map) {
  22448. var index = -1,
  22449. result = Array(map.size);
  22450. map.forEach(function (value, key) {
  22451. result[++index] = [key, value];
  22452. });
  22453. return result;
  22454. }
  22455. var _mapToArray = mapToArray$1;
  22456. /**
  22457. * Converts `set` to an array of its values.
  22458. *
  22459. * @private
  22460. * @param {Object} set The set to convert.
  22461. * @returns {Array} Returns the values.
  22462. */
  22463. function setToArray$3(set) {
  22464. var index = -1,
  22465. result = Array(set.size);
  22466. set.forEach(function (value) {
  22467. result[++index] = value;
  22468. });
  22469. return result;
  22470. }
  22471. var _setToArray = setToArray$3;
  22472. var Symbol$2 = _Symbol,
  22473. Uint8Array = _Uint8Array,
  22474. eq = eq_1,
  22475. equalArrays$1 = _equalArrays,
  22476. mapToArray = _mapToArray,
  22477. setToArray$2 = _setToArray;
  22478. /** Used to compose bitmasks for value comparisons. */
  22479. var COMPARE_PARTIAL_FLAG$4 = 1,
  22480. COMPARE_UNORDERED_FLAG$2 = 2;
  22481. /** `Object#toString` result references. */
  22482. var boolTag$1 = '[object Boolean]',
  22483. dateTag$1 = '[object Date]',
  22484. errorTag$1 = '[object Error]',
  22485. mapTag$2 = '[object Map]',
  22486. numberTag$1 = '[object Number]',
  22487. regexpTag$1 = '[object RegExp]',
  22488. setTag$2 = '[object Set]',
  22489. stringTag$1 = '[object String]',
  22490. symbolTag$1 = '[object Symbol]';
  22491. var arrayBufferTag$1 = '[object ArrayBuffer]',
  22492. dataViewTag$2 = '[object DataView]';
  22493. /** Used to convert symbols to primitives and strings. */
  22494. var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : undefined,
  22495. symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
  22496. /**
  22497. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22498. * the same `toStringTag`.
  22499. *
  22500. * **Note:** This function only supports comparing values with tags of
  22501. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22502. *
  22503. * @private
  22504. * @param {Object} object The object to compare.
  22505. * @param {Object} other The other object to compare.
  22506. * @param {string} tag The `toStringTag` of the objects to compare.
  22507. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22508. * @param {Function} customizer The function to customize comparisons.
  22509. * @param {Function} equalFunc The function to determine equivalents of values.
  22510. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22511. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22512. */
  22513. function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22514. switch (tag) {
  22515. case dataViewTag$2:
  22516. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  22517. return false;
  22518. }
  22519. object = object.buffer;
  22520. other = other.buffer;
  22521. case arrayBufferTag$1:
  22522. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22523. return false;
  22524. }
  22525. return true;
  22526. case boolTag$1:
  22527. case dateTag$1:
  22528. case numberTag$1:
  22529. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22530. // Invalid dates are coerced to `NaN`.
  22531. return eq(+object, +other);
  22532. case errorTag$1:
  22533. return object.name == other.name && object.message == other.message;
  22534. case regexpTag$1:
  22535. case stringTag$1:
  22536. // Coerce regexes to strings and treat strings, primitives and objects,
  22537. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22538. // for more details.
  22539. return object == other + '';
  22540. case mapTag$2:
  22541. var convert = mapToArray;
  22542. case setTag$2:
  22543. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
  22544. convert || (convert = setToArray$2);
  22545. if (object.size != other.size && !isPartial) {
  22546. return false;
  22547. } // Assume cyclic values are equal.
  22548. var stacked = stack.get(object);
  22549. if (stacked) {
  22550. return stacked == other;
  22551. }
  22552. bitmask |= COMPARE_UNORDERED_FLAG$2; // Recursively compare objects (susceptible to call stack limits).
  22553. stack.set(object, other);
  22554. var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22555. stack['delete'](object);
  22556. return result;
  22557. case symbolTag$1:
  22558. if (symbolValueOf) {
  22559. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22560. }
  22561. }
  22562. return false;
  22563. }
  22564. var _equalByTag = equalByTag$1;
  22565. /**
  22566. * Appends the elements of `values` to `array`.
  22567. *
  22568. * @private
  22569. * @param {Array} array The array to modify.
  22570. * @param {Array} values The values to append.
  22571. * @returns {Array} Returns `array`.
  22572. */
  22573. function arrayPush$1(array, values) {
  22574. var index = -1,
  22575. length = values.length,
  22576. offset = array.length;
  22577. while (++index < length) {
  22578. array[offset + index] = values[index];
  22579. }
  22580. return array;
  22581. }
  22582. var _arrayPush = arrayPush$1;
  22583. /**
  22584. * Checks if `value` is classified as an `Array` object.
  22585. *
  22586. * @static
  22587. * @memberOf _
  22588. * @since 0.1.0
  22589. * @category Lang
  22590. * @param {*} value The value to check.
  22591. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  22592. * @example
  22593. *
  22594. * _.isArray([1, 2, 3]);
  22595. * // => true
  22596. *
  22597. * _.isArray(document.body.children);
  22598. * // => false
  22599. *
  22600. * _.isArray('abc');
  22601. * // => false
  22602. *
  22603. * _.isArray(_.noop);
  22604. * // => false
  22605. */
  22606. var isArray$9 = Array.isArray;
  22607. var isArray_1 = isArray$9;
  22608. var arrayPush = _arrayPush,
  22609. isArray$8 = isArray_1;
  22610. /**
  22611. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  22612. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  22613. * symbols of `object`.
  22614. *
  22615. * @private
  22616. * @param {Object} object The object to query.
  22617. * @param {Function} keysFunc The function to get the keys of `object`.
  22618. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  22619. * @returns {Array} Returns the array of property names and symbols.
  22620. */
  22621. function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
  22622. var result = keysFunc(object);
  22623. return isArray$8(object) ? result : arrayPush(result, symbolsFunc(object));
  22624. }
  22625. var _baseGetAllKeys = baseGetAllKeys$1;
  22626. /**
  22627. * A specialized version of `_.filter` for arrays without support for
  22628. * iteratee shorthands.
  22629. *
  22630. * @private
  22631. * @param {Array} [array] The array to iterate over.
  22632. * @param {Function} predicate The function invoked per iteration.
  22633. * @returns {Array} Returns the new filtered array.
  22634. */
  22635. function arrayFilter$1(array, predicate) {
  22636. var index = -1,
  22637. length = array == null ? 0 : array.length,
  22638. resIndex = 0,
  22639. result = [];
  22640. while (++index < length) {
  22641. var value = array[index];
  22642. if (predicate(value, index, array)) {
  22643. result[resIndex++] = value;
  22644. }
  22645. }
  22646. return result;
  22647. }
  22648. var _arrayFilter = arrayFilter$1;
  22649. /**
  22650. * This method returns a new empty array.
  22651. *
  22652. * @static
  22653. * @memberOf _
  22654. * @since 4.13.0
  22655. * @category Util
  22656. * @returns {Array} Returns the new empty array.
  22657. * @example
  22658. *
  22659. * var arrays = _.times(2, _.stubArray);
  22660. *
  22661. * console.log(arrays);
  22662. * // => [[], []]
  22663. *
  22664. * console.log(arrays[0] === arrays[1]);
  22665. * // => false
  22666. */
  22667. function stubArray$1() {
  22668. return [];
  22669. }
  22670. var stubArray_1 = stubArray$1;
  22671. var arrayFilter = _arrayFilter,
  22672. stubArray = stubArray_1;
  22673. /** Used for built-in method references. */
  22674. var objectProto$6 = Object.prototype;
  22675. /** Built-in value references. */
  22676. var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
  22677. /* Built-in method references for those with the same name as other `lodash` methods. */
  22678. var nativeGetSymbols = Object.getOwnPropertySymbols;
  22679. /**
  22680. * Creates an array of the own enumerable symbols of `object`.
  22681. *
  22682. * @private
  22683. * @param {Object} object The object to query.
  22684. * @returns {Array} Returns the array of symbols.
  22685. */
  22686. var getSymbols$1 = !nativeGetSymbols ? stubArray : function (object) {
  22687. if (object == null) {
  22688. return [];
  22689. }
  22690. object = Object(object);
  22691. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  22692. return propertyIsEnumerable$1.call(object, symbol);
  22693. });
  22694. };
  22695. var _getSymbols = getSymbols$1;
  22696. /**
  22697. * The base implementation of `_.times` without support for iteratee shorthands
  22698. * or max array length checks.
  22699. *
  22700. * @private
  22701. * @param {number} n The number of times to invoke `iteratee`.
  22702. * @param {Function} iteratee The function invoked per iteration.
  22703. * @returns {Array} Returns the array of results.
  22704. */
  22705. function baseTimes$1(n, iteratee) {
  22706. var index = -1,
  22707. result = Array(n);
  22708. while (++index < n) {
  22709. result[index] = iteratee(index);
  22710. }
  22711. return result;
  22712. }
  22713. var _baseTimes = baseTimes$1;
  22714. /**
  22715. * Checks if `value` is object-like. A value is object-like if it's not `null`
  22716. * and has a `typeof` result of "object".
  22717. *
  22718. * @static
  22719. * @memberOf _
  22720. * @since 4.0.0
  22721. * @category Lang
  22722. * @param {*} value The value to check.
  22723. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  22724. * @example
  22725. *
  22726. * _.isObjectLike({});
  22727. * // => true
  22728. *
  22729. * _.isObjectLike([1, 2, 3]);
  22730. * // => true
  22731. *
  22732. * _.isObjectLike(_.noop);
  22733. * // => false
  22734. *
  22735. * _.isObjectLike(null);
  22736. * // => false
  22737. */
  22738. function isObjectLike$5(value) {
  22739. return value != null && typeof value == 'object';
  22740. }
  22741. var isObjectLike_1 = isObjectLike$5;
  22742. var baseGetTag$3 = _baseGetTag,
  22743. isObjectLike$4 = isObjectLike_1;
  22744. /** `Object#toString` result references. */
  22745. var argsTag$2 = '[object Arguments]';
  22746. /**
  22747. * The base implementation of `_.isArguments`.
  22748. *
  22749. * @private
  22750. * @param {*} value The value to check.
  22751. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  22752. */
  22753. function baseIsArguments$1(value) {
  22754. return isObjectLike$4(value) && baseGetTag$3(value) == argsTag$2;
  22755. }
  22756. var _baseIsArguments = baseIsArguments$1;
  22757. var baseIsArguments = _baseIsArguments,
  22758. isObjectLike$3 = isObjectLike_1;
  22759. /** Used for built-in method references. */
  22760. var objectProto$5 = Object.prototype;
  22761. /** Used to check objects for own properties. */
  22762. var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
  22763. /** Built-in value references. */
  22764. var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
  22765. /**
  22766. * Checks if `value` is likely an `arguments` object.
  22767. *
  22768. * @static
  22769. * @memberOf _
  22770. * @since 0.1.0
  22771. * @category Lang
  22772. * @param {*} value The value to check.
  22773. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  22774. * else `false`.
  22775. * @example
  22776. *
  22777. * _.isArguments(function() { return arguments; }());
  22778. * // => true
  22779. *
  22780. * _.isArguments([1, 2, 3]);
  22781. * // => false
  22782. */
  22783. var isArguments$2 = baseIsArguments(function () {
  22784. return arguments;
  22785. }()) ? baseIsArguments : function (value) {
  22786. return isObjectLike$3(value) && hasOwnProperty$4.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  22787. };
  22788. var isArguments_1 = isArguments$2;
  22789. var isBuffer$2 = {exports: {}};
  22790. /**
  22791. * This method returns `false`.
  22792. *
  22793. * @static
  22794. * @memberOf _
  22795. * @since 4.13.0
  22796. * @category Util
  22797. * @returns {boolean} Returns `false`.
  22798. * @example
  22799. *
  22800. * _.times(2, _.stubFalse);
  22801. * // => [false, false]
  22802. */
  22803. function stubFalse() {
  22804. return false;
  22805. }
  22806. var stubFalse_1 = stubFalse;
  22807. (function (module, exports) {
  22808. var root = _root,
  22809. stubFalse = stubFalse_1;
  22810. /** Detect free variable `exports`. */
  22811. var freeExports = exports && !exports.nodeType && exports;
  22812. /** Detect free variable `module`. */
  22813. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  22814. /** Detect the popular CommonJS extension `module.exports`. */
  22815. var moduleExports = freeModule && freeModule.exports === freeExports;
  22816. /** Built-in value references. */
  22817. var Buffer = moduleExports ? root.Buffer : undefined;
  22818. /* Built-in method references for those with the same name as other `lodash` methods. */
  22819. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  22820. /**
  22821. * Checks if `value` is a buffer.
  22822. *
  22823. * @static
  22824. * @memberOf _
  22825. * @since 4.3.0
  22826. * @category Lang
  22827. * @param {*} value The value to check.
  22828. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  22829. * @example
  22830. *
  22831. * _.isBuffer(new Buffer(2));
  22832. * // => true
  22833. *
  22834. * _.isBuffer(new Uint8Array(2));
  22835. * // => false
  22836. */
  22837. var isBuffer = nativeIsBuffer || stubFalse;
  22838. module.exports = isBuffer;
  22839. })(isBuffer$2, isBuffer$2.exports);
  22840. /** Used as references for various `Number` constants. */
  22841. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  22842. /** Used to detect unsigned integer values. */
  22843. var reIsUint = /^(?:0|[1-9]\d*)$/;
  22844. /**
  22845. * Checks if `value` is a valid array-like index.
  22846. *
  22847. * @private
  22848. * @param {*} value The value to check.
  22849. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22850. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22851. */
  22852. function isIndex$2(value, length) {
  22853. var type = typeof value;
  22854. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  22855. return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  22856. }
  22857. var _isIndex = isIndex$2;
  22858. /** Used as references for various `Number` constants. */
  22859. var MAX_SAFE_INTEGER = 9007199254740991;
  22860. /**
  22861. * Checks if `value` is a valid array-like length.
  22862. *
  22863. * **Note:** This method is loosely based on
  22864. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  22865. *
  22866. * @static
  22867. * @memberOf _
  22868. * @since 4.0.0
  22869. * @category Lang
  22870. * @param {*} value The value to check.
  22871. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  22872. * @example
  22873. *
  22874. * _.isLength(3);
  22875. * // => true
  22876. *
  22877. * _.isLength(Number.MIN_VALUE);
  22878. * // => false
  22879. *
  22880. * _.isLength(Infinity);
  22881. * // => false
  22882. *
  22883. * _.isLength('3');
  22884. * // => false
  22885. */
  22886. function isLength$3(value) {
  22887. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  22888. }
  22889. var isLength_1 = isLength$3;
  22890. var baseGetTag$2 = _baseGetTag,
  22891. isLength$2 = isLength_1,
  22892. isObjectLike$2 = isObjectLike_1;
  22893. /** `Object#toString` result references. */
  22894. var argsTag$1 = '[object Arguments]',
  22895. arrayTag$1 = '[object Array]',
  22896. boolTag = '[object Boolean]',
  22897. dateTag = '[object Date]',
  22898. errorTag = '[object Error]',
  22899. funcTag = '[object Function]',
  22900. mapTag$1 = '[object Map]',
  22901. numberTag = '[object Number]',
  22902. objectTag$2 = '[object Object]',
  22903. regexpTag = '[object RegExp]',
  22904. setTag$1 = '[object Set]',
  22905. stringTag = '[object String]',
  22906. weakMapTag$1 = '[object WeakMap]';
  22907. var arrayBufferTag = '[object ArrayBuffer]',
  22908. dataViewTag$1 = '[object DataView]',
  22909. float32Tag = '[object Float32Array]',
  22910. float64Tag = '[object Float64Array]',
  22911. int8Tag = '[object Int8Array]',
  22912. int16Tag = '[object Int16Array]',
  22913. int32Tag = '[object Int32Array]',
  22914. uint8Tag = '[object Uint8Array]',
  22915. uint8ClampedTag = '[object Uint8ClampedArray]',
  22916. uint16Tag = '[object Uint16Array]',
  22917. uint32Tag = '[object Uint32Array]';
  22918. /** Used to identify `toStringTag` values of typed arrays. */
  22919. var typedArrayTags = {};
  22920. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  22921. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
  22922. /**
  22923. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  22924. *
  22925. * @private
  22926. * @param {*} value The value to check.
  22927. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  22928. */
  22929. function baseIsTypedArray$1(value) {
  22930. return isObjectLike$2(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$2(value)];
  22931. }
  22932. var _baseIsTypedArray = baseIsTypedArray$1;
  22933. /**
  22934. * The base implementation of `_.unary` without support for storing metadata.
  22935. *
  22936. * @private
  22937. * @param {Function} func The function to cap arguments for.
  22938. * @returns {Function} Returns the new capped function.
  22939. */
  22940. function baseUnary$1(func) {
  22941. return function (value) {
  22942. return func(value);
  22943. };
  22944. }
  22945. var _baseUnary = baseUnary$1;
  22946. var _nodeUtil = {exports: {}};
  22947. (function (module, exports) {
  22948. var freeGlobal = _freeGlobal;
  22949. /** Detect free variable `exports`. */
  22950. var freeExports = exports && !exports.nodeType && exports;
  22951. /** Detect free variable `module`. */
  22952. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  22953. /** Detect the popular CommonJS extension `module.exports`. */
  22954. var moduleExports = freeModule && freeModule.exports === freeExports;
  22955. /** Detect free variable `process` from Node.js. */
  22956. var freeProcess = moduleExports && freeGlobal.process;
  22957. /** Used to access faster Node.js helpers. */
  22958. var nodeUtil = function () {
  22959. try {
  22960. // Use `util.types` for Node.js 10+.
  22961. var types = freeModule && freeModule.require && freeModule.require('util').types;
  22962. if (types) {
  22963. return types;
  22964. } // Legacy `process.binding('util')` for Node.js < 10.
  22965. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  22966. } catch (e) {}
  22967. }();
  22968. module.exports = nodeUtil;
  22969. })(_nodeUtil, _nodeUtil.exports);
  22970. var baseIsTypedArray = _baseIsTypedArray,
  22971. baseUnary = _baseUnary,
  22972. nodeUtil = _nodeUtil.exports;
  22973. /* Node.js helper references. */
  22974. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  22975. /**
  22976. * Checks if `value` is classified as a typed array.
  22977. *
  22978. * @static
  22979. * @memberOf _
  22980. * @since 3.0.0
  22981. * @category Lang
  22982. * @param {*} value The value to check.
  22983. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  22984. * @example
  22985. *
  22986. * _.isTypedArray(new Uint8Array);
  22987. * // => true
  22988. *
  22989. * _.isTypedArray([]);
  22990. * // => false
  22991. */
  22992. var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  22993. var isTypedArray_1 = isTypedArray$2;
  22994. var baseTimes = _baseTimes,
  22995. isArguments$1 = isArguments_1,
  22996. isArray$7 = isArray_1,
  22997. isBuffer$1 = isBuffer$2.exports,
  22998. isIndex$1 = _isIndex,
  22999. isTypedArray$1 = isTypedArray_1;
  23000. /** Used for built-in method references. */
  23001. var objectProto$4 = Object.prototype;
  23002. /** Used to check objects for own properties. */
  23003. var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
  23004. /**
  23005. * Creates an array of the enumerable property names of the array-like `value`.
  23006. *
  23007. * @private
  23008. * @param {*} value The value to query.
  23009. * @param {boolean} inherited Specify returning inherited property names.
  23010. * @returns {Array} Returns the array of property names.
  23011. */
  23012. function arrayLikeKeys$1(value, inherited) {
  23013. var isArr = isArray$7(value),
  23014. isArg = !isArr && isArguments$1(value),
  23015. isBuff = !isArr && !isArg && isBuffer$1(value),
  23016. isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
  23017. skipIndexes = isArr || isArg || isBuff || isType,
  23018. result = skipIndexes ? baseTimes(value.length, String) : [],
  23019. length = result.length;
  23020. for (var key in value) {
  23021. if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
  23022. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
  23023. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
  23024. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
  23025. isIndex$1(key, length)))) {
  23026. result.push(key);
  23027. }
  23028. }
  23029. return result;
  23030. }
  23031. var _arrayLikeKeys = arrayLikeKeys$1;
  23032. /** Used for built-in method references. */
  23033. var objectProto$3 = Object.prototype;
  23034. /**
  23035. * Checks if `value` is likely a prototype object.
  23036. *
  23037. * @private
  23038. * @param {*} value The value to check.
  23039. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23040. */
  23041. function isPrototype$1(value) {
  23042. var Ctor = value && value.constructor,
  23043. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$3;
  23044. return value === proto;
  23045. }
  23046. var _isPrototype = isPrototype$1;
  23047. /**
  23048. * Creates a unary function that invokes `func` with its argument transformed.
  23049. *
  23050. * @private
  23051. * @param {Function} func The function to wrap.
  23052. * @param {Function} transform The argument transform.
  23053. * @returns {Function} Returns the new function.
  23054. */
  23055. function overArg$1(func, transform) {
  23056. return function (arg) {
  23057. return func(transform(arg));
  23058. };
  23059. }
  23060. var _overArg = overArg$1;
  23061. var overArg = _overArg;
  23062. /* Built-in method references for those with the same name as other `lodash` methods. */
  23063. var nativeKeys$1 = overArg(Object.keys, Object);
  23064. var _nativeKeys = nativeKeys$1;
  23065. var isPrototype = _isPrototype,
  23066. nativeKeys = _nativeKeys;
  23067. /** Used for built-in method references. */
  23068. var objectProto$2 = Object.prototype;
  23069. /** Used to check objects for own properties. */
  23070. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  23071. /**
  23072. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  23073. *
  23074. * @private
  23075. * @param {Object} object The object to query.
  23076. * @returns {Array} Returns the array of property names.
  23077. */
  23078. function baseKeys$1(object) {
  23079. if (!isPrototype(object)) {
  23080. return nativeKeys(object);
  23081. }
  23082. var result = [];
  23083. for (var key in Object(object)) {
  23084. if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
  23085. result.push(key);
  23086. }
  23087. }
  23088. return result;
  23089. }
  23090. var _baseKeys = baseKeys$1;
  23091. var isFunction = isFunction_1,
  23092. isLength$1 = isLength_1;
  23093. /**
  23094. * Checks if `value` is array-like. A value is considered array-like if it's
  23095. * not a function and has a `value.length` that's an integer greater than or
  23096. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  23097. *
  23098. * @static
  23099. * @memberOf _
  23100. * @since 4.0.0
  23101. * @category Lang
  23102. * @param {*} value The value to check.
  23103. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  23104. * @example
  23105. *
  23106. * _.isArrayLike([1, 2, 3]);
  23107. * // => true
  23108. *
  23109. * _.isArrayLike(document.body.children);
  23110. * // => true
  23111. *
  23112. * _.isArrayLike('abc');
  23113. * // => true
  23114. *
  23115. * _.isArrayLike(_.noop);
  23116. * // => false
  23117. */
  23118. function isArrayLike$2(value) {
  23119. return value != null && isLength$1(value.length) && !isFunction(value);
  23120. }
  23121. var isArrayLike_1 = isArrayLike$2;
  23122. var arrayLikeKeys = _arrayLikeKeys,
  23123. baseKeys = _baseKeys,
  23124. isArrayLike$1 = isArrayLike_1;
  23125. /**
  23126. * Creates an array of the own enumerable property names of `object`.
  23127. *
  23128. * **Note:** Non-object values are coerced to objects. See the
  23129. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23130. * for more details.
  23131. *
  23132. * @static
  23133. * @since 0.1.0
  23134. * @memberOf _
  23135. * @category Object
  23136. * @param {Object} object The object to query.
  23137. * @returns {Array} Returns the array of property names.
  23138. * @example
  23139. *
  23140. * function Foo() {
  23141. * this.a = 1;
  23142. * this.b = 2;
  23143. * }
  23144. *
  23145. * Foo.prototype.c = 3;
  23146. *
  23147. * _.keys(new Foo);
  23148. * // => ['a', 'b'] (iteration order is not guaranteed)
  23149. *
  23150. * _.keys('hi');
  23151. * // => ['0', '1']
  23152. */
  23153. function keys$3(object) {
  23154. return isArrayLike$1(object) ? arrayLikeKeys(object) : baseKeys(object);
  23155. }
  23156. var keys_1 = keys$3;
  23157. var baseGetAllKeys = _baseGetAllKeys,
  23158. getSymbols = _getSymbols,
  23159. keys$2 = keys_1;
  23160. /**
  23161. * Creates an array of own enumerable property names and symbols of `object`.
  23162. *
  23163. * @private
  23164. * @param {Object} object The object to query.
  23165. * @returns {Array} Returns the array of property names and symbols.
  23166. */
  23167. function getAllKeys$1(object) {
  23168. return baseGetAllKeys(object, keys$2, getSymbols);
  23169. }
  23170. var _getAllKeys = getAllKeys$1;
  23171. var getAllKeys = _getAllKeys;
  23172. /** Used to compose bitmasks for value comparisons. */
  23173. var COMPARE_PARTIAL_FLAG$3 = 1;
  23174. /** Used for built-in method references. */
  23175. var objectProto$1 = Object.prototype;
  23176. /** Used to check objects for own properties. */
  23177. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  23178. /**
  23179. * A specialized version of `baseIsEqualDeep` for objects with support for
  23180. * partial deep comparisons.
  23181. *
  23182. * @private
  23183. * @param {Object} object The object to compare.
  23184. * @param {Object} other The other object to compare.
  23185. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23186. * @param {Function} customizer The function to customize comparisons.
  23187. * @param {Function} equalFunc The function to determine equivalents of values.
  23188. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23189. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23190. */
  23191. function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
  23192. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
  23193. objProps = getAllKeys(object),
  23194. objLength = objProps.length,
  23195. othProps = getAllKeys(other),
  23196. othLength = othProps.length;
  23197. if (objLength != othLength && !isPartial) {
  23198. return false;
  23199. }
  23200. var index = objLength;
  23201. while (index--) {
  23202. var key = objProps[index];
  23203. if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
  23204. return false;
  23205. }
  23206. } // Check that cyclic values are equal.
  23207. var objStacked = stack.get(object);
  23208. var othStacked = stack.get(other);
  23209. if (objStacked && othStacked) {
  23210. return objStacked == other && othStacked == object;
  23211. }
  23212. var result = true;
  23213. stack.set(object, other);
  23214. stack.set(other, object);
  23215. var skipCtor = isPartial;
  23216. while (++index < objLength) {
  23217. key = objProps[index];
  23218. var objValue = object[key],
  23219. othValue = other[key];
  23220. if (customizer) {
  23221. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  23222. } // Recursively compare objects (susceptible to call stack limits).
  23223. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
  23224. result = false;
  23225. break;
  23226. }
  23227. skipCtor || (skipCtor = key == 'constructor');
  23228. }
  23229. if (result && !skipCtor) {
  23230. var objCtor = object.constructor,
  23231. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  23232. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23233. result = false;
  23234. }
  23235. }
  23236. stack['delete'](object);
  23237. stack['delete'](other);
  23238. return result;
  23239. }
  23240. var _equalObjects = equalObjects$1;
  23241. var getNative$3 = _getNative,
  23242. root$3 = _root;
  23243. /* Built-in method references that are verified to be native. */
  23244. var DataView$1 = getNative$3(root$3, 'DataView');
  23245. var _DataView = DataView$1;
  23246. var getNative$2 = _getNative,
  23247. root$2 = _root;
  23248. /* Built-in method references that are verified to be native. */
  23249. var Promise$2 = getNative$2(root$2, 'Promise');
  23250. var _Promise = Promise$2;
  23251. var getNative$1 = _getNative,
  23252. root$1 = _root;
  23253. /* Built-in method references that are verified to be native. */
  23254. var Set$3 = getNative$1(root$1, 'Set');
  23255. var _Set = Set$3;
  23256. var getNative = _getNative,
  23257. root = _root;
  23258. /* Built-in method references that are verified to be native. */
  23259. var WeakMap$2 = getNative(root, 'WeakMap');
  23260. var _WeakMap = WeakMap$2;
  23261. var DataView = _DataView,
  23262. Map$1 = _Map,
  23263. Promise$1 = _Promise,
  23264. Set$2 = _Set,
  23265. WeakMap$1 = _WeakMap,
  23266. baseGetTag$1 = _baseGetTag,
  23267. toSource = _toSource;
  23268. /** `Object#toString` result references. */
  23269. var mapTag = '[object Map]',
  23270. objectTag$1 = '[object Object]',
  23271. promiseTag = '[object Promise]',
  23272. setTag = '[object Set]',
  23273. weakMapTag = '[object WeakMap]';
  23274. var dataViewTag = '[object DataView]';
  23275. /** Used to detect maps, sets, and weakmaps. */
  23276. var dataViewCtorString = toSource(DataView),
  23277. mapCtorString = toSource(Map$1),
  23278. promiseCtorString = toSource(Promise$1),
  23279. setCtorString = toSource(Set$2),
  23280. weakMapCtorString = toSource(WeakMap$1);
  23281. /**
  23282. * Gets the `toStringTag` of `value`.
  23283. *
  23284. * @private
  23285. * @param {*} value The value to query.
  23286. * @returns {string} Returns the `toStringTag`.
  23287. */
  23288. var getTag$1 = baseGetTag$1; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23289. if (DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag$1(new Map$1()) != mapTag || Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag || Set$2 && getTag$1(new Set$2()) != setTag || WeakMap$1 && getTag$1(new WeakMap$1()) != weakMapTag) {
  23290. getTag$1 = function (value) {
  23291. var result = baseGetTag$1(value),
  23292. Ctor = result == objectTag$1 ? value.constructor : undefined,
  23293. ctorString = Ctor ? toSource(Ctor) : '';
  23294. if (ctorString) {
  23295. switch (ctorString) {
  23296. case dataViewCtorString:
  23297. return dataViewTag;
  23298. case mapCtorString:
  23299. return mapTag;
  23300. case promiseCtorString:
  23301. return promiseTag;
  23302. case setCtorString:
  23303. return setTag;
  23304. case weakMapCtorString:
  23305. return weakMapTag;
  23306. }
  23307. }
  23308. return result;
  23309. };
  23310. }
  23311. var _getTag = getTag$1;
  23312. var Stack$1 = _Stack,
  23313. equalArrays = _equalArrays,
  23314. equalByTag = _equalByTag,
  23315. equalObjects = _equalObjects,
  23316. getTag = _getTag,
  23317. isArray$6 = isArray_1,
  23318. isBuffer = isBuffer$2.exports,
  23319. isTypedArray = isTypedArray_1;
  23320. /** Used to compose bitmasks for value comparisons. */
  23321. var COMPARE_PARTIAL_FLAG$2 = 1;
  23322. /** `Object#toString` result references. */
  23323. var argsTag = '[object Arguments]',
  23324. arrayTag = '[object Array]',
  23325. objectTag = '[object Object]';
  23326. /** Used for built-in method references. */
  23327. var objectProto = Object.prototype;
  23328. /** Used to check objects for own properties. */
  23329. var hasOwnProperty = objectProto.hasOwnProperty;
  23330. /**
  23331. * A specialized version of `baseIsEqual` for arrays and objects which performs
  23332. * deep comparisons and tracks traversed objects enabling objects with circular
  23333. * references to be compared.
  23334. *
  23335. * @private
  23336. * @param {Object} object The object to compare.
  23337. * @param {Object} other The other object to compare.
  23338. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23339. * @param {Function} customizer The function to customize comparisons.
  23340. * @param {Function} equalFunc The function to determine equivalents of values.
  23341. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  23342. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23343. */
  23344. function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
  23345. var objIsArr = isArray$6(object),
  23346. othIsArr = isArray$6(other),
  23347. objTag = objIsArr ? arrayTag : getTag(object),
  23348. othTag = othIsArr ? arrayTag : getTag(other);
  23349. objTag = objTag == argsTag ? objectTag : objTag;
  23350. othTag = othTag == argsTag ? objectTag : othTag;
  23351. var objIsObj = objTag == objectTag,
  23352. othIsObj = othTag == objectTag,
  23353. isSameTag = objTag == othTag;
  23354. if (isSameTag && isBuffer(object)) {
  23355. if (!isBuffer(other)) {
  23356. return false;
  23357. }
  23358. objIsArr = true;
  23359. objIsObj = false;
  23360. }
  23361. if (isSameTag && !objIsObj) {
  23362. stack || (stack = new Stack$1());
  23363. return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  23364. }
  23365. if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
  23366. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  23367. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  23368. if (objIsWrapped || othIsWrapped) {
  23369. var objUnwrapped = objIsWrapped ? object.value() : object,
  23370. othUnwrapped = othIsWrapped ? other.value() : other;
  23371. stack || (stack = new Stack$1());
  23372. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  23373. }
  23374. }
  23375. if (!isSameTag) {
  23376. return false;
  23377. }
  23378. stack || (stack = new Stack$1());
  23379. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  23380. }
  23381. var _baseIsEqualDeep = baseIsEqualDeep$1;
  23382. var baseIsEqualDeep = _baseIsEqualDeep,
  23383. isObjectLike$1 = isObjectLike_1;
  23384. /**
  23385. * The base implementation of `_.isEqual` which supports partial comparisons
  23386. * and tracks traversed objects.
  23387. *
  23388. * @private
  23389. * @param {*} value The value to compare.
  23390. * @param {*} other The other value to compare.
  23391. * @param {boolean} bitmask The bitmask flags.
  23392. * 1 - Unordered comparison
  23393. * 2 - Partial comparison
  23394. * @param {Function} [customizer] The function to customize comparisons.
  23395. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  23396. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  23397. */
  23398. function baseIsEqual$2(value, other, bitmask, customizer, stack) {
  23399. if (value === other) {
  23400. return true;
  23401. }
  23402. if (value == null || other == null || !isObjectLike$1(value) && !isObjectLike$1(other)) {
  23403. return value !== value && other !== other;
  23404. }
  23405. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
  23406. }
  23407. var _baseIsEqual = baseIsEqual$2;
  23408. var Stack = _Stack,
  23409. baseIsEqual$1 = _baseIsEqual;
  23410. /** Used to compose bitmasks for value comparisons. */
  23411. var COMPARE_PARTIAL_FLAG$1 = 1,
  23412. COMPARE_UNORDERED_FLAG$1 = 2;
  23413. /**
  23414. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  23415. *
  23416. * @private
  23417. * @param {Object} object The object to inspect.
  23418. * @param {Object} source The object of property values to match.
  23419. * @param {Array} matchData The property names, values, and compare flags to match.
  23420. * @param {Function} [customizer] The function to customize comparisons.
  23421. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  23422. */
  23423. function baseIsMatch$1(object, source, matchData, customizer) {
  23424. var index = matchData.length,
  23425. length = index,
  23426. noCustomizer = !customizer;
  23427. if (object == null) {
  23428. return !length;
  23429. }
  23430. object = Object(object);
  23431. while (index--) {
  23432. var data = matchData[index];
  23433. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  23434. return false;
  23435. }
  23436. }
  23437. while (++index < length) {
  23438. data = matchData[index];
  23439. var key = data[0],
  23440. objValue = object[key],
  23441. srcValue = data[1];
  23442. if (noCustomizer && data[2]) {
  23443. if (objValue === undefined && !(key in object)) {
  23444. return false;
  23445. }
  23446. } else {
  23447. var stack = new Stack();
  23448. if (customizer) {
  23449. var result = customizer(objValue, srcValue, key, object, source, stack);
  23450. }
  23451. if (!(result === undefined ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
  23452. return false;
  23453. }
  23454. }
  23455. }
  23456. return true;
  23457. }
  23458. var _baseIsMatch = baseIsMatch$1;
  23459. var isObject$2 = isObject_1;
  23460. /**
  23461. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23462. *
  23463. * @private
  23464. * @param {*} value The value to check.
  23465. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23466. * equality comparisons, else `false`.
  23467. */
  23468. function isStrictComparable$2(value) {
  23469. return value === value && !isObject$2(value);
  23470. }
  23471. var _isStrictComparable = isStrictComparable$2;
  23472. var isStrictComparable$1 = _isStrictComparable,
  23473. keys$1 = keys_1;
  23474. /**
  23475. * Gets the property names, values, and compare flags of `object`.
  23476. *
  23477. * @private
  23478. * @param {Object} object The object to query.
  23479. * @returns {Array} Returns the match data of `object`.
  23480. */
  23481. function getMatchData$1(object) {
  23482. var result = keys$1(object),
  23483. length = result.length;
  23484. while (length--) {
  23485. var key = result[length],
  23486. value = object[key];
  23487. result[length] = [key, value, isStrictComparable$1(value)];
  23488. }
  23489. return result;
  23490. }
  23491. var _getMatchData = getMatchData$1;
  23492. /**
  23493. * A specialized version of `matchesProperty` for source values suitable
  23494. * for strict equality comparisons, i.e. `===`.
  23495. *
  23496. * @private
  23497. * @param {string} key The key of the property to get.
  23498. * @param {*} srcValue The value to match.
  23499. * @returns {Function} Returns the new spec function.
  23500. */
  23501. function matchesStrictComparable$2(key, srcValue) {
  23502. return function (object) {
  23503. if (object == null) {
  23504. return false;
  23505. }
  23506. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  23507. };
  23508. }
  23509. var _matchesStrictComparable = matchesStrictComparable$2;
  23510. var baseIsMatch = _baseIsMatch,
  23511. getMatchData = _getMatchData,
  23512. matchesStrictComparable$1 = _matchesStrictComparable;
  23513. /**
  23514. * The base implementation of `_.matches` which doesn't clone `source`.
  23515. *
  23516. * @private
  23517. * @param {Object} source The object of property values to match.
  23518. * @returns {Function} Returns the new spec function.
  23519. */
  23520. function baseMatches$1(source) {
  23521. var matchData = getMatchData(source);
  23522. if (matchData.length == 1 && matchData[0][2]) {
  23523. return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
  23524. }
  23525. return function (object) {
  23526. return object === source || baseIsMatch(object, source, matchData);
  23527. };
  23528. }
  23529. var _baseMatches = baseMatches$1;
  23530. var baseGetTag = _baseGetTag,
  23531. isObjectLike = isObjectLike_1;
  23532. /** `Object#toString` result references. */
  23533. var symbolTag = '[object Symbol]';
  23534. /**
  23535. * Checks if `value` is classified as a `Symbol` primitive or object.
  23536. *
  23537. * @static
  23538. * @memberOf _
  23539. * @since 4.0.0
  23540. * @category Lang
  23541. * @param {*} value The value to check.
  23542. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  23543. * @example
  23544. *
  23545. * _.isSymbol(Symbol.iterator);
  23546. * // => true
  23547. *
  23548. * _.isSymbol('abc');
  23549. * // => false
  23550. */
  23551. function isSymbol$3(value) {
  23552. return typeof value == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
  23553. }
  23554. var isSymbol_1 = isSymbol$3;
  23555. var isArray$5 = isArray_1,
  23556. isSymbol$2 = isSymbol_1;
  23557. /** Used to match property names within property paths. */
  23558. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  23559. reIsPlainProp = /^\w*$/;
  23560. /**
  23561. * Checks if `value` is a property name and not a property path.
  23562. *
  23563. * @private
  23564. * @param {*} value The value to check.
  23565. * @param {Object} [object] The object to query keys on.
  23566. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23567. */
  23568. function isKey$3(value, object) {
  23569. if (isArray$5(value)) {
  23570. return false;
  23571. }
  23572. var type = typeof value;
  23573. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
  23574. return true;
  23575. }
  23576. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  23577. }
  23578. var _isKey = isKey$3;
  23579. var MapCache = _MapCache;
  23580. /** Error message constants. */
  23581. var FUNC_ERROR_TEXT = 'Expected a function';
  23582. /**
  23583. * Creates a function that memoizes the result of `func`. If `resolver` is
  23584. * provided, it determines the cache key for storing the result based on the
  23585. * arguments provided to the memoized function. By default, the first argument
  23586. * provided to the memoized function is used as the map cache key. The `func`
  23587. * is invoked with the `this` binding of the memoized function.
  23588. *
  23589. * **Note:** The cache is exposed as the `cache` property on the memoized
  23590. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  23591. * constructor with one whose instances implement the
  23592. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  23593. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  23594. *
  23595. * @static
  23596. * @memberOf _
  23597. * @since 0.1.0
  23598. * @category Function
  23599. * @param {Function} func The function to have its output memoized.
  23600. * @param {Function} [resolver] The function to resolve the cache key.
  23601. * @returns {Function} Returns the new memoized function.
  23602. * @example
  23603. *
  23604. * var object = { 'a': 1, 'b': 2 };
  23605. * var other = { 'c': 3, 'd': 4 };
  23606. *
  23607. * var values = _.memoize(_.values);
  23608. * values(object);
  23609. * // => [1, 2]
  23610. *
  23611. * values(other);
  23612. * // => [3, 4]
  23613. *
  23614. * object.a = 2;
  23615. * values(object);
  23616. * // => [1, 2]
  23617. *
  23618. * // Modify the result cache.
  23619. * values.cache.set(object, ['a', 'b']);
  23620. * values(object);
  23621. * // => ['a', 'b']
  23622. *
  23623. * // Replace `_.memoize.Cache`.
  23624. * _.memoize.Cache = WeakMap;
  23625. */
  23626. function memoize$1(func, resolver) {
  23627. if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
  23628. throw new TypeError(FUNC_ERROR_TEXT);
  23629. }
  23630. var memoized = function () {
  23631. var args = arguments,
  23632. key = resolver ? resolver.apply(this, args) : args[0],
  23633. cache = memoized.cache;
  23634. if (cache.has(key)) {
  23635. return cache.get(key);
  23636. }
  23637. var result = func.apply(this, args);
  23638. memoized.cache = cache.set(key, result) || cache;
  23639. return result;
  23640. };
  23641. memoized.cache = new (memoize$1.Cache || MapCache)();
  23642. return memoized;
  23643. } // Expose `MapCache`.
  23644. memoize$1.Cache = MapCache;
  23645. var memoize_1 = memoize$1;
  23646. var memoize = memoize_1;
  23647. /** Used as the maximum memoize cache size. */
  23648. var MAX_MEMOIZE_SIZE = 500;
  23649. /**
  23650. * A specialized version of `_.memoize` which clears the memoized function's
  23651. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23652. *
  23653. * @private
  23654. * @param {Function} func The function to have its output memoized.
  23655. * @returns {Function} Returns the new memoized function.
  23656. */
  23657. function memoizeCapped$1(func) {
  23658. var result = memoize(func, function (key) {
  23659. if (cache.size === MAX_MEMOIZE_SIZE) {
  23660. cache.clear();
  23661. }
  23662. return key;
  23663. });
  23664. var cache = result.cache;
  23665. return result;
  23666. }
  23667. var _memoizeCapped = memoizeCapped$1;
  23668. var memoizeCapped = _memoizeCapped;
  23669. /** Used to match property names within property paths. */
  23670. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  23671. /** Used to match backslashes in property paths. */
  23672. var reEscapeChar = /\\(\\)?/g;
  23673. /**
  23674. * Converts `string` to a property path array.
  23675. *
  23676. * @private
  23677. * @param {string} string The string to convert.
  23678. * @returns {Array} Returns the property path array.
  23679. */
  23680. var stringToPath$1 = memoizeCapped(function (string) {
  23681. var result = [];
  23682. if (string.charCodeAt(0) === 46
  23683. /* . */
  23684. ) {
  23685. result.push('');
  23686. }
  23687. string.replace(rePropName, function (match, number, quote, subString) {
  23688. result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
  23689. });
  23690. return result;
  23691. });
  23692. var _stringToPath = stringToPath$1;
  23693. /**
  23694. * A specialized version of `_.map` for arrays without support for iteratee
  23695. * shorthands.
  23696. *
  23697. * @private
  23698. * @param {Array} [array] The array to iterate over.
  23699. * @param {Function} iteratee The function invoked per iteration.
  23700. * @returns {Array} Returns the new mapped array.
  23701. */
  23702. function arrayMap$1(array, iteratee) {
  23703. var index = -1,
  23704. length = array == null ? 0 : array.length,
  23705. result = Array(length);
  23706. while (++index < length) {
  23707. result[index] = iteratee(array[index], index, array);
  23708. }
  23709. return result;
  23710. }
  23711. var _arrayMap = arrayMap$1;
  23712. var Symbol$1 = _Symbol,
  23713. arrayMap = _arrayMap,
  23714. isArray$4 = isArray_1,
  23715. isSymbol$1 = isSymbol_1;
  23716. /** Used as references for various `Number` constants. */
  23717. var INFINITY$2 = 1 / 0;
  23718. /** Used to convert symbols to primitives and strings. */
  23719. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
  23720. symbolToString = symbolProto ? symbolProto.toString : undefined;
  23721. /**
  23722. * The base implementation of `_.toString` which doesn't convert nullish
  23723. * values to empty strings.
  23724. *
  23725. * @private
  23726. * @param {*} value The value to process.
  23727. * @returns {string} Returns the string.
  23728. */
  23729. function baseToString$1(value) {
  23730. // Exit early for strings to avoid a performance hit in some environments.
  23731. if (typeof value == 'string') {
  23732. return value;
  23733. }
  23734. if (isArray$4(value)) {
  23735. // Recursively convert values (susceptible to call stack limits).
  23736. return arrayMap(value, baseToString$1) + '';
  23737. }
  23738. if (isSymbol$1(value)) {
  23739. return symbolToString ? symbolToString.call(value) : '';
  23740. }
  23741. var result = value + '';
  23742. return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result;
  23743. }
  23744. var _baseToString = baseToString$1;
  23745. var baseToString = _baseToString;
  23746. /**
  23747. * Converts `value` to a string. An empty string is returned for `null`
  23748. * and `undefined` values. The sign of `-0` is preserved.
  23749. *
  23750. * @static
  23751. * @memberOf _
  23752. * @since 4.0.0
  23753. * @category Lang
  23754. * @param {*} value The value to convert.
  23755. * @returns {string} Returns the converted string.
  23756. * @example
  23757. *
  23758. * _.toString(null);
  23759. * // => ''
  23760. *
  23761. * _.toString(-0);
  23762. * // => '-0'
  23763. *
  23764. * _.toString([1, 2, 3]);
  23765. * // => '1,2,3'
  23766. */
  23767. function toString$1(value) {
  23768. return value == null ? '' : baseToString(value);
  23769. }
  23770. var toString_1 = toString$1;
  23771. var isArray$3 = isArray_1,
  23772. isKey$2 = _isKey,
  23773. stringToPath = _stringToPath,
  23774. toString = toString_1;
  23775. /**
  23776. * Casts `value` to a path array if it's not one.
  23777. *
  23778. * @private
  23779. * @param {*} value The value to inspect.
  23780. * @param {Object} [object] The object to query keys on.
  23781. * @returns {Array} Returns the cast property path array.
  23782. */
  23783. function castPath$2(value, object) {
  23784. if (isArray$3(value)) {
  23785. return value;
  23786. }
  23787. return isKey$2(value, object) ? [value] : stringToPath(toString(value));
  23788. }
  23789. var _castPath = castPath$2;
  23790. var isSymbol = isSymbol_1;
  23791. /** Used as references for various `Number` constants. */
  23792. var INFINITY$1 = 1 / 0;
  23793. /**
  23794. * Converts `value` to a string key if it's not a string or symbol.
  23795. *
  23796. * @private
  23797. * @param {*} value The value to inspect.
  23798. * @returns {string|symbol} Returns the key.
  23799. */
  23800. function toKey$4(value) {
  23801. if (typeof value == 'string' || isSymbol(value)) {
  23802. return value;
  23803. }
  23804. var result = value + '';
  23805. return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
  23806. }
  23807. var _toKey = toKey$4;
  23808. var castPath$1 = _castPath,
  23809. toKey$3 = _toKey;
  23810. /**
  23811. * The base implementation of `_.get` without support for default values.
  23812. *
  23813. * @private
  23814. * @param {Object} object The object to query.
  23815. * @param {Array|string} path The path of the property to get.
  23816. * @returns {*} Returns the resolved value.
  23817. */
  23818. function baseGet$2(object, path) {
  23819. path = castPath$1(path, object);
  23820. var index = 0,
  23821. length = path.length;
  23822. while (object != null && index < length) {
  23823. object = object[toKey$3(path[index++])];
  23824. }
  23825. return index && index == length ? object : undefined;
  23826. }
  23827. var _baseGet = baseGet$2;
  23828. var baseGet$1 = _baseGet;
  23829. /**
  23830. * Gets the value at `path` of `object`. If the resolved value is
  23831. * `undefined`, the `defaultValue` is returned in its place.
  23832. *
  23833. * @static
  23834. * @memberOf _
  23835. * @since 3.7.0
  23836. * @category Object
  23837. * @param {Object} object The object to query.
  23838. * @param {Array|string} path The path of the property to get.
  23839. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  23840. * @returns {*} Returns the resolved value.
  23841. * @example
  23842. *
  23843. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  23844. *
  23845. * _.get(object, 'a[0].b.c');
  23846. * // => 3
  23847. *
  23848. * _.get(object, ['a', '0', 'b', 'c']);
  23849. * // => 3
  23850. *
  23851. * _.get(object, 'a.b.c', 'default');
  23852. * // => 'default'
  23853. */
  23854. function get$1(object, path, defaultValue) {
  23855. var result = object == null ? undefined : baseGet$1(object, path);
  23856. return result === undefined ? defaultValue : result;
  23857. }
  23858. var get_1 = get$1;
  23859. /**
  23860. * The base implementation of `_.hasIn` without support for deep paths.
  23861. *
  23862. * @private
  23863. * @param {Object} [object] The object to query.
  23864. * @param {Array|string} key The key to check.
  23865. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  23866. */
  23867. function baseHasIn$1(object, key) {
  23868. return object != null && key in Object(object);
  23869. }
  23870. var _baseHasIn = baseHasIn$1;
  23871. var castPath = _castPath,
  23872. isArguments = isArguments_1,
  23873. isArray$2 = isArray_1,
  23874. isIndex = _isIndex,
  23875. isLength = isLength_1,
  23876. toKey$2 = _toKey;
  23877. /**
  23878. * Checks if `path` exists on `object`.
  23879. *
  23880. * @private
  23881. * @param {Object} object The object to query.
  23882. * @param {Array|string} path The path to check.
  23883. * @param {Function} hasFunc The function to check properties.
  23884. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23885. */
  23886. function hasPath$1(object, path, hasFunc) {
  23887. path = castPath(path, object);
  23888. var index = -1,
  23889. length = path.length,
  23890. result = false;
  23891. while (++index < length) {
  23892. var key = toKey$2(path[index]);
  23893. if (!(result = object != null && hasFunc(object, key))) {
  23894. break;
  23895. }
  23896. object = object[key];
  23897. }
  23898. if (result || ++index != length) {
  23899. return result;
  23900. }
  23901. length = object == null ? 0 : object.length;
  23902. return !!length && isLength(length) && isIndex(key, length) && (isArray$2(object) || isArguments(object));
  23903. }
  23904. var _hasPath = hasPath$1;
  23905. var baseHasIn = _baseHasIn,
  23906. hasPath = _hasPath;
  23907. /**
  23908. * Checks if `path` is a direct or inherited property of `object`.
  23909. *
  23910. * @static
  23911. * @memberOf _
  23912. * @since 4.0.0
  23913. * @category Object
  23914. * @param {Object} object The object to query.
  23915. * @param {Array|string} path The path to check.
  23916. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23917. * @example
  23918. *
  23919. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  23920. *
  23921. * _.hasIn(object, 'a');
  23922. * // => true
  23923. *
  23924. * _.hasIn(object, 'a.b');
  23925. * // => true
  23926. *
  23927. * _.hasIn(object, ['a', 'b']);
  23928. * // => true
  23929. *
  23930. * _.hasIn(object, 'b');
  23931. * // => false
  23932. */
  23933. function hasIn$1(object, path) {
  23934. return object != null && hasPath(object, path, baseHasIn);
  23935. }
  23936. var hasIn_1 = hasIn$1;
  23937. var baseIsEqual = _baseIsEqual,
  23938. get = get_1,
  23939. hasIn = hasIn_1,
  23940. isKey$1 = _isKey,
  23941. isStrictComparable = _isStrictComparable,
  23942. matchesStrictComparable = _matchesStrictComparable,
  23943. toKey$1 = _toKey;
  23944. /** Used to compose bitmasks for value comparisons. */
  23945. var COMPARE_PARTIAL_FLAG = 1,
  23946. COMPARE_UNORDERED_FLAG = 2;
  23947. /**
  23948. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  23949. *
  23950. * @private
  23951. * @param {string} path The path of the property to get.
  23952. * @param {*} srcValue The value to match.
  23953. * @returns {Function} Returns the new spec function.
  23954. */
  23955. function baseMatchesProperty$1(path, srcValue) {
  23956. if (isKey$1(path) && isStrictComparable(srcValue)) {
  23957. return matchesStrictComparable(toKey$1(path), srcValue);
  23958. }
  23959. return function (object) {
  23960. var objValue = get(object, path);
  23961. return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  23962. };
  23963. }
  23964. var _baseMatchesProperty = baseMatchesProperty$1;
  23965. /**
  23966. * This method returns the first argument it receives.
  23967. *
  23968. * @static
  23969. * @since 0.1.0
  23970. * @memberOf _
  23971. * @category Util
  23972. * @param {*} value Any value.
  23973. * @returns {*} Returns `value`.
  23974. * @example
  23975. *
  23976. * var object = { 'a': 1 };
  23977. *
  23978. * console.log(_.identity(object) === object);
  23979. * // => true
  23980. */
  23981. function identity$3(value) {
  23982. return value;
  23983. }
  23984. var identity_1 = identity$3;
  23985. /**
  23986. * The base implementation of `_.property` without support for deep paths.
  23987. *
  23988. * @private
  23989. * @param {string} key The key of the property to get.
  23990. * @returns {Function} Returns the new accessor function.
  23991. */
  23992. function baseProperty$1(key) {
  23993. return function (object) {
  23994. return object == null ? undefined : object[key];
  23995. };
  23996. }
  23997. var _baseProperty = baseProperty$1;
  23998. var baseGet = _baseGet;
  23999. /**
  24000. * A specialized version of `baseProperty` which supports deep paths.
  24001. *
  24002. * @private
  24003. * @param {Array|string} path The path of the property to get.
  24004. * @returns {Function} Returns the new accessor function.
  24005. */
  24006. function basePropertyDeep$1(path) {
  24007. return function (object) {
  24008. return baseGet(object, path);
  24009. };
  24010. }
  24011. var _basePropertyDeep = basePropertyDeep$1;
  24012. var baseProperty = _baseProperty,
  24013. basePropertyDeep = _basePropertyDeep,
  24014. isKey = _isKey,
  24015. toKey = _toKey;
  24016. /**
  24017. * Creates a function that returns the value at `path` of a given object.
  24018. *
  24019. * @static
  24020. * @memberOf _
  24021. * @since 2.4.0
  24022. * @category Util
  24023. * @param {Array|string} path The path of the property to get.
  24024. * @returns {Function} Returns the new accessor function.
  24025. * @example
  24026. *
  24027. * var objects = [
  24028. * { 'a': { 'b': 2 } },
  24029. * { 'a': { 'b': 1 } }
  24030. * ];
  24031. *
  24032. * _.map(objects, _.property('a.b'));
  24033. * // => [2, 1]
  24034. *
  24035. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  24036. * // => [1, 2]
  24037. */
  24038. function property$2(path) {
  24039. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  24040. }
  24041. var property_1 = property$2;
  24042. var baseMatches = _baseMatches,
  24043. baseMatchesProperty = _baseMatchesProperty,
  24044. identity$2 = identity_1,
  24045. isArray$1 = isArray_1,
  24046. property$1 = property_1;
  24047. /**
  24048. * The base implementation of `_.iteratee`.
  24049. *
  24050. * @private
  24051. * @param {*} [value=_.identity] The value to convert to an iteratee.
  24052. * @returns {Function} Returns the iteratee.
  24053. */
  24054. function baseIteratee$2(value) {
  24055. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  24056. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  24057. if (typeof value == 'function') {
  24058. return value;
  24059. }
  24060. if (value == null) {
  24061. return identity$2;
  24062. }
  24063. if (typeof value == 'object') {
  24064. return isArray$1(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  24065. }
  24066. return property$1(value);
  24067. }
  24068. var _baseIteratee = baseIteratee$2;
  24069. /**
  24070. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  24071. * support for iteratee shorthands.
  24072. *
  24073. * @private
  24074. * @param {Array} array The array to inspect.
  24075. * @param {Function} predicate The function invoked per iteration.
  24076. * @param {number} fromIndex The index to search from.
  24077. * @param {boolean} [fromRight] Specify iterating from right to left.
  24078. * @returns {number} Returns the index of the matched value, else `-1`.
  24079. */
  24080. function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
  24081. var length = array.length,
  24082. index = fromIndex + (fromRight ? 1 : -1);
  24083. while (fromRight ? index-- : ++index < length) {
  24084. if (predicate(array[index], index, array)) {
  24085. return index;
  24086. }
  24087. }
  24088. return -1;
  24089. }
  24090. var _baseFindIndex = baseFindIndex$1;
  24091. /**
  24092. * The base implementation of `_.isNaN` without support for number objects.
  24093. *
  24094. * @private
  24095. * @param {*} value The value to check.
  24096. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  24097. */
  24098. function baseIsNaN$1(value) {
  24099. return value !== value;
  24100. }
  24101. var _baseIsNaN = baseIsNaN$1;
  24102. /**
  24103. * A specialized version of `_.indexOf` which performs strict equality
  24104. * comparisons of values, i.e. `===`.
  24105. *
  24106. * @private
  24107. * @param {Array} array The array to inspect.
  24108. * @param {*} value The value to search for.
  24109. * @param {number} fromIndex The index to search from.
  24110. * @returns {number} Returns the index of the matched value, else `-1`.
  24111. */
  24112. function strictIndexOf$1(array, value, fromIndex) {
  24113. var index = fromIndex - 1,
  24114. length = array.length;
  24115. while (++index < length) {
  24116. if (array[index] === value) {
  24117. return index;
  24118. }
  24119. }
  24120. return -1;
  24121. }
  24122. var _strictIndexOf = strictIndexOf$1;
  24123. var baseFindIndex = _baseFindIndex,
  24124. baseIsNaN = _baseIsNaN,
  24125. strictIndexOf = _strictIndexOf;
  24126. /**
  24127. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  24128. *
  24129. * @private
  24130. * @param {Array} array The array to inspect.
  24131. * @param {*} value The value to search for.
  24132. * @param {number} fromIndex The index to search from.
  24133. * @returns {number} Returns the index of the matched value, else `-1`.
  24134. */
  24135. function baseIndexOf$1(array, value, fromIndex) {
  24136. return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
  24137. }
  24138. var _baseIndexOf = baseIndexOf$1;
  24139. var baseIndexOf = _baseIndexOf;
  24140. /**
  24141. * A specialized version of `_.includes` for arrays without support for
  24142. * specifying an index to search from.
  24143. *
  24144. * @private
  24145. * @param {Array} [array] The array to inspect.
  24146. * @param {*} target The value to search for.
  24147. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  24148. */
  24149. function arrayIncludes$1(array, value) {
  24150. var length = array == null ? 0 : array.length;
  24151. return !!length && baseIndexOf(array, value, 0) > -1;
  24152. }
  24153. var _arrayIncludes = arrayIncludes$1;
  24154. /**
  24155. * This function is like `arrayIncludes` except that it accepts a comparator.
  24156. *
  24157. * @private
  24158. * @param {Array} [array] The array to inspect.
  24159. * @param {*} target The value to search for.
  24160. * @param {Function} comparator The comparator invoked per element.
  24161. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  24162. */
  24163. function arrayIncludesWith$1(array, value, comparator) {
  24164. var index = -1,
  24165. length = array == null ? 0 : array.length;
  24166. while (++index < length) {
  24167. if (comparator(value, array[index])) {
  24168. return true;
  24169. }
  24170. }
  24171. return false;
  24172. }
  24173. var _arrayIncludesWith = arrayIncludesWith$1;
  24174. /**
  24175. * This method returns `undefined`.
  24176. *
  24177. * @static
  24178. * @memberOf _
  24179. * @since 2.3.0
  24180. * @category Util
  24181. * @example
  24182. *
  24183. * _.times(2, _.noop);
  24184. * // => [undefined, undefined]
  24185. */
  24186. function noop$2() {// No operation performed.
  24187. }
  24188. var noop_1 = noop$2;
  24189. var Set$1 = _Set,
  24190. noop$1 = noop_1,
  24191. setToArray$1 = _setToArray;
  24192. /** Used as references for various `Number` constants. */
  24193. var INFINITY = 1 / 0;
  24194. /**
  24195. * Creates a set object of `values`.
  24196. *
  24197. * @private
  24198. * @param {Array} values The values to add to the set.
  24199. * @returns {Object} Returns the new set.
  24200. */
  24201. var createSet$1 = !(Set$1 && 1 / setToArray$1(new Set$1([, -0]))[1] == INFINITY) ? noop$1 : function (values) {
  24202. return new Set$1(values);
  24203. };
  24204. var _createSet = createSet$1;
  24205. var SetCache = _SetCache,
  24206. arrayIncludes = _arrayIncludes,
  24207. arrayIncludesWith = _arrayIncludesWith,
  24208. cacheHas = _cacheHas,
  24209. createSet = _createSet,
  24210. setToArray = _setToArray;
  24211. /** Used as the size to enable large array optimizations. */
  24212. var LARGE_ARRAY_SIZE = 200;
  24213. /**
  24214. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  24215. *
  24216. * @private
  24217. * @param {Array} array The array to inspect.
  24218. * @param {Function} [iteratee] The iteratee invoked per element.
  24219. * @param {Function} [comparator] The comparator invoked per element.
  24220. * @returns {Array} Returns the new duplicate free array.
  24221. */
  24222. function baseUniq$1(array, iteratee, comparator) {
  24223. var index = -1,
  24224. includes = arrayIncludes,
  24225. length = array.length,
  24226. isCommon = true,
  24227. result = [],
  24228. seen = result;
  24229. if (comparator) {
  24230. isCommon = false;
  24231. includes = arrayIncludesWith;
  24232. } else if (length >= LARGE_ARRAY_SIZE) {
  24233. var set = iteratee ? null : createSet(array);
  24234. if (set) {
  24235. return setToArray(set);
  24236. }
  24237. isCommon = false;
  24238. includes = cacheHas;
  24239. seen = new SetCache();
  24240. } else {
  24241. seen = iteratee ? [] : result;
  24242. }
  24243. outer: while (++index < length) {
  24244. var value = array[index],
  24245. computed = iteratee ? iteratee(value) : value;
  24246. value = comparator || value !== 0 ? value : 0;
  24247. if (isCommon && computed === computed) {
  24248. var seenIndex = seen.length;
  24249. while (seenIndex--) {
  24250. if (seen[seenIndex] === computed) {
  24251. continue outer;
  24252. }
  24253. }
  24254. if (iteratee) {
  24255. seen.push(computed);
  24256. }
  24257. result.push(value);
  24258. } else if (!includes(seen, computed, comparator)) {
  24259. if (seen !== result) {
  24260. seen.push(computed);
  24261. }
  24262. result.push(value);
  24263. }
  24264. }
  24265. return result;
  24266. }
  24267. var _baseUniq = baseUniq$1;
  24268. var baseIteratee$1 = _baseIteratee,
  24269. baseUniq = _baseUniq;
  24270. /**
  24271. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24272. * invoked for each element in `array` to generate the criterion by which
  24273. * uniqueness is computed. The order of result values is determined by the
  24274. * order they occur in the array. The iteratee is invoked with one argument:
  24275. * (value).
  24276. *
  24277. * @static
  24278. * @memberOf _
  24279. * @since 4.0.0
  24280. * @category Array
  24281. * @param {Array} array The array to inspect.
  24282. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24283. * @returns {Array} Returns the new duplicate free array.
  24284. * @example
  24285. *
  24286. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24287. * // => [2.1, 1.2]
  24288. *
  24289. * // The `_.property` iteratee shorthand.
  24290. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24291. * // => [{ 'x': 1 }, { 'x': 2 }]
  24292. */
  24293. function uniqBy$1(array, iteratee) {
  24294. return array && array.length ? baseUniq(array, baseIteratee$1(iteratee)) : [];
  24295. }
  24296. var uniqBy_1 = uniqBy$1;
  24297. /**
  24298. * A specialized version of `baseAggregator` for arrays.
  24299. *
  24300. * @private
  24301. * @param {Array} [array] The array to iterate over.
  24302. * @param {Function} setter The function to set `accumulator` values.
  24303. * @param {Function} iteratee The iteratee to transform keys.
  24304. * @param {Object} accumulator The initial aggregated object.
  24305. * @returns {Function} Returns `accumulator`.
  24306. */
  24307. function arrayAggregator$1(array, setter, iteratee, accumulator) {
  24308. var index = -1,
  24309. length = array == null ? 0 : array.length;
  24310. while (++index < length) {
  24311. var value = array[index];
  24312. setter(accumulator, value, iteratee(value), array);
  24313. }
  24314. return accumulator;
  24315. }
  24316. var _arrayAggregator = arrayAggregator$1;
  24317. /**
  24318. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  24319. *
  24320. * @private
  24321. * @param {boolean} [fromRight] Specify iterating from right to left.
  24322. * @returns {Function} Returns the new base function.
  24323. */
  24324. function createBaseFor$1(fromRight) {
  24325. return function (object, iteratee, keysFunc) {
  24326. var index = -1,
  24327. iterable = Object(object),
  24328. props = keysFunc(object),
  24329. length = props.length;
  24330. while (length--) {
  24331. var key = props[fromRight ? length : ++index];
  24332. if (iteratee(iterable[key], key, iterable) === false) {
  24333. break;
  24334. }
  24335. }
  24336. return object;
  24337. };
  24338. }
  24339. var _createBaseFor = createBaseFor$1;
  24340. var createBaseFor = _createBaseFor;
  24341. /**
  24342. * The base implementation of `baseForOwn` which iterates over `object`
  24343. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  24344. * Iteratee functions may exit iteration early by explicitly returning `false`.
  24345. *
  24346. * @private
  24347. * @param {Object} object The object to iterate over.
  24348. * @param {Function} iteratee The function invoked per iteration.
  24349. * @param {Function} keysFunc The function to get the keys of `object`.
  24350. * @returns {Object} Returns `object`.
  24351. */
  24352. var baseFor$1 = createBaseFor();
  24353. var _baseFor = baseFor$1;
  24354. var baseFor = _baseFor,
  24355. keys = keys_1;
  24356. /**
  24357. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  24358. *
  24359. * @private
  24360. * @param {Object} object The object to iterate over.
  24361. * @param {Function} iteratee The function invoked per iteration.
  24362. * @returns {Object} Returns `object`.
  24363. */
  24364. function baseForOwn$1(object, iteratee) {
  24365. return object && baseFor(object, iteratee, keys);
  24366. }
  24367. var _baseForOwn = baseForOwn$1;
  24368. var isArrayLike = isArrayLike_1;
  24369. /**
  24370. * Creates a `baseEach` or `baseEachRight` function.
  24371. *
  24372. * @private
  24373. * @param {Function} eachFunc The function to iterate over a collection.
  24374. * @param {boolean} [fromRight] Specify iterating from right to left.
  24375. * @returns {Function} Returns the new base function.
  24376. */
  24377. function createBaseEach$1(eachFunc, fromRight) {
  24378. return function (collection, iteratee) {
  24379. if (collection == null) {
  24380. return collection;
  24381. }
  24382. if (!isArrayLike(collection)) {
  24383. return eachFunc(collection, iteratee);
  24384. }
  24385. var length = collection.length,
  24386. index = fromRight ? length : -1,
  24387. iterable = Object(collection);
  24388. while (fromRight ? index-- : ++index < length) {
  24389. if (iteratee(iterable[index], index, iterable) === false) {
  24390. break;
  24391. }
  24392. }
  24393. return collection;
  24394. };
  24395. }
  24396. var _createBaseEach = createBaseEach$1;
  24397. var baseForOwn = _baseForOwn,
  24398. createBaseEach = _createBaseEach;
  24399. /**
  24400. * The base implementation of `_.forEach` without support for iteratee shorthands.
  24401. *
  24402. * @private
  24403. * @param {Array|Object} collection The collection to iterate over.
  24404. * @param {Function} iteratee The function invoked per iteration.
  24405. * @returns {Array|Object} Returns `collection`.
  24406. */
  24407. var baseEach$1 = createBaseEach(baseForOwn);
  24408. var _baseEach = baseEach$1;
  24409. var baseEach = _baseEach;
  24410. /**
  24411. * Aggregates elements of `collection` on `accumulator` with keys transformed
  24412. * by `iteratee` and values set by `setter`.
  24413. *
  24414. * @private
  24415. * @param {Array|Object} collection The collection to iterate over.
  24416. * @param {Function} setter The function to set `accumulator` values.
  24417. * @param {Function} iteratee The iteratee to transform keys.
  24418. * @param {Object} accumulator The initial aggregated object.
  24419. * @returns {Function} Returns `accumulator`.
  24420. */
  24421. function baseAggregator$1(collection, setter, iteratee, accumulator) {
  24422. baseEach(collection, function (value, key, collection) {
  24423. setter(accumulator, value, iteratee(value), collection);
  24424. });
  24425. return accumulator;
  24426. }
  24427. var _baseAggregator = baseAggregator$1;
  24428. var arrayAggregator = _arrayAggregator,
  24429. baseAggregator = _baseAggregator,
  24430. baseIteratee = _baseIteratee,
  24431. isArray = isArray_1;
  24432. /**
  24433. * Creates a function like `_.groupBy`.
  24434. *
  24435. * @private
  24436. * @param {Function} setter The function to set accumulator values.
  24437. * @param {Function} [initializer] The accumulator object initializer.
  24438. * @returns {Function} Returns the new aggregator function.
  24439. */
  24440. function createAggregator$1(setter, initializer) {
  24441. return function (collection, iteratee) {
  24442. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  24443. accumulator = initializer ? initializer() : {};
  24444. return func(collection, setter, baseIteratee(iteratee), accumulator);
  24445. };
  24446. }
  24447. var _createAggregator = createAggregator$1;
  24448. var createAggregator = _createAggregator;
  24449. /**
  24450. * Creates an array of elements split into two groups, the first of which
  24451. * contains elements `predicate` returns truthy for, the second of which
  24452. * contains elements `predicate` returns falsey for. The predicate is
  24453. * invoked with one argument: (value).
  24454. *
  24455. * @static
  24456. * @memberOf _
  24457. * @since 3.0.0
  24458. * @category Collection
  24459. * @param {Array|Object} collection The collection to iterate over.
  24460. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24461. * @returns {Array} Returns the array of grouped elements.
  24462. * @example
  24463. *
  24464. * var users = [
  24465. * { 'user': 'barney', 'age': 36, 'active': false },
  24466. * { 'user': 'fred', 'age': 40, 'active': true },
  24467. * { 'user': 'pebbles', 'age': 1, 'active': false }
  24468. * ];
  24469. *
  24470. * _.partition(users, function(o) { return o.active; });
  24471. * // => objects for [['fred'], ['barney', 'pebbles']]
  24472. *
  24473. * // The `_.matches` iteratee shorthand.
  24474. * _.partition(users, { 'age': 1, 'active': false });
  24475. * // => objects for [['pebbles'], ['barney', 'fred']]
  24476. *
  24477. * // The `_.matchesProperty` iteratee shorthand.
  24478. * _.partition(users, ['active', false]);
  24479. * // => objects for [['barney', 'pebbles'], ['fred']]
  24480. *
  24481. * // The `_.property` iteratee shorthand.
  24482. * _.partition(users, 'active');
  24483. * // => objects for [['fred'], ['barney', 'pebbles']]
  24484. */
  24485. var partition$1 = createAggregator(function (result, value, key) {
  24486. result[key ? 0 : 1].push(value);
  24487. }, function () {
  24488. return [[], []];
  24489. });
  24490. var partition_1 = partition$1;
  24491. var globby$2 = {exports: {}};
  24492. var arrayUnion$1 = (...arguments_) => {
  24493. return [...new Set([].concat(...arguments_))];
  24494. };
  24495. /*
  24496. * merge2
  24497. * https://github.com/teambition/merge2
  24498. *
  24499. * Copyright (c) 2014-2020 Teambition
  24500. * Licensed under the MIT license.
  24501. */
  24502. const Stream = require$$0__default$5["default"];
  24503. const PassThrough = Stream.PassThrough;
  24504. const slice = Array.prototype.slice;
  24505. var merge2_1 = merge2$2;
  24506. function merge2$2() {
  24507. const streamsQueue = [];
  24508. const args = slice.call(arguments);
  24509. let merging = false;
  24510. let options = args[args.length - 1];
  24511. if (options && !Array.isArray(options) && options.pipe == null) {
  24512. args.pop();
  24513. } else {
  24514. options = {};
  24515. }
  24516. const doEnd = options.end !== false;
  24517. const doPipeError = options.pipeError === true;
  24518. if (options.objectMode == null) {
  24519. options.objectMode = true;
  24520. }
  24521. if (options.highWaterMark == null) {
  24522. options.highWaterMark = 64 * 1024;
  24523. }
  24524. const mergedStream = PassThrough(options);
  24525. function addStream() {
  24526. for (let i = 0, len = arguments.length; i < len; i++) {
  24527. streamsQueue.push(pauseStreams(arguments[i], options));
  24528. }
  24529. mergeStream();
  24530. return this;
  24531. }
  24532. function mergeStream() {
  24533. if (merging) {
  24534. return;
  24535. }
  24536. merging = true;
  24537. let streams = streamsQueue.shift();
  24538. if (!streams) {
  24539. process.nextTick(endStream);
  24540. return;
  24541. }
  24542. if (!Array.isArray(streams)) {
  24543. streams = [streams];
  24544. }
  24545. let pipesCount = streams.length + 1;
  24546. function next() {
  24547. if (--pipesCount > 0) {
  24548. return;
  24549. }
  24550. merging = false;
  24551. mergeStream();
  24552. }
  24553. function pipe(stream) {
  24554. function onend() {
  24555. stream.removeListener('merge2UnpipeEnd', onend);
  24556. stream.removeListener('end', onend);
  24557. if (doPipeError) {
  24558. stream.removeListener('error', onerror);
  24559. }
  24560. next();
  24561. }
  24562. function onerror(err) {
  24563. mergedStream.emit('error', err);
  24564. } // skip ended stream
  24565. if (stream._readableState.endEmitted) {
  24566. return next();
  24567. }
  24568. stream.on('merge2UnpipeEnd', onend);
  24569. stream.on('end', onend);
  24570. if (doPipeError) {
  24571. stream.on('error', onerror);
  24572. }
  24573. stream.pipe(mergedStream, {
  24574. end: false
  24575. }); // compatible for old stream
  24576. stream.resume();
  24577. }
  24578. for (let i = 0; i < streams.length; i++) {
  24579. pipe(streams[i]);
  24580. }
  24581. next();
  24582. }
  24583. function endStream() {
  24584. merging = false; // emit 'queueDrain' when all streams merged.
  24585. mergedStream.emit('queueDrain');
  24586. if (doEnd) {
  24587. mergedStream.end();
  24588. }
  24589. }
  24590. mergedStream.setMaxListeners(0);
  24591. mergedStream.add = addStream;
  24592. mergedStream.on('unpipe', function (stream) {
  24593. stream.emit('merge2UnpipeEnd');
  24594. });
  24595. if (args.length) {
  24596. addStream.apply(null, args);
  24597. }
  24598. return mergedStream;
  24599. } // check and pause streams for pipe.
  24600. function pauseStreams(streams, options) {
  24601. if (!Array.isArray(streams)) {
  24602. // Backwards-compat with old-style streams
  24603. if (!streams._readableState && streams.pipe) {
  24604. streams = streams.pipe(PassThrough(options));
  24605. }
  24606. if (!streams._readableState || !streams.pause || !streams.pipe) {
  24607. throw new Error('Only readable stream can be merged.');
  24608. }
  24609. streams.pause();
  24610. } else {
  24611. for (let i = 0, len = streams.length; i < len; i++) {
  24612. streams[i] = pauseStreams(streams[i], options);
  24613. }
  24614. }
  24615. return streams;
  24616. }
  24617. var tasks = {};
  24618. var utils$r = {};
  24619. var array$2 = {};
  24620. Object.defineProperty(array$2, "__esModule", {
  24621. value: true
  24622. });
  24623. array$2.splitWhen = array$2.flatten = void 0;
  24624. function flatten(items) {
  24625. return items.reduce((collection, item) => [].concat(collection, item), []);
  24626. }
  24627. array$2.flatten = flatten;
  24628. function splitWhen(items, predicate) {
  24629. const result = [[]];
  24630. let groupIndex = 0;
  24631. for (const item of items) {
  24632. if (predicate(item)) {
  24633. groupIndex++;
  24634. result[groupIndex] = [];
  24635. } else {
  24636. result[groupIndex].push(item);
  24637. }
  24638. }
  24639. return result;
  24640. }
  24641. array$2.splitWhen = splitWhen;
  24642. var errno$1 = {};
  24643. Object.defineProperty(errno$1, "__esModule", {
  24644. value: true
  24645. });
  24646. errno$1.isEnoentCodeError = void 0;
  24647. function isEnoentCodeError(error) {
  24648. return error.code === 'ENOENT';
  24649. }
  24650. errno$1.isEnoentCodeError = isEnoentCodeError;
  24651. var fs$b = {};
  24652. Object.defineProperty(fs$b, "__esModule", {
  24653. value: true
  24654. });
  24655. fs$b.createDirentFromStats = void 0;
  24656. class DirentFromStats$1 {
  24657. constructor(name, stats) {
  24658. this.name = name;
  24659. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  24660. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  24661. this.isDirectory = stats.isDirectory.bind(stats);
  24662. this.isFIFO = stats.isFIFO.bind(stats);
  24663. this.isFile = stats.isFile.bind(stats);
  24664. this.isSocket = stats.isSocket.bind(stats);
  24665. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  24666. }
  24667. }
  24668. function createDirentFromStats$1(name, stats) {
  24669. return new DirentFromStats$1(name, stats);
  24670. }
  24671. fs$b.createDirentFromStats = createDirentFromStats$1;
  24672. var path$c = {};
  24673. Object.defineProperty(path$c, "__esModule", {
  24674. value: true
  24675. });
  24676. path$c.removeLeadingDotSegment = path$c.escape = path$c.makeAbsolute = path$c.unixify = void 0;
  24677. const path$b = require$$0__default$2["default"];
  24678. const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
  24679. const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
  24680. /**
  24681. * Designed to work only with simple paths: `dir\\file`.
  24682. */
  24683. function unixify(filepath) {
  24684. return filepath.replace(/\\/g, '/');
  24685. }
  24686. path$c.unixify = unixify;
  24687. function makeAbsolute(cwd, filepath) {
  24688. return path$b.resolve(cwd, filepath);
  24689. }
  24690. path$c.makeAbsolute = makeAbsolute;
  24691. function escape(pattern) {
  24692. return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  24693. }
  24694. path$c.escape = escape;
  24695. function removeLeadingDotSegment(entry) {
  24696. // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
  24697. // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
  24698. if (entry.charAt(0) === '.') {
  24699. const secondCharactery = entry.charAt(1);
  24700. if (secondCharactery === '/' || secondCharactery === '\\') {
  24701. return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
  24702. }
  24703. }
  24704. return entry;
  24705. }
  24706. path$c.removeLeadingDotSegment = removeLeadingDotSegment;
  24707. var pattern$1 = {};
  24708. /*!
  24709. * is-extglob <https://github.com/jonschlinkert/is-extglob>
  24710. *
  24711. * Copyright (c) 2014-2016, Jon Schlinkert.
  24712. * Licensed under the MIT License.
  24713. */
  24714. var isExtglob$1 = function isExtglob(str) {
  24715. if (typeof str !== 'string' || str === '') {
  24716. return false;
  24717. }
  24718. var match;
  24719. while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
  24720. if (match[2]) return true;
  24721. str = str.slice(match.index + match[0].length);
  24722. }
  24723. return false;
  24724. };
  24725. /*!
  24726. * is-glob <https://github.com/jonschlinkert/is-glob>
  24727. *
  24728. * Copyright (c) 2014-2017, Jon Schlinkert.
  24729. * Released under the MIT License.
  24730. */
  24731. var isExtglob = isExtglob$1;
  24732. var chars$1 = {
  24733. '{': '}',
  24734. '(': ')',
  24735. '[': ']'
  24736. };
  24737. var strictCheck = function (str) {
  24738. if (str[0] === '!') {
  24739. return true;
  24740. }
  24741. var index = 0;
  24742. var pipeIndex = -2;
  24743. var closeSquareIndex = -2;
  24744. var closeCurlyIndex = -2;
  24745. var closeParenIndex = -2;
  24746. var backSlashIndex = -2;
  24747. while (index < str.length) {
  24748. if (str[index] === '*') {
  24749. return true;
  24750. }
  24751. if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
  24752. return true;
  24753. }
  24754. if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') {
  24755. if (closeSquareIndex < index) {
  24756. closeSquareIndex = str.indexOf(']', index);
  24757. }
  24758. if (closeSquareIndex > index) {
  24759. if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
  24760. return true;
  24761. }
  24762. backSlashIndex = str.indexOf('\\', index);
  24763. if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
  24764. return true;
  24765. }
  24766. }
  24767. }
  24768. if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') {
  24769. closeCurlyIndex = str.indexOf('}', index);
  24770. if (closeCurlyIndex > index) {
  24771. backSlashIndex = str.indexOf('\\', index);
  24772. if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) {
  24773. return true;
  24774. }
  24775. }
  24776. }
  24777. if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
  24778. closeParenIndex = str.indexOf(')', index);
  24779. if (closeParenIndex > index) {
  24780. backSlashIndex = str.indexOf('\\', index);
  24781. if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
  24782. return true;
  24783. }
  24784. }
  24785. }
  24786. if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') {
  24787. if (pipeIndex < index) {
  24788. pipeIndex = str.indexOf('|', index);
  24789. }
  24790. if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') {
  24791. closeParenIndex = str.indexOf(')', pipeIndex);
  24792. if (closeParenIndex > pipeIndex) {
  24793. backSlashIndex = str.indexOf('\\', pipeIndex);
  24794. if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
  24795. return true;
  24796. }
  24797. }
  24798. }
  24799. }
  24800. if (str[index] === '\\') {
  24801. var open = str[index + 1];
  24802. index += 2;
  24803. var close = chars$1[open];
  24804. if (close) {
  24805. var n = str.indexOf(close, index);
  24806. if (n !== -1) {
  24807. index = n + 1;
  24808. }
  24809. }
  24810. if (str[index] === '!') {
  24811. return true;
  24812. }
  24813. } else {
  24814. index++;
  24815. }
  24816. }
  24817. return false;
  24818. };
  24819. var relaxedCheck = function (str) {
  24820. if (str[0] === '!') {
  24821. return true;
  24822. }
  24823. var index = 0;
  24824. while (index < str.length) {
  24825. if (/[*?{}()[\]]/.test(str[index])) {
  24826. return true;
  24827. }
  24828. if (str[index] === '\\') {
  24829. var open = str[index + 1];
  24830. index += 2;
  24831. var close = chars$1[open];
  24832. if (close) {
  24833. var n = str.indexOf(close, index);
  24834. if (n !== -1) {
  24835. index = n + 1;
  24836. }
  24837. }
  24838. if (str[index] === '!') {
  24839. return true;
  24840. }
  24841. } else {
  24842. index++;
  24843. }
  24844. }
  24845. return false;
  24846. };
  24847. var isGlob$1 = function isGlob(str, options) {
  24848. if (typeof str !== 'string' || str === '') {
  24849. return false;
  24850. }
  24851. if (isExtglob(str)) {
  24852. return true;
  24853. }
  24854. var check = strictCheck; // optionally relax check
  24855. if (options && options.strict === false) {
  24856. check = relaxedCheck;
  24857. }
  24858. return check(str);
  24859. };
  24860. var isGlob = isGlob$1;
  24861. var pathPosixDirname = require$$0__default$2["default"].posix.dirname;
  24862. var isWin32 = require$$0__default$1["default"].platform() === 'win32';
  24863. var slash$2 = '/';
  24864. var backslash = /\\/g;
  24865. var enclosure = /[\{\[].*[\}\]]$/;
  24866. var globby$1 = /(^|[^\\])([\{\[]|\([^\)]+$)/;
  24867. var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
  24868. /**
  24869. * @param {string} str
  24870. * @param {Object} opts
  24871. * @param {boolean} [opts.flipBackslashes=true]
  24872. * @returns {string}
  24873. */
  24874. var globParent$1 = function globParent(str, opts) {
  24875. var options = Object.assign({
  24876. flipBackslashes: true
  24877. }, opts); // flip windows path separators
  24878. if (options.flipBackslashes && isWin32 && str.indexOf(slash$2) < 0) {
  24879. str = str.replace(backslash, slash$2);
  24880. } // special case for strings ending in enclosure containing path separator
  24881. if (enclosure.test(str)) {
  24882. str += slash$2;
  24883. } // preserves full path in case of trailing path separator
  24884. str += 'a'; // remove path parts that are globby
  24885. do {
  24886. str = pathPosixDirname(str);
  24887. } while (isGlob(str) || globby$1.test(str)); // remove escape chars and return result
  24888. return str.replace(escaped, '$1');
  24889. };
  24890. var utils$q = {};
  24891. (function (exports) {
  24892. exports.isInteger = num => {
  24893. if (typeof num === 'number') {
  24894. return Number.isInteger(num);
  24895. }
  24896. if (typeof num === 'string' && num.trim() !== '') {
  24897. return Number.isInteger(Number(num));
  24898. }
  24899. return false;
  24900. };
  24901. /**
  24902. * Find a node of the given type
  24903. */
  24904. exports.find = (node, type) => node.nodes.find(node => node.type === type);
  24905. /**
  24906. * Find a node of the given type
  24907. */
  24908. exports.exceedsLimit = (min, max, step = 1, limit) => {
  24909. if (limit === false) return false;
  24910. if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
  24911. return (Number(max) - Number(min)) / Number(step) >= limit;
  24912. };
  24913. /**
  24914. * Escape the given node with '\\' before node.value
  24915. */
  24916. exports.escapeNode = (block, n = 0, type) => {
  24917. let node = block.nodes[n];
  24918. if (!node) return;
  24919. if (type && node.type === type || node.type === 'open' || node.type === 'close') {
  24920. if (node.escaped !== true) {
  24921. node.value = '\\' + node.value;
  24922. node.escaped = true;
  24923. }
  24924. }
  24925. };
  24926. /**
  24927. * Returns true if the given brace node should be enclosed in literal braces
  24928. */
  24929. exports.encloseBrace = node => {
  24930. if (node.type !== 'brace') return false;
  24931. if (node.commas >> 0 + node.ranges >> 0 === 0) {
  24932. node.invalid = true;
  24933. return true;
  24934. }
  24935. return false;
  24936. };
  24937. /**
  24938. * Returns true if a brace node is invalid.
  24939. */
  24940. exports.isInvalidBrace = block => {
  24941. if (block.type !== 'brace') return false;
  24942. if (block.invalid === true || block.dollar) return true;
  24943. if (block.commas >> 0 + block.ranges >> 0 === 0) {
  24944. block.invalid = true;
  24945. return true;
  24946. }
  24947. if (block.open !== true || block.close !== true) {
  24948. block.invalid = true;
  24949. return true;
  24950. }
  24951. return false;
  24952. };
  24953. /**
  24954. * Returns true if a node is an open or close node
  24955. */
  24956. exports.isOpenOrClose = node => {
  24957. if (node.type === 'open' || node.type === 'close') {
  24958. return true;
  24959. }
  24960. return node.open === true || node.close === true;
  24961. };
  24962. /**
  24963. * Reduce an array of text nodes.
  24964. */
  24965. exports.reduce = nodes => nodes.reduce((acc, node) => {
  24966. if (node.type === 'text') acc.push(node.value);
  24967. if (node.type === 'range') node.type = 'text';
  24968. return acc;
  24969. }, []);
  24970. /**
  24971. * Flatten an array
  24972. */
  24973. exports.flatten = (...args) => {
  24974. const result = [];
  24975. const flat = arr => {
  24976. for (let i = 0; i < arr.length; i++) {
  24977. let ele = arr[i];
  24978. Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
  24979. }
  24980. return result;
  24981. };
  24982. flat(args);
  24983. return result;
  24984. };
  24985. })(utils$q);
  24986. const utils$p = utils$q;
  24987. var stringify$5 = (ast, options = {}) => {
  24988. let stringify = (node, parent = {}) => {
  24989. let invalidBlock = options.escapeInvalid && utils$p.isInvalidBrace(parent);
  24990. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  24991. let output = '';
  24992. if (node.value) {
  24993. if ((invalidBlock || invalidNode) && utils$p.isOpenOrClose(node)) {
  24994. return '\\' + node.value;
  24995. }
  24996. return node.value;
  24997. }
  24998. if (node.value) {
  24999. return node.value;
  25000. }
  25001. if (node.nodes) {
  25002. for (let child of node.nodes) {
  25003. output += stringify(child);
  25004. }
  25005. }
  25006. return output;
  25007. };
  25008. return stringify(ast);
  25009. };
  25010. /*!
  25011. * is-number <https://github.com/jonschlinkert/is-number>
  25012. *
  25013. * Copyright (c) 2014-present, Jon Schlinkert.
  25014. * Released under the MIT License.
  25015. */
  25016. var isNumber$2 = function (num) {
  25017. if (typeof num === 'number') {
  25018. return num - num === 0;
  25019. }
  25020. if (typeof num === 'string' && num.trim() !== '') {
  25021. return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
  25022. }
  25023. return false;
  25024. };
  25025. const isNumber$1 = isNumber$2;
  25026. const toRegexRange$1 = (min, max, options) => {
  25027. if (isNumber$1(min) === false) {
  25028. throw new TypeError('toRegexRange: expected the first argument to be a number');
  25029. }
  25030. if (max === void 0 || min === max) {
  25031. return String(min);
  25032. }
  25033. if (isNumber$1(max) === false) {
  25034. throw new TypeError('toRegexRange: expected the second argument to be a number.');
  25035. }
  25036. let opts = Object.assign({
  25037. relaxZeros: true
  25038. }, options);
  25039. if (typeof opts.strictZeros === 'boolean') {
  25040. opts.relaxZeros = opts.strictZeros === false;
  25041. }
  25042. let relax = String(opts.relaxZeros);
  25043. let shorthand = String(opts.shorthand);
  25044. let capture = String(opts.capture);
  25045. let wrap = String(opts.wrap);
  25046. let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
  25047. if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) {
  25048. return toRegexRange$1.cache[cacheKey].result;
  25049. }
  25050. let a = Math.min(min, max);
  25051. let b = Math.max(min, max);
  25052. if (Math.abs(a - b) === 1) {
  25053. let result = min + '|' + max;
  25054. if (opts.capture) {
  25055. return `(${result})`;
  25056. }
  25057. if (opts.wrap === false) {
  25058. return result;
  25059. }
  25060. return `(?:${result})`;
  25061. }
  25062. let isPadded = hasPadding(min) || hasPadding(max);
  25063. let state = {
  25064. min,
  25065. max,
  25066. a,
  25067. b
  25068. };
  25069. let positives = [];
  25070. let negatives = [];
  25071. if (isPadded) {
  25072. state.isPadded = isPadded;
  25073. state.maxLen = String(state.max).length;
  25074. }
  25075. if (a < 0) {
  25076. let newMin = b < 0 ? Math.abs(b) : 1;
  25077. negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
  25078. a = state.a = 0;
  25079. }
  25080. if (b >= 0) {
  25081. positives = splitToPatterns(a, b, state, opts);
  25082. }
  25083. state.negatives = negatives;
  25084. state.positives = positives;
  25085. state.result = collatePatterns(negatives, positives);
  25086. if (opts.capture === true) {
  25087. state.result = `(${state.result})`;
  25088. } else if (opts.wrap !== false && positives.length + negatives.length > 1) {
  25089. state.result = `(?:${state.result})`;
  25090. }
  25091. toRegexRange$1.cache[cacheKey] = state;
  25092. return state.result;
  25093. };
  25094. function collatePatterns(neg, pos, options) {
  25095. let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
  25096. let onlyPositive = filterPatterns(pos, neg, '', false) || [];
  25097. let intersected = filterPatterns(neg, pos, '-?', true) || [];
  25098. let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
  25099. return subpatterns.join('|');
  25100. }
  25101. function splitToRanges(min, max) {
  25102. let nines = 1;
  25103. let zeros = 1;
  25104. let stop = countNines(min, nines);
  25105. let stops = new Set([max]);
  25106. while (min <= stop && stop <= max) {
  25107. stops.add(stop);
  25108. nines += 1;
  25109. stop = countNines(min, nines);
  25110. }
  25111. stop = countZeros(max + 1, zeros) - 1;
  25112. while (min < stop && stop <= max) {
  25113. stops.add(stop);
  25114. zeros += 1;
  25115. stop = countZeros(max + 1, zeros) - 1;
  25116. }
  25117. stops = [...stops];
  25118. stops.sort(compare);
  25119. return stops;
  25120. }
  25121. /**
  25122. * Convert a range to a regex pattern
  25123. * @param {Number} `start`
  25124. * @param {Number} `stop`
  25125. * @return {String}
  25126. */
  25127. function rangeToPattern(start, stop, options) {
  25128. if (start === stop) {
  25129. return {
  25130. pattern: start,
  25131. count: [],
  25132. digits: 0
  25133. };
  25134. }
  25135. let zipped = zip(start, stop);
  25136. let digits = zipped.length;
  25137. let pattern = '';
  25138. let count = 0;
  25139. for (let i = 0; i < digits; i++) {
  25140. let [startDigit, stopDigit] = zipped[i];
  25141. if (startDigit === stopDigit) {
  25142. pattern += startDigit;
  25143. } else if (startDigit !== '0' || stopDigit !== '9') {
  25144. pattern += toCharacterClass(startDigit, stopDigit);
  25145. } else {
  25146. count++;
  25147. }
  25148. }
  25149. if (count) {
  25150. pattern += options.shorthand === true ? '\\d' : '[0-9]';
  25151. }
  25152. return {
  25153. pattern,
  25154. count: [count],
  25155. digits
  25156. };
  25157. }
  25158. function splitToPatterns(min, max, tok, options) {
  25159. let ranges = splitToRanges(min, max);
  25160. let tokens = [];
  25161. let start = min;
  25162. let prev;
  25163. for (let i = 0; i < ranges.length; i++) {
  25164. let max = ranges[i];
  25165. let obj = rangeToPattern(String(start), String(max), options);
  25166. let zeros = '';
  25167. if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
  25168. if (prev.count.length > 1) {
  25169. prev.count.pop();
  25170. }
  25171. prev.count.push(obj.count[0]);
  25172. prev.string = prev.pattern + toQuantifier(prev.count);
  25173. start = max + 1;
  25174. continue;
  25175. }
  25176. if (tok.isPadded) {
  25177. zeros = padZeros(max, tok, options);
  25178. }
  25179. obj.string = zeros + obj.pattern + toQuantifier(obj.count);
  25180. tokens.push(obj);
  25181. start = max + 1;
  25182. prev = obj;
  25183. }
  25184. return tokens;
  25185. }
  25186. function filterPatterns(arr, comparison, prefix, intersection, options) {
  25187. let result = [];
  25188. for (let ele of arr) {
  25189. let {
  25190. string
  25191. } = ele; // only push if _both_ are negative...
  25192. if (!intersection && !contains(comparison, 'string', string)) {
  25193. result.push(prefix + string);
  25194. } // or _both_ are positive
  25195. if (intersection && contains(comparison, 'string', string)) {
  25196. result.push(prefix + string);
  25197. }
  25198. }
  25199. return result;
  25200. }
  25201. /**
  25202. * Zip strings
  25203. */
  25204. function zip(a, b) {
  25205. let arr = [];
  25206. for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
  25207. return arr;
  25208. }
  25209. function compare(a, b) {
  25210. return a > b ? 1 : b > a ? -1 : 0;
  25211. }
  25212. function contains(arr, key, val) {
  25213. return arr.some(ele => ele[key] === val);
  25214. }
  25215. function countNines(min, len) {
  25216. return Number(String(min).slice(0, -len) + '9'.repeat(len));
  25217. }
  25218. function countZeros(integer, zeros) {
  25219. return integer - integer % Math.pow(10, zeros);
  25220. }
  25221. function toQuantifier(digits) {
  25222. let [start = 0, stop = ''] = digits;
  25223. if (stop || start > 1) {
  25224. return `{${start + (stop ? ',' + stop : '')}}`;
  25225. }
  25226. return '';
  25227. }
  25228. function toCharacterClass(a, b, options) {
  25229. return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
  25230. }
  25231. function hasPadding(str) {
  25232. return /^-?(0+)\d/.test(str);
  25233. }
  25234. function padZeros(value, tok, options) {
  25235. if (!tok.isPadded) {
  25236. return value;
  25237. }
  25238. let diff = Math.abs(tok.maxLen - String(value).length);
  25239. let relax = options.relaxZeros !== false;
  25240. switch (diff) {
  25241. case 0:
  25242. return '';
  25243. case 1:
  25244. return relax ? '0?' : '0';
  25245. case 2:
  25246. return relax ? '0{0,2}' : '00';
  25247. default:
  25248. {
  25249. return relax ? `0{0,${diff}}` : `0{${diff}}`;
  25250. }
  25251. }
  25252. }
  25253. /**
  25254. * Cache
  25255. */
  25256. toRegexRange$1.cache = {};
  25257. toRegexRange$1.clearCache = () => toRegexRange$1.cache = {};
  25258. /**
  25259. * Expose `toRegexRange`
  25260. */
  25261. var toRegexRange_1 = toRegexRange$1;
  25262. const util$2 = require$$0__default$4["default"];
  25263. const toRegexRange = toRegexRange_1;
  25264. const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  25265. const transform = toNumber => {
  25266. return value => toNumber === true ? Number(value) : String(value);
  25267. };
  25268. const isValidValue = value => {
  25269. return typeof value === 'number' || typeof value === 'string' && value !== '';
  25270. };
  25271. const isNumber = num => Number.isInteger(+num);
  25272. const zeros = input => {
  25273. let value = `${input}`;
  25274. let index = -1;
  25275. if (value[0] === '-') value = value.slice(1);
  25276. if (value === '0') return false;
  25277. while (value[++index] === '0');
  25278. return index > 0;
  25279. };
  25280. const stringify$4 = (start, end, options) => {
  25281. if (typeof start === 'string' || typeof end === 'string') {
  25282. return true;
  25283. }
  25284. return options.stringify === true;
  25285. };
  25286. const pad = (input, maxLength, toNumber) => {
  25287. if (maxLength > 0) {
  25288. let dash = input[0] === '-' ? '-' : '';
  25289. if (dash) input = input.slice(1);
  25290. input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
  25291. }
  25292. if (toNumber === false) {
  25293. return String(input);
  25294. }
  25295. return input;
  25296. };
  25297. const toMaxLen = (input, maxLength) => {
  25298. let negative = input[0] === '-' ? '-' : '';
  25299. if (negative) {
  25300. input = input.slice(1);
  25301. maxLength--;
  25302. }
  25303. while (input.length < maxLength) input = '0' + input;
  25304. return negative ? '-' + input : input;
  25305. };
  25306. const toSequence = (parts, options) => {
  25307. parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  25308. parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
  25309. let prefix = options.capture ? '' : '?:';
  25310. let positives = '';
  25311. let negatives = '';
  25312. let result;
  25313. if (parts.positives.length) {
  25314. positives = parts.positives.join('|');
  25315. }
  25316. if (parts.negatives.length) {
  25317. negatives = `-(${prefix}${parts.negatives.join('|')})`;
  25318. }
  25319. if (positives && negatives) {
  25320. result = `${positives}|${negatives}`;
  25321. } else {
  25322. result = positives || negatives;
  25323. }
  25324. if (options.wrap) {
  25325. return `(${prefix}${result})`;
  25326. }
  25327. return result;
  25328. };
  25329. const toRange = (a, b, isNumbers, options) => {
  25330. if (isNumbers) {
  25331. return toRegexRange(a, b, Object.assign({
  25332. wrap: false
  25333. }, options));
  25334. }
  25335. let start = String.fromCharCode(a);
  25336. if (a === b) return start;
  25337. let stop = String.fromCharCode(b);
  25338. return `[${start}-${stop}]`;
  25339. };
  25340. const toRegex = (start, end, options) => {
  25341. if (Array.isArray(start)) {
  25342. let wrap = options.wrap === true;
  25343. let prefix = options.capture ? '' : '?:';
  25344. return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
  25345. }
  25346. return toRegexRange(start, end, options);
  25347. };
  25348. const rangeError = (...args) => {
  25349. return new RangeError('Invalid range arguments: ' + util$2.inspect(...args));
  25350. };
  25351. const invalidRange = (start, end, options) => {
  25352. if (options.strictRanges === true) throw rangeError([start, end]);
  25353. return [];
  25354. };
  25355. const invalidStep = (step, options) => {
  25356. if (options.strictRanges === true) {
  25357. throw new TypeError(`Expected step "${step}" to be a number`);
  25358. }
  25359. return [];
  25360. };
  25361. const fillNumbers = (start, end, step = 1, options = {}) => {
  25362. let a = Number(start);
  25363. let b = Number(end);
  25364. if (!Number.isInteger(a) || !Number.isInteger(b)) {
  25365. if (options.strictRanges === true) throw rangeError([start, end]);
  25366. return [];
  25367. } // fix negative zero
  25368. if (a === 0) a = 0;
  25369. if (b === 0) b = 0;
  25370. let descending = a > b;
  25371. let startString = String(start);
  25372. let endString = String(end);
  25373. let stepString = String(step);
  25374. step = Math.max(Math.abs(step), 1);
  25375. let padded = zeros(startString) || zeros(endString) || zeros(stepString);
  25376. let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
  25377. let toNumber = padded === false && stringify$4(start, end, options) === false;
  25378. let format = options.transform || transform(toNumber);
  25379. if (options.toRegex && step === 1) {
  25380. return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
  25381. }
  25382. let parts = {
  25383. negatives: [],
  25384. positives: []
  25385. };
  25386. let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
  25387. let range = [];
  25388. let index = 0;
  25389. while (descending ? a >= b : a <= b) {
  25390. if (options.toRegex === true && step > 1) {
  25391. push(a);
  25392. } else {
  25393. range.push(pad(format(a, index), maxLen, toNumber));
  25394. }
  25395. a = descending ? a - step : a + step;
  25396. index++;
  25397. }
  25398. if (options.toRegex === true) {
  25399. return step > 1 ? toSequence(parts, options) : toRegex(range, null, Object.assign({
  25400. wrap: false
  25401. }, options));
  25402. }
  25403. return range;
  25404. };
  25405. const fillLetters = (start, end, step = 1, options = {}) => {
  25406. if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
  25407. return invalidRange(start, end, options);
  25408. }
  25409. let format = options.transform || (val => String.fromCharCode(val));
  25410. let a = `${start}`.charCodeAt(0);
  25411. let b = `${end}`.charCodeAt(0);
  25412. let descending = a > b;
  25413. let min = Math.min(a, b);
  25414. let max = Math.max(a, b);
  25415. if (options.toRegex && step === 1) {
  25416. return toRange(min, max, false, options);
  25417. }
  25418. let range = [];
  25419. let index = 0;
  25420. while (descending ? a >= b : a <= b) {
  25421. range.push(format(a, index));
  25422. a = descending ? a - step : a + step;
  25423. index++;
  25424. }
  25425. if (options.toRegex === true) {
  25426. return toRegex(range, null, {
  25427. wrap: false,
  25428. options
  25429. });
  25430. }
  25431. return range;
  25432. };
  25433. const fill$b = (start, end, step, options = {}) => {
  25434. if (end == null && isValidValue(start)) {
  25435. return [start];
  25436. }
  25437. if (!isValidValue(start) || !isValidValue(end)) {
  25438. return invalidRange(start, end, options);
  25439. }
  25440. if (typeof step === 'function') {
  25441. return fill$b(start, end, 1, {
  25442. transform: step
  25443. });
  25444. }
  25445. if (isObject$1(step)) {
  25446. return fill$b(start, end, 0, step);
  25447. }
  25448. let opts = Object.assign({}, options);
  25449. if (opts.capture === true) opts.wrap = true;
  25450. step = step || opts.step || 1;
  25451. if (!isNumber(step)) {
  25452. if (step != null && !isObject$1(step)) return invalidStep(step, opts);
  25453. return fill$b(start, end, 1, step);
  25454. }
  25455. if (isNumber(start) && isNumber(end)) {
  25456. return fillNumbers(start, end, step, opts);
  25457. }
  25458. return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
  25459. };
  25460. var fillRange = fill$b;
  25461. const fill$a = fillRange;
  25462. const utils$o = utils$q;
  25463. const compile$1 = (ast, options = {}) => {
  25464. let walk = (node, parent = {}) => {
  25465. let invalidBlock = utils$o.isInvalidBrace(parent);
  25466. let invalidNode = node.invalid === true && options.escapeInvalid === true;
  25467. let invalid = invalidBlock === true || invalidNode === true;
  25468. let prefix = options.escapeInvalid === true ? '\\' : '';
  25469. let output = '';
  25470. if (node.isOpen === true) {
  25471. return prefix + node.value;
  25472. }
  25473. if (node.isClose === true) {
  25474. return prefix + node.value;
  25475. }
  25476. if (node.type === 'open') {
  25477. return invalid ? prefix + node.value : '(';
  25478. }
  25479. if (node.type === 'close') {
  25480. return invalid ? prefix + node.value : ')';
  25481. }
  25482. if (node.type === 'comma') {
  25483. return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
  25484. }
  25485. if (node.value) {
  25486. return node.value;
  25487. }
  25488. if (node.nodes && node.ranges > 0) {
  25489. let args = utils$o.reduce(node.nodes);
  25490. let range = fill$a(...args, Object.assign(Object.assign({}, options), {}, {
  25491. wrap: false,
  25492. toRegex: true
  25493. }));
  25494. if (range.length !== 0) {
  25495. return args.length > 1 && range.length > 1 ? `(${range})` : range;
  25496. }
  25497. }
  25498. if (node.nodes) {
  25499. for (let child of node.nodes) {
  25500. output += walk(child, node);
  25501. }
  25502. }
  25503. return output;
  25504. };
  25505. return walk(ast);
  25506. };
  25507. var compile_1 = compile$1;
  25508. const fill$9 = fillRange;
  25509. const stringify$3 = stringify$5;
  25510. const utils$n = utils$q;
  25511. const append = (queue = '', stash = '', enclose = false) => {
  25512. let result = [];
  25513. queue = [].concat(queue);
  25514. stash = [].concat(stash);
  25515. if (!stash.length) return queue;
  25516. if (!queue.length) {
  25517. return enclose ? utils$n.flatten(stash).map(ele => `{${ele}}`) : stash;
  25518. }
  25519. for (let item of queue) {
  25520. if (Array.isArray(item)) {
  25521. for (let value of item) {
  25522. result.push(append(value, stash, enclose));
  25523. }
  25524. } else {
  25525. for (let ele of stash) {
  25526. if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
  25527. result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
  25528. }
  25529. }
  25530. }
  25531. return utils$n.flatten(result);
  25532. };
  25533. const expand$1 = (ast, options = {}) => {
  25534. let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
  25535. let walk = (node, parent = {}) => {
  25536. node.queue = [];
  25537. let p = parent;
  25538. let q = parent.queue;
  25539. while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
  25540. p = p.parent;
  25541. q = p.queue;
  25542. }
  25543. if (node.invalid || node.dollar) {
  25544. q.push(append(q.pop(), stringify$3(node, options)));
  25545. return;
  25546. }
  25547. if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
  25548. q.push(append(q.pop(), ['{}']));
  25549. return;
  25550. }
  25551. if (node.nodes && node.ranges > 0) {
  25552. let args = utils$n.reduce(node.nodes);
  25553. if (utils$n.exceedsLimit(...args, options.step, rangeLimit)) {
  25554. throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
  25555. }
  25556. let range = fill$9(...args, options);
  25557. if (range.length === 0) {
  25558. range = stringify$3(node, options);
  25559. }
  25560. q.push(append(q.pop(), range));
  25561. node.nodes = [];
  25562. return;
  25563. }
  25564. let enclose = utils$n.encloseBrace(node);
  25565. let queue = node.queue;
  25566. let block = node;
  25567. while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
  25568. block = block.parent;
  25569. queue = block.queue;
  25570. }
  25571. for (let i = 0; i < node.nodes.length; i++) {
  25572. let child = node.nodes[i];
  25573. if (child.type === 'comma' && node.type === 'brace') {
  25574. if (i === 1) queue.push('');
  25575. queue.push('');
  25576. continue;
  25577. }
  25578. if (child.type === 'close') {
  25579. q.push(append(q.pop(), queue, enclose));
  25580. continue;
  25581. }
  25582. if (child.value && child.type !== 'open') {
  25583. queue.push(append(queue.pop(), child.value));
  25584. continue;
  25585. }
  25586. if (child.nodes) {
  25587. walk(child, node);
  25588. }
  25589. }
  25590. return queue;
  25591. };
  25592. return utils$n.flatten(walk(ast));
  25593. };
  25594. var expand_1 = expand$1;
  25595. var constants$4 = {
  25596. MAX_LENGTH: 1024 * 64,
  25597. // Digits
  25598. CHAR_0: '0',
  25599. /* 0 */
  25600. CHAR_9: '9',
  25601. /* 9 */
  25602. // Alphabet chars.
  25603. CHAR_UPPERCASE_A: 'A',
  25604. /* A */
  25605. CHAR_LOWERCASE_A: 'a',
  25606. /* a */
  25607. CHAR_UPPERCASE_Z: 'Z',
  25608. /* Z */
  25609. CHAR_LOWERCASE_Z: 'z',
  25610. /* z */
  25611. CHAR_LEFT_PARENTHESES: '(',
  25612. /* ( */
  25613. CHAR_RIGHT_PARENTHESES: ')',
  25614. /* ) */
  25615. CHAR_ASTERISK: '*',
  25616. /* * */
  25617. // Non-alphabetic chars.
  25618. CHAR_AMPERSAND: '&',
  25619. /* & */
  25620. CHAR_AT: '@',
  25621. /* @ */
  25622. CHAR_BACKSLASH: '\\',
  25623. /* \ */
  25624. CHAR_BACKTICK: '`',
  25625. /* ` */
  25626. CHAR_CARRIAGE_RETURN: '\r',
  25627. /* \r */
  25628. CHAR_CIRCUMFLEX_ACCENT: '^',
  25629. /* ^ */
  25630. CHAR_COLON: ':',
  25631. /* : */
  25632. CHAR_COMMA: ',',
  25633. /* , */
  25634. CHAR_DOLLAR: '$',
  25635. /* . */
  25636. CHAR_DOT: '.',
  25637. /* . */
  25638. CHAR_DOUBLE_QUOTE: '"',
  25639. /* " */
  25640. CHAR_EQUAL: '=',
  25641. /* = */
  25642. CHAR_EXCLAMATION_MARK: '!',
  25643. /* ! */
  25644. CHAR_FORM_FEED: '\f',
  25645. /* \f */
  25646. CHAR_FORWARD_SLASH: '/',
  25647. /* / */
  25648. CHAR_HASH: '#',
  25649. /* # */
  25650. CHAR_HYPHEN_MINUS: '-',
  25651. /* - */
  25652. CHAR_LEFT_ANGLE_BRACKET: '<',
  25653. /* < */
  25654. CHAR_LEFT_CURLY_BRACE: '{',
  25655. /* { */
  25656. CHAR_LEFT_SQUARE_BRACKET: '[',
  25657. /* [ */
  25658. CHAR_LINE_FEED: '\n',
  25659. /* \n */
  25660. CHAR_NO_BREAK_SPACE: '\u00A0',
  25661. /* \u00A0 */
  25662. CHAR_PERCENT: '%',
  25663. /* % */
  25664. CHAR_PLUS: '+',
  25665. /* + */
  25666. CHAR_QUESTION_MARK: '?',
  25667. /* ? */
  25668. CHAR_RIGHT_ANGLE_BRACKET: '>',
  25669. /* > */
  25670. CHAR_RIGHT_CURLY_BRACE: '}',
  25671. /* } */
  25672. CHAR_RIGHT_SQUARE_BRACKET: ']',
  25673. /* ] */
  25674. CHAR_SEMICOLON: ';',
  25675. /* ; */
  25676. CHAR_SINGLE_QUOTE: '\'',
  25677. /* ' */
  25678. CHAR_SPACE: ' ',
  25679. /* */
  25680. CHAR_TAB: '\t',
  25681. /* \t */
  25682. CHAR_UNDERSCORE: '_',
  25683. /* _ */
  25684. CHAR_VERTICAL_LINE: '|',
  25685. /* | */
  25686. CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
  25687. /* \uFEFF */
  25688. };
  25689. const stringify$2 = stringify$5;
  25690. /**
  25691. * Constants
  25692. */
  25693. const {
  25694. MAX_LENGTH: MAX_LENGTH$1,
  25695. CHAR_BACKSLASH,
  25696. /* \ */
  25697. CHAR_BACKTICK,
  25698. /* ` */
  25699. CHAR_COMMA: CHAR_COMMA$1,
  25700. /* , */
  25701. CHAR_DOT: CHAR_DOT$1,
  25702. /* . */
  25703. CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1,
  25704. /* ( */
  25705. CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1,
  25706. /* ) */
  25707. CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1,
  25708. /* { */
  25709. CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1,
  25710. /* } */
  25711. CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1,
  25712. /* [ */
  25713. CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1,
  25714. /* ] */
  25715. CHAR_DOUBLE_QUOTE,
  25716. /* " */
  25717. CHAR_SINGLE_QUOTE,
  25718. /* ' */
  25719. CHAR_NO_BREAK_SPACE,
  25720. CHAR_ZERO_WIDTH_NOBREAK_SPACE
  25721. } = constants$4;
  25722. /**
  25723. * parse
  25724. */
  25725. const parse$5 = (input, options = {}) => {
  25726. if (typeof input !== 'string') {
  25727. throw new TypeError('Expected a string');
  25728. }
  25729. let opts = options || {};
  25730. let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
  25731. if (input.length > max) {
  25732. throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
  25733. }
  25734. let ast = {
  25735. type: 'root',
  25736. input,
  25737. nodes: []
  25738. };
  25739. let stack = [ast];
  25740. let block = ast;
  25741. let prev = ast;
  25742. let brackets = 0;
  25743. let length = input.length;
  25744. let index = 0;
  25745. let depth = 0;
  25746. let value;
  25747. /**
  25748. * Helpers
  25749. */
  25750. const advance = () => input[index++];
  25751. const push = node => {
  25752. if (node.type === 'text' && prev.type === 'dot') {
  25753. prev.type = 'text';
  25754. }
  25755. if (prev && prev.type === 'text' && node.type === 'text') {
  25756. prev.value += node.value;
  25757. return;
  25758. }
  25759. block.nodes.push(node);
  25760. node.parent = block;
  25761. node.prev = prev;
  25762. prev = node;
  25763. return node;
  25764. };
  25765. push({
  25766. type: 'bos'
  25767. });
  25768. while (index < length) {
  25769. block = stack[stack.length - 1];
  25770. value = advance();
  25771. /**
  25772. * Invalid chars
  25773. */
  25774. if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
  25775. continue;
  25776. }
  25777. /**
  25778. * Escaped chars
  25779. */
  25780. if (value === CHAR_BACKSLASH) {
  25781. push({
  25782. type: 'text',
  25783. value: (options.keepEscaping ? value : '') + advance()
  25784. });
  25785. continue;
  25786. }
  25787. /**
  25788. * Right square bracket (literal): ']'
  25789. */
  25790. if (value === CHAR_RIGHT_SQUARE_BRACKET$1) {
  25791. push({
  25792. type: 'text',
  25793. value: '\\' + value
  25794. });
  25795. continue;
  25796. }
  25797. /**
  25798. * Left square bracket: '['
  25799. */
  25800. if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
  25801. brackets++;
  25802. let next;
  25803. while (index < length && (next = advance())) {
  25804. value += next;
  25805. if (next === CHAR_LEFT_SQUARE_BRACKET$1) {
  25806. brackets++;
  25807. continue;
  25808. }
  25809. if (next === CHAR_BACKSLASH) {
  25810. value += advance();
  25811. continue;
  25812. }
  25813. if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
  25814. brackets--;
  25815. if (brackets === 0) {
  25816. break;
  25817. }
  25818. }
  25819. }
  25820. push({
  25821. type: 'text',
  25822. value
  25823. });
  25824. continue;
  25825. }
  25826. /**
  25827. * Parentheses
  25828. */
  25829. if (value === CHAR_LEFT_PARENTHESES$1) {
  25830. block = push({
  25831. type: 'paren',
  25832. nodes: []
  25833. });
  25834. stack.push(block);
  25835. push({
  25836. type: 'text',
  25837. value
  25838. });
  25839. continue;
  25840. }
  25841. if (value === CHAR_RIGHT_PARENTHESES$1) {
  25842. if (block.type !== 'paren') {
  25843. push({
  25844. type: 'text',
  25845. value
  25846. });
  25847. continue;
  25848. }
  25849. block = stack.pop();
  25850. push({
  25851. type: 'text',
  25852. value
  25853. });
  25854. block = stack[stack.length - 1];
  25855. continue;
  25856. }
  25857. /**
  25858. * Quotes: '|"|`
  25859. */
  25860. if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
  25861. let open = value;
  25862. let next;
  25863. if (options.keepQuotes !== true) {
  25864. value = '';
  25865. }
  25866. while (index < length && (next = advance())) {
  25867. if (next === CHAR_BACKSLASH) {
  25868. value += next + advance();
  25869. continue;
  25870. }
  25871. if (next === open) {
  25872. if (options.keepQuotes === true) value += next;
  25873. break;
  25874. }
  25875. value += next;
  25876. }
  25877. push({
  25878. type: 'text',
  25879. value
  25880. });
  25881. continue;
  25882. }
  25883. /**
  25884. * Left curly brace: '{'
  25885. */
  25886. if (value === CHAR_LEFT_CURLY_BRACE$1) {
  25887. depth++;
  25888. let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
  25889. let brace = {
  25890. type: 'brace',
  25891. open: true,
  25892. close: false,
  25893. dollar,
  25894. depth,
  25895. commas: 0,
  25896. ranges: 0,
  25897. nodes: []
  25898. };
  25899. block = push(brace);
  25900. stack.push(block);
  25901. push({
  25902. type: 'open',
  25903. value
  25904. });
  25905. continue;
  25906. }
  25907. /**
  25908. * Right curly brace: '}'
  25909. */
  25910. if (value === CHAR_RIGHT_CURLY_BRACE$1) {
  25911. if (block.type !== 'brace') {
  25912. push({
  25913. type: 'text',
  25914. value
  25915. });
  25916. continue;
  25917. }
  25918. let type = 'close';
  25919. block = stack.pop();
  25920. block.close = true;
  25921. push({
  25922. type,
  25923. value
  25924. });
  25925. depth--;
  25926. block = stack[stack.length - 1];
  25927. continue;
  25928. }
  25929. /**
  25930. * Comma: ','
  25931. */
  25932. if (value === CHAR_COMMA$1 && depth > 0) {
  25933. if (block.ranges > 0) {
  25934. block.ranges = 0;
  25935. let open = block.nodes.shift();
  25936. block.nodes = [open, {
  25937. type: 'text',
  25938. value: stringify$2(block)
  25939. }];
  25940. }
  25941. push({
  25942. type: 'comma',
  25943. value
  25944. });
  25945. block.commas++;
  25946. continue;
  25947. }
  25948. /**
  25949. * Dot: '.'
  25950. */
  25951. if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
  25952. let siblings = block.nodes;
  25953. if (depth === 0 || siblings.length === 0) {
  25954. push({
  25955. type: 'text',
  25956. value
  25957. });
  25958. continue;
  25959. }
  25960. if (prev.type === 'dot') {
  25961. block.range = [];
  25962. prev.value += value;
  25963. prev.type = 'range';
  25964. if (block.nodes.length !== 3 && block.nodes.length !== 5) {
  25965. block.invalid = true;
  25966. block.ranges = 0;
  25967. prev.type = 'text';
  25968. continue;
  25969. }
  25970. block.ranges++;
  25971. block.args = [];
  25972. continue;
  25973. }
  25974. if (prev.type === 'range') {
  25975. siblings.pop();
  25976. let before = siblings[siblings.length - 1];
  25977. before.value += prev.value + value;
  25978. prev = before;
  25979. block.ranges--;
  25980. continue;
  25981. }
  25982. push({
  25983. type: 'dot',
  25984. value
  25985. });
  25986. continue;
  25987. }
  25988. /**
  25989. * Text
  25990. */
  25991. push({
  25992. type: 'text',
  25993. value
  25994. });
  25995. } // Mark imbalanced braces and brackets as invalid
  25996. do {
  25997. block = stack.pop();
  25998. if (block.type !== 'root') {
  25999. block.nodes.forEach(node => {
  26000. if (!node.nodes) {
  26001. if (node.type === 'open') node.isOpen = true;
  26002. if (node.type === 'close') node.isClose = true;
  26003. if (!node.nodes) node.type = 'text';
  26004. node.invalid = true;
  26005. }
  26006. }); // get the location of the block on parent.nodes (block's siblings)
  26007. let parent = stack[stack.length - 1];
  26008. let index = parent.nodes.indexOf(block); // replace the (invalid) block with it's nodes
  26009. parent.nodes.splice(index, 1, ...block.nodes);
  26010. }
  26011. } while (stack.length > 0);
  26012. push({
  26013. type: 'eos'
  26014. });
  26015. return ast;
  26016. };
  26017. var parse_1$2 = parse$5;
  26018. const stringify$1 = stringify$5;
  26019. const compile = compile_1;
  26020. const expand = expand_1;
  26021. const parse$4 = parse_1$2;
  26022. /**
  26023. * Expand the given pattern or create a regex-compatible string.
  26024. *
  26025. * ```js
  26026. * const braces = require('braces');
  26027. * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
  26028. * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
  26029. * ```
  26030. * @param {String} `str`
  26031. * @param {Object} `options`
  26032. * @return {String}
  26033. * @api public
  26034. */
  26035. const braces$1 = (input, options = {}) => {
  26036. let output = [];
  26037. if (Array.isArray(input)) {
  26038. for (let pattern of input) {
  26039. let result = braces$1.create(pattern, options);
  26040. if (Array.isArray(result)) {
  26041. output.push(...result);
  26042. } else {
  26043. output.push(result);
  26044. }
  26045. }
  26046. } else {
  26047. output = [].concat(braces$1.create(input, options));
  26048. }
  26049. if (options && options.expand === true && options.nodupes === true) {
  26050. output = [...new Set(output)];
  26051. }
  26052. return output;
  26053. };
  26054. /**
  26055. * Parse the given `str` with the given `options`.
  26056. *
  26057. * ```js
  26058. * // braces.parse(pattern, [, options]);
  26059. * const ast = braces.parse('a/{b,c}/d');
  26060. * console.log(ast);
  26061. * ```
  26062. * @param {String} pattern Brace pattern to parse
  26063. * @param {Object} options
  26064. * @return {Object} Returns an AST
  26065. * @api public
  26066. */
  26067. braces$1.parse = (input, options = {}) => parse$4(input, options);
  26068. /**
  26069. * Creates a braces string from an AST, or an AST node.
  26070. *
  26071. * ```js
  26072. * const braces = require('braces');
  26073. * let ast = braces.parse('foo/{a,b}/bar');
  26074. * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
  26075. * ```
  26076. * @param {String} `input` Brace pattern or AST.
  26077. * @param {Object} `options`
  26078. * @return {Array} Returns an array of expanded values.
  26079. * @api public
  26080. */
  26081. braces$1.stringify = (input, options = {}) => {
  26082. if (typeof input === 'string') {
  26083. return stringify$1(braces$1.parse(input, options), options);
  26084. }
  26085. return stringify$1(input, options);
  26086. };
  26087. /**
  26088. * Compiles a brace pattern into a regex-compatible, optimized string.
  26089. * This method is called by the main [braces](#braces) function by default.
  26090. *
  26091. * ```js
  26092. * const braces = require('braces');
  26093. * console.log(braces.compile('a/{b,c}/d'));
  26094. * //=> ['a/(b|c)/d']
  26095. * ```
  26096. * @param {String} `input` Brace pattern or AST.
  26097. * @param {Object} `options`
  26098. * @return {Array} Returns an array of expanded values.
  26099. * @api public
  26100. */
  26101. braces$1.compile = (input, options = {}) => {
  26102. if (typeof input === 'string') {
  26103. input = braces$1.parse(input, options);
  26104. }
  26105. return compile(input, options);
  26106. };
  26107. /**
  26108. * Expands a brace pattern into an array. This method is called by the
  26109. * main [braces](#braces) function when `options.expand` is true. Before
  26110. * using this method it's recommended that you read the [performance notes](#performance))
  26111. * and advantages of using [.compile](#compile) instead.
  26112. *
  26113. * ```js
  26114. * const braces = require('braces');
  26115. * console.log(braces.expand('a/{b,c}/d'));
  26116. * //=> ['a/b/d', 'a/c/d'];
  26117. * ```
  26118. * @param {String} `pattern` Brace pattern
  26119. * @param {Object} `options`
  26120. * @return {Array} Returns an array of expanded values.
  26121. * @api public
  26122. */
  26123. braces$1.expand = (input, options = {}) => {
  26124. if (typeof input === 'string') {
  26125. input = braces$1.parse(input, options);
  26126. }
  26127. let result = expand(input, options); // filter out empty strings if specified
  26128. if (options.noempty === true) {
  26129. result = result.filter(Boolean);
  26130. } // filter out duplicates if specified
  26131. if (options.nodupes === true) {
  26132. result = [...new Set(result)];
  26133. }
  26134. return result;
  26135. };
  26136. /**
  26137. * Processes a brace pattern and returns either an expanded array
  26138. * (if `options.expand` is true), a highly optimized regex-compatible string.
  26139. * This method is called by the main [braces](#braces) function.
  26140. *
  26141. * ```js
  26142. * const braces = require('braces');
  26143. * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
  26144. * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
  26145. * ```
  26146. * @param {String} `pattern` Brace pattern
  26147. * @param {Object} `options`
  26148. * @return {Array} Returns an array of expanded values.
  26149. * @api public
  26150. */
  26151. braces$1.create = (input, options = {}) => {
  26152. if (input === '' || input.length < 3) {
  26153. return [input];
  26154. }
  26155. return options.expand !== true ? braces$1.compile(input, options) : braces$1.expand(input, options);
  26156. };
  26157. /**
  26158. * Expose "braces"
  26159. */
  26160. var braces_1 = braces$1;
  26161. var utils$m = {};
  26162. const path$a = require$$0__default$2["default"];
  26163. const WIN_SLASH = '\\\\/';
  26164. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  26165. /**
  26166. * Posix glob regex
  26167. */
  26168. const DOT_LITERAL = '\\.';
  26169. const PLUS_LITERAL = '\\+';
  26170. const QMARK_LITERAL = '\\?';
  26171. const SLASH_LITERAL = '\\/';
  26172. const ONE_CHAR = '(?=.)';
  26173. const QMARK = '[^/]';
  26174. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  26175. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  26176. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  26177. const NO_DOT = `(?!${DOT_LITERAL})`;
  26178. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  26179. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  26180. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  26181. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  26182. const STAR = `${QMARK}*?`;
  26183. const POSIX_CHARS = {
  26184. DOT_LITERAL,
  26185. PLUS_LITERAL,
  26186. QMARK_LITERAL,
  26187. SLASH_LITERAL,
  26188. ONE_CHAR,
  26189. QMARK,
  26190. END_ANCHOR,
  26191. DOTS_SLASH,
  26192. NO_DOT,
  26193. NO_DOTS,
  26194. NO_DOT_SLASH,
  26195. NO_DOTS_SLASH,
  26196. QMARK_NO_DOT,
  26197. STAR,
  26198. START_ANCHOR
  26199. };
  26200. /**
  26201. * Windows glob regex
  26202. */
  26203. const WINDOWS_CHARS = Object.assign(Object.assign({}, POSIX_CHARS), {}, {
  26204. SLASH_LITERAL: `[${WIN_SLASH}]`,
  26205. QMARK: WIN_NO_SLASH,
  26206. STAR: `${WIN_NO_SLASH}*?`,
  26207. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  26208. NO_DOT: `(?!${DOT_LITERAL})`,
  26209. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  26210. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  26211. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  26212. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  26213. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  26214. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
  26215. });
  26216. /**
  26217. * POSIX Bracket Regex
  26218. */
  26219. const POSIX_REGEX_SOURCE$1 = {
  26220. alnum: 'a-zA-Z0-9',
  26221. alpha: 'a-zA-Z',
  26222. ascii: '\\x00-\\x7F',
  26223. blank: ' \\t',
  26224. cntrl: '\\x00-\\x1F\\x7F',
  26225. digit: '0-9',
  26226. graph: '\\x21-\\x7E',
  26227. lower: 'a-z',
  26228. print: '\\x20-\\x7E ',
  26229. punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  26230. space: ' \\t\\r\\n\\v\\f',
  26231. upper: 'A-Z',
  26232. word: 'A-Za-z0-9_',
  26233. xdigit: 'A-Fa-f0-9'
  26234. };
  26235. var constants$3 = {
  26236. MAX_LENGTH: 1024 * 64,
  26237. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  26238. // regular expressions
  26239. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  26240. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  26241. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  26242. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  26243. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  26244. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  26245. // Replace globs with equivalent patterns to reduce parsing time.
  26246. REPLACEMENTS: {
  26247. '***': '*',
  26248. '**/**': '**',
  26249. '**/**/**': '**'
  26250. },
  26251. // Digits
  26252. CHAR_0: 48,
  26253. /* 0 */
  26254. CHAR_9: 57,
  26255. /* 9 */
  26256. // Alphabet chars.
  26257. CHAR_UPPERCASE_A: 65,
  26258. /* A */
  26259. CHAR_LOWERCASE_A: 97,
  26260. /* a */
  26261. CHAR_UPPERCASE_Z: 90,
  26262. /* Z */
  26263. CHAR_LOWERCASE_Z: 122,
  26264. /* z */
  26265. CHAR_LEFT_PARENTHESES: 40,
  26266. /* ( */
  26267. CHAR_RIGHT_PARENTHESES: 41,
  26268. /* ) */
  26269. CHAR_ASTERISK: 42,
  26270. /* * */
  26271. // Non-alphabetic chars.
  26272. CHAR_AMPERSAND: 38,
  26273. /* & */
  26274. CHAR_AT: 64,
  26275. /* @ */
  26276. CHAR_BACKWARD_SLASH: 92,
  26277. /* \ */
  26278. CHAR_CARRIAGE_RETURN: 13,
  26279. /* \r */
  26280. CHAR_CIRCUMFLEX_ACCENT: 94,
  26281. /* ^ */
  26282. CHAR_COLON: 58,
  26283. /* : */
  26284. CHAR_COMMA: 44,
  26285. /* , */
  26286. CHAR_DOT: 46,
  26287. /* . */
  26288. CHAR_DOUBLE_QUOTE: 34,
  26289. /* " */
  26290. CHAR_EQUAL: 61,
  26291. /* = */
  26292. CHAR_EXCLAMATION_MARK: 33,
  26293. /* ! */
  26294. CHAR_FORM_FEED: 12,
  26295. /* \f */
  26296. CHAR_FORWARD_SLASH: 47,
  26297. /* / */
  26298. CHAR_GRAVE_ACCENT: 96,
  26299. /* ` */
  26300. CHAR_HASH: 35,
  26301. /* # */
  26302. CHAR_HYPHEN_MINUS: 45,
  26303. /* - */
  26304. CHAR_LEFT_ANGLE_BRACKET: 60,
  26305. /* < */
  26306. CHAR_LEFT_CURLY_BRACE: 123,
  26307. /* { */
  26308. CHAR_LEFT_SQUARE_BRACKET: 91,
  26309. /* [ */
  26310. CHAR_LINE_FEED: 10,
  26311. /* \n */
  26312. CHAR_NO_BREAK_SPACE: 160,
  26313. /* \u00A0 */
  26314. CHAR_PERCENT: 37,
  26315. /* % */
  26316. CHAR_PLUS: 43,
  26317. /* + */
  26318. CHAR_QUESTION_MARK: 63,
  26319. /* ? */
  26320. CHAR_RIGHT_ANGLE_BRACKET: 62,
  26321. /* > */
  26322. CHAR_RIGHT_CURLY_BRACE: 125,
  26323. /* } */
  26324. CHAR_RIGHT_SQUARE_BRACKET: 93,
  26325. /* ] */
  26326. CHAR_SEMICOLON: 59,
  26327. /* ; */
  26328. CHAR_SINGLE_QUOTE: 39,
  26329. /* ' */
  26330. CHAR_SPACE: 32,
  26331. /* */
  26332. CHAR_TAB: 9,
  26333. /* \t */
  26334. CHAR_UNDERSCORE: 95,
  26335. /* _ */
  26336. CHAR_VERTICAL_LINE: 124,
  26337. /* | */
  26338. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
  26339. /* \uFEFF */
  26340. SEP: path$a.sep,
  26341. /**
  26342. * Create EXTGLOB_CHARS
  26343. */
  26344. extglobChars(chars) {
  26345. return {
  26346. '!': {
  26347. type: 'negate',
  26348. open: '(?:(?!(?:',
  26349. close: `))${chars.STAR})`
  26350. },
  26351. '?': {
  26352. type: 'qmark',
  26353. open: '(?:',
  26354. close: ')?'
  26355. },
  26356. '+': {
  26357. type: 'plus',
  26358. open: '(?:',
  26359. close: ')+'
  26360. },
  26361. '*': {
  26362. type: 'star',
  26363. open: '(?:',
  26364. close: ')*'
  26365. },
  26366. '@': {
  26367. type: 'at',
  26368. open: '(?:',
  26369. close: ')'
  26370. }
  26371. };
  26372. },
  26373. /**
  26374. * Create GLOB_CHARS
  26375. */
  26376. globChars(win32) {
  26377. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  26378. }
  26379. };
  26380. (function (exports) {
  26381. const path = require$$0__default$2["default"];
  26382. const win32 = process.platform === 'win32';
  26383. const {
  26384. REGEX_BACKSLASH,
  26385. REGEX_REMOVE_BACKSLASH,
  26386. REGEX_SPECIAL_CHARS,
  26387. REGEX_SPECIAL_CHARS_GLOBAL
  26388. } = constants$3;
  26389. exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
  26390. exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
  26391. exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
  26392. exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
  26393. exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
  26394. exports.removeBackslashes = str => {
  26395. return str.replace(REGEX_REMOVE_BACKSLASH, match => {
  26396. return match === '\\' ? '' : match;
  26397. });
  26398. };
  26399. exports.supportsLookbehinds = () => {
  26400. const segs = process.version.slice(1).split('.').map(Number);
  26401. if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
  26402. return true;
  26403. }
  26404. return false;
  26405. };
  26406. exports.isWindows = options => {
  26407. if (options && typeof options.windows === 'boolean') {
  26408. return options.windows;
  26409. }
  26410. return win32 === true || path.sep === '\\';
  26411. };
  26412. exports.escapeLast = (input, char, lastIdx) => {
  26413. const idx = input.lastIndexOf(char, lastIdx);
  26414. if (idx === -1) return input;
  26415. if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
  26416. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  26417. };
  26418. exports.removePrefix = (input, state = {}) => {
  26419. let output = input;
  26420. if (output.startsWith('./')) {
  26421. output = output.slice(2);
  26422. state.prefix = './';
  26423. }
  26424. return output;
  26425. };
  26426. exports.wrapOutput = (input, state = {}, options = {}) => {
  26427. const prepend = options.contains ? '' : '^';
  26428. const append = options.contains ? '' : '$';
  26429. let output = `${prepend}(?:${input})${append}`;
  26430. if (state.negated === true) {
  26431. output = `(?:^(?!${output}).*$)`;
  26432. }
  26433. return output;
  26434. };
  26435. })(utils$m);
  26436. const utils$l = utils$m;
  26437. const {
  26438. CHAR_ASTERISK,
  26439. /* * */
  26440. CHAR_AT,
  26441. /* @ */
  26442. CHAR_BACKWARD_SLASH,
  26443. /* \ */
  26444. CHAR_COMMA,
  26445. /* , */
  26446. CHAR_DOT,
  26447. /* . */
  26448. CHAR_EXCLAMATION_MARK,
  26449. /* ! */
  26450. CHAR_FORWARD_SLASH,
  26451. /* / */
  26452. CHAR_LEFT_CURLY_BRACE,
  26453. /* { */
  26454. CHAR_LEFT_PARENTHESES,
  26455. /* ( */
  26456. CHAR_LEFT_SQUARE_BRACKET,
  26457. /* [ */
  26458. CHAR_PLUS,
  26459. /* + */
  26460. CHAR_QUESTION_MARK,
  26461. /* ? */
  26462. CHAR_RIGHT_CURLY_BRACE,
  26463. /* } */
  26464. CHAR_RIGHT_PARENTHESES,
  26465. /* ) */
  26466. CHAR_RIGHT_SQUARE_BRACKET
  26467. /* ] */
  26468. } = constants$3;
  26469. const isPathSeparator = code => {
  26470. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  26471. };
  26472. const depth = token => {
  26473. if (token.isPrefix !== true) {
  26474. token.depth = token.isGlobstar ? Infinity : 1;
  26475. }
  26476. };
  26477. /**
  26478. * Quickly scans a glob pattern and returns an object with a handful of
  26479. * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
  26480. * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
  26481. * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
  26482. *
  26483. * ```js
  26484. * const pm = require('picomatch');
  26485. * console.log(pm.scan('foo/bar/*.js'));
  26486. * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
  26487. * ```
  26488. * @param {String} `str`
  26489. * @param {Object} `options`
  26490. * @return {Object} Returns an object with tokens and regex source string.
  26491. * @api public
  26492. */
  26493. const scan$1 = (input, options) => {
  26494. const opts = options || {};
  26495. const length = input.length - 1;
  26496. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  26497. const slashes = [];
  26498. const tokens = [];
  26499. const parts = [];
  26500. let str = input;
  26501. let index = -1;
  26502. let start = 0;
  26503. let lastIndex = 0;
  26504. let isBrace = false;
  26505. let isBracket = false;
  26506. let isGlob = false;
  26507. let isExtglob = false;
  26508. let isGlobstar = false;
  26509. let braceEscaped = false;
  26510. let backslashes = false;
  26511. let negated = false;
  26512. let negatedExtglob = false;
  26513. let finished = false;
  26514. let braces = 0;
  26515. let prev;
  26516. let code;
  26517. let token = {
  26518. value: '',
  26519. depth: 0,
  26520. isGlob: false
  26521. };
  26522. const eos = () => index >= length;
  26523. const peek = () => str.charCodeAt(index + 1);
  26524. const advance = () => {
  26525. prev = code;
  26526. return str.charCodeAt(++index);
  26527. };
  26528. while (index < length) {
  26529. code = advance();
  26530. let next;
  26531. if (code === CHAR_BACKWARD_SLASH) {
  26532. backslashes = token.backslashes = true;
  26533. code = advance();
  26534. if (code === CHAR_LEFT_CURLY_BRACE) {
  26535. braceEscaped = true;
  26536. }
  26537. continue;
  26538. }
  26539. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  26540. braces++;
  26541. while (eos() !== true && (code = advance())) {
  26542. if (code === CHAR_BACKWARD_SLASH) {
  26543. backslashes = token.backslashes = true;
  26544. advance();
  26545. continue;
  26546. }
  26547. if (code === CHAR_LEFT_CURLY_BRACE) {
  26548. braces++;
  26549. continue;
  26550. }
  26551. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  26552. isBrace = token.isBrace = true;
  26553. isGlob = token.isGlob = true;
  26554. finished = true;
  26555. if (scanToEnd === true) {
  26556. continue;
  26557. }
  26558. break;
  26559. }
  26560. if (braceEscaped !== true && code === CHAR_COMMA) {
  26561. isBrace = token.isBrace = true;
  26562. isGlob = token.isGlob = true;
  26563. finished = true;
  26564. if (scanToEnd === true) {
  26565. continue;
  26566. }
  26567. break;
  26568. }
  26569. if (code === CHAR_RIGHT_CURLY_BRACE) {
  26570. braces--;
  26571. if (braces === 0) {
  26572. braceEscaped = false;
  26573. isBrace = token.isBrace = true;
  26574. finished = true;
  26575. break;
  26576. }
  26577. }
  26578. }
  26579. if (scanToEnd === true) {
  26580. continue;
  26581. }
  26582. break;
  26583. }
  26584. if (code === CHAR_FORWARD_SLASH) {
  26585. slashes.push(index);
  26586. tokens.push(token);
  26587. token = {
  26588. value: '',
  26589. depth: 0,
  26590. isGlob: false
  26591. };
  26592. if (finished === true) continue;
  26593. if (prev === CHAR_DOT && index === start + 1) {
  26594. start += 2;
  26595. continue;
  26596. }
  26597. lastIndex = index + 1;
  26598. continue;
  26599. }
  26600. if (opts.noext !== true) {
  26601. const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
  26602. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  26603. isGlob = token.isGlob = true;
  26604. isExtglob = token.isExtglob = true;
  26605. finished = true;
  26606. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  26607. negatedExtglob = true;
  26608. }
  26609. if (scanToEnd === true) {
  26610. while (eos() !== true && (code = advance())) {
  26611. if (code === CHAR_BACKWARD_SLASH) {
  26612. backslashes = token.backslashes = true;
  26613. code = advance();
  26614. continue;
  26615. }
  26616. if (code === CHAR_RIGHT_PARENTHESES) {
  26617. isGlob = token.isGlob = true;
  26618. finished = true;
  26619. break;
  26620. }
  26621. }
  26622. continue;
  26623. }
  26624. break;
  26625. }
  26626. }
  26627. if (code === CHAR_ASTERISK) {
  26628. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  26629. isGlob = token.isGlob = true;
  26630. finished = true;
  26631. if (scanToEnd === true) {
  26632. continue;
  26633. }
  26634. break;
  26635. }
  26636. if (code === CHAR_QUESTION_MARK) {
  26637. isGlob = token.isGlob = true;
  26638. finished = true;
  26639. if (scanToEnd === true) {
  26640. continue;
  26641. }
  26642. break;
  26643. }
  26644. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  26645. while (eos() !== true && (next = advance())) {
  26646. if (next === CHAR_BACKWARD_SLASH) {
  26647. backslashes = token.backslashes = true;
  26648. advance();
  26649. continue;
  26650. }
  26651. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  26652. isBracket = token.isBracket = true;
  26653. isGlob = token.isGlob = true;
  26654. finished = true;
  26655. break;
  26656. }
  26657. }
  26658. if (scanToEnd === true) {
  26659. continue;
  26660. }
  26661. break;
  26662. }
  26663. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  26664. negated = token.negated = true;
  26665. start++;
  26666. continue;
  26667. }
  26668. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  26669. isGlob = token.isGlob = true;
  26670. if (scanToEnd === true) {
  26671. while (eos() !== true && (code = advance())) {
  26672. if (code === CHAR_LEFT_PARENTHESES) {
  26673. backslashes = token.backslashes = true;
  26674. code = advance();
  26675. continue;
  26676. }
  26677. if (code === CHAR_RIGHT_PARENTHESES) {
  26678. finished = true;
  26679. break;
  26680. }
  26681. }
  26682. continue;
  26683. }
  26684. break;
  26685. }
  26686. if (isGlob === true) {
  26687. finished = true;
  26688. if (scanToEnd === true) {
  26689. continue;
  26690. }
  26691. break;
  26692. }
  26693. }
  26694. if (opts.noext === true) {
  26695. isExtglob = false;
  26696. isGlob = false;
  26697. }
  26698. let base = str;
  26699. let prefix = '';
  26700. let glob = '';
  26701. if (start > 0) {
  26702. prefix = str.slice(0, start);
  26703. str = str.slice(start);
  26704. lastIndex -= start;
  26705. }
  26706. if (base && isGlob === true && lastIndex > 0) {
  26707. base = str.slice(0, lastIndex);
  26708. glob = str.slice(lastIndex);
  26709. } else if (isGlob === true) {
  26710. base = '';
  26711. glob = str;
  26712. } else {
  26713. base = str;
  26714. }
  26715. if (base && base !== '' && base !== '/' && base !== str) {
  26716. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  26717. base = base.slice(0, -1);
  26718. }
  26719. }
  26720. if (opts.unescape === true) {
  26721. if (glob) glob = utils$l.removeBackslashes(glob);
  26722. if (base && backslashes === true) {
  26723. base = utils$l.removeBackslashes(base);
  26724. }
  26725. }
  26726. const state = {
  26727. prefix,
  26728. input,
  26729. start,
  26730. base,
  26731. glob,
  26732. isBrace,
  26733. isBracket,
  26734. isGlob,
  26735. isExtglob,
  26736. isGlobstar,
  26737. negated,
  26738. negatedExtglob
  26739. };
  26740. if (opts.tokens === true) {
  26741. state.maxDepth = 0;
  26742. if (!isPathSeparator(code)) {
  26743. tokens.push(token);
  26744. }
  26745. state.tokens = tokens;
  26746. }
  26747. if (opts.parts === true || opts.tokens === true) {
  26748. let prevIndex;
  26749. for (let idx = 0; idx < slashes.length; idx++) {
  26750. const n = prevIndex ? prevIndex + 1 : start;
  26751. const i = slashes[idx];
  26752. const value = input.slice(n, i);
  26753. if (opts.tokens) {
  26754. if (idx === 0 && start !== 0) {
  26755. tokens[idx].isPrefix = true;
  26756. tokens[idx].value = prefix;
  26757. } else {
  26758. tokens[idx].value = value;
  26759. }
  26760. depth(tokens[idx]);
  26761. state.maxDepth += tokens[idx].depth;
  26762. }
  26763. if (idx !== 0 || value !== '') {
  26764. parts.push(value);
  26765. }
  26766. prevIndex = i;
  26767. }
  26768. if (prevIndex && prevIndex + 1 < input.length) {
  26769. const value = input.slice(prevIndex + 1);
  26770. parts.push(value);
  26771. if (opts.tokens) {
  26772. tokens[tokens.length - 1].value = value;
  26773. depth(tokens[tokens.length - 1]);
  26774. state.maxDepth += tokens[tokens.length - 1].depth;
  26775. }
  26776. }
  26777. state.slashes = slashes;
  26778. state.parts = parts;
  26779. }
  26780. return state;
  26781. };
  26782. var scan_1 = scan$1;
  26783. const constants$2 = constants$3;
  26784. const utils$k = utils$m;
  26785. /**
  26786. * Constants
  26787. */
  26788. const {
  26789. MAX_LENGTH,
  26790. POSIX_REGEX_SOURCE,
  26791. REGEX_NON_SPECIAL_CHARS,
  26792. REGEX_SPECIAL_CHARS_BACKREF,
  26793. REPLACEMENTS
  26794. } = constants$2;
  26795. /**
  26796. * Helpers
  26797. */
  26798. const expandRange = (args, options) => {
  26799. if (typeof options.expandRange === 'function') {
  26800. return options.expandRange(...args, options);
  26801. }
  26802. args.sort();
  26803. const value = `[${args.join('-')}]`;
  26804. try {
  26805. /* eslint-disable-next-line no-new */
  26806. new RegExp(value);
  26807. } catch (ex) {
  26808. return args.map(v => utils$k.escapeRegex(v)).join('..');
  26809. }
  26810. return value;
  26811. };
  26812. /**
  26813. * Create the message for a syntax error
  26814. */
  26815. const syntaxError$1 = (type, char) => {
  26816. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  26817. };
  26818. /**
  26819. * Parse the given input string.
  26820. * @param {String} input
  26821. * @param {Object} options
  26822. * @return {Object}
  26823. */
  26824. const parse$3 = (input, options) => {
  26825. if (typeof input !== 'string') {
  26826. throw new TypeError('Expected a string');
  26827. }
  26828. input = REPLACEMENTS[input] || input;
  26829. const opts = Object.assign({}, options);
  26830. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  26831. let len = input.length;
  26832. if (len > max) {
  26833. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  26834. }
  26835. const bos = {
  26836. type: 'bos',
  26837. value: '',
  26838. output: opts.prepend || ''
  26839. };
  26840. const tokens = [bos];
  26841. const capture = opts.capture ? '' : '?:';
  26842. const win32 = utils$k.isWindows(options); // create constants based on platform, for windows or posix
  26843. const PLATFORM_CHARS = constants$2.globChars(win32);
  26844. const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
  26845. const {
  26846. DOT_LITERAL,
  26847. PLUS_LITERAL,
  26848. SLASH_LITERAL,
  26849. ONE_CHAR,
  26850. DOTS_SLASH,
  26851. NO_DOT,
  26852. NO_DOT_SLASH,
  26853. NO_DOTS_SLASH,
  26854. QMARK,
  26855. QMARK_NO_DOT,
  26856. STAR,
  26857. START_ANCHOR
  26858. } = PLATFORM_CHARS;
  26859. const globstar = opts => {
  26860. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  26861. };
  26862. const nodot = opts.dot ? '' : NO_DOT;
  26863. const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
  26864. let star = opts.bash === true ? globstar(opts) : STAR;
  26865. if (opts.capture) {
  26866. star = `(${star})`;
  26867. } // minimatch options support
  26868. if (typeof opts.noext === 'boolean') {
  26869. opts.noextglob = opts.noext;
  26870. }
  26871. const state = {
  26872. input,
  26873. index: -1,
  26874. start: 0,
  26875. dot: opts.dot === true,
  26876. consumed: '',
  26877. output: '',
  26878. prefix: '',
  26879. backtrack: false,
  26880. negated: false,
  26881. brackets: 0,
  26882. braces: 0,
  26883. parens: 0,
  26884. quotes: 0,
  26885. globstar: false,
  26886. tokens
  26887. };
  26888. input = utils$k.removePrefix(input, state);
  26889. len = input.length;
  26890. const extglobs = [];
  26891. const braces = [];
  26892. const stack = [];
  26893. let prev = bos;
  26894. let value;
  26895. /**
  26896. * Tokenizing helpers
  26897. */
  26898. const eos = () => state.index === len - 1;
  26899. const peek = state.peek = (n = 1) => input[state.index + n];
  26900. const advance = state.advance = () => input[++state.index] || '';
  26901. const remaining = () => input.slice(state.index + 1);
  26902. const consume = (value = '', num = 0) => {
  26903. state.consumed += value;
  26904. state.index += num;
  26905. };
  26906. const append = token => {
  26907. state.output += token.output != null ? token.output : token.value;
  26908. consume(token.value);
  26909. };
  26910. const negate = () => {
  26911. let count = 1;
  26912. while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
  26913. advance();
  26914. state.start++;
  26915. count++;
  26916. }
  26917. if (count % 2 === 0) {
  26918. return false;
  26919. }
  26920. state.negated = true;
  26921. state.start++;
  26922. return true;
  26923. };
  26924. const increment = type => {
  26925. state[type]++;
  26926. stack.push(type);
  26927. };
  26928. const decrement = type => {
  26929. state[type]--;
  26930. stack.pop();
  26931. };
  26932. /**
  26933. * Push tokens onto the tokens array. This helper speeds up
  26934. * tokenizing by 1) helping us avoid backtracking as much as possible,
  26935. * and 2) helping us avoid creating extra tokens when consecutive
  26936. * characters are plain text. This improves performance and simplifies
  26937. * lookbehinds.
  26938. */
  26939. const push = tok => {
  26940. if (prev.type === 'globstar') {
  26941. const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
  26942. const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren');
  26943. if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
  26944. state.output = state.output.slice(0, -prev.output.length);
  26945. prev.type = 'star';
  26946. prev.value = '*';
  26947. prev.output = star;
  26948. state.output += prev.output;
  26949. }
  26950. }
  26951. if (extglobs.length && tok.type !== 'paren') {
  26952. extglobs[extglobs.length - 1].inner += tok.value;
  26953. }
  26954. if (tok.value || tok.output) append(tok);
  26955. if (prev && prev.type === 'text' && tok.type === 'text') {
  26956. prev.value += tok.value;
  26957. prev.output = (prev.output || '') + tok.value;
  26958. return;
  26959. }
  26960. tok.prev = prev;
  26961. tokens.push(tok);
  26962. prev = tok;
  26963. };
  26964. const extglobOpen = (type, value) => {
  26965. const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, {
  26966. conditions: 1,
  26967. inner: ''
  26968. });
  26969. token.prev = prev;
  26970. token.parens = state.parens;
  26971. token.output = state.output;
  26972. const output = (opts.capture ? '(' : '') + token.open;
  26973. increment('parens');
  26974. push({
  26975. type,
  26976. value,
  26977. output: state.output ? '' : ONE_CHAR
  26978. });
  26979. push({
  26980. type: 'paren',
  26981. extglob: true,
  26982. value: advance(),
  26983. output
  26984. });
  26985. extglobs.push(token);
  26986. };
  26987. const extglobClose = token => {
  26988. let output = token.close + (opts.capture ? ')' : '');
  26989. let rest;
  26990. if (token.type === 'negate') {
  26991. let extglobStar = star;
  26992. if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
  26993. extglobStar = globstar(opts);
  26994. }
  26995. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  26996. output = token.close = `)$))${extglobStar}`;
  26997. }
  26998. if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  26999. output = token.close = `)${rest})${extglobStar})`;
  27000. }
  27001. if (token.prev.type === 'bos') {
  27002. state.negatedExtglob = true;
  27003. }
  27004. }
  27005. push({
  27006. type: 'paren',
  27007. extglob: true,
  27008. value,
  27009. output
  27010. });
  27011. decrement('parens');
  27012. };
  27013. /**
  27014. * Fast paths
  27015. */
  27016. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  27017. let backslashes = false;
  27018. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  27019. if (first === '\\') {
  27020. backslashes = true;
  27021. return m;
  27022. }
  27023. if (first === '?') {
  27024. if (esc) {
  27025. return esc + first + (rest ? QMARK.repeat(rest.length) : '');
  27026. }
  27027. if (index === 0) {
  27028. return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
  27029. }
  27030. return QMARK.repeat(chars.length);
  27031. }
  27032. if (first === '.') {
  27033. return DOT_LITERAL.repeat(chars.length);
  27034. }
  27035. if (first === '*') {
  27036. if (esc) {
  27037. return esc + first + (rest ? star : '');
  27038. }
  27039. return star;
  27040. }
  27041. return esc ? m : `\\${m}`;
  27042. });
  27043. if (backslashes === true) {
  27044. if (opts.unescape === true) {
  27045. output = output.replace(/\\/g, '');
  27046. } else {
  27047. output = output.replace(/\\+/g, m => {
  27048. return m.length % 2 === 0 ? '\\\\' : m ? '\\' : '';
  27049. });
  27050. }
  27051. }
  27052. if (output === input && opts.contains === true) {
  27053. state.output = input;
  27054. return state;
  27055. }
  27056. state.output = utils$k.wrapOutput(output, state, options);
  27057. return state;
  27058. }
  27059. /**
  27060. * Tokenize input until we reach end-of-string
  27061. */
  27062. while (!eos()) {
  27063. value = advance();
  27064. if (value === '\u0000') {
  27065. continue;
  27066. }
  27067. /**
  27068. * Escaped characters
  27069. */
  27070. if (value === '\\') {
  27071. const next = peek();
  27072. if (next === '/' && opts.bash !== true) {
  27073. continue;
  27074. }
  27075. if (next === '.' || next === ';') {
  27076. continue;
  27077. }
  27078. if (!next) {
  27079. value += '\\';
  27080. push({
  27081. type: 'text',
  27082. value
  27083. });
  27084. continue;
  27085. } // collapse slashes to reduce potential for exploits
  27086. const match = /^\\+/.exec(remaining());
  27087. let slashes = 0;
  27088. if (match && match[0].length > 2) {
  27089. slashes = match[0].length;
  27090. state.index += slashes;
  27091. if (slashes % 2 !== 0) {
  27092. value += '\\';
  27093. }
  27094. }
  27095. if (opts.unescape === true) {
  27096. value = advance();
  27097. } else {
  27098. value += advance();
  27099. }
  27100. if (state.brackets === 0) {
  27101. push({
  27102. type: 'text',
  27103. value
  27104. });
  27105. continue;
  27106. }
  27107. }
  27108. /**
  27109. * If we're inside a regex character class, continue
  27110. * until we reach the closing bracket.
  27111. */
  27112. if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
  27113. if (opts.posix !== false && value === ':') {
  27114. const inner = prev.value.slice(1);
  27115. if (inner.includes('[')) {
  27116. prev.posix = true;
  27117. if (inner.includes(':')) {
  27118. const idx = prev.value.lastIndexOf('[');
  27119. const pre = prev.value.slice(0, idx);
  27120. const rest = prev.value.slice(idx + 2);
  27121. const posix = POSIX_REGEX_SOURCE[rest];
  27122. if (posix) {
  27123. prev.value = pre + posix;
  27124. state.backtrack = true;
  27125. advance();
  27126. if (!bos.output && tokens.indexOf(prev) === 1) {
  27127. bos.output = ONE_CHAR;
  27128. }
  27129. continue;
  27130. }
  27131. }
  27132. }
  27133. }
  27134. if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') {
  27135. value = `\\${value}`;
  27136. }
  27137. if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
  27138. value = `\\${value}`;
  27139. }
  27140. if (opts.posix === true && value === '!' && prev.value === '[') {
  27141. value = '^';
  27142. }
  27143. prev.value += value;
  27144. append({
  27145. value
  27146. });
  27147. continue;
  27148. }
  27149. /**
  27150. * If we're inside a quoted string, continue
  27151. * until we reach the closing double quote.
  27152. */
  27153. if (state.quotes === 1 && value !== '"') {
  27154. value = utils$k.escapeRegex(value);
  27155. prev.value += value;
  27156. append({
  27157. value
  27158. });
  27159. continue;
  27160. }
  27161. /**
  27162. * Double quotes
  27163. */
  27164. if (value === '"') {
  27165. state.quotes = state.quotes === 1 ? 0 : 1;
  27166. if (opts.keepQuotes === true) {
  27167. push({
  27168. type: 'text',
  27169. value
  27170. });
  27171. }
  27172. continue;
  27173. }
  27174. /**
  27175. * Parentheses
  27176. */
  27177. if (value === '(') {
  27178. increment('parens');
  27179. push({
  27180. type: 'paren',
  27181. value
  27182. });
  27183. continue;
  27184. }
  27185. if (value === ')') {
  27186. if (state.parens === 0 && opts.strictBrackets === true) {
  27187. throw new SyntaxError(syntaxError$1('opening', '('));
  27188. }
  27189. const extglob = extglobs[extglobs.length - 1];
  27190. if (extglob && state.parens === extglob.parens + 1) {
  27191. extglobClose(extglobs.pop());
  27192. continue;
  27193. }
  27194. push({
  27195. type: 'paren',
  27196. value,
  27197. output: state.parens ? ')' : '\\)'
  27198. });
  27199. decrement('parens');
  27200. continue;
  27201. }
  27202. /**
  27203. * Square brackets
  27204. */
  27205. if (value === '[') {
  27206. if (opts.nobracket === true || !remaining().includes(']')) {
  27207. if (opts.nobracket !== true && opts.strictBrackets === true) {
  27208. throw new SyntaxError(syntaxError$1('closing', ']'));
  27209. }
  27210. value = `\\${value}`;
  27211. } else {
  27212. increment('brackets');
  27213. }
  27214. push({
  27215. type: 'bracket',
  27216. value
  27217. });
  27218. continue;
  27219. }
  27220. if (value === ']') {
  27221. if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) {
  27222. push({
  27223. type: 'text',
  27224. value,
  27225. output: `\\${value}`
  27226. });
  27227. continue;
  27228. }
  27229. if (state.brackets === 0) {
  27230. if (opts.strictBrackets === true) {
  27231. throw new SyntaxError(syntaxError$1('opening', '['));
  27232. }
  27233. push({
  27234. type: 'text',
  27235. value,
  27236. output: `\\${value}`
  27237. });
  27238. continue;
  27239. }
  27240. decrement('brackets');
  27241. const prevValue = prev.value.slice(1);
  27242. if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
  27243. value = `/${value}`;
  27244. }
  27245. prev.value += value;
  27246. append({
  27247. value
  27248. }); // when literal brackets are explicitly disabled
  27249. // assume we should match with a regex character class
  27250. if (opts.literalBrackets === false || utils$k.hasRegexChars(prevValue)) {
  27251. continue;
  27252. }
  27253. const escaped = utils$k.escapeRegex(prev.value);
  27254. state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled
  27255. // assume we should escape the brackets to match literal characters
  27256. if (opts.literalBrackets === true) {
  27257. state.output += escaped;
  27258. prev.value = escaped;
  27259. continue;
  27260. } // when the user specifies nothing, try to match both
  27261. prev.value = `(${capture}${escaped}|${prev.value})`;
  27262. state.output += prev.value;
  27263. continue;
  27264. }
  27265. /**
  27266. * Braces
  27267. */
  27268. if (value === '{' && opts.nobrace !== true) {
  27269. increment('braces');
  27270. const open = {
  27271. type: 'brace',
  27272. value,
  27273. output: '(',
  27274. outputIndex: state.output.length,
  27275. tokensIndex: state.tokens.length
  27276. };
  27277. braces.push(open);
  27278. push(open);
  27279. continue;
  27280. }
  27281. if (value === '}') {
  27282. const brace = braces[braces.length - 1];
  27283. if (opts.nobrace === true || !brace) {
  27284. push({
  27285. type: 'text',
  27286. value,
  27287. output: value
  27288. });
  27289. continue;
  27290. }
  27291. let output = ')';
  27292. if (brace.dots === true) {
  27293. const arr = tokens.slice();
  27294. const range = [];
  27295. for (let i = arr.length - 1; i >= 0; i--) {
  27296. tokens.pop();
  27297. if (arr[i].type === 'brace') {
  27298. break;
  27299. }
  27300. if (arr[i].type !== 'dots') {
  27301. range.unshift(arr[i].value);
  27302. }
  27303. }
  27304. output = expandRange(range, opts);
  27305. state.backtrack = true;
  27306. }
  27307. if (brace.comma !== true && brace.dots !== true) {
  27308. const out = state.output.slice(0, brace.outputIndex);
  27309. const toks = state.tokens.slice(brace.tokensIndex);
  27310. brace.value = brace.output = '\\{';
  27311. value = output = '\\}';
  27312. state.output = out;
  27313. for (const t of toks) {
  27314. state.output += t.output || t.value;
  27315. }
  27316. }
  27317. push({
  27318. type: 'brace',
  27319. value,
  27320. output
  27321. });
  27322. decrement('braces');
  27323. braces.pop();
  27324. continue;
  27325. }
  27326. /**
  27327. * Pipes
  27328. */
  27329. if (value === '|') {
  27330. if (extglobs.length > 0) {
  27331. extglobs[extglobs.length - 1].conditions++;
  27332. }
  27333. push({
  27334. type: 'text',
  27335. value
  27336. });
  27337. continue;
  27338. }
  27339. /**
  27340. * Commas
  27341. */
  27342. if (value === ',') {
  27343. let output = value;
  27344. const brace = braces[braces.length - 1];
  27345. if (brace && stack[stack.length - 1] === 'braces') {
  27346. brace.comma = true;
  27347. output = '|';
  27348. }
  27349. push({
  27350. type: 'comma',
  27351. value,
  27352. output
  27353. });
  27354. continue;
  27355. }
  27356. /**
  27357. * Slashes
  27358. */
  27359. if (value === '/') {
  27360. // if the beginning of the glob is "./", advance the start
  27361. // to the current index, and don't add the "./" characters
  27362. // to the state. This greatly simplifies lookbehinds when
  27363. // checking for BOS characters like "!" and "." (not "./")
  27364. if (prev.type === 'dot' && state.index === state.start + 1) {
  27365. state.start = state.index + 1;
  27366. state.consumed = '';
  27367. state.output = '';
  27368. tokens.pop();
  27369. prev = bos; // reset "prev" to the first token
  27370. continue;
  27371. }
  27372. push({
  27373. type: 'slash',
  27374. value,
  27375. output: SLASH_LITERAL
  27376. });
  27377. continue;
  27378. }
  27379. /**
  27380. * Dots
  27381. */
  27382. if (value === '.') {
  27383. if (state.braces > 0 && prev.type === 'dot') {
  27384. if (prev.value === '.') prev.output = DOT_LITERAL;
  27385. const brace = braces[braces.length - 1];
  27386. prev.type = 'dots';
  27387. prev.output += value;
  27388. prev.value += value;
  27389. brace.dots = true;
  27390. continue;
  27391. }
  27392. if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
  27393. push({
  27394. type: 'text',
  27395. value,
  27396. output: DOT_LITERAL
  27397. });
  27398. continue;
  27399. }
  27400. push({
  27401. type: 'dot',
  27402. value,
  27403. output: DOT_LITERAL
  27404. });
  27405. continue;
  27406. }
  27407. /**
  27408. * Question marks
  27409. */
  27410. if (value === '?') {
  27411. const isGroup = prev && prev.value === '(';
  27412. if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  27413. extglobOpen('qmark', value);
  27414. continue;
  27415. }
  27416. if (prev && prev.type === 'paren') {
  27417. const next = peek();
  27418. let output = value;
  27419. if (next === '<' && !utils$k.supportsLookbehinds()) {
  27420. throw new Error('Node.js v10 or higher is required for regex lookbehinds');
  27421. }
  27422. if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) {
  27423. output = `\\${value}`;
  27424. }
  27425. push({
  27426. type: 'text',
  27427. value,
  27428. output
  27429. });
  27430. continue;
  27431. }
  27432. if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
  27433. push({
  27434. type: 'qmark',
  27435. value,
  27436. output: QMARK_NO_DOT
  27437. });
  27438. continue;
  27439. }
  27440. push({
  27441. type: 'qmark',
  27442. value,
  27443. output: QMARK
  27444. });
  27445. continue;
  27446. }
  27447. /**
  27448. * Exclamation
  27449. */
  27450. if (value === '!') {
  27451. if (opts.noextglob !== true && peek() === '(') {
  27452. if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
  27453. extglobOpen('negate', value);
  27454. continue;
  27455. }
  27456. }
  27457. if (opts.nonegate !== true && state.index === 0) {
  27458. negate();
  27459. continue;
  27460. }
  27461. }
  27462. /**
  27463. * Plus
  27464. */
  27465. if (value === '+') {
  27466. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  27467. extglobOpen('plus', value);
  27468. continue;
  27469. }
  27470. if (prev && prev.value === '(' || opts.regex === false) {
  27471. push({
  27472. type: 'plus',
  27473. value,
  27474. output: PLUS_LITERAL
  27475. });
  27476. continue;
  27477. }
  27478. if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) {
  27479. push({
  27480. type: 'plus',
  27481. value
  27482. });
  27483. continue;
  27484. }
  27485. push({
  27486. type: 'plus',
  27487. value: PLUS_LITERAL
  27488. });
  27489. continue;
  27490. }
  27491. /**
  27492. * Plain text
  27493. */
  27494. if (value === '@') {
  27495. if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
  27496. push({
  27497. type: 'at',
  27498. extglob: true,
  27499. value,
  27500. output: ''
  27501. });
  27502. continue;
  27503. }
  27504. push({
  27505. type: 'text',
  27506. value
  27507. });
  27508. continue;
  27509. }
  27510. /**
  27511. * Plain text
  27512. */
  27513. if (value !== '*') {
  27514. if (value === '$' || value === '^') {
  27515. value = `\\${value}`;
  27516. }
  27517. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  27518. if (match) {
  27519. value += match[0];
  27520. state.index += match[0].length;
  27521. }
  27522. push({
  27523. type: 'text',
  27524. value
  27525. });
  27526. continue;
  27527. }
  27528. /**
  27529. * Stars
  27530. */
  27531. if (prev && (prev.type === 'globstar' || prev.star === true)) {
  27532. prev.type = 'star';
  27533. prev.star = true;
  27534. prev.value += value;
  27535. prev.output = star;
  27536. state.backtrack = true;
  27537. state.globstar = true;
  27538. consume(value);
  27539. continue;
  27540. }
  27541. let rest = remaining();
  27542. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  27543. extglobOpen('star', value);
  27544. continue;
  27545. }
  27546. if (prev.type === 'star') {
  27547. if (opts.noglobstar === true) {
  27548. consume(value);
  27549. continue;
  27550. }
  27551. const prior = prev.prev;
  27552. const before = prior.prev;
  27553. const isStart = prior.type === 'slash' || prior.type === 'bos';
  27554. const afterStar = before && (before.type === 'star' || before.type === 'globstar');
  27555. if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) {
  27556. push({
  27557. type: 'star',
  27558. value,
  27559. output: ''
  27560. });
  27561. continue;
  27562. }
  27563. const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
  27564. const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
  27565. if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
  27566. push({
  27567. type: 'star',
  27568. value,
  27569. output: ''
  27570. });
  27571. continue;
  27572. } // strip consecutive `/**/`
  27573. while (rest.slice(0, 3) === '/**') {
  27574. const after = input[state.index + 4];
  27575. if (after && after !== '/') {
  27576. break;
  27577. }
  27578. rest = rest.slice(3);
  27579. consume('/**', 3);
  27580. }
  27581. if (prior.type === 'bos' && eos()) {
  27582. prev.type = 'globstar';
  27583. prev.value += value;
  27584. prev.output = globstar(opts);
  27585. state.output = prev.output;
  27586. state.globstar = true;
  27587. consume(value);
  27588. continue;
  27589. }
  27590. if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
  27591. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  27592. prior.output = `(?:${prior.output}`;
  27593. prev.type = 'globstar';
  27594. prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
  27595. prev.value += value;
  27596. state.globstar = true;
  27597. state.output += prior.output + prev.output;
  27598. consume(value);
  27599. continue;
  27600. }
  27601. if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
  27602. const end = rest[1] !== void 0 ? '|$' : '';
  27603. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  27604. prior.output = `(?:${prior.output}`;
  27605. prev.type = 'globstar';
  27606. prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
  27607. prev.value += value;
  27608. state.output += prior.output + prev.output;
  27609. state.globstar = true;
  27610. consume(value + advance());
  27611. push({
  27612. type: 'slash',
  27613. value: '/',
  27614. output: ''
  27615. });
  27616. continue;
  27617. }
  27618. if (prior.type === 'bos' && rest[0] === '/') {
  27619. prev.type = 'globstar';
  27620. prev.value += value;
  27621. prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
  27622. state.output = prev.output;
  27623. state.globstar = true;
  27624. consume(value + advance());
  27625. push({
  27626. type: 'slash',
  27627. value: '/',
  27628. output: ''
  27629. });
  27630. continue;
  27631. } // remove single star from output
  27632. state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar
  27633. prev.type = 'globstar';
  27634. prev.output = globstar(opts);
  27635. prev.value += value; // reset output with globstar
  27636. state.output += prev.output;
  27637. state.globstar = true;
  27638. consume(value);
  27639. continue;
  27640. }
  27641. const token = {
  27642. type: 'star',
  27643. value,
  27644. output: star
  27645. };
  27646. if (opts.bash === true) {
  27647. token.output = '.*?';
  27648. if (prev.type === 'bos' || prev.type === 'slash') {
  27649. token.output = nodot + token.output;
  27650. }
  27651. push(token);
  27652. continue;
  27653. }
  27654. if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
  27655. token.output = value;
  27656. push(token);
  27657. continue;
  27658. }
  27659. if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
  27660. if (prev.type === 'dot') {
  27661. state.output += NO_DOT_SLASH;
  27662. prev.output += NO_DOT_SLASH;
  27663. } else if (opts.dot === true) {
  27664. state.output += NO_DOTS_SLASH;
  27665. prev.output += NO_DOTS_SLASH;
  27666. } else {
  27667. state.output += nodot;
  27668. prev.output += nodot;
  27669. }
  27670. if (peek() !== '*') {
  27671. state.output += ONE_CHAR;
  27672. prev.output += ONE_CHAR;
  27673. }
  27674. }
  27675. push(token);
  27676. }
  27677. while (state.brackets > 0) {
  27678. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ']'));
  27679. state.output = utils$k.escapeLast(state.output, '[');
  27680. decrement('brackets');
  27681. }
  27682. while (state.parens > 0) {
  27683. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', ')'));
  27684. state.output = utils$k.escapeLast(state.output, '(');
  27685. decrement('parens');
  27686. }
  27687. while (state.braces > 0) {
  27688. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError$1('closing', '}'));
  27689. state.output = utils$k.escapeLast(state.output, '{');
  27690. decrement('braces');
  27691. }
  27692. if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
  27693. push({
  27694. type: 'maybe_slash',
  27695. value: '',
  27696. output: `${SLASH_LITERAL}?`
  27697. });
  27698. } // rebuild the output if we had to backtrack at any point
  27699. if (state.backtrack === true) {
  27700. state.output = '';
  27701. for (const token of state.tokens) {
  27702. state.output += token.output != null ? token.output : token.value;
  27703. if (token.suffix) {
  27704. state.output += token.suffix;
  27705. }
  27706. }
  27707. }
  27708. return state;
  27709. };
  27710. /**
  27711. * Fast paths for creating regular expressions for common glob patterns.
  27712. * This can significantly speed up processing and has very little downside
  27713. * impact when none of the fast paths match.
  27714. */
  27715. parse$3.fastpaths = (input, options) => {
  27716. const opts = Object.assign({}, options);
  27717. const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  27718. const len = input.length;
  27719. if (len > max) {
  27720. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  27721. }
  27722. input = REPLACEMENTS[input] || input;
  27723. const win32 = utils$k.isWindows(options); // create constants based on platform, for windows or posix
  27724. const {
  27725. DOT_LITERAL,
  27726. SLASH_LITERAL,
  27727. ONE_CHAR,
  27728. DOTS_SLASH,
  27729. NO_DOT,
  27730. NO_DOTS,
  27731. NO_DOTS_SLASH,
  27732. STAR,
  27733. START_ANCHOR
  27734. } = constants$2.globChars(win32);
  27735. const nodot = opts.dot ? NO_DOTS : NO_DOT;
  27736. const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
  27737. const capture = opts.capture ? '' : '?:';
  27738. const state = {
  27739. negated: false,
  27740. prefix: ''
  27741. };
  27742. let star = opts.bash === true ? '.*?' : STAR;
  27743. if (opts.capture) {
  27744. star = `(${star})`;
  27745. }
  27746. const globstar = opts => {
  27747. if (opts.noglobstar === true) return star;
  27748. return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
  27749. };
  27750. const create = str => {
  27751. switch (str) {
  27752. case '*':
  27753. return `${nodot}${ONE_CHAR}${star}`;
  27754. case '.*':
  27755. return `${DOT_LITERAL}${ONE_CHAR}${star}`;
  27756. case '*.*':
  27757. return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  27758. case '*/*':
  27759. return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
  27760. case '**':
  27761. return nodot + globstar(opts);
  27762. case '**/*':
  27763. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
  27764. case '**/*.*':
  27765. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
  27766. case '**/.*':
  27767. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
  27768. default:
  27769. {
  27770. const match = /^(.*?)\.(\w+)$/.exec(str);
  27771. if (!match) return;
  27772. const source = create(match[1]);
  27773. if (!source) return;
  27774. return source + DOT_LITERAL + match[2];
  27775. }
  27776. }
  27777. };
  27778. const output = utils$k.removePrefix(input, state);
  27779. let source = create(output);
  27780. if (source && opts.strictSlashes !== true) {
  27781. source += `${SLASH_LITERAL}?`;
  27782. }
  27783. return source;
  27784. };
  27785. var parse_1$1 = parse$3;
  27786. const path$9 = require$$0__default$2["default"];
  27787. const scan = scan_1;
  27788. const parse$2 = parse_1$1;
  27789. const utils$j = utils$m;
  27790. const constants$1 = constants$3;
  27791. const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
  27792. /**
  27793. * Creates a matcher function from one or more glob patterns. The
  27794. * returned function takes a string to match as its first argument,
  27795. * and returns true if the string is a match. The returned matcher
  27796. * function also takes a boolean as the second argument that, when true,
  27797. * returns an object with additional information.
  27798. *
  27799. * ```js
  27800. * const picomatch = require('picomatch');
  27801. * // picomatch(glob[, options]);
  27802. *
  27803. * const isMatch = picomatch('*.!(*a)');
  27804. * console.log(isMatch('a.a')); //=> false
  27805. * console.log(isMatch('a.b')); //=> true
  27806. * ```
  27807. * @name picomatch
  27808. * @param {String|Array} `globs` One or more glob patterns.
  27809. * @param {Object=} `options`
  27810. * @return {Function=} Returns a matcher function.
  27811. * @api public
  27812. */
  27813. const picomatch$2 = (glob, options, returnState = false) => {
  27814. if (Array.isArray(glob)) {
  27815. const fns = glob.map(input => picomatch$2(input, options, returnState));
  27816. const arrayMatcher = str => {
  27817. for (const isMatch of fns) {
  27818. const state = isMatch(str);
  27819. if (state) return state;
  27820. }
  27821. return false;
  27822. };
  27823. return arrayMatcher;
  27824. }
  27825. const isState = isObject(glob) && glob.tokens && glob.input;
  27826. if (glob === '' || typeof glob !== 'string' && !isState) {
  27827. throw new TypeError('Expected pattern to be a non-empty string');
  27828. }
  27829. const opts = options || {};
  27830. const posix = utils$j.isWindows(options);
  27831. const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
  27832. const state = regex.state;
  27833. delete regex.state;
  27834. let isIgnored = () => false;
  27835. if (opts.ignore) {
  27836. const ignoreOpts = Object.assign(Object.assign({}, options), {}, {
  27837. ignore: null,
  27838. onMatch: null,
  27839. onResult: null
  27840. });
  27841. isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
  27842. }
  27843. const matcher = (input, returnObject = false) => {
  27844. const {
  27845. isMatch,
  27846. match,
  27847. output
  27848. } = picomatch$2.test(input, regex, options, {
  27849. glob,
  27850. posix
  27851. });
  27852. const result = {
  27853. glob,
  27854. state,
  27855. regex,
  27856. posix,
  27857. input,
  27858. output,
  27859. match,
  27860. isMatch
  27861. };
  27862. if (typeof opts.onResult === 'function') {
  27863. opts.onResult(result);
  27864. }
  27865. if (isMatch === false) {
  27866. result.isMatch = false;
  27867. return returnObject ? result : false;
  27868. }
  27869. if (isIgnored(input)) {
  27870. if (typeof opts.onIgnore === 'function') {
  27871. opts.onIgnore(result);
  27872. }
  27873. result.isMatch = false;
  27874. return returnObject ? result : false;
  27875. }
  27876. if (typeof opts.onMatch === 'function') {
  27877. opts.onMatch(result);
  27878. }
  27879. return returnObject ? result : true;
  27880. };
  27881. if (returnState) {
  27882. matcher.state = state;
  27883. }
  27884. return matcher;
  27885. };
  27886. /**
  27887. * Test `input` with the given `regex`. This is used by the main
  27888. * `picomatch()` function to test the input string.
  27889. *
  27890. * ```js
  27891. * const picomatch = require('picomatch');
  27892. * // picomatch.test(input, regex[, options]);
  27893. *
  27894. * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  27895. * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  27896. * ```
  27897. * @param {String} `input` String to test.
  27898. * @param {RegExp} `regex`
  27899. * @return {Object} Returns an object with matching info.
  27900. * @api public
  27901. */
  27902. picomatch$2.test = (input, regex, options, {
  27903. glob,
  27904. posix
  27905. } = {}) => {
  27906. if (typeof input !== 'string') {
  27907. throw new TypeError('Expected input to be a string');
  27908. }
  27909. if (input === '') {
  27910. return {
  27911. isMatch: false,
  27912. output: ''
  27913. };
  27914. }
  27915. const opts = options || {};
  27916. const format = opts.format || (posix ? utils$j.toPosixSlashes : null);
  27917. let match = input === glob;
  27918. let output = match && format ? format(input) : input;
  27919. if (match === false) {
  27920. output = format ? format(input) : input;
  27921. match = output === glob;
  27922. }
  27923. if (match === false || opts.capture === true) {
  27924. if (opts.matchBase === true || opts.basename === true) {
  27925. match = picomatch$2.matchBase(input, regex, options, posix);
  27926. } else {
  27927. match = regex.exec(output);
  27928. }
  27929. }
  27930. return {
  27931. isMatch: Boolean(match),
  27932. match,
  27933. output
  27934. };
  27935. };
  27936. /**
  27937. * Match the basename of a filepath.
  27938. *
  27939. * ```js
  27940. * const picomatch = require('picomatch');
  27941. * // picomatch.matchBase(input, glob[, options]);
  27942. * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  27943. * ```
  27944. * @param {String} `input` String to test.
  27945. * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
  27946. * @return {Boolean}
  27947. * @api public
  27948. */
  27949. picomatch$2.matchBase = (input, glob, options, posix = utils$j.isWindows(options)) => {
  27950. const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
  27951. return regex.test(path$9.basename(input));
  27952. };
  27953. /**
  27954. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  27955. *
  27956. * ```js
  27957. * const picomatch = require('picomatch');
  27958. * // picomatch.isMatch(string, patterns[, options]);
  27959. *
  27960. * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  27961. * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  27962. * ```
  27963. * @param {String|Array} str The string to test.
  27964. * @param {String|Array} patterns One or more glob patterns to use for matching.
  27965. * @param {Object} [options] See available [options](#options).
  27966. * @return {Boolean} Returns true if any patterns match `str`
  27967. * @api public
  27968. */
  27969. picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
  27970. /**
  27971. * Parse a glob pattern to create the source string for a regular
  27972. * expression.
  27973. *
  27974. * ```js
  27975. * const picomatch = require('picomatch');
  27976. * const result = picomatch.parse(pattern[, options]);
  27977. * ```
  27978. * @param {String} `pattern`
  27979. * @param {Object} `options`
  27980. * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
  27981. * @api public
  27982. */
  27983. picomatch$2.parse = (pattern, options) => {
  27984. if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
  27985. return parse$2(pattern, Object.assign(Object.assign({}, options), {}, {
  27986. fastpaths: false
  27987. }));
  27988. };
  27989. /**
  27990. * Scan a glob pattern to separate the pattern into segments.
  27991. *
  27992. * ```js
  27993. * const picomatch = require('picomatch');
  27994. * // picomatch.scan(input[, options]);
  27995. *
  27996. * const result = picomatch.scan('!./foo/*.js');
  27997. * console.log(result);
  27998. * { prefix: '!./',
  27999. * input: '!./foo/*.js',
  28000. * start: 3,
  28001. * base: 'foo',
  28002. * glob: '*.js',
  28003. * isBrace: false,
  28004. * isBracket: false,
  28005. * isGlob: true,
  28006. * isExtglob: false,
  28007. * isGlobstar: false,
  28008. * negated: true }
  28009. * ```
  28010. * @param {String} `input` Glob pattern to scan.
  28011. * @param {Object} `options`
  28012. * @return {Object} Returns an object with
  28013. * @api public
  28014. */
  28015. picomatch$2.scan = (input, options) => scan(input, options);
  28016. /**
  28017. * Compile a regular expression from the `state` object returned by the
  28018. * [parse()](#parse) method.
  28019. *
  28020. * @param {Object} `state`
  28021. * @param {Object} `options`
  28022. * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
  28023. * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  28024. * @return {RegExp}
  28025. * @api public
  28026. */
  28027. picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
  28028. if (returnOutput === true) {
  28029. return state.output;
  28030. }
  28031. const opts = options || {};
  28032. const prepend = opts.contains ? '' : '^';
  28033. const append = opts.contains ? '' : '$';
  28034. let source = `${prepend}(?:${state.output})${append}`;
  28035. if (state && state.negated === true) {
  28036. source = `^(?!${source}).*$`;
  28037. }
  28038. const regex = picomatch$2.toRegex(source, options);
  28039. if (returnState === true) {
  28040. regex.state = state;
  28041. }
  28042. return regex;
  28043. };
  28044. /**
  28045. * Create a regular expression from a parsed glob pattern.
  28046. *
  28047. * ```js
  28048. * const picomatch = require('picomatch');
  28049. * const state = picomatch.parse('*.js');
  28050. * // picomatch.compileRe(state[, options]);
  28051. *
  28052. * console.log(picomatch.compileRe(state));
  28053. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  28054. * ```
  28055. * @param {String} `state` The object returned from the `.parse` method.
  28056. * @param {Object} `options`
  28057. * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
  28058. * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  28059. * @return {RegExp} Returns a regex created from the given pattern.
  28060. * @api public
  28061. */
  28062. picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  28063. if (!input || typeof input !== 'string') {
  28064. throw new TypeError('Expected a non-empty string');
  28065. }
  28066. let parsed = {
  28067. negated: false,
  28068. fastpaths: true
  28069. };
  28070. if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
  28071. parsed.output = parse$2.fastpaths(input, options);
  28072. }
  28073. if (!parsed.output) {
  28074. parsed = parse$2(input, options);
  28075. }
  28076. return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
  28077. };
  28078. /**
  28079. * Create a regular expression from the given regex source string.
  28080. *
  28081. * ```js
  28082. * const picomatch = require('picomatch');
  28083. * // picomatch.toRegex(source[, options]);
  28084. *
  28085. * const { output } = picomatch.parse('*.js');
  28086. * console.log(picomatch.toRegex(output));
  28087. * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  28088. * ```
  28089. * @param {String} `source` Regular expression source string.
  28090. * @param {Object} `options`
  28091. * @return {RegExp}
  28092. * @api public
  28093. */
  28094. picomatch$2.toRegex = (source, options) => {
  28095. try {
  28096. const opts = options || {};
  28097. return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
  28098. } catch (err) {
  28099. if (options && options.debug === true) throw err;
  28100. return /$^/;
  28101. }
  28102. };
  28103. /**
  28104. * Picomatch constants.
  28105. * @return {Object}
  28106. */
  28107. picomatch$2.constants = constants$1;
  28108. /**
  28109. * Expose "picomatch"
  28110. */
  28111. var picomatch_1 = picomatch$2;
  28112. var picomatch$1 = picomatch_1;
  28113. const util$1 = require$$0__default$4["default"];
  28114. const braces = braces_1;
  28115. const picomatch = picomatch$1;
  28116. const utils$i = utils$m;
  28117. const isEmptyString = val => val === '' || val === './';
  28118. /**
  28119. * Returns an array of strings that match one or more glob patterns.
  28120. *
  28121. * ```js
  28122. * const mm = require('micromatch');
  28123. * // mm(list, patterns[, options]);
  28124. *
  28125. * console.log(mm(['a.js', 'a.txt'], ['*.js']));
  28126. * //=> [ 'a.js' ]
  28127. * ```
  28128. * @param {String|Array<string>} `list` List of strings to match.
  28129. * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
  28130. * @param {Object} `options` See available [options](#options)
  28131. * @return {Array} Returns an array of matches
  28132. * @summary false
  28133. * @api public
  28134. */
  28135. const micromatch$1 = (list, patterns, options) => {
  28136. patterns = [].concat(patterns);
  28137. list = [].concat(list);
  28138. let omit = new Set();
  28139. let keep = new Set();
  28140. let items = new Set();
  28141. let negatives = 0;
  28142. let onResult = state => {
  28143. items.add(state.output);
  28144. if (options && options.onResult) {
  28145. options.onResult(state);
  28146. }
  28147. };
  28148. for (let i = 0; i < patterns.length; i++) {
  28149. let isMatch = picomatch(String(patterns[i]), Object.assign(Object.assign({}, options), {}, {
  28150. onResult
  28151. }), true);
  28152. let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
  28153. if (negated) negatives++;
  28154. for (let item of list) {
  28155. let matched = isMatch(item, true);
  28156. let match = negated ? !matched.isMatch : matched.isMatch;
  28157. if (!match) continue;
  28158. if (negated) {
  28159. omit.add(matched.output);
  28160. } else {
  28161. omit.delete(matched.output);
  28162. keep.add(matched.output);
  28163. }
  28164. }
  28165. }
  28166. let result = negatives === patterns.length ? [...items] : [...keep];
  28167. let matches = result.filter(item => !omit.has(item));
  28168. if (options && matches.length === 0) {
  28169. if (options.failglob === true) {
  28170. throw new Error(`No matches found for "${patterns.join(', ')}"`);
  28171. }
  28172. if (options.nonull === true || options.nullglob === true) {
  28173. return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
  28174. }
  28175. }
  28176. return matches;
  28177. };
  28178. /**
  28179. * Backwards compatibility
  28180. */
  28181. micromatch$1.match = micromatch$1;
  28182. /**
  28183. * Returns a matcher function from the given glob `pattern` and `options`.
  28184. * The returned function takes a string to match as its only argument and returns
  28185. * true if the string is a match.
  28186. *
  28187. * ```js
  28188. * const mm = require('micromatch');
  28189. * // mm.matcher(pattern[, options]);
  28190. *
  28191. * const isMatch = mm.matcher('*.!(*a)');
  28192. * console.log(isMatch('a.a')); //=> false
  28193. * console.log(isMatch('a.b')); //=> true
  28194. * ```
  28195. * @param {String} `pattern` Glob pattern
  28196. * @param {Object} `options`
  28197. * @return {Function} Returns a matcher function.
  28198. * @api public
  28199. */
  28200. micromatch$1.matcher = (pattern, options) => picomatch(pattern, options);
  28201. /**
  28202. * Returns true if **any** of the given glob `patterns` match the specified `string`.
  28203. *
  28204. * ```js
  28205. * const mm = require('micromatch');
  28206. * // mm.isMatch(string, patterns[, options]);
  28207. *
  28208. * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
  28209. * console.log(mm.isMatch('a.a', 'b.*')); //=> false
  28210. * ```
  28211. * @param {String} `str` The string to test.
  28212. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  28213. * @param {Object} `[options]` See available [options](#options).
  28214. * @return {Boolean} Returns true if any patterns match `str`
  28215. * @api public
  28216. */
  28217. micromatch$1.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
  28218. /**
  28219. * Backwards compatibility
  28220. */
  28221. micromatch$1.any = micromatch$1.isMatch;
  28222. /**
  28223. * Returns a list of strings that _**do not match any**_ of the given `patterns`.
  28224. *
  28225. * ```js
  28226. * const mm = require('micromatch');
  28227. * // mm.not(list, patterns[, options]);
  28228. *
  28229. * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
  28230. * //=> ['b.b', 'c.c']
  28231. * ```
  28232. * @param {Array} `list` Array of strings to match.
  28233. * @param {String|Array} `patterns` One or more glob pattern to use for matching.
  28234. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28235. * @return {Array} Returns an array of strings that **do not match** the given patterns.
  28236. * @api public
  28237. */
  28238. micromatch$1.not = (list, patterns, options = {}) => {
  28239. patterns = [].concat(patterns).map(String);
  28240. let result = new Set();
  28241. let items = [];
  28242. let onResult = state => {
  28243. if (options.onResult) options.onResult(state);
  28244. items.push(state.output);
  28245. };
  28246. let matches = micromatch$1(list, patterns, Object.assign(Object.assign({}, options), {}, {
  28247. onResult
  28248. }));
  28249. for (let item of items) {
  28250. if (!matches.includes(item)) {
  28251. result.add(item);
  28252. }
  28253. }
  28254. return [...result];
  28255. };
  28256. /**
  28257. * Returns true if the given `string` contains the given pattern. Similar
  28258. * to [.isMatch](#isMatch) but the pattern can match any part of the string.
  28259. *
  28260. * ```js
  28261. * var mm = require('micromatch');
  28262. * // mm.contains(string, pattern[, options]);
  28263. *
  28264. * console.log(mm.contains('aa/bb/cc', '*b'));
  28265. * //=> true
  28266. * console.log(mm.contains('aa/bb/cc', '*d'));
  28267. * //=> false
  28268. * ```
  28269. * @param {String} `str` The string to match.
  28270. * @param {String|Array} `patterns` Glob pattern to use for matching.
  28271. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28272. * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
  28273. * @api public
  28274. */
  28275. micromatch$1.contains = (str, pattern, options) => {
  28276. if (typeof str !== 'string') {
  28277. throw new TypeError(`Expected a string: "${util$1.inspect(str)}"`);
  28278. }
  28279. if (Array.isArray(pattern)) {
  28280. return pattern.some(p => micromatch$1.contains(str, p, options));
  28281. }
  28282. if (typeof pattern === 'string') {
  28283. if (isEmptyString(str) || isEmptyString(pattern)) {
  28284. return false;
  28285. }
  28286. if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) {
  28287. return true;
  28288. }
  28289. }
  28290. return micromatch$1.isMatch(str, pattern, Object.assign(Object.assign({}, options), {}, {
  28291. contains: true
  28292. }));
  28293. };
  28294. /**
  28295. * Filter the keys of the given object with the given `glob` pattern
  28296. * and `options`. Does not attempt to match nested keys. If you need this feature,
  28297. * use [glob-object][] instead.
  28298. *
  28299. * ```js
  28300. * const mm = require('micromatch');
  28301. * // mm.matchKeys(object, patterns[, options]);
  28302. *
  28303. * const obj = { aa: 'a', ab: 'b', ac: 'c' };
  28304. * console.log(mm.matchKeys(obj, '*b'));
  28305. * //=> { ab: 'b' }
  28306. * ```
  28307. * @param {Object} `object` The object with keys to filter.
  28308. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  28309. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28310. * @return {Object} Returns an object with only keys that match the given patterns.
  28311. * @api public
  28312. */
  28313. micromatch$1.matchKeys = (obj, patterns, options) => {
  28314. if (!utils$i.isObject(obj)) {
  28315. throw new TypeError('Expected the first argument to be an object');
  28316. }
  28317. let keys = micromatch$1(Object.keys(obj), patterns, options);
  28318. let res = {};
  28319. for (let key of keys) res[key] = obj[key];
  28320. return res;
  28321. };
  28322. /**
  28323. * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
  28324. *
  28325. * ```js
  28326. * const mm = require('micromatch');
  28327. * // mm.some(list, patterns[, options]);
  28328. *
  28329. * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  28330. * // true
  28331. * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
  28332. * // false
  28333. * ```
  28334. * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
  28335. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  28336. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28337. * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
  28338. * @api public
  28339. */
  28340. micromatch$1.some = (list, patterns, options) => {
  28341. let items = [].concat(list);
  28342. for (let pattern of [].concat(patterns)) {
  28343. let isMatch = picomatch(String(pattern), options);
  28344. if (items.some(item => isMatch(item))) {
  28345. return true;
  28346. }
  28347. }
  28348. return false;
  28349. };
  28350. /**
  28351. * Returns true if every string in the given `list` matches
  28352. * any of the given glob `patterns`.
  28353. *
  28354. * ```js
  28355. * const mm = require('micromatch');
  28356. * // mm.every(list, patterns[, options]);
  28357. *
  28358. * console.log(mm.every('foo.js', ['foo.js']));
  28359. * // true
  28360. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
  28361. * // true
  28362. * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
  28363. * // false
  28364. * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
  28365. * // false
  28366. * ```
  28367. * @param {String|Array} `list` The string or array of strings to test.
  28368. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  28369. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28370. * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
  28371. * @api public
  28372. */
  28373. micromatch$1.every = (list, patterns, options) => {
  28374. let items = [].concat(list);
  28375. for (let pattern of [].concat(patterns)) {
  28376. let isMatch = picomatch(String(pattern), options);
  28377. if (!items.every(item => isMatch(item))) {
  28378. return false;
  28379. }
  28380. }
  28381. return true;
  28382. };
  28383. /**
  28384. * Returns true if **all** of the given `patterns` match
  28385. * the specified string.
  28386. *
  28387. * ```js
  28388. * const mm = require('micromatch');
  28389. * // mm.all(string, patterns[, options]);
  28390. *
  28391. * console.log(mm.all('foo.js', ['foo.js']));
  28392. * // true
  28393. *
  28394. * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
  28395. * // false
  28396. *
  28397. * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
  28398. * // true
  28399. *
  28400. * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
  28401. * // true
  28402. * ```
  28403. * @param {String|Array} `str` The string to test.
  28404. * @param {String|Array} `patterns` One or more glob patterns to use for matching.
  28405. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28406. * @return {Boolean} Returns true if any patterns match `str`
  28407. * @api public
  28408. */
  28409. micromatch$1.all = (str, patterns, options) => {
  28410. if (typeof str !== 'string') {
  28411. throw new TypeError(`Expected a string: "${util$1.inspect(str)}"`);
  28412. }
  28413. return [].concat(patterns).every(p => picomatch(p, options)(str));
  28414. };
  28415. /**
  28416. * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
  28417. *
  28418. * ```js
  28419. * const mm = require('micromatch');
  28420. * // mm.capture(pattern, string[, options]);
  28421. *
  28422. * console.log(mm.capture('test/*.js', 'test/foo.js'));
  28423. * //=> ['foo']
  28424. * console.log(mm.capture('test/*.js', 'foo/bar.css'));
  28425. * //=> null
  28426. * ```
  28427. * @param {String} `glob` Glob pattern to use for matching.
  28428. * @param {String} `input` String to match
  28429. * @param {Object} `options` See available [options](#options) for changing how matches are performed
  28430. * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
  28431. * @api public
  28432. */
  28433. micromatch$1.capture = (glob, input, options) => {
  28434. let posix = utils$i.isWindows(options);
  28435. let regex = picomatch.makeRe(String(glob), Object.assign(Object.assign({}, options), {}, {
  28436. capture: true
  28437. }));
  28438. let match = regex.exec(posix ? utils$i.toPosixSlashes(input) : input);
  28439. if (match) {
  28440. return match.slice(1).map(v => v === void 0 ? '' : v);
  28441. }
  28442. };
  28443. /**
  28444. * Create a regular expression from the given glob `pattern`.
  28445. *
  28446. * ```js
  28447. * const mm = require('micromatch');
  28448. * // mm.makeRe(pattern[, options]);
  28449. *
  28450. * console.log(mm.makeRe('*.js'));
  28451. * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
  28452. * ```
  28453. * @param {String} `pattern` A glob pattern to convert to regex.
  28454. * @param {Object} `options`
  28455. * @return {RegExp} Returns a regex created from the given pattern.
  28456. * @api public
  28457. */
  28458. micromatch$1.makeRe = (...args) => picomatch.makeRe(...args);
  28459. /**
  28460. * Scan a glob pattern to separate the pattern into segments. Used
  28461. * by the [split](#split) method.
  28462. *
  28463. * ```js
  28464. * const mm = require('micromatch');
  28465. * const state = mm.scan(pattern[, options]);
  28466. * ```
  28467. * @param {String} `pattern`
  28468. * @param {Object} `options`
  28469. * @return {Object} Returns an object with
  28470. * @api public
  28471. */
  28472. micromatch$1.scan = (...args) => picomatch.scan(...args);
  28473. /**
  28474. * Parse a glob pattern to create the source string for a regular
  28475. * expression.
  28476. *
  28477. * ```js
  28478. * const mm = require('micromatch');
  28479. * const state = mm(pattern[, options]);
  28480. * ```
  28481. * @param {String} `glob`
  28482. * @param {Object} `options`
  28483. * @return {Object} Returns an object with useful properties and output to be used as regex source string.
  28484. * @api public
  28485. */
  28486. micromatch$1.parse = (patterns, options) => {
  28487. let res = [];
  28488. for (let pattern of [].concat(patterns || [])) {
  28489. for (let str of braces(String(pattern), options)) {
  28490. res.push(picomatch.parse(str, options));
  28491. }
  28492. }
  28493. return res;
  28494. };
  28495. /**
  28496. * Process the given brace `pattern`.
  28497. *
  28498. * ```js
  28499. * const { braces } = require('micromatch');
  28500. * console.log(braces('foo/{a,b,c}/bar'));
  28501. * //=> [ 'foo/(a|b|c)/bar' ]
  28502. *
  28503. * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
  28504. * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
  28505. * ```
  28506. * @param {String} `pattern` String with brace pattern to process.
  28507. * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
  28508. * @return {Array}
  28509. * @api public
  28510. */
  28511. micromatch$1.braces = (pattern, options) => {
  28512. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  28513. if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
  28514. return [pattern];
  28515. }
  28516. return braces(pattern, options);
  28517. };
  28518. /**
  28519. * Expand braces
  28520. */
  28521. micromatch$1.braceExpand = (pattern, options) => {
  28522. if (typeof pattern !== 'string') throw new TypeError('Expected a string');
  28523. return micromatch$1.braces(pattern, Object.assign(Object.assign({}, options), {}, {
  28524. expand: true
  28525. }));
  28526. };
  28527. /**
  28528. * Expose micromatch
  28529. */
  28530. var micromatch_1 = micromatch$1;
  28531. Object.defineProperty(pattern$1, "__esModule", {
  28532. value: true
  28533. });
  28534. pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
  28535. const path$8 = require$$0__default$2["default"];
  28536. const globParent = globParent$1;
  28537. const micromatch = micromatch_1;
  28538. const GLOBSTAR = '**';
  28539. const ESCAPE_SYMBOL = '\\';
  28540. const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
  28541. const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
  28542. const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
  28543. const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
  28544. const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
  28545. function isStaticPattern(pattern, options = {}) {
  28546. return !isDynamicPattern(pattern, options);
  28547. }
  28548. pattern$1.isStaticPattern = isStaticPattern;
  28549. function isDynamicPattern(pattern, options = {}) {
  28550. /**
  28551. * A special case with an empty string is necessary for matching patterns that start with a forward slash.
  28552. * An empty string cannot be a dynamic pattern.
  28553. * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
  28554. */
  28555. if (pattern === '') {
  28556. return false;
  28557. }
  28558. /**
  28559. * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
  28560. * filepath directly (without read directory).
  28561. */
  28562. if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
  28563. return true;
  28564. }
  28565. if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
  28566. return true;
  28567. }
  28568. if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
  28569. return true;
  28570. }
  28571. if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
  28572. return true;
  28573. }
  28574. return false;
  28575. }
  28576. pattern$1.isDynamicPattern = isDynamicPattern;
  28577. function convertToPositivePattern(pattern) {
  28578. return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
  28579. }
  28580. pattern$1.convertToPositivePattern = convertToPositivePattern;
  28581. function convertToNegativePattern(pattern) {
  28582. return '!' + pattern;
  28583. }
  28584. pattern$1.convertToNegativePattern = convertToNegativePattern;
  28585. function isNegativePattern(pattern) {
  28586. return pattern.startsWith('!') && pattern[1] !== '(';
  28587. }
  28588. pattern$1.isNegativePattern = isNegativePattern;
  28589. function isPositivePattern(pattern) {
  28590. return !isNegativePattern(pattern);
  28591. }
  28592. pattern$1.isPositivePattern = isPositivePattern;
  28593. function getNegativePatterns(patterns) {
  28594. return patterns.filter(isNegativePattern);
  28595. }
  28596. pattern$1.getNegativePatterns = getNegativePatterns;
  28597. function getPositivePatterns$1(patterns) {
  28598. return patterns.filter(isPositivePattern);
  28599. }
  28600. pattern$1.getPositivePatterns = getPositivePatterns$1;
  28601. /**
  28602. * Returns patterns that can be applied inside the current directory.
  28603. *
  28604. * @example
  28605. * // ['./*', '*', 'a/*']
  28606. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  28607. */
  28608. function getPatternsInsideCurrentDirectory(patterns) {
  28609. return patterns.filter(pattern => !isPatternRelatedToParentDirectory(pattern));
  28610. }
  28611. pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
  28612. /**
  28613. * Returns patterns to be expanded relative to (outside) the current directory.
  28614. *
  28615. * @example
  28616. * // ['../*', './../*']
  28617. * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
  28618. */
  28619. function getPatternsOutsideCurrentDirectory(patterns) {
  28620. return patterns.filter(isPatternRelatedToParentDirectory);
  28621. }
  28622. pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
  28623. function isPatternRelatedToParentDirectory(pattern) {
  28624. return pattern.startsWith('..') || pattern.startsWith('./..');
  28625. }
  28626. pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
  28627. function getBaseDirectory(pattern) {
  28628. return globParent(pattern, {
  28629. flipBackslashes: false
  28630. });
  28631. }
  28632. pattern$1.getBaseDirectory = getBaseDirectory;
  28633. function hasGlobStar(pattern) {
  28634. return pattern.includes(GLOBSTAR);
  28635. }
  28636. pattern$1.hasGlobStar = hasGlobStar;
  28637. function endsWithSlashGlobStar(pattern) {
  28638. return pattern.endsWith('/' + GLOBSTAR);
  28639. }
  28640. pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
  28641. function isAffectDepthOfReadingPattern(pattern) {
  28642. const basename = path$8.basename(pattern);
  28643. return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
  28644. }
  28645. pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
  28646. function expandPatternsWithBraceExpansion(patterns) {
  28647. return patterns.reduce((collection, pattern) => {
  28648. return collection.concat(expandBraceExpansion(pattern));
  28649. }, []);
  28650. }
  28651. pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
  28652. function expandBraceExpansion(pattern) {
  28653. return micromatch.braces(pattern, {
  28654. expand: true,
  28655. nodupes: true
  28656. });
  28657. }
  28658. pattern$1.expandBraceExpansion = expandBraceExpansion;
  28659. function getPatternParts(pattern, options) {
  28660. let {
  28661. parts
  28662. } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), {
  28663. parts: true
  28664. }));
  28665. /**
  28666. * The scan method returns an empty array in some cases.
  28667. * See micromatch/picomatch#58 for more details.
  28668. */
  28669. if (parts.length === 0) {
  28670. parts = [pattern];
  28671. }
  28672. /**
  28673. * The scan method does not return an empty part for the pattern with a forward slash.
  28674. * This is another part of micromatch/picomatch#58.
  28675. */
  28676. if (parts[0].startsWith('/')) {
  28677. parts[0] = parts[0].slice(1);
  28678. parts.unshift('');
  28679. }
  28680. return parts;
  28681. }
  28682. pattern$1.getPatternParts = getPatternParts;
  28683. function makeRe(pattern, options) {
  28684. return micromatch.makeRe(pattern, options);
  28685. }
  28686. pattern$1.makeRe = makeRe;
  28687. function convertPatternsToRe(patterns, options) {
  28688. return patterns.map(pattern => makeRe(pattern, options));
  28689. }
  28690. pattern$1.convertPatternsToRe = convertPatternsToRe;
  28691. function matchAny(entry, patternsRe) {
  28692. return patternsRe.some(patternRe => patternRe.test(entry));
  28693. }
  28694. pattern$1.matchAny = matchAny;
  28695. var stream$4 = {};
  28696. Object.defineProperty(stream$4, "__esModule", {
  28697. value: true
  28698. });
  28699. stream$4.merge = void 0;
  28700. const merge2$1 = merge2_1;
  28701. function merge(streams) {
  28702. const mergedStream = merge2$1(streams);
  28703. streams.forEach(stream => {
  28704. stream.once('error', error => mergedStream.emit('error', error));
  28705. });
  28706. mergedStream.once('close', () => propagateCloseEventToSources(streams));
  28707. mergedStream.once('end', () => propagateCloseEventToSources(streams));
  28708. return mergedStream;
  28709. }
  28710. stream$4.merge = merge;
  28711. function propagateCloseEventToSources(streams) {
  28712. streams.forEach(stream => stream.emit('close'));
  28713. }
  28714. var string$1 = {};
  28715. Object.defineProperty(string$1, "__esModule", {
  28716. value: true
  28717. });
  28718. string$1.isEmpty = string$1.isString = void 0;
  28719. function isString$1(input) {
  28720. return typeof input === 'string';
  28721. }
  28722. string$1.isString = isString$1;
  28723. function isEmpty(input) {
  28724. return input === '';
  28725. }
  28726. string$1.isEmpty = isEmpty;
  28727. Object.defineProperty(utils$r, "__esModule", {
  28728. value: true
  28729. });
  28730. utils$r.string = utils$r.stream = utils$r.pattern = utils$r.path = utils$r.fs = utils$r.errno = utils$r.array = void 0;
  28731. const array$1 = array$2;
  28732. utils$r.array = array$1;
  28733. const errno = errno$1;
  28734. utils$r.errno = errno;
  28735. const fs$a = fs$b;
  28736. utils$r.fs = fs$a;
  28737. const path$7 = path$c;
  28738. utils$r.path = path$7;
  28739. const pattern = pattern$1;
  28740. utils$r.pattern = pattern;
  28741. const stream$3 = stream$4;
  28742. utils$r.stream = stream$3;
  28743. const string = string$1;
  28744. utils$r.string = string;
  28745. Object.defineProperty(tasks, "__esModule", {
  28746. value: true
  28747. });
  28748. tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
  28749. const utils$h = utils$r;
  28750. function generate(patterns, settings) {
  28751. const positivePatterns = getPositivePatterns(patterns);
  28752. const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
  28753. const staticPatterns = positivePatterns.filter(pattern => utils$h.pattern.isStaticPattern(pattern, settings));
  28754. const dynamicPatterns = positivePatterns.filter(pattern => utils$h.pattern.isDynamicPattern(pattern, settings));
  28755. const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns,
  28756. /* dynamic */
  28757. false);
  28758. const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns,
  28759. /* dynamic */
  28760. true);
  28761. return staticTasks.concat(dynamicTasks);
  28762. }
  28763. tasks.generate = generate;
  28764. /**
  28765. * Returns tasks grouped by basic pattern directories.
  28766. *
  28767. * Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
  28768. * This is necessary because directory traversal starts at the base directory and goes deeper.
  28769. */
  28770. function convertPatternsToTasks(positive, negative, dynamic) {
  28771. const tasks = [];
  28772. const patternsOutsideCurrentDirectory = utils$h.pattern.getPatternsOutsideCurrentDirectory(positive);
  28773. const patternsInsideCurrentDirectory = utils$h.pattern.getPatternsInsideCurrentDirectory(positive);
  28774. const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
  28775. const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
  28776. tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
  28777. /*
  28778. * For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
  28779. * into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
  28780. */
  28781. if ('.' in insideCurrentDirectoryGroup) {
  28782. tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
  28783. } else {
  28784. tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
  28785. }
  28786. return tasks;
  28787. }
  28788. tasks.convertPatternsToTasks = convertPatternsToTasks;
  28789. function getPositivePatterns(patterns) {
  28790. return utils$h.pattern.getPositivePatterns(patterns);
  28791. }
  28792. tasks.getPositivePatterns = getPositivePatterns;
  28793. function getNegativePatternsAsPositive(patterns, ignore) {
  28794. const negative = utils$h.pattern.getNegativePatterns(patterns).concat(ignore);
  28795. const positive = negative.map(utils$h.pattern.convertToPositivePattern);
  28796. return positive;
  28797. }
  28798. tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
  28799. function groupPatternsByBaseDirectory(patterns) {
  28800. const group = {};
  28801. return patterns.reduce((collection, pattern) => {
  28802. const base = utils$h.pattern.getBaseDirectory(pattern);
  28803. if (base in collection) {
  28804. collection[base].push(pattern);
  28805. } else {
  28806. collection[base] = [pattern];
  28807. }
  28808. return collection;
  28809. }, group);
  28810. }
  28811. tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
  28812. function convertPatternGroupsToTasks(positive, negative, dynamic) {
  28813. return Object.keys(positive).map(base => {
  28814. return convertPatternGroupToTask(base, positive[base], negative, dynamic);
  28815. });
  28816. }
  28817. tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
  28818. function convertPatternGroupToTask(base, positive, negative, dynamic) {
  28819. return {
  28820. dynamic,
  28821. positive,
  28822. negative,
  28823. base,
  28824. patterns: [].concat(positive, negative.map(utils$h.pattern.convertToNegativePattern))
  28825. };
  28826. }
  28827. tasks.convertPatternGroupToTask = convertPatternGroupToTask;
  28828. var async$6 = {};
  28829. var stream$2 = {};
  28830. var out$3 = {};
  28831. var async$5 = {};
  28832. Object.defineProperty(async$5, "__esModule", {
  28833. value: true
  28834. });
  28835. async$5.read = void 0;
  28836. function read$3(path, settings, callback) {
  28837. settings.fs.lstat(path, (lstatError, lstat) => {
  28838. if (lstatError !== null) {
  28839. callFailureCallback$2(callback, lstatError);
  28840. return;
  28841. }
  28842. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  28843. callSuccessCallback$2(callback, lstat);
  28844. return;
  28845. }
  28846. settings.fs.stat(path, (statError, stat) => {
  28847. if (statError !== null) {
  28848. if (settings.throwErrorOnBrokenSymbolicLink) {
  28849. callFailureCallback$2(callback, statError);
  28850. return;
  28851. }
  28852. callSuccessCallback$2(callback, lstat);
  28853. return;
  28854. }
  28855. if (settings.markSymbolicLink) {
  28856. stat.isSymbolicLink = () => true;
  28857. }
  28858. callSuccessCallback$2(callback, stat);
  28859. });
  28860. });
  28861. }
  28862. async$5.read = read$3;
  28863. function callFailureCallback$2(callback, error) {
  28864. callback(error);
  28865. }
  28866. function callSuccessCallback$2(callback, result) {
  28867. callback(null, result);
  28868. }
  28869. var sync$7 = {};
  28870. Object.defineProperty(sync$7, "__esModule", {
  28871. value: true
  28872. });
  28873. sync$7.read = void 0;
  28874. function read$2(path, settings) {
  28875. const lstat = settings.fs.lstatSync(path);
  28876. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  28877. return lstat;
  28878. }
  28879. try {
  28880. const stat = settings.fs.statSync(path);
  28881. if (settings.markSymbolicLink) {
  28882. stat.isSymbolicLink = () => true;
  28883. }
  28884. return stat;
  28885. } catch (error) {
  28886. if (!settings.throwErrorOnBrokenSymbolicLink) {
  28887. return lstat;
  28888. }
  28889. throw error;
  28890. }
  28891. }
  28892. sync$7.read = read$2;
  28893. var settings$3 = {};
  28894. var fs$9 = {};
  28895. (function (exports) {
  28896. Object.defineProperty(exports, "__esModule", {
  28897. value: true
  28898. });
  28899. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  28900. const fs = require$$0__default["default"];
  28901. exports.FILE_SYSTEM_ADAPTER = {
  28902. lstat: fs.lstat,
  28903. stat: fs.stat,
  28904. lstatSync: fs.lstatSync,
  28905. statSync: fs.statSync
  28906. };
  28907. function createFileSystemAdapter(fsMethods) {
  28908. if (fsMethods === undefined) {
  28909. return exports.FILE_SYSTEM_ADAPTER;
  28910. }
  28911. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  28912. }
  28913. exports.createFileSystemAdapter = createFileSystemAdapter;
  28914. })(fs$9);
  28915. Object.defineProperty(settings$3, "__esModule", {
  28916. value: true
  28917. });
  28918. const fs$8 = fs$9;
  28919. class Settings$2 {
  28920. constructor(_options = {}) {
  28921. this._options = _options;
  28922. this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
  28923. this.fs = fs$8.createFileSystemAdapter(this._options.fs);
  28924. this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
  28925. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  28926. }
  28927. _getValue(option, value) {
  28928. return option !== null && option !== void 0 ? option : value;
  28929. }
  28930. }
  28931. settings$3.default = Settings$2;
  28932. Object.defineProperty(out$3, "__esModule", {
  28933. value: true
  28934. });
  28935. out$3.statSync = out$3.stat = out$3.Settings = void 0;
  28936. const async$4 = async$5;
  28937. const sync$6 = sync$7;
  28938. const settings_1$3 = settings$3;
  28939. out$3.Settings = settings_1$3.default;
  28940. function stat(path, optionsOrSettingsOrCallback, callback) {
  28941. if (typeof optionsOrSettingsOrCallback === 'function') {
  28942. async$4.read(path, getSettings$2(), optionsOrSettingsOrCallback);
  28943. return;
  28944. }
  28945. async$4.read(path, getSettings$2(optionsOrSettingsOrCallback), callback);
  28946. }
  28947. out$3.stat = stat;
  28948. function statSync(path, optionsOrSettings) {
  28949. const settings = getSettings$2(optionsOrSettings);
  28950. return sync$6.read(path, settings);
  28951. }
  28952. out$3.statSync = statSync;
  28953. function getSettings$2(settingsOrOptions = {}) {
  28954. if (settingsOrOptions instanceof settings_1$3.default) {
  28955. return settingsOrOptions;
  28956. }
  28957. return new settings_1$3.default(settingsOrOptions);
  28958. }
  28959. var out$2 = {};
  28960. var async$3 = {};
  28961. var async$2 = {};
  28962. var out$1 = {};
  28963. var async$1 = {};
  28964. /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  28965. let promise;
  28966. var queueMicrotask_1 = typeof queueMicrotask === 'function' ? queueMicrotask.bind(typeof window !== 'undefined' ? window : global) // reuse resolved promise, and allocate it lazily
  28967. : cb => (promise || (promise = Promise.resolve())).then(cb).catch(err => setTimeout(() => {
  28968. throw err;
  28969. }, 0));
  28970. /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  28971. var runParallel_1 = runParallel;
  28972. const queueMicrotask$1 = queueMicrotask_1;
  28973. function runParallel(tasks, cb) {
  28974. let results, pending, keys;
  28975. let isSync = true;
  28976. if (Array.isArray(tasks)) {
  28977. results = [];
  28978. pending = tasks.length;
  28979. } else {
  28980. keys = Object.keys(tasks);
  28981. results = {};
  28982. pending = keys.length;
  28983. }
  28984. function done(err) {
  28985. function end() {
  28986. if (cb) cb(err, results);
  28987. cb = null;
  28988. }
  28989. if (isSync) queueMicrotask$1(end);else end();
  28990. }
  28991. function each(i, err, result) {
  28992. results[i] = result;
  28993. if (--pending === 0 || err) {
  28994. done(err);
  28995. }
  28996. }
  28997. if (!pending) {
  28998. // empty
  28999. done(null);
  29000. } else if (keys) {
  29001. // object
  29002. keys.forEach(function (key) {
  29003. tasks[key](function (err, result) {
  29004. each(key, err, result);
  29005. });
  29006. });
  29007. } else {
  29008. // array
  29009. tasks.forEach(function (task, i) {
  29010. task(function (err, result) {
  29011. each(i, err, result);
  29012. });
  29013. });
  29014. }
  29015. isSync = false;
  29016. }
  29017. var constants = {};
  29018. Object.defineProperty(constants, "__esModule", {
  29019. value: true
  29020. });
  29021. constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
  29022. const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
  29023. if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) {
  29024. throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);
  29025. }
  29026. const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
  29027. const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
  29028. const SUPPORTED_MAJOR_VERSION = 10;
  29029. const SUPPORTED_MINOR_VERSION = 10;
  29030. const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
  29031. const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
  29032. /**
  29033. * IS `true` for Node.js 10.10 and greater.
  29034. */
  29035. constants.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
  29036. var utils$g = {};
  29037. var fs$7 = {};
  29038. Object.defineProperty(fs$7, "__esModule", {
  29039. value: true
  29040. });
  29041. fs$7.createDirentFromStats = void 0;
  29042. class DirentFromStats {
  29043. constructor(name, stats) {
  29044. this.name = name;
  29045. this.isBlockDevice = stats.isBlockDevice.bind(stats);
  29046. this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
  29047. this.isDirectory = stats.isDirectory.bind(stats);
  29048. this.isFIFO = stats.isFIFO.bind(stats);
  29049. this.isFile = stats.isFile.bind(stats);
  29050. this.isSocket = stats.isSocket.bind(stats);
  29051. this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
  29052. }
  29053. }
  29054. function createDirentFromStats(name, stats) {
  29055. return new DirentFromStats(name, stats);
  29056. }
  29057. fs$7.createDirentFromStats = createDirentFromStats;
  29058. Object.defineProperty(utils$g, "__esModule", {
  29059. value: true
  29060. });
  29061. utils$g.fs = void 0;
  29062. const fs$6 = fs$7;
  29063. utils$g.fs = fs$6;
  29064. var common$6 = {};
  29065. Object.defineProperty(common$6, "__esModule", {
  29066. value: true
  29067. });
  29068. common$6.joinPathSegments = void 0;
  29069. function joinPathSegments$1(a, b, separator) {
  29070. /**
  29071. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  29072. */
  29073. if (a.endsWith(separator)) {
  29074. return a + b;
  29075. }
  29076. return a + separator + b;
  29077. }
  29078. common$6.joinPathSegments = joinPathSegments$1;
  29079. Object.defineProperty(async$1, "__esModule", {
  29080. value: true
  29081. });
  29082. async$1.readdir = async$1.readdirWithFileTypes = async$1.read = void 0;
  29083. const fsStat$5 = out$3;
  29084. const rpl = runParallel_1;
  29085. const constants_1$1 = constants;
  29086. const utils$f = utils$g;
  29087. const common$5 = common$6;
  29088. function read$1(directory, settings, callback) {
  29089. if (!settings.stats && constants_1$1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  29090. readdirWithFileTypes$1(directory, settings, callback);
  29091. return;
  29092. }
  29093. readdir$1(directory, settings, callback);
  29094. }
  29095. async$1.read = read$1;
  29096. function readdirWithFileTypes$1(directory, settings, callback) {
  29097. settings.fs.readdir(directory, {
  29098. withFileTypes: true
  29099. }, (readdirError, dirents) => {
  29100. if (readdirError !== null) {
  29101. callFailureCallback$1(callback, readdirError);
  29102. return;
  29103. }
  29104. const entries = dirents.map(dirent => ({
  29105. dirent,
  29106. name: dirent.name,
  29107. path: common$5.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  29108. }));
  29109. if (!settings.followSymbolicLinks) {
  29110. callSuccessCallback$1(callback, entries);
  29111. return;
  29112. }
  29113. const tasks = entries.map(entry => makeRplTaskEntry(entry, settings));
  29114. rpl(tasks, (rplError, rplEntries) => {
  29115. if (rplError !== null) {
  29116. callFailureCallback$1(callback, rplError);
  29117. return;
  29118. }
  29119. callSuccessCallback$1(callback, rplEntries);
  29120. });
  29121. });
  29122. }
  29123. async$1.readdirWithFileTypes = readdirWithFileTypes$1;
  29124. function makeRplTaskEntry(entry, settings) {
  29125. return done => {
  29126. if (!entry.dirent.isSymbolicLink()) {
  29127. done(null, entry);
  29128. return;
  29129. }
  29130. settings.fs.stat(entry.path, (statError, stats) => {
  29131. if (statError !== null) {
  29132. if (settings.throwErrorOnBrokenSymbolicLink) {
  29133. done(statError);
  29134. return;
  29135. }
  29136. done(null, entry);
  29137. return;
  29138. }
  29139. entry.dirent = utils$f.fs.createDirentFromStats(entry.name, stats);
  29140. done(null, entry);
  29141. });
  29142. };
  29143. }
  29144. function readdir$1(directory, settings, callback) {
  29145. settings.fs.readdir(directory, (readdirError, names) => {
  29146. if (readdirError !== null) {
  29147. callFailureCallback$1(callback, readdirError);
  29148. return;
  29149. }
  29150. const tasks = names.map(name => {
  29151. const path = common$5.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  29152. return done => {
  29153. fsStat$5.stat(path, settings.fsStatSettings, (error, stats) => {
  29154. if (error !== null) {
  29155. done(error);
  29156. return;
  29157. }
  29158. const entry = {
  29159. name,
  29160. path,
  29161. dirent: utils$f.fs.createDirentFromStats(name, stats)
  29162. };
  29163. if (settings.stats) {
  29164. entry.stats = stats;
  29165. }
  29166. done(null, entry);
  29167. });
  29168. };
  29169. });
  29170. rpl(tasks, (rplError, entries) => {
  29171. if (rplError !== null) {
  29172. callFailureCallback$1(callback, rplError);
  29173. return;
  29174. }
  29175. callSuccessCallback$1(callback, entries);
  29176. });
  29177. });
  29178. }
  29179. async$1.readdir = readdir$1;
  29180. function callFailureCallback$1(callback, error) {
  29181. callback(error);
  29182. }
  29183. function callSuccessCallback$1(callback, result) {
  29184. callback(null, result);
  29185. }
  29186. var sync$5 = {};
  29187. Object.defineProperty(sync$5, "__esModule", {
  29188. value: true
  29189. });
  29190. sync$5.readdir = sync$5.readdirWithFileTypes = sync$5.read = void 0;
  29191. const fsStat$4 = out$3;
  29192. const constants_1 = constants;
  29193. const utils$e = utils$g;
  29194. const common$4 = common$6;
  29195. function read(directory, settings) {
  29196. if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
  29197. return readdirWithFileTypes(directory, settings);
  29198. }
  29199. return readdir(directory, settings);
  29200. }
  29201. sync$5.read = read;
  29202. function readdirWithFileTypes(directory, settings) {
  29203. const dirents = settings.fs.readdirSync(directory, {
  29204. withFileTypes: true
  29205. });
  29206. return dirents.map(dirent => {
  29207. const entry = {
  29208. dirent,
  29209. name: dirent.name,
  29210. path: common$4.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
  29211. };
  29212. if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
  29213. try {
  29214. const stats = settings.fs.statSync(entry.path);
  29215. entry.dirent = utils$e.fs.createDirentFromStats(entry.name, stats);
  29216. } catch (error) {
  29217. if (settings.throwErrorOnBrokenSymbolicLink) {
  29218. throw error;
  29219. }
  29220. }
  29221. }
  29222. return entry;
  29223. });
  29224. }
  29225. sync$5.readdirWithFileTypes = readdirWithFileTypes;
  29226. function readdir(directory, settings) {
  29227. const names = settings.fs.readdirSync(directory);
  29228. return names.map(name => {
  29229. const entryPath = common$4.joinPathSegments(directory, name, settings.pathSegmentSeparator);
  29230. const stats = fsStat$4.statSync(entryPath, settings.fsStatSettings);
  29231. const entry = {
  29232. name,
  29233. path: entryPath,
  29234. dirent: utils$e.fs.createDirentFromStats(name, stats)
  29235. };
  29236. if (settings.stats) {
  29237. entry.stats = stats;
  29238. }
  29239. return entry;
  29240. });
  29241. }
  29242. sync$5.readdir = readdir;
  29243. var settings$2 = {};
  29244. var fs$5 = {};
  29245. (function (exports) {
  29246. Object.defineProperty(exports, "__esModule", {
  29247. value: true
  29248. });
  29249. exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
  29250. const fs = require$$0__default["default"];
  29251. exports.FILE_SYSTEM_ADAPTER = {
  29252. lstat: fs.lstat,
  29253. stat: fs.stat,
  29254. lstatSync: fs.lstatSync,
  29255. statSync: fs.statSync,
  29256. readdir: fs.readdir,
  29257. readdirSync: fs.readdirSync
  29258. };
  29259. function createFileSystemAdapter(fsMethods) {
  29260. if (fsMethods === undefined) {
  29261. return exports.FILE_SYSTEM_ADAPTER;
  29262. }
  29263. return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
  29264. }
  29265. exports.createFileSystemAdapter = createFileSystemAdapter;
  29266. })(fs$5);
  29267. Object.defineProperty(settings$2, "__esModule", {
  29268. value: true
  29269. });
  29270. const path$6 = require$$0__default$2["default"];
  29271. const fsStat$3 = out$3;
  29272. const fs$4 = fs$5;
  29273. class Settings$1 {
  29274. constructor(_options = {}) {
  29275. this._options = _options;
  29276. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
  29277. this.fs = fs$4.createFileSystemAdapter(this._options.fs);
  29278. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$6.sep);
  29279. this.stats = this._getValue(this._options.stats, false);
  29280. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
  29281. this.fsStatSettings = new fsStat$3.Settings({
  29282. followSymbolicLink: this.followSymbolicLinks,
  29283. fs: this.fs,
  29284. throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
  29285. });
  29286. }
  29287. _getValue(option, value) {
  29288. return option !== null && option !== void 0 ? option : value;
  29289. }
  29290. }
  29291. settings$2.default = Settings$1;
  29292. Object.defineProperty(out$1, "__esModule", {
  29293. value: true
  29294. });
  29295. out$1.Settings = out$1.scandirSync = out$1.scandir = void 0;
  29296. const async = async$1;
  29297. const sync$4 = sync$5;
  29298. const settings_1$2 = settings$2;
  29299. out$1.Settings = settings_1$2.default;
  29300. function scandir(path, optionsOrSettingsOrCallback, callback) {
  29301. if (typeof optionsOrSettingsOrCallback === 'function') {
  29302. async.read(path, getSettings$1(), optionsOrSettingsOrCallback);
  29303. return;
  29304. }
  29305. async.read(path, getSettings$1(optionsOrSettingsOrCallback), callback);
  29306. }
  29307. out$1.scandir = scandir;
  29308. function scandirSync(path, optionsOrSettings) {
  29309. const settings = getSettings$1(optionsOrSettings);
  29310. return sync$4.read(path, settings);
  29311. }
  29312. out$1.scandirSync = scandirSync;
  29313. function getSettings$1(settingsOrOptions = {}) {
  29314. if (settingsOrOptions instanceof settings_1$2.default) {
  29315. return settingsOrOptions;
  29316. }
  29317. return new settings_1$2.default(settingsOrOptions);
  29318. }
  29319. var queue = {exports: {}};
  29320. function reusify$1(Constructor) {
  29321. var head = new Constructor();
  29322. var tail = head;
  29323. function get() {
  29324. var current = head;
  29325. if (current.next) {
  29326. head = current.next;
  29327. } else {
  29328. head = new Constructor();
  29329. tail = head;
  29330. }
  29331. current.next = null;
  29332. return current;
  29333. }
  29334. function release(obj) {
  29335. tail.next = obj;
  29336. tail = obj;
  29337. }
  29338. return {
  29339. get: get,
  29340. release: release
  29341. };
  29342. }
  29343. var reusify_1 = reusify$1;
  29344. /* eslint-disable no-var */
  29345. var reusify = reusify_1;
  29346. function fastqueue(context, worker, concurrency) {
  29347. if (typeof context === 'function') {
  29348. concurrency = worker;
  29349. worker = context;
  29350. context = null;
  29351. }
  29352. if (concurrency < 1) {
  29353. throw new Error('fastqueue concurrency must be greater than 1');
  29354. }
  29355. var cache = reusify(Task);
  29356. var queueHead = null;
  29357. var queueTail = null;
  29358. var _running = 0;
  29359. var errorHandler = null;
  29360. var self = {
  29361. push: push,
  29362. drain: noop,
  29363. saturated: noop,
  29364. pause: pause,
  29365. paused: false,
  29366. concurrency: concurrency,
  29367. running: running,
  29368. resume: resume,
  29369. idle: idle,
  29370. length: length,
  29371. getQueue: getQueue,
  29372. unshift: unshift,
  29373. empty: noop,
  29374. kill: kill,
  29375. killAndDrain: killAndDrain,
  29376. error: error
  29377. };
  29378. return self;
  29379. function running() {
  29380. return _running;
  29381. }
  29382. function pause() {
  29383. self.paused = true;
  29384. }
  29385. function length() {
  29386. var current = queueHead;
  29387. var counter = 0;
  29388. while (current) {
  29389. current = current.next;
  29390. counter++;
  29391. }
  29392. return counter;
  29393. }
  29394. function getQueue() {
  29395. var current = queueHead;
  29396. var tasks = [];
  29397. while (current) {
  29398. tasks.push(current.value);
  29399. current = current.next;
  29400. }
  29401. return tasks;
  29402. }
  29403. function resume() {
  29404. if (!self.paused) return;
  29405. self.paused = false;
  29406. for (var i = 0; i < self.concurrency; i++) {
  29407. _running++;
  29408. release();
  29409. }
  29410. }
  29411. function idle() {
  29412. return _running === 0 && self.length() === 0;
  29413. }
  29414. function push(value, done) {
  29415. var current = cache.get();
  29416. current.context = context;
  29417. current.release = release;
  29418. current.value = value;
  29419. current.callback = done || noop;
  29420. current.errorHandler = errorHandler;
  29421. if (_running === self.concurrency || self.paused) {
  29422. if (queueTail) {
  29423. queueTail.next = current;
  29424. queueTail = current;
  29425. } else {
  29426. queueHead = current;
  29427. queueTail = current;
  29428. self.saturated();
  29429. }
  29430. } else {
  29431. _running++;
  29432. worker.call(context, current.value, current.worked);
  29433. }
  29434. }
  29435. function unshift(value, done) {
  29436. var current = cache.get();
  29437. current.context = context;
  29438. current.release = release;
  29439. current.value = value;
  29440. current.callback = done || noop;
  29441. if (_running === self.concurrency || self.paused) {
  29442. if (queueHead) {
  29443. current.next = queueHead;
  29444. queueHead = current;
  29445. } else {
  29446. queueHead = current;
  29447. queueTail = current;
  29448. self.saturated();
  29449. }
  29450. } else {
  29451. _running++;
  29452. worker.call(context, current.value, current.worked);
  29453. }
  29454. }
  29455. function release(holder) {
  29456. if (holder) {
  29457. cache.release(holder);
  29458. }
  29459. var next = queueHead;
  29460. if (next) {
  29461. if (!self.paused) {
  29462. if (queueTail === queueHead) {
  29463. queueTail = null;
  29464. }
  29465. queueHead = next.next;
  29466. next.next = null;
  29467. worker.call(context, next.value, next.worked);
  29468. if (queueTail === null) {
  29469. self.empty();
  29470. }
  29471. } else {
  29472. _running--;
  29473. }
  29474. } else if (--_running === 0) {
  29475. self.drain();
  29476. }
  29477. }
  29478. function kill() {
  29479. queueHead = null;
  29480. queueTail = null;
  29481. self.drain = noop;
  29482. }
  29483. function killAndDrain() {
  29484. queueHead = null;
  29485. queueTail = null;
  29486. self.drain();
  29487. self.drain = noop;
  29488. }
  29489. function error(handler) {
  29490. errorHandler = handler;
  29491. }
  29492. }
  29493. function noop() {}
  29494. function Task() {
  29495. this.value = null;
  29496. this.callback = noop;
  29497. this.next = null;
  29498. this.release = noop;
  29499. this.context = null;
  29500. this.errorHandler = null;
  29501. var self = this;
  29502. this.worked = function worked(err, result) {
  29503. var callback = self.callback;
  29504. var errorHandler = self.errorHandler;
  29505. var val = self.value;
  29506. self.value = null;
  29507. self.callback = noop;
  29508. if (self.errorHandler) {
  29509. errorHandler(err, val);
  29510. }
  29511. callback.call(self.context, err, result);
  29512. self.release(self);
  29513. };
  29514. }
  29515. function queueAsPromised(context, worker, concurrency) {
  29516. if (typeof context === 'function') {
  29517. concurrency = worker;
  29518. worker = context;
  29519. context = null;
  29520. }
  29521. function asyncWrapper(arg, cb) {
  29522. worker.call(this, arg).then(function (res) {
  29523. cb(null, res);
  29524. }, cb);
  29525. }
  29526. var queue = fastqueue(context, asyncWrapper, concurrency);
  29527. var pushCb = queue.push;
  29528. var unshiftCb = queue.unshift;
  29529. queue.push = push;
  29530. queue.unshift = unshift;
  29531. queue.drained = drained;
  29532. return queue;
  29533. function push(value) {
  29534. var p = new Promise(function (resolve, reject) {
  29535. pushCb(value, function (err, result) {
  29536. if (err) {
  29537. reject(err);
  29538. return;
  29539. }
  29540. resolve(result);
  29541. });
  29542. }); // Let's fork the promise chain to
  29543. // make the error bubble up to the user but
  29544. // not lead to a unhandledRejection
  29545. p.catch(noop);
  29546. return p;
  29547. }
  29548. function unshift(value) {
  29549. var p = new Promise(function (resolve, reject) {
  29550. unshiftCb(value, function (err, result) {
  29551. if (err) {
  29552. reject(err);
  29553. return;
  29554. }
  29555. resolve(result);
  29556. });
  29557. }); // Let's fork the promise chain to
  29558. // make the error bubble up to the user but
  29559. // not lead to a unhandledRejection
  29560. p.catch(noop);
  29561. return p;
  29562. }
  29563. function drained() {
  29564. var previousDrain = queue.drain;
  29565. var p = new Promise(function (resolve) {
  29566. queue.drain = function () {
  29567. previousDrain();
  29568. resolve();
  29569. };
  29570. });
  29571. return p;
  29572. }
  29573. }
  29574. queue.exports = fastqueue;
  29575. queue.exports.promise = queueAsPromised;
  29576. var common$3 = {};
  29577. Object.defineProperty(common$3, "__esModule", {
  29578. value: true
  29579. });
  29580. common$3.joinPathSegments = common$3.replacePathSegmentSeparator = common$3.isAppliedFilter = common$3.isFatalError = void 0;
  29581. function isFatalError(settings, error) {
  29582. if (settings.errorFilter === null) {
  29583. return true;
  29584. }
  29585. return !settings.errorFilter(error);
  29586. }
  29587. common$3.isFatalError = isFatalError;
  29588. function isAppliedFilter(filter, value) {
  29589. return filter === null || filter(value);
  29590. }
  29591. common$3.isAppliedFilter = isAppliedFilter;
  29592. function replacePathSegmentSeparator(filepath, separator) {
  29593. return filepath.split(/[/\\]/).join(separator);
  29594. }
  29595. common$3.replacePathSegmentSeparator = replacePathSegmentSeparator;
  29596. function joinPathSegments(a, b, separator) {
  29597. if (a === '') {
  29598. return b;
  29599. }
  29600. /**
  29601. * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
  29602. */
  29603. if (a.endsWith(separator)) {
  29604. return a + b;
  29605. }
  29606. return a + separator + b;
  29607. }
  29608. common$3.joinPathSegments = joinPathSegments;
  29609. var reader$1 = {};
  29610. Object.defineProperty(reader$1, "__esModule", {
  29611. value: true
  29612. });
  29613. const common$2 = common$3;
  29614. class Reader$1 {
  29615. constructor(_root, _settings) {
  29616. this._root = _root;
  29617. this._settings = _settings;
  29618. this._root = common$2.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
  29619. }
  29620. }
  29621. reader$1.default = Reader$1;
  29622. Object.defineProperty(async$2, "__esModule", {
  29623. value: true
  29624. });
  29625. const events_1 = require$$0__default$6["default"];
  29626. const fsScandir$2 = out$1;
  29627. const fastq = queue.exports;
  29628. const common$1 = common$3;
  29629. const reader_1$3 = reader$1;
  29630. class AsyncReader extends reader_1$3.default {
  29631. constructor(_root, _settings) {
  29632. super(_root, _settings);
  29633. this._settings = _settings;
  29634. this._scandir = fsScandir$2.scandir;
  29635. this._emitter = new events_1.EventEmitter();
  29636. this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
  29637. this._isFatalError = false;
  29638. this._isDestroyed = false;
  29639. this._queue.drain = () => {
  29640. if (!this._isFatalError) {
  29641. this._emitter.emit('end');
  29642. }
  29643. };
  29644. }
  29645. read() {
  29646. this._isFatalError = false;
  29647. this._isDestroyed = false;
  29648. setImmediate(() => {
  29649. this._pushToQueue(this._root, this._settings.basePath);
  29650. });
  29651. return this._emitter;
  29652. }
  29653. get isDestroyed() {
  29654. return this._isDestroyed;
  29655. }
  29656. destroy() {
  29657. if (this._isDestroyed) {
  29658. throw new Error('The reader is already destroyed');
  29659. }
  29660. this._isDestroyed = true;
  29661. this._queue.killAndDrain();
  29662. }
  29663. onEntry(callback) {
  29664. this._emitter.on('entry', callback);
  29665. }
  29666. onError(callback) {
  29667. this._emitter.once('error', callback);
  29668. }
  29669. onEnd(callback) {
  29670. this._emitter.once('end', callback);
  29671. }
  29672. _pushToQueue(directory, base) {
  29673. const queueItem = {
  29674. directory,
  29675. base
  29676. };
  29677. this._queue.push(queueItem, error => {
  29678. if (error !== null) {
  29679. this._handleError(error);
  29680. }
  29681. });
  29682. }
  29683. _worker(item, done) {
  29684. this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
  29685. if (error !== null) {
  29686. done(error, undefined);
  29687. return;
  29688. }
  29689. for (const entry of entries) {
  29690. this._handleEntry(entry, item.base);
  29691. }
  29692. done(null, undefined);
  29693. });
  29694. }
  29695. _handleError(error) {
  29696. if (this._isDestroyed || !common$1.isFatalError(this._settings, error)) {
  29697. return;
  29698. }
  29699. this._isFatalError = true;
  29700. this._isDestroyed = true;
  29701. this._emitter.emit('error', error);
  29702. }
  29703. _handleEntry(entry, base) {
  29704. if (this._isDestroyed || this._isFatalError) {
  29705. return;
  29706. }
  29707. const fullpath = entry.path;
  29708. if (base !== undefined) {
  29709. entry.path = common$1.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  29710. }
  29711. if (common$1.isAppliedFilter(this._settings.entryFilter, entry)) {
  29712. this._emitEntry(entry);
  29713. }
  29714. if (entry.dirent.isDirectory() && common$1.isAppliedFilter(this._settings.deepFilter, entry)) {
  29715. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  29716. }
  29717. }
  29718. _emitEntry(entry) {
  29719. this._emitter.emit('entry', entry);
  29720. }
  29721. }
  29722. async$2.default = AsyncReader;
  29723. Object.defineProperty(async$3, "__esModule", {
  29724. value: true
  29725. });
  29726. const async_1$3 = async$2;
  29727. class AsyncProvider {
  29728. constructor(_root, _settings) {
  29729. this._root = _root;
  29730. this._settings = _settings;
  29731. this._reader = new async_1$3.default(this._root, this._settings);
  29732. this._storage = [];
  29733. }
  29734. read(callback) {
  29735. this._reader.onError(error => {
  29736. callFailureCallback(callback, error);
  29737. });
  29738. this._reader.onEntry(entry => {
  29739. this._storage.push(entry);
  29740. });
  29741. this._reader.onEnd(() => {
  29742. callSuccessCallback(callback, this._storage);
  29743. });
  29744. this._reader.read();
  29745. }
  29746. }
  29747. async$3.default = AsyncProvider;
  29748. function callFailureCallback(callback, error) {
  29749. callback(error);
  29750. }
  29751. function callSuccessCallback(callback, entries) {
  29752. callback(null, entries);
  29753. }
  29754. var stream$1 = {};
  29755. Object.defineProperty(stream$1, "__esModule", {
  29756. value: true
  29757. });
  29758. const stream_1$5 = require$$0__default$5["default"];
  29759. const async_1$2 = async$2;
  29760. class StreamProvider {
  29761. constructor(_root, _settings) {
  29762. this._root = _root;
  29763. this._settings = _settings;
  29764. this._reader = new async_1$2.default(this._root, this._settings);
  29765. this._stream = new stream_1$5.Readable({
  29766. objectMode: true,
  29767. read: () => {},
  29768. destroy: () => {
  29769. if (!this._reader.isDestroyed) {
  29770. this._reader.destroy();
  29771. }
  29772. }
  29773. });
  29774. }
  29775. read() {
  29776. this._reader.onError(error => {
  29777. this._stream.emit('error', error);
  29778. });
  29779. this._reader.onEntry(entry => {
  29780. this._stream.push(entry);
  29781. });
  29782. this._reader.onEnd(() => {
  29783. this._stream.push(null);
  29784. });
  29785. this._reader.read();
  29786. return this._stream;
  29787. }
  29788. }
  29789. stream$1.default = StreamProvider;
  29790. var sync$3 = {};
  29791. var sync$2 = {};
  29792. Object.defineProperty(sync$2, "__esModule", {
  29793. value: true
  29794. });
  29795. const fsScandir$1 = out$1;
  29796. const common = common$3;
  29797. const reader_1$2 = reader$1;
  29798. class SyncReader extends reader_1$2.default {
  29799. constructor() {
  29800. super(...arguments);
  29801. this._scandir = fsScandir$1.scandirSync;
  29802. this._storage = [];
  29803. this._queue = new Set();
  29804. }
  29805. read() {
  29806. this._pushToQueue(this._root, this._settings.basePath);
  29807. this._handleQueue();
  29808. return this._storage;
  29809. }
  29810. _pushToQueue(directory, base) {
  29811. this._queue.add({
  29812. directory,
  29813. base
  29814. });
  29815. }
  29816. _handleQueue() {
  29817. for (const item of this._queue.values()) {
  29818. this._handleDirectory(item.directory, item.base);
  29819. }
  29820. }
  29821. _handleDirectory(directory, base) {
  29822. try {
  29823. const entries = this._scandir(directory, this._settings.fsScandirSettings);
  29824. for (const entry of entries) {
  29825. this._handleEntry(entry, base);
  29826. }
  29827. } catch (error) {
  29828. this._handleError(error);
  29829. }
  29830. }
  29831. _handleError(error) {
  29832. if (!common.isFatalError(this._settings, error)) {
  29833. return;
  29834. }
  29835. throw error;
  29836. }
  29837. _handleEntry(entry, base) {
  29838. const fullpath = entry.path;
  29839. if (base !== undefined) {
  29840. entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
  29841. }
  29842. if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
  29843. this._pushToStorage(entry);
  29844. }
  29845. if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
  29846. this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
  29847. }
  29848. }
  29849. _pushToStorage(entry) {
  29850. this._storage.push(entry);
  29851. }
  29852. }
  29853. sync$2.default = SyncReader;
  29854. Object.defineProperty(sync$3, "__esModule", {
  29855. value: true
  29856. });
  29857. const sync_1$3 = sync$2;
  29858. class SyncProvider {
  29859. constructor(_root, _settings) {
  29860. this._root = _root;
  29861. this._settings = _settings;
  29862. this._reader = new sync_1$3.default(this._root, this._settings);
  29863. }
  29864. read() {
  29865. return this._reader.read();
  29866. }
  29867. }
  29868. sync$3.default = SyncProvider;
  29869. var settings$1 = {};
  29870. Object.defineProperty(settings$1, "__esModule", {
  29871. value: true
  29872. });
  29873. const path$5 = require$$0__default$2["default"];
  29874. const fsScandir = out$1;
  29875. class Settings {
  29876. constructor(_options = {}) {
  29877. this._options = _options;
  29878. this.basePath = this._getValue(this._options.basePath, undefined);
  29879. this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
  29880. this.deepFilter = this._getValue(this._options.deepFilter, null);
  29881. this.entryFilter = this._getValue(this._options.entryFilter, null);
  29882. this.errorFilter = this._getValue(this._options.errorFilter, null);
  29883. this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$5.sep);
  29884. this.fsScandirSettings = new fsScandir.Settings({
  29885. followSymbolicLinks: this._options.followSymbolicLinks,
  29886. fs: this._options.fs,
  29887. pathSegmentSeparator: this._options.pathSegmentSeparator,
  29888. stats: this._options.stats,
  29889. throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
  29890. });
  29891. }
  29892. _getValue(option, value) {
  29893. return option !== null && option !== void 0 ? option : value;
  29894. }
  29895. }
  29896. settings$1.default = Settings;
  29897. Object.defineProperty(out$2, "__esModule", {
  29898. value: true
  29899. });
  29900. out$2.Settings = out$2.walkStream = out$2.walkSync = out$2.walk = void 0;
  29901. const async_1$1 = async$3;
  29902. const stream_1$4 = stream$1;
  29903. const sync_1$2 = sync$3;
  29904. const settings_1$1 = settings$1;
  29905. out$2.Settings = settings_1$1.default;
  29906. function walk(directory, optionsOrSettingsOrCallback, callback) {
  29907. if (typeof optionsOrSettingsOrCallback === 'function') {
  29908. new async_1$1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
  29909. return;
  29910. }
  29911. new async_1$1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
  29912. }
  29913. out$2.walk = walk;
  29914. function walkSync(directory, optionsOrSettings) {
  29915. const settings = getSettings(optionsOrSettings);
  29916. const provider = new sync_1$2.default(directory, settings);
  29917. return provider.read();
  29918. }
  29919. out$2.walkSync = walkSync;
  29920. function walkStream(directory, optionsOrSettings) {
  29921. const settings = getSettings(optionsOrSettings);
  29922. const provider = new stream_1$4.default(directory, settings);
  29923. return provider.read();
  29924. }
  29925. out$2.walkStream = walkStream;
  29926. function getSettings(settingsOrOptions = {}) {
  29927. if (settingsOrOptions instanceof settings_1$1.default) {
  29928. return settingsOrOptions;
  29929. }
  29930. return new settings_1$1.default(settingsOrOptions);
  29931. }
  29932. var reader = {};
  29933. Object.defineProperty(reader, "__esModule", {
  29934. value: true
  29935. });
  29936. const path$4 = require$$0__default$2["default"];
  29937. const fsStat$2 = out$3;
  29938. const utils$d = utils$r;
  29939. class Reader {
  29940. constructor(_settings) {
  29941. this._settings = _settings;
  29942. this._fsStatSettings = new fsStat$2.Settings({
  29943. followSymbolicLink: this._settings.followSymbolicLinks,
  29944. fs: this._settings.fs,
  29945. throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
  29946. });
  29947. }
  29948. _getFullEntryPath(filepath) {
  29949. return path$4.resolve(this._settings.cwd, filepath);
  29950. }
  29951. _makeEntry(stats, pattern) {
  29952. const entry = {
  29953. name: pattern,
  29954. path: pattern,
  29955. dirent: utils$d.fs.createDirentFromStats(pattern, stats)
  29956. };
  29957. if (this._settings.stats) {
  29958. entry.stats = stats;
  29959. }
  29960. return entry;
  29961. }
  29962. _isFatalError(error) {
  29963. return !utils$d.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
  29964. }
  29965. }
  29966. reader.default = Reader;
  29967. Object.defineProperty(stream$2, "__esModule", {
  29968. value: true
  29969. });
  29970. const stream_1$3 = require$$0__default$5["default"];
  29971. const fsStat$1 = out$3;
  29972. const fsWalk$1 = out$2;
  29973. const reader_1$1 = reader;
  29974. class ReaderStream extends reader_1$1.default {
  29975. constructor() {
  29976. super(...arguments);
  29977. this._walkStream = fsWalk$1.walkStream;
  29978. this._stat = fsStat$1.stat;
  29979. }
  29980. dynamic(root, options) {
  29981. return this._walkStream(root, options);
  29982. }
  29983. static(patterns, options) {
  29984. const filepaths = patterns.map(this._getFullEntryPath, this);
  29985. const stream = new stream_1$3.PassThrough({
  29986. objectMode: true
  29987. });
  29988. stream._write = (index, _enc, done) => {
  29989. return this._getEntry(filepaths[index], patterns[index], options).then(entry => {
  29990. if (entry !== null && options.entryFilter(entry)) {
  29991. stream.push(entry);
  29992. }
  29993. if (index === filepaths.length - 1) {
  29994. stream.end();
  29995. }
  29996. done();
  29997. }).catch(done);
  29998. };
  29999. for (let i = 0; i < filepaths.length; i++) {
  30000. stream.write(i);
  30001. }
  30002. return stream;
  30003. }
  30004. _getEntry(filepath, pattern, options) {
  30005. return this._getStat(filepath).then(stats => this._makeEntry(stats, pattern)).catch(error => {
  30006. if (options.errorFilter(error)) {
  30007. return null;
  30008. }
  30009. throw error;
  30010. });
  30011. }
  30012. _getStat(filepath) {
  30013. return new Promise((resolve, reject) => {
  30014. this._stat(filepath, this._fsStatSettings, (error, stats) => {
  30015. return error === null ? resolve(stats) : reject(error);
  30016. });
  30017. });
  30018. }
  30019. }
  30020. stream$2.default = ReaderStream;
  30021. var provider = {};
  30022. var deep = {};
  30023. var partial = {};
  30024. var matcher = {};
  30025. Object.defineProperty(matcher, "__esModule", {
  30026. value: true
  30027. });
  30028. const utils$c = utils$r;
  30029. class Matcher {
  30030. constructor(_patterns, _settings, _micromatchOptions) {
  30031. this._patterns = _patterns;
  30032. this._settings = _settings;
  30033. this._micromatchOptions = _micromatchOptions;
  30034. this._storage = [];
  30035. this._fillStorage();
  30036. }
  30037. _fillStorage() {
  30038. /**
  30039. * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
  30040. * So, before expand patterns with brace expansion into separated patterns.
  30041. */
  30042. const patterns = utils$c.pattern.expandPatternsWithBraceExpansion(this._patterns);
  30043. for (const pattern of patterns) {
  30044. const segments = this._getPatternSegments(pattern);
  30045. const sections = this._splitSegmentsIntoSections(segments);
  30046. this._storage.push({
  30047. complete: sections.length <= 1,
  30048. pattern,
  30049. segments,
  30050. sections
  30051. });
  30052. }
  30053. }
  30054. _getPatternSegments(pattern) {
  30055. const parts = utils$c.pattern.getPatternParts(pattern, this._micromatchOptions);
  30056. return parts.map(part => {
  30057. const dynamic = utils$c.pattern.isDynamicPattern(part, this._settings);
  30058. if (!dynamic) {
  30059. return {
  30060. dynamic: false,
  30061. pattern: part
  30062. };
  30063. }
  30064. return {
  30065. dynamic: true,
  30066. pattern: part,
  30067. patternRe: utils$c.pattern.makeRe(part, this._micromatchOptions)
  30068. };
  30069. });
  30070. }
  30071. _splitSegmentsIntoSections(segments) {
  30072. return utils$c.array.splitWhen(segments, segment => segment.dynamic && utils$c.pattern.hasGlobStar(segment.pattern));
  30073. }
  30074. }
  30075. matcher.default = Matcher;
  30076. Object.defineProperty(partial, "__esModule", {
  30077. value: true
  30078. });
  30079. const matcher_1 = matcher;
  30080. class PartialMatcher extends matcher_1.default {
  30081. match(filepath) {
  30082. const parts = filepath.split('/');
  30083. const levels = parts.length;
  30084. const patterns = this._storage.filter(info => !info.complete || info.segments.length > levels);
  30085. for (const pattern of patterns) {
  30086. const section = pattern.sections[0];
  30087. /**
  30088. * In this case, the pattern has a globstar and we must read all directories unconditionally,
  30089. * but only if the level has reached the end of the first group.
  30090. *
  30091. * fixtures/{a,b}/**
  30092. * ^ true/false ^ always true
  30093. */
  30094. if (!pattern.complete && levels > section.length) {
  30095. return true;
  30096. }
  30097. const match = parts.every((part, index) => {
  30098. const segment = pattern.segments[index];
  30099. if (segment.dynamic && segment.patternRe.test(part)) {
  30100. return true;
  30101. }
  30102. if (!segment.dynamic && segment.pattern === part) {
  30103. return true;
  30104. }
  30105. return false;
  30106. });
  30107. if (match) {
  30108. return true;
  30109. }
  30110. }
  30111. return false;
  30112. }
  30113. }
  30114. partial.default = PartialMatcher;
  30115. Object.defineProperty(deep, "__esModule", {
  30116. value: true
  30117. });
  30118. const utils$b = utils$r;
  30119. const partial_1 = partial;
  30120. class DeepFilter {
  30121. constructor(_settings, _micromatchOptions) {
  30122. this._settings = _settings;
  30123. this._micromatchOptions = _micromatchOptions;
  30124. }
  30125. getFilter(basePath, positive, negative) {
  30126. const matcher = this._getMatcher(positive);
  30127. const negativeRe = this._getNegativePatternsRe(negative);
  30128. return entry => this._filter(basePath, entry, matcher, negativeRe);
  30129. }
  30130. _getMatcher(patterns) {
  30131. return new partial_1.default(patterns, this._settings, this._micromatchOptions);
  30132. }
  30133. _getNegativePatternsRe(patterns) {
  30134. const affectDepthOfReadingPatterns = patterns.filter(utils$b.pattern.isAffectDepthOfReadingPattern);
  30135. return utils$b.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
  30136. }
  30137. _filter(basePath, entry, matcher, negativeRe) {
  30138. if (this._isSkippedByDeep(basePath, entry.path)) {
  30139. return false;
  30140. }
  30141. if (this._isSkippedSymbolicLink(entry)) {
  30142. return false;
  30143. }
  30144. const filepath = utils$b.path.removeLeadingDotSegment(entry.path);
  30145. if (this._isSkippedByPositivePatterns(filepath, matcher)) {
  30146. return false;
  30147. }
  30148. return this._isSkippedByNegativePatterns(filepath, negativeRe);
  30149. }
  30150. _isSkippedByDeep(basePath, entryPath) {
  30151. /**
  30152. * Avoid unnecessary depth calculations when it doesn't matter.
  30153. */
  30154. if (this._settings.deep === Infinity) {
  30155. return false;
  30156. }
  30157. return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
  30158. }
  30159. _getEntryLevel(basePath, entryPath) {
  30160. const entryPathDepth = entryPath.split('/').length;
  30161. if (basePath === '') {
  30162. return entryPathDepth;
  30163. }
  30164. const basePathDepth = basePath.split('/').length;
  30165. return entryPathDepth - basePathDepth;
  30166. }
  30167. _isSkippedSymbolicLink(entry) {
  30168. return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
  30169. }
  30170. _isSkippedByPositivePatterns(entryPath, matcher) {
  30171. return !this._settings.baseNameMatch && !matcher.match(entryPath);
  30172. }
  30173. _isSkippedByNegativePatterns(entryPath, patternsRe) {
  30174. return !utils$b.pattern.matchAny(entryPath, patternsRe);
  30175. }
  30176. }
  30177. deep.default = DeepFilter;
  30178. var entry$1 = {};
  30179. Object.defineProperty(entry$1, "__esModule", {
  30180. value: true
  30181. });
  30182. const utils$a = utils$r;
  30183. class EntryFilter {
  30184. constructor(_settings, _micromatchOptions) {
  30185. this._settings = _settings;
  30186. this._micromatchOptions = _micromatchOptions;
  30187. this.index = new Map();
  30188. }
  30189. getFilter(positive, negative) {
  30190. const positiveRe = utils$a.pattern.convertPatternsToRe(positive, this._micromatchOptions);
  30191. const negativeRe = utils$a.pattern.convertPatternsToRe(negative, this._micromatchOptions);
  30192. return entry => this._filter(entry, positiveRe, negativeRe);
  30193. }
  30194. _filter(entry, positiveRe, negativeRe) {
  30195. if (this._settings.unique && this._isDuplicateEntry(entry)) {
  30196. return false;
  30197. }
  30198. if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
  30199. return false;
  30200. }
  30201. if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
  30202. return false;
  30203. }
  30204. const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
  30205. const isMatched = this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe);
  30206. if (this._settings.unique && isMatched) {
  30207. this._createIndexRecord(entry);
  30208. }
  30209. return isMatched;
  30210. }
  30211. _isDuplicateEntry(entry) {
  30212. return this.index.has(entry.path);
  30213. }
  30214. _createIndexRecord(entry) {
  30215. this.index.set(entry.path, undefined);
  30216. }
  30217. _onlyFileFilter(entry) {
  30218. return this._settings.onlyFiles && !entry.dirent.isFile();
  30219. }
  30220. _onlyDirectoryFilter(entry) {
  30221. return this._settings.onlyDirectories && !entry.dirent.isDirectory();
  30222. }
  30223. _isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
  30224. if (!this._settings.absolute) {
  30225. return false;
  30226. }
  30227. const fullpath = utils$a.path.makeAbsolute(this._settings.cwd, entryPath);
  30228. return utils$a.pattern.matchAny(fullpath, patternsRe);
  30229. }
  30230. _isMatchToPatterns(entryPath, patternsRe) {
  30231. const filepath = utils$a.path.removeLeadingDotSegment(entryPath);
  30232. return utils$a.pattern.matchAny(filepath, patternsRe);
  30233. }
  30234. }
  30235. entry$1.default = EntryFilter;
  30236. var error$1 = {};
  30237. Object.defineProperty(error$1, "__esModule", {
  30238. value: true
  30239. });
  30240. const utils$9 = utils$r;
  30241. class ErrorFilter {
  30242. constructor(_settings) {
  30243. this._settings = _settings;
  30244. }
  30245. getFilter() {
  30246. return error => this._isNonFatalError(error);
  30247. }
  30248. _isNonFatalError(error) {
  30249. return utils$9.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
  30250. }
  30251. }
  30252. error$1.default = ErrorFilter;
  30253. var entry = {};
  30254. Object.defineProperty(entry, "__esModule", {
  30255. value: true
  30256. });
  30257. const utils$8 = utils$r;
  30258. class EntryTransformer {
  30259. constructor(_settings) {
  30260. this._settings = _settings;
  30261. }
  30262. getTransformer() {
  30263. return entry => this._transform(entry);
  30264. }
  30265. _transform(entry) {
  30266. let filepath = entry.path;
  30267. if (this._settings.absolute) {
  30268. filepath = utils$8.path.makeAbsolute(this._settings.cwd, filepath);
  30269. filepath = utils$8.path.unixify(filepath);
  30270. }
  30271. if (this._settings.markDirectories && entry.dirent.isDirectory()) {
  30272. filepath += '/';
  30273. }
  30274. if (!this._settings.objectMode) {
  30275. return filepath;
  30276. }
  30277. return Object.assign(Object.assign({}, entry), {
  30278. path: filepath
  30279. });
  30280. }
  30281. }
  30282. entry.default = EntryTransformer;
  30283. Object.defineProperty(provider, "__esModule", {
  30284. value: true
  30285. });
  30286. const path$3 = require$$0__default$2["default"];
  30287. const deep_1 = deep;
  30288. const entry_1 = entry$1;
  30289. const error_1 = error$1;
  30290. const entry_2 = entry;
  30291. class Provider {
  30292. constructor(_settings) {
  30293. this._settings = _settings;
  30294. this.errorFilter = new error_1.default(this._settings);
  30295. this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
  30296. this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
  30297. this.entryTransformer = new entry_2.default(this._settings);
  30298. }
  30299. _getRootDirectory(task) {
  30300. return path$3.resolve(this._settings.cwd, task.base);
  30301. }
  30302. _getReaderOptions(task) {
  30303. const basePath = task.base === '.' ? '' : task.base;
  30304. return {
  30305. basePath,
  30306. pathSegmentSeparator: '/',
  30307. concurrency: this._settings.concurrency,
  30308. deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
  30309. entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
  30310. errorFilter: this.errorFilter.getFilter(),
  30311. followSymbolicLinks: this._settings.followSymbolicLinks,
  30312. fs: this._settings.fs,
  30313. stats: this._settings.stats,
  30314. throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
  30315. transform: this.entryTransformer.getTransformer()
  30316. };
  30317. }
  30318. _getMicromatchOptions() {
  30319. return {
  30320. dot: this._settings.dot,
  30321. matchBase: this._settings.baseNameMatch,
  30322. nobrace: !this._settings.braceExpansion,
  30323. nocase: !this._settings.caseSensitiveMatch,
  30324. noext: !this._settings.extglob,
  30325. noglobstar: !this._settings.globstar,
  30326. posix: true,
  30327. strictSlashes: false
  30328. };
  30329. }
  30330. }
  30331. provider.default = Provider;
  30332. Object.defineProperty(async$6, "__esModule", {
  30333. value: true
  30334. });
  30335. const stream_1$2 = stream$2;
  30336. const provider_1$2 = provider;
  30337. class ProviderAsync extends provider_1$2.default {
  30338. constructor() {
  30339. super(...arguments);
  30340. this._reader = new stream_1$2.default(this._settings);
  30341. }
  30342. read(task) {
  30343. const root = this._getRootDirectory(task);
  30344. const options = this._getReaderOptions(task);
  30345. const entries = [];
  30346. return new Promise((resolve, reject) => {
  30347. const stream = this.api(root, task, options);
  30348. stream.once('error', reject);
  30349. stream.on('data', entry => entries.push(options.transform(entry)));
  30350. stream.once('end', () => resolve(entries));
  30351. });
  30352. }
  30353. api(root, task, options) {
  30354. if (task.dynamic) {
  30355. return this._reader.dynamic(root, options);
  30356. }
  30357. return this._reader.static(task.patterns, options);
  30358. }
  30359. }
  30360. async$6.default = ProviderAsync;
  30361. var stream = {};
  30362. Object.defineProperty(stream, "__esModule", {
  30363. value: true
  30364. });
  30365. const stream_1$1 = require$$0__default$5["default"];
  30366. const stream_2 = stream$2;
  30367. const provider_1$1 = provider;
  30368. class ProviderStream extends provider_1$1.default {
  30369. constructor() {
  30370. super(...arguments);
  30371. this._reader = new stream_2.default(this._settings);
  30372. }
  30373. read(task) {
  30374. const root = this._getRootDirectory(task);
  30375. const options = this._getReaderOptions(task);
  30376. const source = this.api(root, task, options);
  30377. const destination = new stream_1$1.Readable({
  30378. objectMode: true,
  30379. read: () => {}
  30380. });
  30381. source.once('error', error => destination.emit('error', error)).on('data', entry => destination.emit('data', options.transform(entry))).once('end', () => destination.emit('end'));
  30382. destination.once('close', () => source.destroy());
  30383. return destination;
  30384. }
  30385. api(root, task, options) {
  30386. if (task.dynamic) {
  30387. return this._reader.dynamic(root, options);
  30388. }
  30389. return this._reader.static(task.patterns, options);
  30390. }
  30391. }
  30392. stream.default = ProviderStream;
  30393. var sync$1 = {};
  30394. var sync = {};
  30395. Object.defineProperty(sync, "__esModule", {
  30396. value: true
  30397. });
  30398. const fsStat = out$3;
  30399. const fsWalk = out$2;
  30400. const reader_1 = reader;
  30401. class ReaderSync extends reader_1.default {
  30402. constructor() {
  30403. super(...arguments);
  30404. this._walkSync = fsWalk.walkSync;
  30405. this._statSync = fsStat.statSync;
  30406. }
  30407. dynamic(root, options) {
  30408. return this._walkSync(root, options);
  30409. }
  30410. static(patterns, options) {
  30411. const entries = [];
  30412. for (const pattern of patterns) {
  30413. const filepath = this._getFullEntryPath(pattern);
  30414. const entry = this._getEntry(filepath, pattern, options);
  30415. if (entry === null || !options.entryFilter(entry)) {
  30416. continue;
  30417. }
  30418. entries.push(entry);
  30419. }
  30420. return entries;
  30421. }
  30422. _getEntry(filepath, pattern, options) {
  30423. try {
  30424. const stats = this._getStat(filepath);
  30425. return this._makeEntry(stats, pattern);
  30426. } catch (error) {
  30427. if (options.errorFilter(error)) {
  30428. return null;
  30429. }
  30430. throw error;
  30431. }
  30432. }
  30433. _getStat(filepath) {
  30434. return this._statSync(filepath, this._fsStatSettings);
  30435. }
  30436. }
  30437. sync.default = ReaderSync;
  30438. Object.defineProperty(sync$1, "__esModule", {
  30439. value: true
  30440. });
  30441. const sync_1$1 = sync;
  30442. const provider_1 = provider;
  30443. class ProviderSync extends provider_1.default {
  30444. constructor() {
  30445. super(...arguments);
  30446. this._reader = new sync_1$1.default(this._settings);
  30447. }
  30448. read(task) {
  30449. const root = this._getRootDirectory(task);
  30450. const options = this._getReaderOptions(task);
  30451. const entries = this.api(root, task, options);
  30452. return entries.map(options.transform);
  30453. }
  30454. api(root, task, options) {
  30455. if (task.dynamic) {
  30456. return this._reader.dynamic(root, options);
  30457. }
  30458. return this._reader.static(task.patterns, options);
  30459. }
  30460. }
  30461. sync$1.default = ProviderSync;
  30462. var settings = {};
  30463. (function (exports) {
  30464. Object.defineProperty(exports, "__esModule", {
  30465. value: true
  30466. });
  30467. exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
  30468. const fs = require$$0__default["default"];
  30469. const os = require$$0__default$1["default"];
  30470. /**
  30471. * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
  30472. * https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
  30473. */
  30474. const CPU_COUNT = Math.max(os.cpus().length, 1);
  30475. exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
  30476. lstat: fs.lstat,
  30477. lstatSync: fs.lstatSync,
  30478. stat: fs.stat,
  30479. statSync: fs.statSync,
  30480. readdir: fs.readdir,
  30481. readdirSync: fs.readdirSync
  30482. };
  30483. class Settings {
  30484. constructor(_options = {}) {
  30485. this._options = _options;
  30486. this.absolute = this._getValue(this._options.absolute, false);
  30487. this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
  30488. this.braceExpansion = this._getValue(this._options.braceExpansion, true);
  30489. this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
  30490. this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
  30491. this.cwd = this._getValue(this._options.cwd, process.cwd());
  30492. this.deep = this._getValue(this._options.deep, Infinity);
  30493. this.dot = this._getValue(this._options.dot, false);
  30494. this.extglob = this._getValue(this._options.extglob, true);
  30495. this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
  30496. this.fs = this._getFileSystemMethods(this._options.fs);
  30497. this.globstar = this._getValue(this._options.globstar, true);
  30498. this.ignore = this._getValue(this._options.ignore, []);
  30499. this.markDirectories = this._getValue(this._options.markDirectories, false);
  30500. this.objectMode = this._getValue(this._options.objectMode, false);
  30501. this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
  30502. this.onlyFiles = this._getValue(this._options.onlyFiles, true);
  30503. this.stats = this._getValue(this._options.stats, false);
  30504. this.suppressErrors = this._getValue(this._options.suppressErrors, false);
  30505. this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
  30506. this.unique = this._getValue(this._options.unique, true);
  30507. if (this.onlyDirectories) {
  30508. this.onlyFiles = false;
  30509. }
  30510. if (this.stats) {
  30511. this.objectMode = true;
  30512. }
  30513. }
  30514. _getValue(option, value) {
  30515. return option === undefined ? value : option;
  30516. }
  30517. _getFileSystemMethods(methods = {}) {
  30518. return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
  30519. }
  30520. }
  30521. exports.default = Settings;
  30522. })(settings);
  30523. const taskManager = tasks;
  30524. const async_1 = async$6;
  30525. const stream_1 = stream;
  30526. const sync_1 = sync$1;
  30527. const settings_1 = settings;
  30528. const utils$7 = utils$r;
  30529. async function FastGlob(source, options) {
  30530. assertPatternsInput$1(source);
  30531. const works = getWorks(source, async_1.default, options);
  30532. const result = await Promise.all(works);
  30533. return utils$7.array.flatten(result);
  30534. } // https://github.com/typescript-eslint/typescript-eslint/issues/60
  30535. // eslint-disable-next-line no-redeclare
  30536. (function (FastGlob) {
  30537. function sync(source, options) {
  30538. assertPatternsInput$1(source);
  30539. const works = getWorks(source, sync_1.default, options);
  30540. return utils$7.array.flatten(works);
  30541. }
  30542. FastGlob.sync = sync;
  30543. function stream(source, options) {
  30544. assertPatternsInput$1(source);
  30545. const works = getWorks(source, stream_1.default, options);
  30546. /**
  30547. * The stream returned by the provider cannot work with an asynchronous iterator.
  30548. * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
  30549. * This affects performance (+25%). I don't see best solution right now.
  30550. */
  30551. return utils$7.stream.merge(works);
  30552. }
  30553. FastGlob.stream = stream;
  30554. function generateTasks(source, options) {
  30555. assertPatternsInput$1(source);
  30556. const patterns = [].concat(source);
  30557. const settings = new settings_1.default(options);
  30558. return taskManager.generate(patterns, settings);
  30559. }
  30560. FastGlob.generateTasks = generateTasks;
  30561. function isDynamicPattern(source, options) {
  30562. assertPatternsInput$1(source);
  30563. const settings = new settings_1.default(options);
  30564. return utils$7.pattern.isDynamicPattern(source, settings);
  30565. }
  30566. FastGlob.isDynamicPattern = isDynamicPattern;
  30567. function escapePath(source) {
  30568. assertPatternsInput$1(source);
  30569. return utils$7.path.escape(source);
  30570. }
  30571. FastGlob.escapePath = escapePath;
  30572. })(FastGlob || (FastGlob = {}));
  30573. function getWorks(source, _Provider, options) {
  30574. const patterns = [].concat(source);
  30575. const settings = new settings_1.default(options);
  30576. const tasks = taskManager.generate(patterns, settings);
  30577. const provider = new _Provider(settings);
  30578. return tasks.map(provider.read, provider);
  30579. }
  30580. function assertPatternsInput$1(input) {
  30581. const source = [].concat(input);
  30582. const isValidSource = source.every(item => utils$7.string.isString(item) && !utils$7.string.isEmpty(item));
  30583. if (!isValidSource) {
  30584. throw new TypeError('Patterns must be a string (non empty) or an array of strings');
  30585. }
  30586. }
  30587. var out = FastGlob;
  30588. var dirGlob$1 = {exports: {}};
  30589. var pathType$1 = {};
  30590. const {
  30591. promisify: promisify$1
  30592. } = require$$0__default$4["default"];
  30593. const fs$3 = require$$0__default["default"];
  30594. async function isType(fsStatType, statsMethodName, filePath) {
  30595. if (typeof filePath !== 'string') {
  30596. throw new TypeError(`Expected a string, got ${typeof filePath}`);
  30597. }
  30598. try {
  30599. const stats = await promisify$1(fs$3[fsStatType])(filePath);
  30600. return stats[statsMethodName]();
  30601. } catch (error) {
  30602. if (error.code === 'ENOENT') {
  30603. return false;
  30604. }
  30605. throw error;
  30606. }
  30607. }
  30608. function isTypeSync(fsStatType, statsMethodName, filePath) {
  30609. if (typeof filePath !== 'string') {
  30610. throw new TypeError(`Expected a string, got ${typeof filePath}`);
  30611. }
  30612. try {
  30613. return fs$3[fsStatType](filePath)[statsMethodName]();
  30614. } catch (error) {
  30615. if (error.code === 'ENOENT') {
  30616. return false;
  30617. }
  30618. throw error;
  30619. }
  30620. }
  30621. pathType$1.isFile = isType.bind(null, 'stat', 'isFile');
  30622. pathType$1.isDirectory = isType.bind(null, 'stat', 'isDirectory');
  30623. pathType$1.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
  30624. pathType$1.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
  30625. pathType$1.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
  30626. pathType$1.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
  30627. const path$2 = require$$0__default$2["default"];
  30628. const pathType = pathType$1;
  30629. const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
  30630. const getPath = (filepath, cwd) => {
  30631. const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
  30632. return path$2.isAbsolute(pth) ? pth : path$2.join(cwd, pth);
  30633. };
  30634. const addExtensions = (file, extensions) => {
  30635. if (path$2.extname(file)) {
  30636. return `**/${file}`;
  30637. }
  30638. return `**/${file}.${getExtensions(extensions)}`;
  30639. };
  30640. const getGlob = (directory, options) => {
  30641. if (options.files && !Array.isArray(options.files)) {
  30642. throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
  30643. }
  30644. if (options.extensions && !Array.isArray(options.extensions)) {
  30645. throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
  30646. }
  30647. if (options.files && options.extensions) {
  30648. return options.files.map(x => path$2.posix.join(directory, addExtensions(x, options.extensions)));
  30649. }
  30650. if (options.files) {
  30651. return options.files.map(x => path$2.posix.join(directory, `**/${x}`));
  30652. }
  30653. if (options.extensions) {
  30654. return [path$2.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
  30655. }
  30656. return [path$2.posix.join(directory, '**')];
  30657. };
  30658. dirGlob$1.exports = async (input, options) => {
  30659. options = Object.assign({
  30660. cwd: process.cwd()
  30661. }, options);
  30662. if (typeof options.cwd !== 'string') {
  30663. throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
  30664. }
  30665. const globs = await Promise.all([].concat(input).map(async x => {
  30666. const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
  30667. return isDirectory ? getGlob(x, options) : x;
  30668. }));
  30669. return [].concat.apply([], globs); // eslint-disable-line prefer-spread
  30670. };
  30671. dirGlob$1.exports.sync = (input, options) => {
  30672. options = Object.assign({
  30673. cwd: process.cwd()
  30674. }, options);
  30675. if (typeof options.cwd !== 'string') {
  30676. throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
  30677. }
  30678. const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
  30679. return [].concat.apply([], globs); // eslint-disable-line prefer-spread
  30680. };
  30681. var gitignore$1 = {exports: {}};
  30682. function makeArray(subject) {
  30683. return Array.isArray(subject) ? subject : [subject];
  30684. }
  30685. const EMPTY = '';
  30686. const SPACE = ' ';
  30687. const ESCAPE = '\\';
  30688. const REGEX_TEST_BLANK_LINE = /^\s+$/;
  30689. const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  30690. const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
  30691. const REGEX_SPLITALL_CRLF = /\r?\n/g; // /foo,
  30692. // ./foo,
  30693. // ../foo,
  30694. // .
  30695. // ..
  30696. const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
  30697. const SLASH = '/';
  30698. const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  30699. /* istanbul ignore next */
  30700. : 'node-ignore';
  30701. const define = (object, key, value) => Object.defineProperty(object, key, {
  30702. value
  30703. });
  30704. const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
  30705. // The cases are complicated, see test cases for details
  30706. const sanitizeRange = range => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
  30707. // fatal for JavaScript regular expression, so eliminate it.
  30708. : EMPTY); // See fixtures #59
  30709. const cleanRangeBackSlash = slashes => {
  30710. const {
  30711. length
  30712. } = slashes;
  30713. return slashes.slice(0, length - length % 2);
  30714. }; // > If the pattern ends with a slash,
  30715. // > it is removed for the purpose of the following description,
  30716. // > but it would only find a match with a directory.
  30717. // > In other words, foo/ will match a directory foo and paths underneath it,
  30718. // > but will not match a regular file or a symbolic link foo
  30719. // > (this is consistent with the way how pathspec works in general in Git).
  30720. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  30721. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  30722. // you could use option `mark: true` with `glob`
  30723. // '`foo/`' should not continue with the '`..`'
  30724. const REPLACERS = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  30725. [// (a\ ) -> (a )
  30726. // (a ) -> (a)
  30727. // (a \ ) -> (a )
  30728. /\\?\s+$/, match => match.indexOf('\\') === 0 ? SPACE : EMPTY], // replace (\ ) with ' '
  30729. [/\\\s/g, () => SPACE], // Escape metacharacters
  30730. // which is written down by users but means special for regular expressions.
  30731. // > There are 12 characters with special meanings:
  30732. // > - the backslash \,
  30733. // > - the caret ^,
  30734. // > - the dollar sign $,
  30735. // > - the period or dot .,
  30736. // > - the vertical bar or pipe symbol |,
  30737. // > - the question mark ?,
  30738. // > - the asterisk or star *,
  30739. // > - the plus sign +,
  30740. // > - the opening parenthesis (,
  30741. // > - the closing parenthesis ),
  30742. // > - and the opening square bracket [,
  30743. // > - the opening curly brace {,
  30744. // > These special characters are often called "metacharacters".
  30745. [/[\\$.|*+(){^]/g, match => `\\${match}`], [// > a question mark (?) matches a single character
  30746. /(?!\\)\?/g, () => '[^/]'], // leading slash
  30747. [// > A leading slash matches the beginning of the pathname.
  30748. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  30749. // A leading slash matches the beginning of the pathname
  30750. /^\//, () => '^'], // replace special metacharacter slash after the leading slash
  30751. [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
  30752. // > For example, "**/foo" matches file or directory "foo" anywhere,
  30753. // > the same as pattern "foo".
  30754. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  30755. // > under directory "foo".
  30756. // Notice that the '*'s have been replaced as '\\*'
  30757. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  30758. () => '^(?:.*\\/)?'], // starting
  30759. [// there will be no leading '/'
  30760. // (which has been replaced by section "leading slash")
  30761. // If starts with '**', adding a '^' to the regular expression also works
  30762. /^(?=[^^])/, function startingReplacer() {
  30763. // If has a slash `/` at the beginning or middle
  30764. return !/\/(?!$)/.test(this) // > Prior to 2.22.1
  30765. // > If the pattern does not contain a slash /,
  30766. // > Git treats it as a shell glob pattern
  30767. // Actually, if there is only a trailing slash,
  30768. // git also treats it as a shell glob pattern
  30769. // After 2.22.1 (compatible but clearer)
  30770. // > If there is a separator at the beginning or middle (or both)
  30771. // > of the pattern, then the pattern is relative to the directory
  30772. // > level of the particular .gitignore file itself.
  30773. // > Otherwise the pattern may also match at any level below
  30774. // > the .gitignore level.
  30775. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
  30776. // > consumption by fnmatch(3)
  30777. : '^';
  30778. }], // two globstars
  30779. [// Use lookahead assertions so that we could match more than one `'/**'`
  30780. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  30781. // should not use '*', or it will be replaced by the next replacer
  30782. // Check if it is not the last `'/**'`
  30783. (_, index, str) => index + 6 < str.length // case: /**/
  30784. // > A slash followed by two consecutive asterisks then a slash matches
  30785. // > zero or more directories.
  30786. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  30787. // '/**/'
  30788. ? '(?:\\/[^\\/]+)*' // case: /**
  30789. // > A trailing `"/**"` matches everything inside.
  30790. // #21: everything inside but it should not include the current folder
  30791. : '\\/.+'], // intermediate wildcards
  30792. [// Never replace escaped '*'
  30793. // ignore rule '\*' will match the path '*'
  30794. // 'abc.*/' -> go
  30795. // 'abc.*' -> skip this rule
  30796. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  30797. // '*.js' doesn't match 'abc'
  30798. (_, p1) => `${p1}[^\\/]*`], [// unescape, revert step 3 except for back slash
  30799. // For example, if a user escape a '\\*',
  30800. // after step 3, the result will be '\\\\\\*'
  30801. /\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE], [// '\\\\' -> '\\'
  30802. /\\\\/g, () => ESCAPE], [// > The range notation, e.g. [a-zA-Z],
  30803. // > can be used to match one of the characters in a range.
  30804. // `\` is escaped by step 3
  30805. /(\\)?\[([^\]/]*?)(\\*)($|\])/g, (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE // '\\[bar]' -> '\\\\[bar\\]'
  30806. ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === ']' ? endEscape.length % 2 === 0 // A normal case, and it is a range notation
  30807. // '[bar]'
  30808. // '[bar\\\\]'
  30809. ? `[${sanitizeRange(range)}${endEscape}]` // Invalid range notaton
  30810. // '[bar\\]' -> '[bar\\\\]'
  30811. : '[]' : '[]'], // ending
  30812. [// 'js' will not match 'js.'
  30813. // 'ab' will not match 'abc'
  30814. /(?:[^*])$/, // WTF!
  30815. // https://git-scm.com/docs/gitignore
  30816. // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
  30817. // which re-fixes #24, #38
  30818. // > If there is a separator at the end of the pattern then the pattern
  30819. // > will only match directories, otherwise the pattern can match both
  30820. // > files and directories.
  30821. // 'js*' will not match 'a.js'
  30822. // 'js/' will not match 'a.js'
  30823. // 'js' will match 'a.js' and 'a.js/'
  30824. match => /\/$/.test(match) // foo/ will not match 'foo'
  30825. ? `${match}$` // foo matches 'foo' and 'foo/'
  30826. : `${match}(?=$|\\/$)`], // trailing wildcard
  30827. [/(\^|\\\/)?\\\*$/, (_, p1) => {
  30828. const prefix = p1 // '\^':
  30829. // '/*' does not match EMPTY
  30830. // '/*' does not match everything
  30831. // '\\\/':
  30832. // 'abc/*' does not match 'abc/'
  30833. ? `${p1}[^/]+` // 'a*' matches 'a'
  30834. // 'a*' matches 'aa'
  30835. : '[^/]*';
  30836. return `${prefix}(?=$|\\/$)`;
  30837. }]]; // A simple cache, because an ignore rule only has only one certain meaning
  30838. const regexCache = Object.create(null); // @param {pattern}
  30839. const makeRegex = (pattern, ignorecase) => {
  30840. let source = regexCache[pattern];
  30841. if (!source) {
  30842. source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
  30843. regexCache[pattern] = source;
  30844. }
  30845. return ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  30846. };
  30847. const isString = subject => typeof subject === 'string'; // > A blank line matches no files, so it can serve as a separator for readability.
  30848. const checkPattern = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  30849. && pattern.indexOf('#') !== 0;
  30850. const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
  30851. class IgnoreRule {
  30852. constructor(origin, pattern, negative, regex) {
  30853. this.origin = origin;
  30854. this.pattern = pattern;
  30855. this.negative = negative;
  30856. this.regex = regex;
  30857. }
  30858. }
  30859. const createRule = (pattern, ignorecase) => {
  30860. const origin = pattern;
  30861. let negative = false; // > An optional prefix "!" which negates the pattern;
  30862. if (pattern.indexOf('!') === 0) {
  30863. negative = true;
  30864. pattern = pattern.substr(1);
  30865. }
  30866. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
  30867. // > begin with a literal "!", for example, `"\!important!.txt"`.
  30868. .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
  30869. // > begin with a hash.
  30870. .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
  30871. const regex = makeRegex(pattern, ignorecase);
  30872. return new IgnoreRule(origin, pattern, negative, regex);
  30873. };
  30874. const throwError = (message, Ctor) => {
  30875. throw new Ctor(message);
  30876. };
  30877. const checkPath = (path, originalPath, doThrow) => {
  30878. if (!isString(path)) {
  30879. return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
  30880. } // We don't know if we should ignore EMPTY, so throw
  30881. if (!path) {
  30882. return doThrow(`path must not be empty`, TypeError);
  30883. } // Check if it is a relative path
  30884. if (checkPath.isNotRelative(path)) {
  30885. const r = '`path.relative()`d';
  30886. return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
  30887. }
  30888. return true;
  30889. };
  30890. const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
  30891. checkPath.isNotRelative = isNotRelative;
  30892. checkPath.convert = p => p;
  30893. class Ignore {
  30894. constructor({
  30895. ignorecase = true
  30896. } = {}) {
  30897. define(this, KEY_IGNORE, true);
  30898. this._rules = [];
  30899. this._ignorecase = ignorecase;
  30900. this._initCache();
  30901. }
  30902. _initCache() {
  30903. this._ignoreCache = Object.create(null);
  30904. this._testCache = Object.create(null);
  30905. }
  30906. _addPattern(pattern) {
  30907. // #32
  30908. if (pattern && pattern[KEY_IGNORE]) {
  30909. this._rules = this._rules.concat(pattern._rules);
  30910. this._added = true;
  30911. return;
  30912. }
  30913. if (checkPattern(pattern)) {
  30914. const rule = createRule(pattern, this._ignorecase);
  30915. this._added = true;
  30916. this._rules.push(rule);
  30917. }
  30918. } // @param {Array<string> | string | Ignore} pattern
  30919. add(pattern) {
  30920. this._added = false;
  30921. makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  30922. // making the behavior changed.
  30923. if (this._added) {
  30924. this._initCache();
  30925. }
  30926. return this;
  30927. } // legacy
  30928. addPattern(pattern) {
  30929. return this.add(pattern);
  30930. } // | ignored : unignored
  30931. // negative | 0:0 | 0:1 | 1:0 | 1:1
  30932. // -------- | ------- | ------- | ------- | --------
  30933. // 0 | TEST | TEST | SKIP | X
  30934. // 1 | TESTIF | SKIP | TEST | X
  30935. // - SKIP: always skip
  30936. // - TEST: always test
  30937. // - TESTIF: only test if checkUnignored
  30938. // - X: that never happen
  30939. // @param {boolean} whether should check if the path is unignored,
  30940. // setting `checkUnignored` to `false` could reduce additional
  30941. // path matching.
  30942. // @returns {TestResult} true if a file is ignored
  30943. _testOne(path, checkUnignored) {
  30944. let ignored = false;
  30945. let unignored = false;
  30946. this._rules.forEach(rule => {
  30947. const {
  30948. negative
  30949. } = rule;
  30950. if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
  30951. return;
  30952. }
  30953. const matched = rule.regex.test(path);
  30954. if (matched) {
  30955. ignored = !negative;
  30956. unignored = negative;
  30957. }
  30958. });
  30959. return {
  30960. ignored,
  30961. unignored
  30962. };
  30963. } // @returns {TestResult}
  30964. _test(originalPath, cache, checkUnignored, slices) {
  30965. const path = originalPath // Supports nullable path
  30966. && checkPath.convert(originalPath);
  30967. checkPath(path, originalPath, throwError);
  30968. return this._t(path, cache, checkUnignored, slices);
  30969. }
  30970. _t(path, cache, checkUnignored, slices) {
  30971. if (path in cache) {
  30972. return cache[path];
  30973. }
  30974. if (!slices) {
  30975. // path/to/a.js
  30976. // ['path', 'to', 'a.js']
  30977. slices = path.split(SLASH);
  30978. }
  30979. slices.pop(); // If the path has no parent directory, just test it
  30980. if (!slices.length) {
  30981. return cache[path] = this._testOne(path, checkUnignored);
  30982. }
  30983. const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices); // If the path contains a parent directory, check the parent first
  30984. return cache[path] = parent.ignored // > It is not possible to re-include a file if a parent directory of
  30985. // > that file is excluded.
  30986. ? parent : this._testOne(path, checkUnignored);
  30987. }
  30988. ignores(path) {
  30989. return this._test(path, this._ignoreCache, false).ignored;
  30990. }
  30991. createFilter() {
  30992. return path => !this.ignores(path);
  30993. }
  30994. filter(paths) {
  30995. return makeArray(paths).filter(this.createFilter());
  30996. } // @returns {TestResult}
  30997. test(path) {
  30998. return this._test(path, this._testCache, true);
  30999. }
  31000. }
  31001. const factory = options => new Ignore(options);
  31002. const returnFalse = () => false;
  31003. const isPathValid = path => checkPath(path && checkPath.convert(path), path, returnFalse);
  31004. factory.isPathValid = isPathValid; // Fixes typescript
  31005. factory.default = factory;
  31006. var ignore = factory; // Windows
  31007. // --------------------------------------------------------------
  31008. /* istanbul ignore if */
  31009. if ( // Detect `process` so that it can run in browsers.
  31010. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  31011. /* eslint no-control-regex: "off" */
  31012. const makePosix = str => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, '/');
  31013. checkPath.convert = makePosix; // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
  31014. // 'd:\\foo'
  31015. const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
  31016. checkPath.isNotRelative = path => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
  31017. }
  31018. var slash$1 = path => {
  31019. const isExtendedLengthPath = /^\\\\\?\\/.test(path);
  31020. const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
  31021. if (isExtendedLengthPath || hasNonAscii) {
  31022. return path;
  31023. }
  31024. return path.replace(/\\/g, '/');
  31025. };
  31026. const {
  31027. promisify
  31028. } = require$$0__default$4["default"];
  31029. const fs$2 = require$$0__default["default"];
  31030. const path$1 = require$$0__default$2["default"];
  31031. const fastGlob$1 = out;
  31032. const gitIgnore = ignore;
  31033. const slash = slash$1;
  31034. const DEFAULT_IGNORE = ['**/node_modules/**', '**/flow-typed/**', '**/coverage/**', '**/.git'];
  31035. const readFileP = promisify(fs$2.readFile);
  31036. const mapGitIgnorePatternTo = base => ignore => {
  31037. if (ignore.startsWith('!')) {
  31038. return '!' + path$1.posix.join(base, ignore.slice(1));
  31039. }
  31040. return path$1.posix.join(base, ignore);
  31041. };
  31042. const parseGitIgnore = (content, options) => {
  31043. const base = slash(path$1.relative(options.cwd, path$1.dirname(options.fileName)));
  31044. return content.split(/\r?\n/).filter(Boolean).filter(line => !line.startsWith('#')).map(mapGitIgnorePatternTo(base));
  31045. };
  31046. const reduceIgnore = files => {
  31047. const ignores = gitIgnore();
  31048. for (const file of files) {
  31049. ignores.add(parseGitIgnore(file.content, {
  31050. cwd: file.cwd,
  31051. fileName: file.filePath
  31052. }));
  31053. }
  31054. return ignores;
  31055. };
  31056. const ensureAbsolutePathForCwd = (cwd, p) => {
  31057. cwd = slash(cwd);
  31058. if (path$1.isAbsolute(p)) {
  31059. if (slash(p).startsWith(cwd)) {
  31060. return p;
  31061. }
  31062. throw new Error(`Path ${p} is not in cwd ${cwd}`);
  31063. }
  31064. return path$1.join(cwd, p);
  31065. };
  31066. const getIsIgnoredPredecate = (ignores, cwd) => {
  31067. return p => ignores.ignores(slash(path$1.relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p))));
  31068. };
  31069. const getFile = async (file, cwd) => {
  31070. const filePath = path$1.join(cwd, file);
  31071. const content = await readFileP(filePath, 'utf8');
  31072. return {
  31073. cwd,
  31074. filePath,
  31075. content
  31076. };
  31077. };
  31078. const getFileSync = (file, cwd) => {
  31079. const filePath = path$1.join(cwd, file);
  31080. const content = fs$2.readFileSync(filePath, 'utf8');
  31081. return {
  31082. cwd,
  31083. filePath,
  31084. content
  31085. };
  31086. };
  31087. const normalizeOptions = ({
  31088. ignore = [],
  31089. cwd = slash(process.cwd())
  31090. } = {}) => {
  31091. return {
  31092. ignore,
  31093. cwd
  31094. };
  31095. };
  31096. gitignore$1.exports = async options => {
  31097. options = normalizeOptions(options);
  31098. const paths = await fastGlob$1('**/.gitignore', {
  31099. ignore: DEFAULT_IGNORE.concat(options.ignore),
  31100. cwd: options.cwd
  31101. });
  31102. const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
  31103. const ignores = reduceIgnore(files);
  31104. return getIsIgnoredPredecate(ignores, options.cwd);
  31105. };
  31106. gitignore$1.exports.sync = options => {
  31107. options = normalizeOptions(options);
  31108. const paths = fastGlob$1.sync('**/.gitignore', {
  31109. ignore: DEFAULT_IGNORE.concat(options.ignore),
  31110. cwd: options.cwd
  31111. });
  31112. const files = paths.map(file => getFileSync(file, options.cwd));
  31113. const ignores = reduceIgnore(files);
  31114. return getIsIgnoredPredecate(ignores, options.cwd);
  31115. };
  31116. const {
  31117. Transform
  31118. } = require$$0__default$5["default"];
  31119. class ObjectTransform extends Transform {
  31120. constructor() {
  31121. super({
  31122. objectMode: true
  31123. });
  31124. }
  31125. }
  31126. class FilterStream$1 extends ObjectTransform {
  31127. constructor(filter) {
  31128. super();
  31129. this._filter = filter;
  31130. }
  31131. _transform(data, encoding, callback) {
  31132. if (this._filter(data)) {
  31133. this.push(data);
  31134. }
  31135. callback();
  31136. }
  31137. }
  31138. class UniqueStream$1 extends ObjectTransform {
  31139. constructor() {
  31140. super();
  31141. this._pushed = new Set();
  31142. }
  31143. _transform(data, encoding, callback) {
  31144. if (!this._pushed.has(data)) {
  31145. this.push(data);
  31146. this._pushed.add(data);
  31147. }
  31148. callback();
  31149. }
  31150. }
  31151. var streamUtils = {
  31152. FilterStream: FilterStream$1,
  31153. UniqueStream: UniqueStream$1
  31154. };
  31155. const fs$1 = require$$0__default["default"];
  31156. const arrayUnion = arrayUnion$1;
  31157. const merge2 = merge2_1;
  31158. const fastGlob = out;
  31159. const dirGlob = dirGlob$1.exports;
  31160. const gitignore = gitignore$1.exports;
  31161. const {
  31162. FilterStream,
  31163. UniqueStream
  31164. } = streamUtils;
  31165. const DEFAULT_FILTER = () => false;
  31166. const isNegative = pattern => pattern[0] === '!';
  31167. const assertPatternsInput = patterns => {
  31168. if (!patterns.every(pattern => typeof pattern === 'string')) {
  31169. throw new TypeError('Patterns must be a string or an array of strings');
  31170. }
  31171. };
  31172. const checkCwdOption = (options = {}) => {
  31173. if (!options.cwd) {
  31174. return;
  31175. }
  31176. let stat;
  31177. try {
  31178. stat = fs$1.statSync(options.cwd);
  31179. } catch {
  31180. return;
  31181. }
  31182. if (!stat.isDirectory()) {
  31183. throw new Error('The `cwd` option must be a path to a directory');
  31184. }
  31185. };
  31186. const getPathString = p => p.stats instanceof fs$1.Stats ? p.path : p;
  31187. const generateGlobTasks = (patterns, taskOptions) => {
  31188. patterns = arrayUnion([].concat(patterns));
  31189. assertPatternsInput(patterns);
  31190. checkCwdOption(taskOptions);
  31191. const globTasks = [];
  31192. taskOptions = Object.assign({
  31193. ignore: [],
  31194. expandDirectories: true
  31195. }, taskOptions);
  31196. for (const [index, pattern] of patterns.entries()) {
  31197. if (isNegative(pattern)) {
  31198. continue;
  31199. }
  31200. const ignore = patterns.slice(index).filter(pattern => isNegative(pattern)).map(pattern => pattern.slice(1));
  31201. const options = Object.assign(Object.assign({}, taskOptions), {}, {
  31202. ignore: taskOptions.ignore.concat(ignore)
  31203. });
  31204. globTasks.push({
  31205. pattern,
  31206. options
  31207. });
  31208. }
  31209. return globTasks;
  31210. };
  31211. const globDirs = (task, fn) => {
  31212. let options = {};
  31213. if (task.options.cwd) {
  31214. options.cwd = task.options.cwd;
  31215. }
  31216. if (Array.isArray(task.options.expandDirectories)) {
  31217. options = Object.assign(Object.assign({}, options), {}, {
  31218. files: task.options.expandDirectories
  31219. });
  31220. } else if (typeof task.options.expandDirectories === 'object') {
  31221. options = Object.assign(Object.assign({}, options), task.options.expandDirectories);
  31222. }
  31223. return fn(task.pattern, options);
  31224. };
  31225. const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern];
  31226. const getFilterSync = options => {
  31227. return options && options.gitignore ? gitignore.sync({
  31228. cwd: options.cwd,
  31229. ignore: options.ignore
  31230. }) : DEFAULT_FILTER;
  31231. };
  31232. const globToTask = task => glob => {
  31233. const {
  31234. options
  31235. } = task;
  31236. if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
  31237. options.ignore = dirGlob.sync(options.ignore);
  31238. }
  31239. return {
  31240. pattern: glob,
  31241. options
  31242. };
  31243. };
  31244. globby$2.exports = async (patterns, options) => {
  31245. const globTasks = generateGlobTasks(patterns, options);
  31246. const getFilter = async () => {
  31247. return options && options.gitignore ? gitignore({
  31248. cwd: options.cwd,
  31249. ignore: options.ignore
  31250. }) : DEFAULT_FILTER;
  31251. };
  31252. const getTasks = async () => {
  31253. const tasks = await Promise.all(globTasks.map(async task => {
  31254. const globs = await getPattern(task, dirGlob);
  31255. return Promise.all(globs.map(globToTask(task)));
  31256. }));
  31257. return arrayUnion(...tasks);
  31258. };
  31259. const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
  31260. const paths = await Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)));
  31261. return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_)));
  31262. };
  31263. globby$2.exports.sync = (patterns, options) => {
  31264. const globTasks = generateGlobTasks(patterns, options);
  31265. const tasks = [];
  31266. for (const task of globTasks) {
  31267. const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
  31268. tasks.push(...newTask);
  31269. }
  31270. const filter = getFilterSync(options);
  31271. let matches = [];
  31272. for (const task of tasks) {
  31273. matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options));
  31274. }
  31275. return matches.filter(path_ => !filter(path_));
  31276. };
  31277. globby$2.exports.stream = (patterns, options) => {
  31278. const globTasks = generateGlobTasks(patterns, options);
  31279. const tasks = [];
  31280. for (const task of globTasks) {
  31281. const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
  31282. tasks.push(...newTask);
  31283. }
  31284. const filter = getFilterSync(options);
  31285. const filterStream = new FilterStream(p => !filter(p));
  31286. const uniqueStream = new UniqueStream();
  31287. return merge2(tasks.map(task => fastGlob.stream(task.pattern, task.options))).pipe(filterStream).pipe(uniqueStream);
  31288. };
  31289. globby$2.exports.generateGlobTasks = generateGlobTasks;
  31290. globby$2.exports.hasMagic = (patterns, options) => [].concat(patterns).some(pattern => fastGlob.isDynamicPattern(pattern, options));
  31291. globby$2.exports.gitignore = gitignore;
  31292. const _excluded = ["languageId"];
  31293. var createLanguage$7 = function (linguistData, override) {
  31294. const {
  31295. languageId
  31296. } = linguistData,
  31297. rest = _objectWithoutProperties(linguistData, _excluded);
  31298. return Object.assign(Object.assign({
  31299. linguistLanguageId: languageId
  31300. }, rest), override(linguistData));
  31301. };
  31302. var utils$6 = {};
  31303. var ast = {exports: {}};
  31304. /*
  31305. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  31306. Redistribution and use in source and binary forms, with or without
  31307. modification, are permitted provided that the following conditions are met:
  31308. * Redistributions of source code must retain the above copyright
  31309. notice, this list of conditions and the following disclaimer.
  31310. * Redistributions in binary form must reproduce the above copyright
  31311. notice, this list of conditions and the following disclaimer in the
  31312. documentation and/or other materials provided with the distribution.
  31313. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  31314. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31315. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31316. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31317. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31318. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31319. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31320. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31321. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31322. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31323. */
  31324. (function () {
  31325. function isExpression(node) {
  31326. if (node == null) {
  31327. return false;
  31328. }
  31329. switch (node.type) {
  31330. case 'ArrayExpression':
  31331. case 'AssignmentExpression':
  31332. case 'BinaryExpression':
  31333. case 'CallExpression':
  31334. case 'ConditionalExpression':
  31335. case 'FunctionExpression':
  31336. case 'Identifier':
  31337. case 'Literal':
  31338. case 'LogicalExpression':
  31339. case 'MemberExpression':
  31340. case 'NewExpression':
  31341. case 'ObjectExpression':
  31342. case 'SequenceExpression':
  31343. case 'ThisExpression':
  31344. case 'UnaryExpression':
  31345. case 'UpdateExpression':
  31346. return true;
  31347. }
  31348. return false;
  31349. }
  31350. function isIterationStatement(node) {
  31351. if (node == null) {
  31352. return false;
  31353. }
  31354. switch (node.type) {
  31355. case 'DoWhileStatement':
  31356. case 'ForInStatement':
  31357. case 'ForStatement':
  31358. case 'WhileStatement':
  31359. return true;
  31360. }
  31361. return false;
  31362. }
  31363. function isStatement(node) {
  31364. if (node == null) {
  31365. return false;
  31366. }
  31367. switch (node.type) {
  31368. case 'BlockStatement':
  31369. case 'BreakStatement':
  31370. case 'ContinueStatement':
  31371. case 'DebuggerStatement':
  31372. case 'DoWhileStatement':
  31373. case 'EmptyStatement':
  31374. case 'ExpressionStatement':
  31375. case 'ForInStatement':
  31376. case 'ForStatement':
  31377. case 'IfStatement':
  31378. case 'LabeledStatement':
  31379. case 'ReturnStatement':
  31380. case 'SwitchStatement':
  31381. case 'ThrowStatement':
  31382. case 'TryStatement':
  31383. case 'VariableDeclaration':
  31384. case 'WhileStatement':
  31385. case 'WithStatement':
  31386. return true;
  31387. }
  31388. return false;
  31389. }
  31390. function isSourceElement(node) {
  31391. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  31392. }
  31393. function trailingStatement(node) {
  31394. switch (node.type) {
  31395. case 'IfStatement':
  31396. if (node.alternate != null) {
  31397. return node.alternate;
  31398. }
  31399. return node.consequent;
  31400. case 'LabeledStatement':
  31401. case 'ForStatement':
  31402. case 'ForInStatement':
  31403. case 'WhileStatement':
  31404. case 'WithStatement':
  31405. return node.body;
  31406. }
  31407. return null;
  31408. }
  31409. function isProblematicIfStatement(node) {
  31410. var current;
  31411. if (node.type !== 'IfStatement') {
  31412. return false;
  31413. }
  31414. if (node.alternate == null) {
  31415. return false;
  31416. }
  31417. current = node.consequent;
  31418. do {
  31419. if (current.type === 'IfStatement') {
  31420. if (current.alternate == null) {
  31421. return true;
  31422. }
  31423. }
  31424. current = trailingStatement(current);
  31425. } while (current);
  31426. return false;
  31427. }
  31428. ast.exports = {
  31429. isExpression: isExpression,
  31430. isStatement: isStatement,
  31431. isIterationStatement: isIterationStatement,
  31432. isSourceElement: isSourceElement,
  31433. isProblematicIfStatement: isProblematicIfStatement,
  31434. trailingStatement: trailingStatement
  31435. };
  31436. })();
  31437. var code = {exports: {}};
  31438. /*
  31439. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  31440. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  31441. Redistribution and use in source and binary forms, with or without
  31442. modification, are permitted provided that the following conditions are met:
  31443. * Redistributions of source code must retain the above copyright
  31444. notice, this list of conditions and the following disclaimer.
  31445. * Redistributions in binary form must reproduce the above copyright
  31446. notice, this list of conditions and the following disclaimer in the
  31447. documentation and/or other materials provided with the distribution.
  31448. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31449. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31450. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31451. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31452. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31453. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31454. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31455. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31456. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31457. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31458. */
  31459. (function () {
  31460. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  31461. ES5Regex = {
  31462. // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
  31463. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
  31464. // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
  31465. NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
  31466. };
  31467. ES6Regex = {
  31468. // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
  31469. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
  31470. // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
  31471. NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  31472. };
  31473. function isDecimalDigit(ch) {
  31474. return 0x30 <= ch && ch <= 0x39; // 0..9
  31475. }
  31476. function isHexDigit(ch) {
  31477. return 0x30 <= ch && ch <= 0x39 || // 0..9
  31478. 0x61 <= ch && ch <= 0x66 || // a..f
  31479. 0x41 <= ch && ch <= 0x46; // A..F
  31480. }
  31481. function isOctalDigit(ch) {
  31482. return ch >= 0x30 && ch <= 0x37; // 0..7
  31483. } // 7.2 White Space
  31484. NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  31485. function isWhiteSpace(ch) {
  31486. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  31487. } // 7.3 Line Terminators
  31488. function isLineTerminator(ch) {
  31489. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  31490. } // 7.6 Identifier Names and Identifiers
  31491. function fromCodePoint(cp) {
  31492. if (cp <= 0xFFFF) {
  31493. return String.fromCharCode(cp);
  31494. }
  31495. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  31496. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  31497. return cu1 + cu2;
  31498. }
  31499. IDENTIFIER_START = new Array(0x80);
  31500. for (ch = 0; ch < 0x80; ++ch) {
  31501. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  31502. ch >= 0x41 && ch <= 0x5A || // A..Z
  31503. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  31504. }
  31505. IDENTIFIER_PART = new Array(0x80);
  31506. for (ch = 0; ch < 0x80; ++ch) {
  31507. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  31508. ch >= 0x41 && ch <= 0x5A || // A..Z
  31509. ch >= 0x30 && ch <= 0x39 || // 0..9
  31510. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  31511. }
  31512. function isIdentifierStartES5(ch) {
  31513. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  31514. }
  31515. function isIdentifierPartES5(ch) {
  31516. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  31517. }
  31518. function isIdentifierStartES6(ch) {
  31519. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  31520. }
  31521. function isIdentifierPartES6(ch) {
  31522. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  31523. }
  31524. code.exports = {
  31525. isDecimalDigit: isDecimalDigit,
  31526. isHexDigit: isHexDigit,
  31527. isOctalDigit: isOctalDigit,
  31528. isWhiteSpace: isWhiteSpace,
  31529. isLineTerminator: isLineTerminator,
  31530. isIdentifierStartES5: isIdentifierStartES5,
  31531. isIdentifierPartES5: isIdentifierPartES5,
  31532. isIdentifierStartES6: isIdentifierStartES6,
  31533. isIdentifierPartES6: isIdentifierPartES6
  31534. };
  31535. })();
  31536. var keyword = {exports: {}};
  31537. /*
  31538. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  31539. Redistribution and use in source and binary forms, with or without
  31540. modification, are permitted provided that the following conditions are met:
  31541. * Redistributions of source code must retain the above copyright
  31542. notice, this list of conditions and the following disclaimer.
  31543. * Redistributions in binary form must reproduce the above copyright
  31544. notice, this list of conditions and the following disclaimer in the
  31545. documentation and/or other materials provided with the distribution.
  31546. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31547. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31548. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31549. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31550. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31551. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31552. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31553. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31554. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31555. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31556. */
  31557. (function () {
  31558. var code$1 = code.exports;
  31559. function isStrictModeReservedWordES6(id) {
  31560. switch (id) {
  31561. case 'implements':
  31562. case 'interface':
  31563. case 'package':
  31564. case 'private':
  31565. case 'protected':
  31566. case 'public':
  31567. case 'static':
  31568. case 'let':
  31569. return true;
  31570. default:
  31571. return false;
  31572. }
  31573. }
  31574. function isKeywordES5(id, strict) {
  31575. // yield should not be treated as keyword under non-strict mode.
  31576. if (!strict && id === 'yield') {
  31577. return false;
  31578. }
  31579. return isKeywordES6(id, strict);
  31580. }
  31581. function isKeywordES6(id, strict) {
  31582. if (strict && isStrictModeReservedWordES6(id)) {
  31583. return true;
  31584. }
  31585. switch (id.length) {
  31586. case 2:
  31587. return id === 'if' || id === 'in' || id === 'do';
  31588. case 3:
  31589. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  31590. case 4:
  31591. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  31592. case 5:
  31593. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  31594. case 6:
  31595. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  31596. case 7:
  31597. return id === 'default' || id === 'finally' || id === 'extends';
  31598. case 8:
  31599. return id === 'function' || id === 'continue' || id === 'debugger';
  31600. case 10:
  31601. return id === 'instanceof';
  31602. default:
  31603. return false;
  31604. }
  31605. }
  31606. function isReservedWordES5(id, strict) {
  31607. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  31608. }
  31609. function isReservedWordES6(id, strict) {
  31610. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  31611. }
  31612. function isRestrictedWord(id) {
  31613. return id === 'eval' || id === 'arguments';
  31614. }
  31615. function isIdentifierNameES5(id) {
  31616. var i, iz, ch;
  31617. if (id.length === 0) {
  31618. return false;
  31619. }
  31620. ch = id.charCodeAt(0);
  31621. if (!code$1.isIdentifierStartES5(ch)) {
  31622. return false;
  31623. }
  31624. for (i = 1, iz = id.length; i < iz; ++i) {
  31625. ch = id.charCodeAt(i);
  31626. if (!code$1.isIdentifierPartES5(ch)) {
  31627. return false;
  31628. }
  31629. }
  31630. return true;
  31631. }
  31632. function decodeUtf16(lead, trail) {
  31633. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  31634. }
  31635. function isIdentifierNameES6(id) {
  31636. var i, iz, ch, lowCh, check;
  31637. if (id.length === 0) {
  31638. return false;
  31639. }
  31640. check = code$1.isIdentifierStartES6;
  31641. for (i = 0, iz = id.length; i < iz; ++i) {
  31642. ch = id.charCodeAt(i);
  31643. if (0xD800 <= ch && ch <= 0xDBFF) {
  31644. ++i;
  31645. if (i >= iz) {
  31646. return false;
  31647. }
  31648. lowCh = id.charCodeAt(i);
  31649. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  31650. return false;
  31651. }
  31652. ch = decodeUtf16(ch, lowCh);
  31653. }
  31654. if (!check(ch)) {
  31655. return false;
  31656. }
  31657. check = code$1.isIdentifierPartES6;
  31658. }
  31659. return true;
  31660. }
  31661. function isIdentifierES5(id, strict) {
  31662. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  31663. }
  31664. function isIdentifierES6(id, strict) {
  31665. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  31666. }
  31667. keyword.exports = {
  31668. isKeywordES5: isKeywordES5,
  31669. isKeywordES6: isKeywordES6,
  31670. isReservedWordES5: isReservedWordES5,
  31671. isReservedWordES6: isReservedWordES6,
  31672. isRestrictedWord: isRestrictedWord,
  31673. isIdentifierNameES5: isIdentifierNameES5,
  31674. isIdentifierNameES6: isIdentifierNameES6,
  31675. isIdentifierES5: isIdentifierES5,
  31676. isIdentifierES6: isIdentifierES6
  31677. };
  31678. })();
  31679. /*
  31680. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  31681. Redistribution and use in source and binary forms, with or without
  31682. modification, are permitted provided that the following conditions are met:
  31683. * Redistributions of source code must retain the above copyright
  31684. notice, this list of conditions and the following disclaimer.
  31685. * Redistributions in binary form must reproduce the above copyright
  31686. notice, this list of conditions and the following disclaimer in the
  31687. documentation and/or other materials provided with the distribution.
  31688. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31689. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31690. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31691. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31692. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31693. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31694. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31695. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31696. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31697. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31698. */
  31699. (function () {
  31700. utils$6.ast = ast.exports;
  31701. utils$6.code = code.exports;
  31702. utils$6.keyword = keyword.exports;
  31703. })();
  31704. const isIdentifierName = utils$6.keyword.isIdentifierNameES5;
  31705. const {
  31706. getLast: getLast$l,
  31707. hasNewline: hasNewline$7,
  31708. skipWhitespace,
  31709. isNonEmptyArray: isNonEmptyArray$i,
  31710. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$1,
  31711. getStringWidth: getStringWidth$3
  31712. } = util$8;
  31713. const {
  31714. locStart: locStart$q,
  31715. locEnd: locEnd$p,
  31716. hasSameLocStart
  31717. } = loc$6;
  31718. /**
  31719. * @typedef {import("./types/estree").Node} Node
  31720. * @typedef {import("./types/estree").TemplateLiteral} TemplateLiteral
  31721. * @typedef {import("./types/estree").Comment} Comment
  31722. * @typedef {import("./types/estree").MemberExpression} MemberExpression
  31723. * @typedef {import("./types/estree").OptionalMemberExpression} OptionalMemberExpression
  31724. * @typedef {import("./types/estree").CallExpression} CallExpression
  31725. * @typedef {import("./types/estree").OptionalCallExpression} OptionalCallExpression
  31726. * @typedef {import("./types/estree").Expression} Expression
  31727. * @typedef {import("./types/estree").Property} Property
  31728. * @typedef {import("./types/estree").ObjectTypeProperty} ObjectTypeProperty
  31729. * @typedef {import("./types/estree").TaggedTemplateExpression} TaggedTemplateExpression
  31730. * @typedef {import("./types/estree").Literal} Literal
  31731. *
  31732. * @typedef {import("../common/ast-path")} AstPath
  31733. */
  31734. // We match any whitespace except line terminators because
  31735. // Flow annotation comments cannot be split across lines. For example:
  31736. //
  31737. // (this /*
  31738. // : any */).foo = 5;
  31739. //
  31740. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  31741. // removing the newline would create a type annotation that the user did not intend
  31742. // to create.
  31743. const NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  31744. const FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
  31745. const FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
  31746. /**
  31747. * @param {Node} node
  31748. * @returns {boolean}
  31749. */
  31750. function hasFlowShorthandAnnotationComment$3(node) {
  31751. // https://flow.org/en/docs/types/comments/
  31752. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  31753. return node.extra && node.extra.parenthesized && isNonEmptyArray$i(node.trailingComments) && isBlockComment$5(node.trailingComments[0]) && FLOW_SHORTHAND_ANNOTATION.test(node.trailingComments[0].value);
  31754. }
  31755. /**
  31756. * @param {Comment[]} comments
  31757. * @returns {boolean}
  31758. */
  31759. function hasFlowAnnotationComment$2(comments) {
  31760. return isNonEmptyArray$i(comments) && isBlockComment$5(comments[0]) && FLOW_ANNOTATION.test(comments[0].value);
  31761. }
  31762. /**
  31763. * @param {Node} node
  31764. * @param {(Node) => boolean} fn
  31765. * @returns {boolean}
  31766. */
  31767. function hasNode$2(node, fn) {
  31768. if (!node || typeof node !== "object") {
  31769. return false;
  31770. }
  31771. if (Array.isArray(node)) {
  31772. return node.some(value => hasNode$2(value, fn));
  31773. }
  31774. const result = fn(node);
  31775. return typeof result === "boolean" ? result : Object.values(node).some(value => hasNode$2(value, fn));
  31776. }
  31777. /**
  31778. * @param {Node} node
  31779. * @returns {boolean}
  31780. */
  31781. function hasNakedLeftSide$3(node) {
  31782. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || isCallExpression$d(node) || isMemberExpression$a(node) || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
  31783. }
  31784. function getLeftSide$1(node) {
  31785. if (node.expressions) {
  31786. return node.expressions[0];
  31787. }
  31788. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  31789. }
  31790. function getLeftSidePathName$2(path, node) {
  31791. if (node.expressions) {
  31792. return ["expressions", 0];
  31793. }
  31794. if (node.left) {
  31795. return ["left"];
  31796. }
  31797. if (node.test) {
  31798. return ["test"];
  31799. }
  31800. if (node.object) {
  31801. return ["object"];
  31802. }
  31803. if (node.callee) {
  31804. return ["callee"];
  31805. }
  31806. if (node.tag) {
  31807. return ["tag"];
  31808. }
  31809. if (node.argument) {
  31810. return ["argument"];
  31811. }
  31812. if (node.expression) {
  31813. return ["expression"];
  31814. }
  31815. throw new Error("Unexpected node has no left side.");
  31816. }
  31817. /**
  31818. * @param {Comment} comment
  31819. * @returns {boolean}
  31820. */
  31821. function isBlockComment$5(comment) {
  31822. return comment.type === "Block" || comment.type === "CommentBlock" || // `meriyah`
  31823. comment.type === "MultiLine";
  31824. }
  31825. /**
  31826. * @param {Comment} comment
  31827. * @returns {boolean}
  31828. */
  31829. function isLineComment$3(comment) {
  31830. return comment.type === "Line" || comment.type === "CommentLine" || // `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
  31831. comment.type === "SingleLine" || comment.type === "HashbangComment" || comment.type === "HTMLOpen" || comment.type === "HTMLClose";
  31832. }
  31833. const exportDeclarationTypes = new Set(["ExportDefaultDeclaration", "ExportDefaultSpecifier", "DeclareExportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
  31834. /**
  31835. * @param {Node} node
  31836. * @returns {boolean}
  31837. */
  31838. function isExportDeclaration(node) {
  31839. return node && exportDeclarationTypes.has(node.type);
  31840. }
  31841. /**
  31842. * @param {AstPath} path
  31843. * @returns {Node | null}
  31844. */
  31845. function getParentExportDeclaration$2(path) {
  31846. const parentNode = path.getParentNode();
  31847. if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
  31848. return parentNode;
  31849. }
  31850. return null;
  31851. }
  31852. /**
  31853. * @param {Node} node
  31854. * @returns {boolean}
  31855. */
  31856. function isLiteral$3(node) {
  31857. return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
  31858. }
  31859. /**
  31860. * @param {Node} node
  31861. * @returns {boolean}
  31862. */
  31863. function isNumericLiteral$5(node) {
  31864. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  31865. }
  31866. function isSignedNumericLiteral$2(node) {
  31867. return node.type === "UnaryExpression" && (node.operator === "+" || node.operator === "-") && isNumericLiteral$5(node.argument);
  31868. }
  31869. /**
  31870. * @param {Node} node
  31871. * @returns {boolean}
  31872. */
  31873. function isStringLiteral$5(node) {
  31874. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  31875. }
  31876. /**
  31877. * @param {Node} node
  31878. * @returns {boolean}
  31879. */
  31880. function isObjectType$3(node) {
  31881. return node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || node.type === "TSMappedType";
  31882. }
  31883. /**
  31884. * @param {Node} node
  31885. * @returns {boolean}
  31886. */
  31887. function isFunctionOrArrowExpression$1(node) {
  31888. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  31889. }
  31890. /**
  31891. * @param {Node} node
  31892. * @returns {boolean}
  31893. */
  31894. function isFunctionOrArrowExpressionWithBody(node) {
  31895. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  31896. }
  31897. /**
  31898. * @param {Node} node
  31899. * @returns {boolean}
  31900. */
  31901. function isTemplateLiteral(node) {
  31902. return node.type === "TemplateLiteral";
  31903. }
  31904. /**
  31905. * Note: `inject` is used in AngularJS 1.x, `async` in Angular 2+
  31906. * example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  31907. *
  31908. * @param {CallExpression} node
  31909. * @returns {boolean}
  31910. */
  31911. function isAngularTestWrapper(node) {
  31912. return isCallExpression$d(node) && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  31913. }
  31914. /**
  31915. * @param {Node} node
  31916. * @returns {boolean}
  31917. */
  31918. function isJsxNode$7(node) {
  31919. return node.type === "JSXElement" || node.type === "JSXFragment";
  31920. }
  31921. function isTheOnlyJsxElementInMarkdown$2(options, path) {
  31922. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  31923. return false;
  31924. }
  31925. const node = path.getNode();
  31926. if (!node.expression || !isJsxNode$7(node.expression)) {
  31927. return false;
  31928. }
  31929. const parent = path.getParentNode();
  31930. return parent.type === "Program" && parent.body.length === 1;
  31931. }
  31932. function isGetterOrSetter$1(node) {
  31933. return node.kind === "get" || node.kind === "set";
  31934. } // TODO: This is a bad hack and we need a better way to distinguish between
  31935. // arrow functions and otherwise
  31936. function isFunctionNotation$1(node) {
  31937. return isGetterOrSetter$1(node) || hasSameLocStart(node, node.value);
  31938. } // Hack to differentiate between the following two which have the same ast
  31939. // type T = { method: () => void };
  31940. // type T = { method(): void };
  31941. /**
  31942. * @param {Node} node
  31943. * @returns {boolean}
  31944. */
  31945. function isObjectTypePropertyAFunction$2(node) {
  31946. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation$1(node);
  31947. } // Hack to differentiate between the following two which have the same ast
  31948. // declare function f(a): void;
  31949. // var f: (a) => void;
  31950. function isTypeAnnotationAFunction$1(node) {
  31951. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !hasSameLocStart(node, node.typeAnnotation);
  31952. }
  31953. const binaryishNodeTypes = new Set(["BinaryExpression", "LogicalExpression", "NGPipeExpression"]);
  31954. /**
  31955. * @param {Node} node
  31956. * @returns {boolean}
  31957. */
  31958. function isBinaryish$5(node) {
  31959. return binaryishNodeTypes.has(node.type);
  31960. }
  31961. /**
  31962. * @param {Node} node
  31963. * @returns {boolean}
  31964. */
  31965. function isMemberish$2(node) {
  31966. return isMemberExpression$a(node) || node.type === "BindExpression" && Boolean(node.object);
  31967. }
  31968. const simpleTypeAnnotations = new Set([// `any`
  31969. "AnyTypeAnnotation", "TSAnyKeyword", // `null`
  31970. "NullLiteralTypeAnnotation", "TSNullKeyword", // `this`
  31971. "ThisTypeAnnotation", "TSThisType", // `number`
  31972. "NumberTypeAnnotation", "TSNumberKeyword", // `void`
  31973. "VoidTypeAnnotation", "TSVoidKeyword", // `boolean`
  31974. "BooleanTypeAnnotation", "TSBooleanKeyword", // `bigint`
  31975. "BigIntTypeAnnotation", "TSBigIntKeyword", // `symbol`
  31976. "SymbolTypeAnnotation", "TSSymbolKeyword", // `string`
  31977. "StringTypeAnnotation", "TSStringKeyword", // literals
  31978. "BooleanLiteralTypeAnnotation", "StringLiteralTypeAnnotation", "BigIntLiteralTypeAnnotation", "NumberLiteralTypeAnnotation", "TSLiteralType", "TSTemplateLiteralType", // flow only, `empty`, `mixed`
  31979. "EmptyTypeAnnotation", "MixedTypeAnnotation", // typescript only, `never`, `object`, `undefined`, `unknown`
  31980. "TSNeverKeyword", "TSObjectKeyword", "TSUndefinedKeyword", "TSUnknownKeyword"]);
  31981. /**
  31982. * @param {Node} node
  31983. * @returns {boolean}
  31984. */
  31985. function isSimpleType$2(node) {
  31986. if (!node) {
  31987. return false;
  31988. }
  31989. if ((node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference") && !node.typeParameters) {
  31990. return true;
  31991. }
  31992. if (simpleTypeAnnotations.has(node.type)) {
  31993. return true;
  31994. }
  31995. return false;
  31996. }
  31997. const unitTestRe = /^(?:skip|[fx]?(?:it|describe|test))$/;
  31998. /**
  31999. * @param {{callee: MemberExpression | OptionalMemberExpression}} node
  32000. * @returns {boolean}
  32001. */
  32002. function isSkipOrOnlyBlock(node) {
  32003. return isMemberExpression$a(node.callee) && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
  32004. }
  32005. /**
  32006. * @param {CallExpression} node
  32007. * @returns {boolean}
  32008. */
  32009. function isUnitTestSetUp(node) {
  32010. const unitTestSetUpRe = /^(?:before|after)(?:Each|All)$/;
  32011. return node.callee.type === "Identifier" && unitTestSetUpRe.test(node.callee.name) && node.arguments.length === 1;
  32012. } // eg; `describe("some string", (done) => {})`
  32013. function isTestCall$3(node, parent) {
  32014. if (node.type !== "CallExpression") {
  32015. return false;
  32016. }
  32017. if (node.arguments.length === 1) {
  32018. if (isAngularTestWrapper(node) && parent && isTestCall$3(parent)) {
  32019. return isFunctionOrArrowExpression$1(node.arguments[0]);
  32020. }
  32021. if (isUnitTestSetUp(node)) {
  32022. return isAngularTestWrapper(node.arguments[0]);
  32023. }
  32024. } else if (node.arguments.length === 2 || node.arguments.length === 3) {
  32025. if ((node.callee.type === "Identifier" && unitTestRe.test(node.callee.name) || isSkipOrOnlyBlock(node)) && (isTemplateLiteral(node.arguments[0]) || isStringLiteral$5(node.arguments[0]))) {
  32026. // it("name", () => { ... }, 2500)
  32027. if (node.arguments[2] && !isNumericLiteral$5(node.arguments[2])) {
  32028. return false;
  32029. }
  32030. return (node.arguments.length === 2 ? isFunctionOrArrowExpression$1(node.arguments[1]) : isFunctionOrArrowExpressionWithBody(node.arguments[1]) && getFunctionParameters$6(node.arguments[1]).length <= 1) || isAngularTestWrapper(node.arguments[1]);
  32031. }
  32032. }
  32033. return false;
  32034. }
  32035. /**
  32036. * @param {Node} node
  32037. * @returns {boolean}
  32038. */
  32039. function isCallExpression$d(node) {
  32040. return node && (node.type === "CallExpression" || node.type === "OptionalCallExpression");
  32041. }
  32042. /**
  32043. * @param {Node} node
  32044. * @returns {boolean}
  32045. */
  32046. function isMemberExpression$a(node) {
  32047. return node && (node.type === "MemberExpression" || node.type === "OptionalMemberExpression");
  32048. }
  32049. /**
  32050. *
  32051. * @param {any} node
  32052. * @returns {boolean}
  32053. */
  32054. function isSimpleTemplateLiteral$1(node) {
  32055. let expressionsKey = "expressions";
  32056. if (node.type === "TSTemplateLiteralType") {
  32057. expressionsKey = "types";
  32058. }
  32059. const expressions = node[expressionsKey];
  32060. if (expressions.length === 0) {
  32061. return false;
  32062. }
  32063. return expressions.every(expr => {
  32064. // Disallow comments since printDocToString can't print them here
  32065. if (hasComment$j(expr)) {
  32066. return false;
  32067. } // Allow `x` and `this`
  32068. if (expr.type === "Identifier" || expr.type === "ThisExpression") {
  32069. return true;
  32070. } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
  32071. if (isMemberExpression$a(expr)) {
  32072. let head = expr;
  32073. while (isMemberExpression$a(head)) {
  32074. if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") {
  32075. return false;
  32076. }
  32077. head = head.object;
  32078. if (hasComment$j(head)) {
  32079. return false;
  32080. }
  32081. }
  32082. if (head.type === "Identifier" || head.type === "ThisExpression") {
  32083. return true;
  32084. }
  32085. return false;
  32086. }
  32087. return false;
  32088. });
  32089. }
  32090. /**
  32091. * @param {string} tokenNode
  32092. * @param {string} keyword
  32093. * @returns {string}
  32094. */
  32095. function getTypeScriptMappedTypeModifier$1(tokenNode, keyword) {
  32096. if (tokenNode === "+") {
  32097. return "+" + keyword;
  32098. }
  32099. if (tokenNode === "-") {
  32100. return "-" + keyword;
  32101. }
  32102. return keyword;
  32103. }
  32104. /**
  32105. * @param {string} text
  32106. * @param {Node} typeAnnotation
  32107. * @returns {boolean}
  32108. */
  32109. function isFlowAnnotationComment$2(text, typeAnnotation) {
  32110. const start = locStart$q(typeAnnotation);
  32111. const end = skipWhitespace(text, locEnd$p(typeAnnotation));
  32112. return end !== false && text.slice(start, start + 2) === "/*" && text.slice(end, end + 2) === "*/";
  32113. }
  32114. /**
  32115. * @param {string} text
  32116. * @param {Node} node
  32117. * @returns {boolean}
  32118. */
  32119. function hasLeadingOwnLineComment$4(text, node) {
  32120. if (isJsxNode$7(node)) {
  32121. return hasNodeIgnoreComment$1(node);
  32122. }
  32123. return hasComment$j(node, CommentCheckFlags$g.Leading, comment => hasNewline$7(text, locEnd$p(comment)));
  32124. } // Note: Quoting/unquoting numbers in TypeScript is not safe.
  32125. //
  32126. // let a = { 1: 1, 2: 2 }
  32127. // let b = { '1': 1, '2': 2 }
  32128. //
  32129. // declare let aa: keyof typeof a;
  32130. // declare let bb: keyof typeof b;
  32131. //
  32132. // aa = bb;
  32133. // ^^
  32134. // Type '"1" | "2"' is not assignable to type '1 | 2'.
  32135. // Type '"1"' is not assignable to type '1 | 2'.(2322)
  32136. //
  32137. // And in Flow, you get:
  32138. //
  32139. // const x = {
  32140. // 0: 1
  32141. // ^ Non-string literal property keys not supported. [unsupported-syntax]
  32142. // }
  32143. //
  32144. // Angular does not support unquoted numbers in expressions.
  32145. //
  32146. // So we play it safe and only unquote numbers for the JavaScript parsers.
  32147. // (Vue supports unquoted numbers in expressions, but let’s keep it simple.)
  32148. //
  32149. // Identifiers can be unquoted in more circumstances, though.
  32150. function isStringPropSafeToUnquote$1(node, options) {
  32151. return options.parser !== "json" && isStringLiteral$5(node.key) && rawText$5(node.key).slice(1, -1) === node.key.value && (isIdentifierName(node.key.value) && // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
  32152. // See https://github.com/microsoft/TypeScript/pull/20075
  32153. !(options.parser === "babel-ts" && node.type === "ClassProperty" || options.parser === "typescript" && node.type === "PropertyDefinition") || isSimpleNumber$1(node.key.value) && String(Number(node.key.value)) === node.key.value && (options.parser === "babel" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree"));
  32154. } // Matches “simple” numbers like `123` and `2.5` but not `1_000`, `1e+100` or `0b10`.
  32155. function isSimpleNumber$1(numberString) {
  32156. return /^(?:\d+|\d+\.\d+)$/.test(numberString);
  32157. }
  32158. /**
  32159. * @param {Node} node
  32160. * @param {Node} parentNode
  32161. * @returns {boolean}
  32162. */
  32163. function isJestEachTemplateLiteral$1(node, parentNode) {
  32164. /**
  32165. * describe.each`table`(name, fn)
  32166. * describe.only.each`table`(name, fn)
  32167. * describe.skip.each`table`(name, fn)
  32168. * test.each`table`(name, fn)
  32169. * test.only.each`table`(name, fn)
  32170. * test.skip.each`table`(name, fn)
  32171. *
  32172. * Ref: https://github.com/facebook/jest/pull/6102
  32173. */
  32174. const jestEachTriggerRegex = /^[fx]?(?:describe|it|test)$/;
  32175. 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));
  32176. }
  32177. /**
  32178. * @param {TemplateLiteral} template
  32179. * @returns {boolean}
  32180. */
  32181. function templateLiteralHasNewLines(template) {
  32182. return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
  32183. }
  32184. /**
  32185. * @param {TemplateLiteral | TaggedTemplateExpression} node
  32186. * @param {string} text
  32187. * @returns {boolean}
  32188. */
  32189. function isTemplateOnItsOwnLine$2(node, text) {
  32190. return (node.type === "TemplateLiteral" && templateLiteralHasNewLines(node) || node.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(node.quasi)) && !hasNewline$7(text, locStart$q(node), {
  32191. backwards: true
  32192. });
  32193. }
  32194. /**
  32195. * @param {Node} node
  32196. * @returns {boolean}
  32197. */
  32198. function needsHardlineAfterDanglingComment$2(node) {
  32199. if (!hasComment$j(node)) {
  32200. return false;
  32201. }
  32202. const lastDanglingComment = getLast$l(getComments$5(node, CommentCheckFlags$g.Dangling));
  32203. return lastDanglingComment && !isBlockComment$5(lastDanglingComment);
  32204. } // Logic to check for args with multiple anonymous functions. For instance,
  32205. // the following call should be split on multiple lines for readability:
  32206. // source.pipe(map((x) => x + x), filter((x) => x % 2 === 0))
  32207. function isFunctionCompositionArgs$1(args) {
  32208. if (args.length <= 1) {
  32209. return false;
  32210. }
  32211. let count = 0;
  32212. for (const arg of args) {
  32213. if (isFunctionOrArrowExpression$1(arg)) {
  32214. count += 1;
  32215. if (count > 1) {
  32216. return true;
  32217. }
  32218. } else if (isCallExpression$d(arg)) {
  32219. for (const childArg of arg.arguments) {
  32220. if (isFunctionOrArrowExpression$1(childArg)) {
  32221. return true;
  32222. }
  32223. }
  32224. }
  32225. }
  32226. return false;
  32227. } // Logic to determine if a call is a “long curried function call”.
  32228. // See https://github.com/prettier/prettier/issues/1420.
  32229. //
  32230. // `connect(a, b, c)(d)`
  32231. // In the above call expression, the second call is the parent node and the
  32232. // first call is the current node.
  32233. /**
  32234. * @param {AstPath} path
  32235. * @returns {boolean}
  32236. */
  32237. function isLongCurriedCallExpression$2(path) {
  32238. const node = path.getValue();
  32239. const parent = path.getParentNode();
  32240. return isCallExpression$d(node) && isCallExpression$d(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
  32241. }
  32242. /**
  32243. * @param {any} node
  32244. * @param {number} depth
  32245. * @returns {boolean}
  32246. */
  32247. function isSimpleCallArgument$1(node, depth) {
  32248. if (depth >= 2) {
  32249. return false;
  32250. }
  32251. const isChildSimple = child => isSimpleCallArgument$1(child, depth + 1);
  32252. const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
  32253. if (regexpPattern && getStringWidth$3(regexpPattern) > 5) {
  32254. return false;
  32255. }
  32256. if (node.type === "Literal" || node.type === "BigIntLiteral" || node.type === "DecimalLiteral" || node.type === "BooleanLiteral" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "Identifier" || node.type === "ThisExpression" || node.type === "Super" || node.type === "PrivateName" || node.type === "PrivateIdentifier" || node.type === "ArgumentPlaceholder" || node.type === "Import") {
  32257. return true;
  32258. }
  32259. if (node.type === "TemplateLiteral") {
  32260. return node.quasis.every(element => !element.value.raw.includes("\n")) && node.expressions.every(isChildSimple);
  32261. }
  32262. if (node.type === "ObjectExpression") {
  32263. return node.properties.every(p => !p.computed && (p.shorthand || p.value && isChildSimple(p.value)));
  32264. }
  32265. if (node.type === "ArrayExpression") {
  32266. return node.elements.every(x => x === null || isChildSimple(x));
  32267. }
  32268. if (isCallLikeExpression$2(node)) {
  32269. return (node.type === "ImportExpression" || isSimpleCallArgument$1(node.callee, depth)) && getCallArguments$5(node).every(isChildSimple);
  32270. }
  32271. if (isMemberExpression$a(node)) {
  32272. return isSimpleCallArgument$1(node.object, depth) && isSimpleCallArgument$1(node.property, depth);
  32273. }
  32274. if (node.type === "UnaryExpression" && (node.operator === "!" || node.operator === "-")) {
  32275. return isSimpleCallArgument$1(node.argument, depth);
  32276. }
  32277. if (node.type === "TSNonNullExpression") {
  32278. return isSimpleCallArgument$1(node.expression, depth);
  32279. }
  32280. return false;
  32281. }
  32282. function rawText$5(node) {
  32283. return node.extra ? node.extra.raw : node.raw;
  32284. }
  32285. function identity$1(x) {
  32286. return x;
  32287. }
  32288. function isTSXFile$1(options) {
  32289. return options.filepath && /\.tsx$/i.test(options.filepath);
  32290. }
  32291. /**
  32292. * @param {any} options
  32293. * @param {("es5" | "all")} [level]
  32294. * @returns {boolean}
  32295. */
  32296. function shouldPrintComma$b(options, level = "es5") {
  32297. return options.trailingComma === "es5" && level === "es5" || options.trailingComma === "all" && (level === "all" || level === "es5");
  32298. }
  32299. /**
  32300. * Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  32301. * holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  32302. * already necessary grouping parentheses.
  32303. *
  32304. * @param {Node} node
  32305. * @param {boolean} forbidFunctionClassAndDoExpr
  32306. * @returns {boolean}
  32307. */
  32308. function startsWithNoLookaheadToken$2(node, forbidFunctionClassAndDoExpr) {
  32309. node = getLeftMost(node);
  32310. switch (node.type) {
  32311. case "FunctionExpression":
  32312. case "ClassExpression":
  32313. case "DoExpression":
  32314. return forbidFunctionClassAndDoExpr;
  32315. case "ObjectExpression":
  32316. return true;
  32317. case "MemberExpression":
  32318. case "OptionalMemberExpression":
  32319. return startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
  32320. case "TaggedTemplateExpression":
  32321. if (node.tag.type === "FunctionExpression") {
  32322. // IIFEs are always already parenthesized
  32323. return false;
  32324. }
  32325. return startsWithNoLookaheadToken$2(node.tag, forbidFunctionClassAndDoExpr);
  32326. case "CallExpression":
  32327. case "OptionalCallExpression":
  32328. if (node.callee.type === "FunctionExpression") {
  32329. // IIFEs are always already parenthesized
  32330. return false;
  32331. }
  32332. return startsWithNoLookaheadToken$2(node.callee, forbidFunctionClassAndDoExpr);
  32333. case "ConditionalExpression":
  32334. return startsWithNoLookaheadToken$2(node.test, forbidFunctionClassAndDoExpr);
  32335. case "UpdateExpression":
  32336. return !node.prefix && startsWithNoLookaheadToken$2(node.argument, forbidFunctionClassAndDoExpr);
  32337. case "BindExpression":
  32338. return node.object && startsWithNoLookaheadToken$2(node.object, forbidFunctionClassAndDoExpr);
  32339. case "SequenceExpression":
  32340. return startsWithNoLookaheadToken$2(node.expressions[0], forbidFunctionClassAndDoExpr);
  32341. case "TSAsExpression":
  32342. case "TSNonNullExpression":
  32343. return startsWithNoLookaheadToken$2(node.expression, forbidFunctionClassAndDoExpr);
  32344. default:
  32345. return false;
  32346. }
  32347. }
  32348. const equalityOperators = {
  32349. "==": true,
  32350. "!=": true,
  32351. "===": true,
  32352. "!==": true
  32353. };
  32354. const multiplicativeOperators = {
  32355. "*": true,
  32356. "/": true,
  32357. "%": true
  32358. };
  32359. const bitshiftOperators = {
  32360. ">>": true,
  32361. ">>>": true,
  32362. "<<": true
  32363. };
  32364. function shouldFlatten$2(parentOp, nodeOp) {
  32365. if (getPrecedence$1(nodeOp) !== getPrecedence$1(parentOp)) {
  32366. return false;
  32367. } // ** is right-associative
  32368. // x ** y ** z --> x ** (y ** z)
  32369. if (parentOp === "**") {
  32370. return false;
  32371. } // x == y == z --> (x == y) == z
  32372. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  32373. return false;
  32374. } // x * y % z --> (x * y) % z
  32375. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  32376. return false;
  32377. } // x * y / z --> (x * y) / z
  32378. // x / y * z --> (x / y) * z
  32379. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  32380. return false;
  32381. } // x << y << z --> (x << y) << z
  32382. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  32383. return false;
  32384. }
  32385. return true;
  32386. }
  32387. const PRECEDENCE = {};
  32388. for (const [i, tier] of [["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].entries()) {
  32389. for (const op of tier) {
  32390. PRECEDENCE[op] = i;
  32391. }
  32392. }
  32393. function getPrecedence$1(op) {
  32394. return PRECEDENCE[op];
  32395. }
  32396. function getLeftMost(node) {
  32397. while (node.left) {
  32398. node = node.left;
  32399. }
  32400. return node;
  32401. }
  32402. function isBitwiseOperator$1(operator) {
  32403. return Boolean(bitshiftOperators[operator]) || operator === "|" || operator === "^" || operator === "&";
  32404. }
  32405. function hasRestParameter$1(node) {
  32406. if (node.rest) {
  32407. return true;
  32408. }
  32409. const parameters = getFunctionParameters$6(node);
  32410. return parameters.length > 0 && getLast$l(parameters).type === "RestElement";
  32411. }
  32412. const functionParametersCache = new WeakMap();
  32413. function getFunctionParameters$6(node) {
  32414. if (functionParametersCache.has(node)) {
  32415. return functionParametersCache.get(node);
  32416. }
  32417. const parameters = [];
  32418. if (node.this) {
  32419. parameters.push(node.this);
  32420. } // `params` vs `parameters` - see https://github.com/babel/babel/issues/9231
  32421. if (Array.isArray(node.parameters)) {
  32422. parameters.push(...node.parameters);
  32423. } else if (Array.isArray(node.params)) {
  32424. parameters.push(...node.params);
  32425. }
  32426. if (node.rest) {
  32427. parameters.push(node.rest);
  32428. }
  32429. functionParametersCache.set(node, parameters);
  32430. return parameters;
  32431. }
  32432. function iterateFunctionParametersPath$1(path, iteratee) {
  32433. const node = path.getValue();
  32434. let index = 0;
  32435. const callback = childPath => iteratee(childPath, index++);
  32436. if (node.this) {
  32437. path.call(callback, "this");
  32438. }
  32439. if (Array.isArray(node.parameters)) {
  32440. path.each(callback, "parameters");
  32441. } else if (Array.isArray(node.params)) {
  32442. path.each(callback, "params");
  32443. }
  32444. if (node.rest) {
  32445. path.call(callback, "rest");
  32446. }
  32447. }
  32448. const callArgumentsCache = new WeakMap();
  32449. function getCallArguments$5(node) {
  32450. if (callArgumentsCache.has(node)) {
  32451. return callArgumentsCache.get(node);
  32452. }
  32453. let args = node.arguments;
  32454. if (node.type === "ImportExpression") {
  32455. args = [node.source];
  32456. if (node.attributes) {
  32457. args.push(node.attributes);
  32458. }
  32459. }
  32460. callArgumentsCache.set(node, args);
  32461. return args;
  32462. }
  32463. function iterateCallArgumentsPath$2(path, iteratee) {
  32464. const node = path.getValue();
  32465. if (node.type === "ImportExpression") {
  32466. path.call(sourcePath => iteratee(sourcePath, 0), "source");
  32467. if (node.attributes) {
  32468. path.call(sourcePath => iteratee(sourcePath, 1), "attributes");
  32469. }
  32470. } else {
  32471. path.each(iteratee, "arguments");
  32472. }
  32473. }
  32474. function isPrettierIgnoreComment$1(comment) {
  32475. return comment.value.trim() === "prettier-ignore" && !comment.unignore;
  32476. }
  32477. function hasNodeIgnoreComment$1(node) {
  32478. return node && (node.prettierIgnore || hasComment$j(node, CommentCheckFlags$g.PrettierIgnore));
  32479. }
  32480. function hasIgnoreComment$2(path) {
  32481. const node = path.getValue();
  32482. return hasNodeIgnoreComment$1(node);
  32483. }
  32484. const CommentCheckFlags$g = {
  32485. /** Check comment is a leading comment */
  32486. Leading: 1 << 1,
  32487. /** Check comment is a trailing comment */
  32488. Trailing: 1 << 2,
  32489. /** Check comment is a dangling comment */
  32490. Dangling: 1 << 3,
  32491. /** Check comment is a block comment */
  32492. Block: 1 << 4,
  32493. /** Check comment is a line comment */
  32494. Line: 1 << 5,
  32495. /** Check comment is a `prettier-ignore` comment */
  32496. PrettierIgnore: 1 << 6,
  32497. /** Check comment is the first attached comment */
  32498. First: 1 << 7,
  32499. /** Check comment is the last attached comment */
  32500. Last: 1 << 8
  32501. };
  32502. const getCommentTestFunction = (flags, fn) => {
  32503. if (typeof flags === "function") {
  32504. fn = flags;
  32505. flags = 0;
  32506. }
  32507. if (flags || fn) {
  32508. return (comment, index, comments) => !(flags & CommentCheckFlags$g.Leading && !comment.leading || flags & CommentCheckFlags$g.Trailing && !comment.trailing || flags & CommentCheckFlags$g.Dangling && (comment.leading || comment.trailing) || flags & CommentCheckFlags$g.Block && !isBlockComment$5(comment) || flags & CommentCheckFlags$g.Line && !isLineComment$3(comment) || flags & CommentCheckFlags$g.First && index !== 0 || flags & CommentCheckFlags$g.Last && index !== comments.length - 1 || flags & CommentCheckFlags$g.PrettierIgnore && !isPrettierIgnoreComment$1(comment) || fn && !fn(comment));
  32509. }
  32510. };
  32511. /**
  32512. * @param {Node} node
  32513. * @param {number | function} [flags]
  32514. * @param {function} [fn]
  32515. * @returns {boolean}
  32516. */
  32517. function hasComment$j(node, flags, fn) {
  32518. if (!node || !isNonEmptyArray$i(node.comments)) {
  32519. return false;
  32520. }
  32521. const test = getCommentTestFunction(flags, fn);
  32522. return test ? node.comments.some(test) : true;
  32523. }
  32524. /**
  32525. * @param {Node} node
  32526. * @param {number | function} [flags]
  32527. * @param {function} [fn]
  32528. * @returns {Comment[]}
  32529. */
  32530. function getComments$5(node, flags, fn) {
  32531. if (!node || !Array.isArray(node.comments)) {
  32532. return [];
  32533. }
  32534. const test = getCommentTestFunction(flags, fn);
  32535. return test ? node.comments.filter(test) : node.comments;
  32536. }
  32537. /**
  32538. * @param {Node} node
  32539. * @returns {boolean}
  32540. */
  32541. const isNextLineEmpty$c = (node, {
  32542. originalText
  32543. }) => isNextLineEmptyAfterIndex$1(originalText, locEnd$p(node));
  32544. function isCallLikeExpression$2(node) {
  32545. return isCallExpression$d(node) || node.type === "NewExpression" || node.type === "ImportExpression";
  32546. }
  32547. function isObjectProperty$6(node) {
  32548. return node && (node.type === "ObjectProperty" || node.type === "Property" && !node.method && node.kind === "init");
  32549. }
  32550. function isEnabledHackPipeline$1(options) {
  32551. return Boolean(options.__isUsingHackPipeline);
  32552. }
  32553. var utils$5 = {
  32554. getFunctionParameters: getFunctionParameters$6,
  32555. iterateFunctionParametersPath: iterateFunctionParametersPath$1,
  32556. getCallArguments: getCallArguments$5,
  32557. iterateCallArgumentsPath: iterateCallArgumentsPath$2,
  32558. hasRestParameter: hasRestParameter$1,
  32559. getLeftSide: getLeftSide$1,
  32560. getLeftSidePathName: getLeftSidePathName$2,
  32561. getParentExportDeclaration: getParentExportDeclaration$2,
  32562. getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier$1,
  32563. hasFlowAnnotationComment: hasFlowAnnotationComment$2,
  32564. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$3,
  32565. hasLeadingOwnLineComment: hasLeadingOwnLineComment$4,
  32566. hasNakedLeftSide: hasNakedLeftSide$3,
  32567. hasNode: hasNode$2,
  32568. hasIgnoreComment: hasIgnoreComment$2,
  32569. hasNodeIgnoreComment: hasNodeIgnoreComment$1,
  32570. identity: identity$1,
  32571. isBinaryish: isBinaryish$5,
  32572. isBlockComment: isBlockComment$5,
  32573. isCallLikeExpression: isCallLikeExpression$2,
  32574. isEnabledHackPipeline: isEnabledHackPipeline$1,
  32575. isLineComment: isLineComment$3,
  32576. isPrettierIgnoreComment: isPrettierIgnoreComment$1,
  32577. isCallExpression: isCallExpression$d,
  32578. isMemberExpression: isMemberExpression$a,
  32579. isExportDeclaration,
  32580. isFlowAnnotationComment: isFlowAnnotationComment$2,
  32581. isFunctionCompositionArgs: isFunctionCompositionArgs$1,
  32582. isFunctionNotation: isFunctionNotation$1,
  32583. isFunctionOrArrowExpression: isFunctionOrArrowExpression$1,
  32584. isGetterOrSetter: isGetterOrSetter$1,
  32585. isJestEachTemplateLiteral: isJestEachTemplateLiteral$1,
  32586. isJsxNode: isJsxNode$7,
  32587. isLiteral: isLiteral$3,
  32588. isLongCurriedCallExpression: isLongCurriedCallExpression$2,
  32589. isSimpleCallArgument: isSimpleCallArgument$1,
  32590. isMemberish: isMemberish$2,
  32591. isNumericLiteral: isNumericLiteral$5,
  32592. isSignedNumericLiteral: isSignedNumericLiteral$2,
  32593. isObjectProperty: isObjectProperty$6,
  32594. isObjectType: isObjectType$3,
  32595. isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$2,
  32596. isSimpleType: isSimpleType$2,
  32597. isSimpleNumber: isSimpleNumber$1,
  32598. isSimpleTemplateLiteral: isSimpleTemplateLiteral$1,
  32599. isStringLiteral: isStringLiteral$5,
  32600. isStringPropSafeToUnquote: isStringPropSafeToUnquote$1,
  32601. isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$2,
  32602. isTestCall: isTestCall$3,
  32603. isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$2,
  32604. isTSXFile: isTSXFile$1,
  32605. isTypeAnnotationAFunction: isTypeAnnotationAFunction$1,
  32606. isNextLineEmpty: isNextLineEmpty$c,
  32607. needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$2,
  32608. rawText: rawText$5,
  32609. shouldPrintComma: shouldPrintComma$b,
  32610. isBitwiseOperator: isBitwiseOperator$1,
  32611. shouldFlatten: shouldFlatten$2,
  32612. startsWithNoLookaheadToken: startsWithNoLookaheadToken$2,
  32613. getPrecedence: getPrecedence$1,
  32614. hasComment: hasComment$j,
  32615. getComments: getComments$5,
  32616. CommentCheckFlags: CommentCheckFlags$g
  32617. };
  32618. const getLast$k = getLast_1;
  32619. const {
  32620. getStringWidth: getStringWidth$2,
  32621. getIndentSize
  32622. } = util$8;
  32623. const {
  32624. builders: {
  32625. join: join$u,
  32626. hardline: hardline$A,
  32627. softline: softline$t,
  32628. group: group$C,
  32629. indent: indent$y,
  32630. align: align$5,
  32631. lineSuffixBoundary: lineSuffixBoundary$1,
  32632. addAlignmentToDoc
  32633. },
  32634. printer: {
  32635. printDocToString: printDocToString$1
  32636. },
  32637. utils: {
  32638. mapDoc: mapDoc$3
  32639. }
  32640. } = require$$7$3;
  32641. const {
  32642. isBinaryish: isBinaryish$4,
  32643. isJestEachTemplateLiteral,
  32644. isSimpleTemplateLiteral,
  32645. hasComment: hasComment$i,
  32646. isMemberExpression: isMemberExpression$9
  32647. } = utils$5;
  32648. function printTemplateLiteral$2(path, print, options) {
  32649. const node = path.getValue();
  32650. const isTemplateLiteral = node.type === "TemplateLiteral";
  32651. if (isTemplateLiteral && isJestEachTemplateLiteral(node, path.getParentNode())) {
  32652. const printed = printJestEachTemplateLiteral(path, options, print);
  32653. if (printed) {
  32654. return printed;
  32655. }
  32656. }
  32657. let expressionsKey = "expressions";
  32658. if (node.type === "TSTemplateLiteralType") {
  32659. expressionsKey = "types";
  32660. }
  32661. const parts = [];
  32662. let expressions = path.map(print, expressionsKey);
  32663. const isSimple = isSimpleTemplateLiteral(node);
  32664. if (isSimple) {
  32665. expressions = expressions.map(doc => printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
  32666. printWidth: Number.POSITIVE_INFINITY
  32667. })).formatted);
  32668. }
  32669. parts.push(lineSuffixBoundary$1, "`");
  32670. path.each(childPath => {
  32671. const i = childPath.getName();
  32672. parts.push(print());
  32673. if (i < expressions.length) {
  32674. // For a template literal of the following form:
  32675. // `someQuery {
  32676. // ${call({
  32677. // a,
  32678. // b,
  32679. // })}
  32680. // }`
  32681. // the expression is on its own line (there is a \n in the previous
  32682. // quasi literal), therefore we want to indent the JavaScript
  32683. // expression inside at the beginning of ${ instead of the beginning
  32684. // of the `.
  32685. const {
  32686. tabWidth
  32687. } = options;
  32688. const quasi = childPath.getValue();
  32689. const indentSize = getIndentSize(quasi.value.raw, tabWidth);
  32690. let printed = expressions[i];
  32691. if (!isSimple) {
  32692. const expression = node[expressionsKey][i]; // Breaks at the template element boundaries (${ and }) are preferred to breaking
  32693. // in the middle of a MemberExpression
  32694. if (hasComment$i(expression) || isMemberExpression$9(expression) || expression.type === "ConditionalExpression" || expression.type === "SequenceExpression" || expression.type === "TSAsExpression" || isBinaryish$4(expression)) {
  32695. printed = [indent$y([softline$t, printed]), softline$t];
  32696. }
  32697. }
  32698. const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$5(Number.NEGATIVE_INFINITY, printed) : addAlignmentToDoc(printed, indentSize, tabWidth);
  32699. parts.push(group$C(["${", aligned, lineSuffixBoundary$1, "}"]));
  32700. }
  32701. }, "quasis");
  32702. parts.push("`");
  32703. return parts;
  32704. }
  32705. function printJestEachTemplateLiteral(path, options, print) {
  32706. /**
  32707. * a | b | expected
  32708. * ${1} | ${1} | ${2}
  32709. * ${1} | ${2} | ${3}
  32710. * ${2} | ${1} | ${3}
  32711. */
  32712. const node = path.getNode();
  32713. const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  32714. if (headerNames.length > 1 || headerNames.some(headerName => headerName.length > 0)) {
  32715. options.__inJestEach = true;
  32716. const expressions = path.map(print, "expressions");
  32717. options.__inJestEach = false;
  32718. const parts = [];
  32719. const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$1(doc, Object.assign(Object.assign({}, options), {}, {
  32720. printWidth: Number.POSITIVE_INFINITY,
  32721. endOfLine: "lf"
  32722. })).formatted + "}");
  32723. const tableBody = [{
  32724. hasLineBreak: false,
  32725. cells: []
  32726. }];
  32727. for (let i = 1; i < node.quasis.length; i++) {
  32728. const row = getLast$k(tableBody);
  32729. const correspondingExpression = stringifiedExpressions[i - 1];
  32730. row.cells.push(correspondingExpression);
  32731. if (correspondingExpression.includes("\n")) {
  32732. row.hasLineBreak = true;
  32733. }
  32734. if (node.quasis[i].value.raw.includes("\n")) {
  32735. tableBody.push({
  32736. hasLineBreak: false,
  32737. cells: []
  32738. });
  32739. }
  32740. }
  32741. const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
  32742. const maxColumnWidths = Array.from({
  32743. length: maxColumnCount
  32744. }).fill(0);
  32745. const table = [{
  32746. cells: headerNames
  32747. }, ...tableBody.filter(row => row.cells.length > 0)];
  32748. for (const {
  32749. cells
  32750. } of table.filter(row => !row.hasLineBreak)) {
  32751. for (const [index, cell] of cells.entries()) {
  32752. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  32753. }
  32754. }
  32755. parts.push(lineSuffixBoundary$1, "`", indent$y([hardline$A, join$u(hardline$A, table.map(row => join$u(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell))))))]), hardline$A, "`");
  32756. return parts;
  32757. }
  32758. }
  32759. function printTemplateExpression(path, print) {
  32760. const node = path.getValue();
  32761. let printed = print();
  32762. if (hasComment$i(node)) {
  32763. printed = group$C([indent$y([softline$t, printed]), softline$t]);
  32764. }
  32765. return ["${", printed, lineSuffixBoundary$1, "}"];
  32766. }
  32767. function printTemplateExpressions$3(path, print) {
  32768. return path.map(path => printTemplateExpression(path, print), "expressions");
  32769. }
  32770. function escapeTemplateCharacters$2(doc, raw) {
  32771. return mapDoc$3(doc, currentDoc => {
  32772. if (typeof currentDoc === "string") {
  32773. return raw ? currentDoc.replace(/(\\*)`/g, "$1$1\\`") : uncookTemplateElementValue$1(currentDoc);
  32774. }
  32775. return currentDoc;
  32776. });
  32777. }
  32778. function uncookTemplateElementValue$1(cookedValue) {
  32779. return cookedValue.replace(/([\\`]|\${)/g, "\\$1");
  32780. }
  32781. var templateLiteral = {
  32782. printTemplateLiteral: printTemplateLiteral$2,
  32783. printTemplateExpressions: printTemplateExpressions$3,
  32784. escapeTemplateCharacters: escapeTemplateCharacters$2,
  32785. uncookTemplateElementValue: uncookTemplateElementValue$1
  32786. };
  32787. const {
  32788. builders: {
  32789. indent: indent$x,
  32790. softline: softline$s,
  32791. literalline: literalline$4,
  32792. dedentToRoot: dedentToRoot$2
  32793. }
  32794. } = require$$7$3;
  32795. const {
  32796. escapeTemplateCharacters: escapeTemplateCharacters$1
  32797. } = templateLiteral;
  32798. function format$3(path, print, textToDoc) {
  32799. const node = path.getValue();
  32800. let text = node.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
  32801. const indentation = getIndentation(text);
  32802. const hasIndent = indentation !== "";
  32803. if (hasIndent) {
  32804. text = text.replace(new RegExp(`^${indentation}`, "gm"), "");
  32805. }
  32806. const doc = escapeTemplateCharacters$1(textToDoc(text, {
  32807. parser: "markdown",
  32808. __inJsTemplate: true
  32809. }, {
  32810. stripTrailingHardline: true
  32811. }), true);
  32812. return ["`", hasIndent ? indent$x([softline$s, doc]) : [literalline$4, dedentToRoot$2(doc)], softline$s, "`"];
  32813. }
  32814. function getIndentation(str) {
  32815. const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  32816. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  32817. }
  32818. var markdown = format$3;
  32819. const {
  32820. isNonEmptyArray: isNonEmptyArray$h
  32821. } = util$8;
  32822. const {
  32823. builders: {
  32824. indent: indent$w,
  32825. hardline: hardline$z,
  32826. softline: softline$r
  32827. },
  32828. utils: {
  32829. mapDoc: mapDoc$2,
  32830. replaceEndOfLine: replaceEndOfLine$1,
  32831. cleanDoc: cleanDoc$3
  32832. }
  32833. } = require$$7$3;
  32834. const {
  32835. printTemplateExpressions: printTemplateExpressions$2
  32836. } = templateLiteral;
  32837. function format$2(path, print, textToDoc) {
  32838. const node = path.getValue(); // Get full template literal with expressions replaced by placeholders
  32839. const rawQuasis = node.quasis.map(q => q.value.raw);
  32840. let placeholderID = 0;
  32841. const text = rawQuasis.reduce((prevVal, currVal, idx) => idx === 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal, "");
  32842. const doc = textToDoc(text, {
  32843. parser: "scss"
  32844. }, {
  32845. stripTrailingHardline: true
  32846. });
  32847. const expressionDocs = printTemplateExpressions$2(path, print);
  32848. return transformCssDoc(doc, node, expressionDocs);
  32849. }
  32850. function transformCssDoc(quasisDoc, parentNode, expressionDocs) {
  32851. const isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  32852. if (isEmpty) {
  32853. return "``";
  32854. }
  32855. const newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  32856. /* istanbul ignore if */
  32857. if (!newDoc) {
  32858. throw new Error("Couldn't insert all the expressions");
  32859. }
  32860. return ["`", indent$w([hardline$z, newDoc]), softline$r, "`"];
  32861. } // Search all the placeholders in the quasisDoc tree
  32862. // and replace them with the expression docs one by one
  32863. // returns a new doc with all the placeholders replaced,
  32864. // or null if it couldn't replace any expression
  32865. function replacePlaceholders(quasisDoc, expressionDocs) {
  32866. if (!isNonEmptyArray$h(expressionDocs)) {
  32867. return quasisDoc;
  32868. }
  32869. let replaceCounter = 0;
  32870. const newDoc = mapDoc$2(cleanDoc$3(quasisDoc), doc => {
  32871. if (typeof doc !== "string" || !doc.includes("@prettier-placeholder")) {
  32872. return doc;
  32873. } // When we have multiple placeholders in one line, like:
  32874. // ${Child}${Child2}:not(:first-child)
  32875. return doc.split(/@prettier-placeholder-(\d+)-id/).map((component, idx) => {
  32876. // The placeholder is always at odd indices
  32877. if (idx % 2 === 0) {
  32878. return replaceEndOfLine$1(component);
  32879. } // The component will always be a number at odd index
  32880. replaceCounter++;
  32881. return expressionDocs[component];
  32882. });
  32883. });
  32884. return expressionDocs.length === replaceCounter ? newDoc : null;
  32885. }
  32886. var css = format$2;
  32887. const {
  32888. builders: {
  32889. indent: indent$v,
  32890. join: join$t,
  32891. hardline: hardline$y
  32892. }
  32893. } = require$$7$3;
  32894. const {
  32895. escapeTemplateCharacters,
  32896. printTemplateExpressions: printTemplateExpressions$1
  32897. } = templateLiteral;
  32898. function format$1(path, print, textToDoc) {
  32899. const node = path.getValue();
  32900. const numQuasis = node.quasis.length;
  32901. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  32902. return "``";
  32903. }
  32904. const expressionDocs = printTemplateExpressions$1(path, print);
  32905. const parts = [];
  32906. for (let i = 0; i < numQuasis; i++) {
  32907. const templateElement = node.quasis[i];
  32908. const isFirst = i === 0;
  32909. const isLast = i === numQuasis - 1;
  32910. const text = templateElement.value.cooked;
  32911. const lines = text.split("\n");
  32912. const numLines = lines.length;
  32913. const expressionDoc = expressionDocs[i];
  32914. const startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  32915. const endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  32916. const commentsAndWhitespaceOnly = lines.every(line => /^\s*(?:#[^\n\r]*)?$/.test(line)); // Bail out if an interpolation occurs within a comment.
  32917. if (!isLast && /#[^\n\r]*$/.test(lines[numLines - 1])) {
  32918. return null;
  32919. }
  32920. let doc = null;
  32921. if (commentsAndWhitespaceOnly) {
  32922. doc = printGraphqlComments(lines);
  32923. } else {
  32924. doc = textToDoc(text, {
  32925. parser: "graphql"
  32926. }, {
  32927. stripTrailingHardline: true
  32928. });
  32929. }
  32930. if (doc) {
  32931. doc = escapeTemplateCharacters(doc, false);
  32932. if (!isFirst && startsWithBlankLine) {
  32933. parts.push("");
  32934. }
  32935. parts.push(doc);
  32936. if (!isLast && endsWithBlankLine) {
  32937. parts.push("");
  32938. }
  32939. } else if (!isFirst && !isLast && startsWithBlankLine) {
  32940. parts.push("");
  32941. }
  32942. if (expressionDoc) {
  32943. parts.push(expressionDoc);
  32944. }
  32945. }
  32946. return ["`", indent$v([hardline$y, join$t(hardline$y, parts)]), hardline$y, "`"];
  32947. }
  32948. function printGraphqlComments(lines) {
  32949. const parts = [];
  32950. let seenComment = false;
  32951. const array = lines.map(textLine => textLine.trim());
  32952. for (const [i, textLine] of array.entries()) {
  32953. // Lines are either whitespace only, or a comment (with potential whitespace
  32954. // around it). Drop whitespace-only lines.
  32955. if (textLine === "") {
  32956. continue;
  32957. }
  32958. if (array[i - 1] === "" && seenComment) {
  32959. // If a non-first comment is preceded by a blank (whitespace only) line,
  32960. // add in a blank line.
  32961. parts.push([hardline$y, textLine]);
  32962. } else {
  32963. parts.push(textLine);
  32964. }
  32965. seenComment = true;
  32966. } // If `lines` was whitespace only, return `null`.
  32967. return parts.length === 0 ? null : join$t(hardline$y, parts);
  32968. }
  32969. var graphql = format$1;
  32970. const {
  32971. builders: {
  32972. indent: indent$u,
  32973. line: line$y,
  32974. hardline: hardline$x,
  32975. group: group$B
  32976. },
  32977. utils: {
  32978. mapDoc: mapDoc$1
  32979. }
  32980. } = require$$7$3;
  32981. const {
  32982. printTemplateExpressions,
  32983. uncookTemplateElementValue
  32984. } = templateLiteral; // The counter is needed to distinguish nested embeds.
  32985. let htmlTemplateLiteralCounter = 0;
  32986. function format(path, print, textToDoc, options, {
  32987. parser
  32988. }) {
  32989. const node = path.getValue();
  32990. const counter = htmlTemplateLiteralCounter;
  32991. htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
  32992. const composePlaceholder = index => `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
  32993. const text = node.quasis.map((quasi, index, quasis) => index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index)).join("");
  32994. const expressionDocs = printTemplateExpressions(path, print);
  32995. if (expressionDocs.length === 0 && text.trim().length === 0) {
  32996. return "``";
  32997. }
  32998. const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
  32999. let topLevelCount = 0;
  33000. const doc = textToDoc(text, {
  33001. parser,
  33002. __onHtmlRoot(root) {
  33003. topLevelCount = root.children.length;
  33004. }
  33005. }, {
  33006. stripTrailingHardline: true
  33007. });
  33008. const contentDoc = mapDoc$1(doc, doc => {
  33009. if (typeof doc !== "string") {
  33010. return doc;
  33011. }
  33012. const parts = [];
  33013. const components = doc.split(placeholderRegex);
  33014. for (let i = 0; i < components.length; i++) {
  33015. let component = components[i];
  33016. if (i % 2 === 0) {
  33017. if (component) {
  33018. component = uncookTemplateElementValue(component);
  33019. if (options.__embeddedInHtml) {
  33020. component = component.replace(/<\/(script)\b/gi, "<\\/$1");
  33021. }
  33022. parts.push(component);
  33023. }
  33024. continue;
  33025. }
  33026. const placeholderIndex = Number(component);
  33027. parts.push(expressionDocs[placeholderIndex]);
  33028. }
  33029. return parts;
  33030. });
  33031. const leadingWhitespace = /^\s/.test(text) ? " " : "";
  33032. const trailingWhitespace = /\s$/.test(text) ? " " : "";
  33033. const linebreak = options.htmlWhitespaceSensitivity === "ignore" ? hardline$x : leadingWhitespace && trailingWhitespace ? line$y : null;
  33034. if (linebreak) {
  33035. return group$B(["`", indent$u([linebreak, group$B(contentDoc)]), linebreak, "`"]);
  33036. }
  33037. return group$B(["`", leadingWhitespace, topLevelCount > 1 ? indent$u(group$B(contentDoc)) : group$B(contentDoc), trailingWhitespace, "`"]);
  33038. }
  33039. var html$3 = format;
  33040. const {
  33041. hasComment: hasComment$h,
  33042. CommentCheckFlags: CommentCheckFlags$f,
  33043. isObjectProperty: isObjectProperty$5
  33044. } = utils$5;
  33045. const formatMarkdown = markdown;
  33046. const formatCss = css;
  33047. const formatGraphql = graphql;
  33048. const formatHtml = html$3;
  33049. function getLanguage(path) {
  33050. if (isStyledJsx(path) || isStyledComponents(path) || isCssProp(path) || isAngularComponentStyles(path)) {
  33051. return "css";
  33052. }
  33053. if (isGraphQL(path)) {
  33054. return "graphql";
  33055. }
  33056. if (isHtml(path)) {
  33057. return "html";
  33058. }
  33059. if (isAngularComponentTemplate(path)) {
  33060. return "angular";
  33061. }
  33062. if (isMarkdown(path)) {
  33063. return "markdown";
  33064. }
  33065. }
  33066. function embed$a(path, print, textToDoc, options) {
  33067. const node = path.getValue();
  33068. if (node.type !== "TemplateLiteral" || // Bail out if any of the quasis have an invalid escape sequence
  33069. // (which would make the `cooked` value be `null`)
  33070. hasInvalidCookedValue(node)) {
  33071. return;
  33072. }
  33073. const language = getLanguage(path);
  33074. if (!language) {
  33075. return;
  33076. }
  33077. if (language === "markdown") {
  33078. return formatMarkdown(path, print, textToDoc);
  33079. }
  33080. if (language === "css") {
  33081. return formatCss(path, print, textToDoc);
  33082. }
  33083. if (language === "graphql") {
  33084. return formatGraphql(path, print, textToDoc);
  33085. }
  33086. if (language === "html" || language === "angular") {
  33087. return formatHtml(path, print, textToDoc, options, {
  33088. parser: language
  33089. });
  33090. }
  33091. }
  33092. /**
  33093. * md`...`
  33094. * markdown`...`
  33095. */
  33096. function isMarkdown(path) {
  33097. const node = path.getValue();
  33098. const parent = path.getParentNode();
  33099. return parent && parent.type === "TaggedTemplateExpression" && node.quasis.length === 1 && parent.tag.type === "Identifier" && (parent.tag.name === "md" || parent.tag.name === "markdown");
  33100. }
  33101. /**
  33102. * Template literal in these contexts:
  33103. * <style jsx>{`div{color:red}`}</style>
  33104. * css``
  33105. * css.global``
  33106. * css.resolve``
  33107. */
  33108. function isStyledJsx(path) {
  33109. const node = path.getValue();
  33110. const parent = path.getParentNode();
  33111. const parentParent = path.getParentNode(1);
  33112. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(attribute => attribute.name.name === "jsx") || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
  33113. }
  33114. /**
  33115. * Angular Components can have:
  33116. * - Inline HTML template
  33117. * - Inline CSS styles
  33118. *
  33119. * ...which are both within template literals somewhere
  33120. * inside of the Component decorator factory.
  33121. *
  33122. * E.g.
  33123. * @Component({
  33124. * template: `<div>...</div>`,
  33125. * styles: [`h1 { color: blue; }`]
  33126. * })
  33127. */
  33128. function isAngularComponentStyles(path) {
  33129. return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "styles" && name === "value", ...angularComponentObjectExpressionPredicates);
  33130. }
  33131. function isAngularComponentTemplate(path) {
  33132. return path.match(node => node.type === "TemplateLiteral", (node, name) => isObjectProperty$5(node) && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
  33133. }
  33134. const angularComponentObjectExpressionPredicates = [(node, name) => node.type === "ObjectExpression" && name === "properties", (node, name) => node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments", (node, name) => node.type === "Decorator" && name === "expression"];
  33135. /**
  33136. * styled-components template literals
  33137. */
  33138. function isStyledComponents(path) {
  33139. const parent = path.getParentNode();
  33140. if (!parent || parent.type !== "TaggedTemplateExpression") {
  33141. return false;
  33142. }
  33143. const tag = parent.tag.type === "ParenthesizedExpression" ? parent.tag.expression : parent.tag;
  33144. switch (tag.type) {
  33145. case "MemberExpression":
  33146. return (// styled.foo``
  33147. isStyledIdentifier(tag.object) || // Component.extend``
  33148. isStyledExtend(tag)
  33149. );
  33150. case "CallExpression":
  33151. return (// styled(Component)``
  33152. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})``
  33153. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
  33154. isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})``
  33155. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  33156. );
  33157. case "Identifier":
  33158. // css``
  33159. return tag.name === "css";
  33160. default:
  33161. return false;
  33162. }
  33163. }
  33164. /**
  33165. * JSX element with CSS prop
  33166. */
  33167. function isCssProp(path) {
  33168. const parent = path.getParentNode();
  33169. const parentParent = path.getParentNode(1);
  33170. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  33171. }
  33172. function isStyledIdentifier(node) {
  33173. return node.type === "Identifier" && node.name === "styled";
  33174. }
  33175. function isStyledExtend(node) {
  33176. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  33177. }
  33178. /*
  33179. * react-relay and graphql-tag
  33180. * graphql`...`
  33181. * graphql.experimental`...`
  33182. * gql`...`
  33183. * GraphQL comment block
  33184. *
  33185. * This intentionally excludes Relay Classic tags, as Prettier does not
  33186. * support Relay Classic formatting.
  33187. */
  33188. function isGraphQL(path) {
  33189. const node = path.getValue();
  33190. const parent = path.getParentNode();
  33191. 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");
  33192. }
  33193. function hasLanguageComment(node, languageName) {
  33194. // This checks for a leading comment that is exactly `/* GraphQL */`
  33195. // In order to be in line with other implementations of this comment tag
  33196. // we will not trim the comment value and we will expect exactly one space on
  33197. // either side of the GraphQL string
  33198. // Also see ./clean.js
  33199. return hasComment$h(node, CommentCheckFlags$f.Block | CommentCheckFlags$f.Leading, ({
  33200. value
  33201. }) => value === ` ${languageName} `);
  33202. }
  33203. /**
  33204. * - html`...`
  33205. * - HTML comment block
  33206. */
  33207. function isHtml(path) {
  33208. return hasLanguageComment(path.getValue(), "HTML") || path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi");
  33209. }
  33210. function hasInvalidCookedValue({
  33211. quasis
  33212. }) {
  33213. return quasis.some(({
  33214. value: {
  33215. cooked
  33216. }
  33217. }) => cooked === null);
  33218. }
  33219. var embed_1$4 = embed$a;
  33220. const {
  33221. isBlockComment: isBlockComment$4
  33222. } = utils$5;
  33223. const ignoredProperties$4 = new Set(["range", "raw", "comments", "leadingComments", "trailingComments", "innerComments", "extra", "start", "end", "loc", "flags", "errors", "tokens"]);
  33224. const removeTemplateElementsValue = node => {
  33225. for (const templateElement of node.quasis) {
  33226. delete templateElement.value;
  33227. }
  33228. };
  33229. function clean$c(ast, newObj, parent) {
  33230. if (ast.type === "Program") {
  33231. delete newObj.sourceType;
  33232. }
  33233. if (ast.type === "BigIntLiteral" || ast.type === "BigIntLiteralTypeAnnotation") {
  33234. if (newObj.value) {
  33235. newObj.value = newObj.value.toLowerCase();
  33236. }
  33237. }
  33238. if (ast.type === "BigIntLiteral" || ast.type === "Literal") {
  33239. if (newObj.bigint) {
  33240. newObj.bigint = newObj.bigint.toLowerCase();
  33241. }
  33242. }
  33243. if (ast.type === "DecimalLiteral") {
  33244. newObj.value = Number(newObj.value);
  33245. }
  33246. if (ast.type === "Literal" && newObj.decimal) {
  33247. newObj.decimal = Number(newObj.decimal);
  33248. } // We remove extra `;` and add them when needed
  33249. if (ast.type === "EmptyStatement") {
  33250. return null;
  33251. } // We move text around, including whitespaces and add {" "}
  33252. if (ast.type === "JSXText") {
  33253. return null;
  33254. }
  33255. if (ast.type === "JSXExpressionContainer" && (ast.expression.type === "Literal" || ast.expression.type === "StringLiteral") && ast.expression.value === " ") {
  33256. return null;
  33257. } // We change {'key': value} into {key: value}.
  33258. // And {key: value} into {'key': value}.
  33259. // Also for (some) number keys.
  33260. if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "ClassMethod" || ast.type === "PropertyDefinition" || ast.type === "TSDeclareMethod" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "NumericLiteral" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
  33261. delete newObj.key;
  33262. } // Remove raw and cooked values from TemplateElement when it's CSS
  33263. // styled-jsx
  33264. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(attr => attr.name.name === "jsx")) {
  33265. for (const {
  33266. type,
  33267. expression
  33268. } of newObj.children) {
  33269. if (type === "JSXExpressionContainer" && expression.type === "TemplateLiteral") {
  33270. removeTemplateElementsValue(expression);
  33271. }
  33272. }
  33273. } // CSS template literals in css prop
  33274. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  33275. removeTemplateElementsValue(newObj.value.expression);
  33276. } // We change quotes
  33277. if (ast.type === "JSXAttribute" && ast.value && ast.value.type === "Literal" && /["']|&quot;|&apos;/.test(ast.value.value)) {
  33278. newObj.value.value = newObj.value.value.replace(/["']|&quot;|&apos;/g, '"');
  33279. } // Angular Components: Inline HTML template and Inline CSS styles
  33280. const expression = ast.expression || ast.callee;
  33281. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  33282. const astProps = ast.expression.arguments[0].properties;
  33283. for (const [index, prop] of newObj.expression.arguments[0].properties.entries()) {
  33284. switch (astProps[index].key.name) {
  33285. case "styles":
  33286. if (prop.value.type === "ArrayExpression") {
  33287. removeTemplateElementsValue(prop.value.elements[0]);
  33288. }
  33289. break;
  33290. case "template":
  33291. if (prop.value.type === "TemplateLiteral") {
  33292. removeTemplateElementsValue(prop.value);
  33293. }
  33294. break;
  33295. }
  33296. }
  33297. } // styled-components, graphql, markdown
  33298. 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")) {
  33299. removeTemplateElementsValue(newObj.quasi);
  33300. }
  33301. if (ast.type === "TemplateLiteral") {
  33302. // This checks for a leading comment that is exactly `/* GraphQL */`
  33303. // In order to be in line with other implementations of this comment tag
  33304. // we will not trim the comment value and we will expect exactly one space on
  33305. // either side of the GraphQL string
  33306. // Also see ./embed.js
  33307. const hasLanguageComment = ast.leadingComments && ast.leadingComments.some(comment => isBlockComment$4(comment) && ["GraphQL", "HTML"].some(languageName => comment.value === ` ${languageName} `));
  33308. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql" || // TODO: check parser
  33309. // `flow` and `typescript` don't have `leadingComments`
  33310. !ast.leadingComments) {
  33311. removeTemplateElementsValue(newObj);
  33312. }
  33313. }
  33314. if (ast.type === "InterpreterDirective") {
  33315. newObj.value = newObj.value.trimEnd();
  33316. } // Prettier removes degenerate union and intersection types with only one member.
  33317. if ((ast.type === "TSIntersectionType" || ast.type === "TSUnionType") && ast.types.length === 1) {
  33318. return newObj.types[0];
  33319. }
  33320. }
  33321. clean$c.ignoredProperties = ignoredProperties$4;
  33322. var clean_1$4 = clean$c;
  33323. var build = {};
  33324. var detectNewline$1 = {exports: {}};
  33325. const detectNewline = string => {
  33326. if (typeof string !== 'string') {
  33327. throw new TypeError('Expected a string');
  33328. }
  33329. const newlines = string.match(/(?:\r?\n)/g) || [];
  33330. if (newlines.length === 0) {
  33331. return;
  33332. }
  33333. const crlf = newlines.filter(newline => newline === '\r\n').length;
  33334. const lf = newlines.length - crlf;
  33335. return crlf > lf ? '\r\n' : '\n';
  33336. };
  33337. detectNewline$1.exports = detectNewline;
  33338. detectNewline$1.exports.graceful = string => typeof string === 'string' && detectNewline(string) || '\n';
  33339. Object.defineProperty(build, '__esModule', {
  33340. value: true
  33341. });
  33342. build.extract = extract$1;
  33343. build.strip = strip$1;
  33344. build.parse = parse$1;
  33345. build.parseWithComments = parseWithComments$1;
  33346. build.print = print$3;
  33347. function _os() {
  33348. const data = require$$0__default$1["default"];
  33349. _os = function () {
  33350. return data;
  33351. };
  33352. return data;
  33353. }
  33354. function _detectNewline() {
  33355. const data = _interopRequireDefault(detectNewline$1.exports);
  33356. _detectNewline = function () {
  33357. return data;
  33358. };
  33359. return data;
  33360. }
  33361. function _interopRequireDefault(obj) {
  33362. return obj && obj.__esModule ? obj : {
  33363. default: obj
  33364. };
  33365. }
  33366. /**
  33367. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  33368. *
  33369. * This source code is licensed under the MIT license found in the
  33370. * LICENSE file in the root directory of this source tree.
  33371. */
  33372. const commentEndRe = /\*\/$/;
  33373. const commentStartRe = /^\/\*\*/;
  33374. const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  33375. const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  33376. const ltrimNewlineRe = /^(\r?\n)+/;
  33377. const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  33378. const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  33379. const stringStartRe = /(\r?\n|^) *\* ?/g;
  33380. const STRING_ARRAY = [];
  33381. function extract$1(contents) {
  33382. const match = contents.match(docblockRe);
  33383. return match ? match[0].trimLeft() : '';
  33384. }
  33385. function strip$1(contents) {
  33386. const match = contents.match(docblockRe);
  33387. return match && match[0] ? contents.substring(match[0].length) : contents;
  33388. }
  33389. function parse$1(docblock) {
  33390. return parseWithComments$1(docblock).pragmas;
  33391. }
  33392. function parseWithComments$1(docblock) {
  33393. const line = (0, _detectNewline().default)(docblock) || _os().EOL;
  33394. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  33395. let prev = '';
  33396. while (prev !== docblock) {
  33397. prev = docblock;
  33398. docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
  33399. }
  33400. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  33401. const result = Object.create(null);
  33402. const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  33403. let match;
  33404. while (match = propertyRe.exec(docblock)) {
  33405. // strip linecomments from pragmas
  33406. const nextPragma = match[2].replace(lineCommentRe, '');
  33407. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  33408. result[match[1]] = STRING_ARRAY.concat(result[match[1]], nextPragma);
  33409. } else {
  33410. result[match[1]] = nextPragma;
  33411. }
  33412. }
  33413. return {
  33414. comments,
  33415. pragmas: result
  33416. };
  33417. }
  33418. function print$3({
  33419. comments = '',
  33420. pragmas = {}
  33421. }) {
  33422. const line = (0, _detectNewline().default)(comments) || _os().EOL;
  33423. const head = '/**';
  33424. const start = ' *';
  33425. const tail = ' */';
  33426. const keys = Object.keys(pragmas);
  33427. const printedObject = keys.map(key => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map(keyValue => start + ' ' + keyValue + line).join('');
  33428. if (!comments) {
  33429. if (keys.length === 0) {
  33430. return '';
  33431. }
  33432. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  33433. const value = pragmas[keys[0]];
  33434. return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
  33435. }
  33436. }
  33437. const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line;
  33438. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  33439. }
  33440. function printKeyValues(key, valueOrArray) {
  33441. return STRING_ARRAY.concat(valueOrArray).map(value => `@${key} ${value}`.trim());
  33442. }
  33443. const {
  33444. parseWithComments,
  33445. strip,
  33446. extract,
  33447. print: print$2
  33448. } = build;
  33449. const {
  33450. getShebang
  33451. } = util$8;
  33452. const {
  33453. normalizeEndOfLine
  33454. } = endOfLine;
  33455. function parseDocBlock(text) {
  33456. const shebang = getShebang(text);
  33457. if (shebang) {
  33458. text = text.slice(shebang.length + 1);
  33459. }
  33460. const docBlock = extract(text);
  33461. const {
  33462. pragmas,
  33463. comments
  33464. } = parseWithComments(docBlock);
  33465. return {
  33466. shebang,
  33467. text,
  33468. pragmas,
  33469. comments
  33470. };
  33471. }
  33472. function hasPragma$4(text) {
  33473. const pragmas = Object.keys(parseDocBlock(text).pragmas);
  33474. return pragmas.includes("prettier") || pragmas.includes("format");
  33475. }
  33476. function insertPragma$a(originalText) {
  33477. const {
  33478. shebang,
  33479. text,
  33480. pragmas,
  33481. comments
  33482. } = parseDocBlock(originalText);
  33483. const strippedText = strip(text);
  33484. const docBlock = print$2({
  33485. pragmas: Object.assign({
  33486. format: ""
  33487. }, pragmas),
  33488. comments: comments.trimStart()
  33489. });
  33490. return (shebang ? `${shebang}\n` : "") + // normalise newlines (mitigate use of os.EOL by jest-docblock)
  33491. normalizeEndOfLine(docBlock) + (strippedText.startsWith("\n") ? "\n" : "\n\n") + strippedText;
  33492. }
  33493. var pragma$5 = {
  33494. hasPragma: hasPragma$4,
  33495. insertPragma: insertPragma$a
  33496. };
  33497. const {
  33498. getLast: getLast$j,
  33499. hasNewline: hasNewline$6,
  33500. getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  33501. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$1,
  33502. hasNewlineInRange: hasNewlineInRange$3,
  33503. addLeadingComment,
  33504. addTrailingComment,
  33505. addDanglingComment,
  33506. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$2,
  33507. isNonEmptyArray: isNonEmptyArray$g
  33508. } = util$8;
  33509. const {
  33510. isBlockComment: isBlockComment$3,
  33511. getFunctionParameters: getFunctionParameters$5,
  33512. isPrettierIgnoreComment,
  33513. isJsxNode: isJsxNode$6,
  33514. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  33515. hasFlowAnnotationComment: hasFlowAnnotationComment$1,
  33516. hasIgnoreComment: hasIgnoreComment$1,
  33517. isCallLikeExpression: isCallLikeExpression$1,
  33518. getCallArguments: getCallArguments$4,
  33519. isCallExpression: isCallExpression$c,
  33520. isMemberExpression: isMemberExpression$8,
  33521. isObjectProperty: isObjectProperty$4,
  33522. getComments: getComments$4,
  33523. CommentCheckFlags: CommentCheckFlags$e
  33524. } = utils$5;
  33525. const {
  33526. locStart: locStart$p,
  33527. locEnd: locEnd$o
  33528. } = loc$6;
  33529. /**
  33530. * @typedef {import("./types/estree").Node} Node
  33531. * @typedef {import("./types/estree").Comment} Comment
  33532. * @typedef {import("../common/ast-path")} AstPath
  33533. *
  33534. * @typedef {Object} CommentContext
  33535. * @property {Comment} comment
  33536. * @property {Node} precedingNode
  33537. * @property {Node} enclosingNode
  33538. * @property {Node} followingNode
  33539. * @property {string} text
  33540. * @property {any} options
  33541. * @property {Node} ast
  33542. * @property {boolean} isLastComment
  33543. */
  33544. /**
  33545. * @param {CommentContext} context
  33546. * @returns {boolean}
  33547. */
  33548. function handleOwnLineComment(context) {
  33549. return [handleIgnoreComments, handleLastFunctionArgComments, handleMemberExpressionComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleImportSpecifierComments, handleForComments, handleUnionTypeComments, handleOnlyComments, handleImportDeclarationComments, handleAssignmentPatternComments, handleMethodNameComments, handleLabeledStatementComments].some(fn => fn(context));
  33550. }
  33551. /**
  33552. * @param {CommentContext} context
  33553. * @returns {boolean}
  33554. */
  33555. function handleEndOfLineComment(context) {
  33556. return [handleClosureTypeCastComments, handleLastFunctionArgComments, handleConditionalExpressionComments, handleImportSpecifierComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleLabeledStatementComments, handleCallExpressionComments, handlePropertyComments, handleOnlyComments, handleTypeAliasComments, handleVariableDeclaratorComments].some(fn => fn(context));
  33557. }
  33558. /**
  33559. * @param {CommentContext} context
  33560. * @returns {boolean}
  33561. */
  33562. function handleRemainingComment(context) {
  33563. return [handleIgnoreComments, handleIfStatementComments, handleWhileComments, handleObjectPropertyAssignment, handleCommentInEmptyParens, handleMethodNameComments, handleOnlyComments, handleCommentAfterArrowParams, handleFunctionNameComments, handleTSMappedTypeComments, handleBreakAndContinueStatementComments, handleTSFunctionTrailingComments].some(fn => fn(context));
  33564. }
  33565. /**
  33566. * @param {Node} node
  33567. * @returns {void}
  33568. */
  33569. function addBlockStatementFirstComment(node, comment) {
  33570. // @ts-expect-error
  33571. const firstNonEmptyNode = (node.body || node.properties).find(({
  33572. type
  33573. }) => type !== "EmptyStatement");
  33574. if (firstNonEmptyNode) {
  33575. addLeadingComment(firstNonEmptyNode, comment);
  33576. } else {
  33577. addDanglingComment(node, comment);
  33578. }
  33579. }
  33580. /**
  33581. * @param {Node} node
  33582. * @returns {void}
  33583. */
  33584. function addBlockOrNotComment(node, comment) {
  33585. if (node.type === "BlockStatement") {
  33586. addBlockStatementFirstComment(node, comment);
  33587. } else {
  33588. addLeadingComment(node, comment);
  33589. }
  33590. }
  33591. function handleClosureTypeCastComments({
  33592. comment,
  33593. followingNode
  33594. }) {
  33595. if (followingNode && isTypeCastComment(comment)) {
  33596. addLeadingComment(followingNode, comment);
  33597. return true;
  33598. }
  33599. return false;
  33600. } // There are often comments before the else clause of if statements like
  33601. //
  33602. // if (1) { ... }
  33603. // // comment
  33604. // else { ... }
  33605. //
  33606. // They are being attached as leading comments of the BlockExpression which
  33607. // is not well printed. What we want is to instead move the comment inside
  33608. // of the block and make it leadingComment of the first element of the block
  33609. // or dangling comment of the block if there is nothing inside
  33610. //
  33611. // if (1) { ... }
  33612. // else {
  33613. // // comment
  33614. // ...
  33615. // }
  33616. function handleIfStatementComments({
  33617. comment,
  33618. precedingNode,
  33619. enclosingNode,
  33620. followingNode,
  33621. text
  33622. }) {
  33623. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  33624. return false;
  33625. } // We unfortunately have no way using the AST or location of nodes to know
  33626. // if the comment is positioned before the condition parenthesis:
  33627. // if (a /* comment */) {}
  33628. // The only workaround I found is to look at the next character to see if
  33629. // it is a ).
  33630. const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
  33631. if (nextCharacter === ")") {
  33632. addTrailingComment(precedingNode, comment);
  33633. return true;
  33634. } // Comments before `else`:
  33635. // - treat as trailing comments of the consequent, if it's a BlockStatement
  33636. // - treat as a dangling comment otherwise
  33637. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  33638. if (precedingNode.type === "BlockStatement") {
  33639. addTrailingComment(precedingNode, comment);
  33640. } else {
  33641. addDanglingComment(enclosingNode, comment);
  33642. }
  33643. return true;
  33644. }
  33645. if (followingNode.type === "BlockStatement") {
  33646. addBlockStatementFirstComment(followingNode, comment);
  33647. return true;
  33648. }
  33649. if (followingNode.type === "IfStatement") {
  33650. addBlockOrNotComment(followingNode.consequent, comment);
  33651. return true;
  33652. } // For comments positioned after the condition parenthesis in an if statement
  33653. // before the consequent without brackets on, such as
  33654. // if (a) /* comment */ true,
  33655. // we look at the next character to see if the following node
  33656. // is the consequent for the if statement
  33657. if (enclosingNode.consequent === followingNode) {
  33658. addLeadingComment(followingNode, comment);
  33659. return true;
  33660. }
  33661. return false;
  33662. }
  33663. function handleWhileComments({
  33664. comment,
  33665. precedingNode,
  33666. enclosingNode,
  33667. followingNode,
  33668. text
  33669. }) {
  33670. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  33671. return false;
  33672. } // We unfortunately have no way using the AST or location of nodes to know
  33673. // if the comment is positioned before the condition parenthesis:
  33674. // while (a /* comment */) {}
  33675. // The only workaround I found is to look at the next character to see if
  33676. // it is a ).
  33677. const nextCharacter = getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o);
  33678. if (nextCharacter === ")") {
  33679. addTrailingComment(precedingNode, comment);
  33680. return true;
  33681. }
  33682. if (followingNode.type === "BlockStatement") {
  33683. addBlockStatementFirstComment(followingNode, comment);
  33684. return true;
  33685. }
  33686. if (enclosingNode.body === followingNode) {
  33687. addLeadingComment(followingNode, comment);
  33688. return true;
  33689. }
  33690. return false;
  33691. } // Same as IfStatement but for TryStatement
  33692. function handleTryStatementComments({
  33693. comment,
  33694. precedingNode,
  33695. enclosingNode,
  33696. followingNode
  33697. }) {
  33698. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  33699. return false;
  33700. }
  33701. if (enclosingNode.type === "CatchClause" && precedingNode) {
  33702. addTrailingComment(precedingNode, comment);
  33703. return true;
  33704. }
  33705. if (followingNode.type === "BlockStatement") {
  33706. addBlockStatementFirstComment(followingNode, comment);
  33707. return true;
  33708. }
  33709. if (followingNode.type === "TryStatement") {
  33710. addBlockOrNotComment(followingNode.finalizer, comment);
  33711. return true;
  33712. }
  33713. if (followingNode.type === "CatchClause") {
  33714. addBlockOrNotComment(followingNode.body, comment);
  33715. return true;
  33716. }
  33717. return false;
  33718. }
  33719. function handleMemberExpressionComments({
  33720. comment,
  33721. enclosingNode,
  33722. followingNode
  33723. }) {
  33724. if (isMemberExpression$8(enclosingNode) && followingNode && followingNode.type === "Identifier") {
  33725. addLeadingComment(enclosingNode, comment);
  33726. return true;
  33727. }
  33728. return false;
  33729. }
  33730. function handleConditionalExpressionComments({
  33731. comment,
  33732. precedingNode,
  33733. enclosingNode,
  33734. followingNode,
  33735. text
  33736. }) {
  33737. const isSameLineAsPrecedingNode = precedingNode && !hasNewlineInRange$3(text, locEnd$o(precedingNode), locStart$p(comment));
  33738. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && (enclosingNode.type === "ConditionalExpression" || enclosingNode.type === "TSConditionalType") && followingNode) {
  33739. addLeadingComment(followingNode, comment);
  33740. return true;
  33741. }
  33742. return false;
  33743. }
  33744. function handleObjectPropertyAssignment({
  33745. comment,
  33746. precedingNode,
  33747. enclosingNode
  33748. }) {
  33749. if (isObjectProperty$4(enclosingNode) && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  33750. addTrailingComment(enclosingNode.value.left, comment);
  33751. return true;
  33752. }
  33753. return false;
  33754. }
  33755. function handleClassComments({
  33756. comment,
  33757. precedingNode,
  33758. enclosingNode,
  33759. followingNode
  33760. }) {
  33761. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression" || enclosingNode.type === "DeclareClass" || enclosingNode.type === "DeclareInterface" || enclosingNode.type === "InterfaceDeclaration" || enclosingNode.type === "TSInterfaceDeclaration")) {
  33762. if (isNonEmptyArray$g(enclosingNode.decorators) && !(followingNode && followingNode.type === "Decorator")) {
  33763. addTrailingComment(getLast$j(enclosingNode.decorators), comment);
  33764. return true;
  33765. }
  33766. if (enclosingNode.body && followingNode === enclosingNode.body) {
  33767. addBlockStatementFirstComment(enclosingNode.body, comment);
  33768. return true;
  33769. } // Don't add leading comments to `implements`, `extends`, `mixins` to
  33770. // avoid printing the comment after the keyword.
  33771. if (followingNode) {
  33772. for (const prop of ["implements", "extends", "mixins"]) {
  33773. if (enclosingNode[prop] && followingNode === enclosingNode[prop][0]) {
  33774. if (precedingNode && (precedingNode === enclosingNode.id || precedingNode === enclosingNode.typeParameters || precedingNode === enclosingNode.superClass)) {
  33775. addTrailingComment(precedingNode, comment);
  33776. } else {
  33777. addDanglingComment(enclosingNode, comment, prop);
  33778. }
  33779. return true;
  33780. }
  33781. }
  33782. }
  33783. }
  33784. return false;
  33785. }
  33786. function handleMethodNameComments({
  33787. comment,
  33788. precedingNode,
  33789. enclosingNode,
  33790. text
  33791. }) {
  33792. // This is only needed for estree parsers (flow, typescript) to attach
  33793. // after a method name:
  33794. // obj = { fn /*comment*/() {} };
  33795. if (enclosingNode && precedingNode && ( // "MethodDefinition" is handled in getCommentChildNodes
  33796. enclosingNode.type === "Property" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "TSAbstractMethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  33797. // comment should be attached to value instead of key
  33798. getNextNonSpaceNonCommentCharacter$1(text, precedingNode, locEnd$o) !== ":") {
  33799. addTrailingComment(precedingNode, comment);
  33800. return true;
  33801. } // Print comments between decorators and class methods as a trailing comment
  33802. // on the decorator node instead of the method node
  33803. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "PropertyDefinition" || enclosingNode.type === "TSAbstractPropertyDefinition" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "MethodDefinition")) {
  33804. addTrailingComment(precedingNode, comment);
  33805. return true;
  33806. }
  33807. return false;
  33808. }
  33809. function handleFunctionNameComments({
  33810. comment,
  33811. precedingNode,
  33812. enclosingNode,
  33813. text
  33814. }) {
  33815. if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== "(") {
  33816. return false;
  33817. }
  33818. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  33819. addTrailingComment(precedingNode, comment);
  33820. return true;
  33821. }
  33822. return false;
  33823. }
  33824. function handleCommentAfterArrowParams({
  33825. comment,
  33826. enclosingNode,
  33827. text
  33828. }) {
  33829. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  33830. return false;
  33831. }
  33832. const index = getNextNonSpaceNonCommentCharacterIndex$2(text, comment, locEnd$o);
  33833. if (index !== false && text.slice(index, index + 2) === "=>") {
  33834. addDanglingComment(enclosingNode, comment);
  33835. return true;
  33836. }
  33837. return false;
  33838. }
  33839. function handleCommentInEmptyParens({
  33840. comment,
  33841. enclosingNode,
  33842. text
  33843. }) {
  33844. if (getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) !== ")") {
  33845. return false;
  33846. } // Only add dangling comments to fix the case when no params are present,
  33847. // i.e. a function without any argument.
  33848. if (enclosingNode && (isRealFunctionLikeNode(enclosingNode) && getFunctionParameters$5(enclosingNode).length === 0 || isCallLikeExpression$1(enclosingNode) && getCallArguments$4(enclosingNode).length === 0)) {
  33849. addDanglingComment(enclosingNode, comment);
  33850. return true;
  33851. }
  33852. if (enclosingNode && (enclosingNode.type === "MethodDefinition" || enclosingNode.type === "TSAbstractMethodDefinition") && getFunctionParameters$5(enclosingNode.value).length === 0) {
  33853. addDanglingComment(enclosingNode.value, comment);
  33854. return true;
  33855. }
  33856. return false;
  33857. }
  33858. function handleLastFunctionArgComments({
  33859. comment,
  33860. precedingNode,
  33861. enclosingNode,
  33862. followingNode,
  33863. text
  33864. }) {
  33865. // Flow function type definitions
  33866. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  33867. addTrailingComment(precedingNode, comment);
  33868. return true;
  33869. } // Real functions and TypeScript function type definitions
  33870. if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && isRealFunctionLikeNode(enclosingNode) && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ")") {
  33871. addTrailingComment(precedingNode, comment);
  33872. return true;
  33873. }
  33874. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  33875. const functionParamRightParenIndex = (() => {
  33876. const parameters = getFunctionParameters$5(enclosingNode);
  33877. if (parameters.length > 0) {
  33878. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(getLast$j(parameters)));
  33879. }
  33880. const functionParamLeftParenIndex = getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd$o(enclosingNode.id));
  33881. return functionParamLeftParenIndex !== false && getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  33882. })();
  33883. if (locStart$p(comment) > functionParamRightParenIndex) {
  33884. addBlockStatementFirstComment(followingNode, comment);
  33885. return true;
  33886. }
  33887. }
  33888. return false;
  33889. }
  33890. function handleImportSpecifierComments({
  33891. comment,
  33892. enclosingNode
  33893. }) {
  33894. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  33895. addLeadingComment(enclosingNode, comment);
  33896. return true;
  33897. }
  33898. return false;
  33899. }
  33900. function handleLabeledStatementComments({
  33901. comment,
  33902. enclosingNode
  33903. }) {
  33904. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  33905. addLeadingComment(enclosingNode, comment);
  33906. return true;
  33907. }
  33908. return false;
  33909. }
  33910. function handleBreakAndContinueStatementComments({
  33911. comment,
  33912. enclosingNode
  33913. }) {
  33914. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  33915. addTrailingComment(enclosingNode, comment);
  33916. return true;
  33917. }
  33918. return false;
  33919. }
  33920. function handleCallExpressionComments({
  33921. comment,
  33922. precedingNode,
  33923. enclosingNode
  33924. }) {
  33925. if (isCallExpression$c(enclosingNode) && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  33926. addLeadingComment(enclosingNode.arguments[0], comment);
  33927. return true;
  33928. }
  33929. return false;
  33930. }
  33931. function handleUnionTypeComments({
  33932. comment,
  33933. precedingNode,
  33934. enclosingNode,
  33935. followingNode
  33936. }) {
  33937. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  33938. if (isPrettierIgnoreComment(comment)) {
  33939. followingNode.prettierIgnore = true;
  33940. comment.unignore = true;
  33941. }
  33942. if (precedingNode) {
  33943. addTrailingComment(precedingNode, comment);
  33944. return true;
  33945. }
  33946. return false;
  33947. }
  33948. if (followingNode && (followingNode.type === "UnionTypeAnnotation" || followingNode.type === "TSUnionType") && isPrettierIgnoreComment(comment)) {
  33949. followingNode.types[0].prettierIgnore = true;
  33950. comment.unignore = true;
  33951. }
  33952. return false;
  33953. }
  33954. function handlePropertyComments({
  33955. comment,
  33956. enclosingNode
  33957. }) {
  33958. if (isObjectProperty$4(enclosingNode)) {
  33959. addLeadingComment(enclosingNode, comment);
  33960. return true;
  33961. }
  33962. return false;
  33963. }
  33964. function handleOnlyComments({
  33965. comment,
  33966. enclosingNode,
  33967. followingNode,
  33968. ast,
  33969. isLastComment
  33970. }) {
  33971. // With Flow the enclosingNode is undefined so use the AST instead.
  33972. if (ast && ast.body && ast.body.length === 0) {
  33973. if (isLastComment) {
  33974. addDanglingComment(ast, comment);
  33975. } else {
  33976. addLeadingComment(ast, comment);
  33977. }
  33978. return true;
  33979. }
  33980. if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && !isNonEmptyArray$g(enclosingNode.directives)) {
  33981. if (isLastComment) {
  33982. addDanglingComment(enclosingNode, comment);
  33983. } else {
  33984. addLeadingComment(enclosingNode, comment);
  33985. }
  33986. return true;
  33987. }
  33988. if (followingNode && followingNode.type === "Program" && followingNode.body.length === 0 && enclosingNode && enclosingNode.type === "ModuleExpression") {
  33989. addDanglingComment(followingNode, comment);
  33990. return true;
  33991. }
  33992. return false;
  33993. }
  33994. function handleForComments({
  33995. comment,
  33996. enclosingNode
  33997. }) {
  33998. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  33999. addLeadingComment(enclosingNode, comment);
  34000. return true;
  34001. }
  34002. return false;
  34003. }
  34004. function handleImportDeclarationComments({
  34005. comment,
  34006. precedingNode,
  34007. enclosingNode,
  34008. text
  34009. }) {
  34010. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && hasNewline$6(text, locEnd$o(comment))) {
  34011. addTrailingComment(precedingNode, comment);
  34012. return true;
  34013. }
  34014. return false;
  34015. }
  34016. function handleAssignmentPatternComments({
  34017. comment,
  34018. enclosingNode
  34019. }) {
  34020. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  34021. addLeadingComment(enclosingNode, comment);
  34022. return true;
  34023. }
  34024. return false;
  34025. }
  34026. function handleTypeAliasComments({
  34027. comment,
  34028. enclosingNode
  34029. }) {
  34030. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  34031. addLeadingComment(enclosingNode, comment);
  34032. return true;
  34033. }
  34034. return false;
  34035. }
  34036. function handleVariableDeclaratorComments({
  34037. comment,
  34038. enclosingNode,
  34039. followingNode
  34040. }) {
  34041. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression" || isBlockComment$3(comment))) {
  34042. addLeadingComment(followingNode, comment);
  34043. return true;
  34044. }
  34045. return false;
  34046. }
  34047. function handleTSFunctionTrailingComments({
  34048. comment,
  34049. enclosingNode,
  34050. followingNode,
  34051. text
  34052. }) {
  34053. if (!followingNode && enclosingNode && (enclosingNode.type === "TSMethodSignature" || enclosingNode.type === "TSDeclareFunction" || enclosingNode.type === "TSAbstractMethodDefinition") && getNextNonSpaceNonCommentCharacter$1(text, comment, locEnd$o) === ";") {
  34054. addTrailingComment(enclosingNode, comment);
  34055. return true;
  34056. }
  34057. return false;
  34058. }
  34059. function handleIgnoreComments({
  34060. comment,
  34061. enclosingNode,
  34062. followingNode
  34063. }) {
  34064. if (isPrettierIgnoreComment(comment) && enclosingNode && enclosingNode.type === "TSMappedType" && followingNode && followingNode.type === "TSTypeParameter" && followingNode.constraint) {
  34065. enclosingNode.prettierIgnore = true;
  34066. comment.unignore = true;
  34067. return true;
  34068. }
  34069. }
  34070. function handleTSMappedTypeComments({
  34071. comment,
  34072. precedingNode,
  34073. enclosingNode,
  34074. followingNode
  34075. }) {
  34076. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  34077. return false;
  34078. }
  34079. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  34080. addLeadingComment(followingNode.name, comment);
  34081. return true;
  34082. }
  34083. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  34084. addTrailingComment(precedingNode.constraint, comment);
  34085. return true;
  34086. }
  34087. return false;
  34088. }
  34089. /**
  34090. * @param {Node} node
  34091. * @returns {boolean}
  34092. */
  34093. function isRealFunctionLikeNode(node) {
  34094. return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "TSDeclareFunction" || node.type === "TSCallSignatureDeclaration" || node.type === "TSConstructSignatureDeclaration" || node.type === "TSMethodSignature" || node.type === "TSConstructorType" || node.type === "TSFunctionType" || node.type === "TSDeclareMethod";
  34095. }
  34096. /**
  34097. * @param {any} node
  34098. * @returns {Node[] | void}
  34099. */
  34100. function getCommentChildNodes(node, options) {
  34101. // Prevent attaching comments to FunctionExpression in this case:
  34102. // class Foo {
  34103. // bar() // comment
  34104. // {
  34105. // baz();
  34106. // }
  34107. // }
  34108. if ((options.parser === "typescript" || options.parser === "flow" || options.parser === "espree" || options.parser === "meriyah" || options.parser === "__babel_estree") && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && getFunctionParameters$5(node.value).length === 0 && !node.value.returnType && !isNonEmptyArray$g(node.value.typeParameters) && node.value.body) {
  34109. return [...(node.decorators || []), node.key, node.value.body];
  34110. }
  34111. }
  34112. /**
  34113. * @param {Comment} comment
  34114. * @returns {boolean}
  34115. */
  34116. function isTypeCastComment(comment) {
  34117. return isBlockComment$3(comment) && comment.value[0] === "*" && // TypeScript expects the type to be enclosed in curly brackets, however
  34118. // Closure Compiler accepts types in parens and even without any delimiters at all.
  34119. // That's why we just search for "@type".
  34120. /@type\b/.test(comment.value);
  34121. }
  34122. /**
  34123. * @param {AstPath} path
  34124. * @returns {boolean}
  34125. */
  34126. function willPrintOwnComments$1(path
  34127. /*, options */
  34128. ) {
  34129. const node = path.getValue();
  34130. const parent = path.getParentNode();
  34131. const hasFlowAnnotations = node => hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Leading)) || hasFlowAnnotationComment$1(getComments$4(node, CommentCheckFlags$e.Trailing));
  34132. return (node && (isJsxNode$6(node) || hasFlowShorthandAnnotationComment$2(node) || isCallExpression$c(parent) && hasFlowAnnotations(node)) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$1(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
  34133. }
  34134. var comments = {
  34135. handleOwnLineComment,
  34136. handleEndOfLineComment,
  34137. handleRemainingComment,
  34138. isTypeCastComment,
  34139. getCommentChildNodes,
  34140. willPrintOwnComments: willPrintOwnComments$1
  34141. };
  34142. const getLast$i = getLast_1;
  34143. const {
  34144. getFunctionParameters: getFunctionParameters$4,
  34145. getLeftSidePathName: getLeftSidePathName$1,
  34146. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$1,
  34147. hasNakedLeftSide: hasNakedLeftSide$2,
  34148. hasNode: hasNode$1,
  34149. isBitwiseOperator,
  34150. startsWithNoLookaheadToken: startsWithNoLookaheadToken$1,
  34151. shouldFlatten: shouldFlatten$1,
  34152. getPrecedence,
  34153. isCallExpression: isCallExpression$b,
  34154. isMemberExpression: isMemberExpression$7,
  34155. isObjectProperty: isObjectProperty$3
  34156. } = utils$5;
  34157. function needsParens(path, options) {
  34158. const parent = path.getParentNode();
  34159. if (!parent) {
  34160. return false;
  34161. }
  34162. const name = path.getName();
  34163. const node = path.getNode(); // to avoid unexpected `}}` in HTML interpolations
  34164. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
  34165. return true;
  34166. } // Only statements don't need parentheses.
  34167. if (isStatement(node)) {
  34168. return false;
  34169. }
  34170. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  34171. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  34172. // AST, which we handle separately.
  34173. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
  34174. return true;
  34175. } // Identifiers never need parentheses.
  34176. if (node.type === "Identifier") {
  34177. // ...unless those identifiers are embed placeholders. They might be substituted by complex
  34178. // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
  34179. // let tpl = html`<script> f((${expr}) / 2); </script>`;
  34180. // If the inner JS formatter removes the parens, the expression might change its meaning:
  34181. // f((a + b) / 2) vs f(a + b / 2)
  34182. if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
  34183. return true;
  34184. } // `for (async of []);` is invalid
  34185. if (name === "left" && node.name === "async" && parent.type === "ForOfStatement" && !parent.await) {
  34186. return true;
  34187. }
  34188. return false;
  34189. }
  34190. switch (parent.type) {
  34191. case "ParenthesizedExpression":
  34192. return false;
  34193. case "ClassDeclaration":
  34194. case "ClassExpression":
  34195. {
  34196. // Add parens around the extends clause of a class. It is needed for almost
  34197. // all expressions.
  34198. if (name === "superClass" && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression" || node.type === "TSNonNullExpression")) {
  34199. return true;
  34200. }
  34201. break;
  34202. }
  34203. case "ExportDefaultDeclaration":
  34204. {
  34205. return (// `export default function` or `export default class` can't be followed by
  34206. // anything after. So an expression like `export default (function(){}).toString()`
  34207. // needs to be followed by a parentheses
  34208. shouldWrapFunctionForExportDefault(path, options) || // `export default (foo, bar)` also needs parentheses
  34209. node.type === "SequenceExpression"
  34210. );
  34211. }
  34212. case "Decorator":
  34213. {
  34214. if (name === "expression") {
  34215. let hasCallExpression = false;
  34216. let hasMemberExpression = false;
  34217. let current = node;
  34218. while (current) {
  34219. switch (current.type) {
  34220. case "MemberExpression":
  34221. hasMemberExpression = true;
  34222. current = current.object;
  34223. break;
  34224. case "CallExpression":
  34225. if (
  34226. /** @(x().y) */
  34227. hasMemberExpression ||
  34228. /** @(x().y()) */
  34229. hasCallExpression) {
  34230. return options.parser !== "typescript";
  34231. }
  34232. hasCallExpression = true;
  34233. current = current.callee;
  34234. break;
  34235. case "Identifier":
  34236. return false;
  34237. case "TaggedTemplateExpression":
  34238. // babel-parser cannot parse
  34239. // @foo`bar`
  34240. return options.parser !== "typescript";
  34241. default:
  34242. return true;
  34243. }
  34244. }
  34245. return true;
  34246. }
  34247. break;
  34248. }
  34249. case "ExpressionStatement":
  34250. {
  34251. if (startsWithNoLookaheadToken$1(node,
  34252. /* forbidFunctionClassAndDoExpr */
  34253. true)) {
  34254. return true;
  34255. }
  34256. break;
  34257. }
  34258. case "ArrowFunctionExpression":
  34259. {
  34260. if (name === "body" && node.type !== "SequenceExpression" && // these have parens added anyway
  34261. startsWithNoLookaheadToken$1(node,
  34262. /* forbidFunctionClassAndDoExpr */
  34263. false)) {
  34264. return true;
  34265. }
  34266. break;
  34267. }
  34268. }
  34269. switch (node.type) {
  34270. case "UpdateExpression":
  34271. if (parent.type === "UnaryExpression") {
  34272. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  34273. }
  34274. // else fallthrough
  34275. case "UnaryExpression":
  34276. switch (parent.type) {
  34277. case "UnaryExpression":
  34278. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  34279. case "BindExpression":
  34280. return true;
  34281. case "MemberExpression":
  34282. case "OptionalMemberExpression":
  34283. return name === "object";
  34284. case "TaggedTemplateExpression":
  34285. return true;
  34286. case "NewExpression":
  34287. case "CallExpression":
  34288. case "OptionalCallExpression":
  34289. return name === "callee";
  34290. case "BinaryExpression":
  34291. return name === "left" && parent.operator === "**";
  34292. case "TSNonNullExpression":
  34293. return true;
  34294. default:
  34295. return false;
  34296. }
  34297. case "BinaryExpression":
  34298. {
  34299. if (parent.type === "UpdateExpression") {
  34300. return true;
  34301. } // We add parentheses to any `a in b` inside `ForStatement` initializer
  34302. // https://github.com/prettier/prettier/issues/907#issuecomment-284304321
  34303. if (node.operator === "in" && isPathInForStatementInitializer(path)) {
  34304. return true;
  34305. }
  34306. if (node.operator === "|>" && node.extra && node.extra.parenthesized) {
  34307. const grandParent = path.getParentNode(1);
  34308. if (grandParent.type === "BinaryExpression" && grandParent.operator === "|>") {
  34309. return true;
  34310. }
  34311. }
  34312. }
  34313. // fallthrough
  34314. case "TSTypeAssertion":
  34315. case "TSAsExpression":
  34316. case "LogicalExpression":
  34317. switch (parent.type) {
  34318. case "TSAsExpression":
  34319. // example: foo as unknown as Bar
  34320. return node.type !== "TSAsExpression";
  34321. case "ConditionalExpression":
  34322. return node.type === "TSAsExpression";
  34323. case "CallExpression":
  34324. case "NewExpression":
  34325. case "OptionalCallExpression":
  34326. return name === "callee";
  34327. case "ClassExpression":
  34328. case "ClassDeclaration":
  34329. return name === "superClass";
  34330. case "TSTypeAssertion":
  34331. case "TaggedTemplateExpression":
  34332. case "UnaryExpression":
  34333. case "JSXSpreadAttribute":
  34334. case "SpreadElement":
  34335. case "SpreadProperty":
  34336. case "BindExpression":
  34337. case "AwaitExpression":
  34338. case "TSNonNullExpression":
  34339. case "UpdateExpression":
  34340. return true;
  34341. case "MemberExpression":
  34342. case "OptionalMemberExpression":
  34343. return name === "object";
  34344. case "AssignmentExpression":
  34345. case "AssignmentPattern":
  34346. return name === "left" && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  34347. case "LogicalExpression":
  34348. if (node.type === "LogicalExpression") {
  34349. return parent.operator !== node.operator;
  34350. }
  34351. // else fallthrough
  34352. case "BinaryExpression":
  34353. {
  34354. const {
  34355. operator,
  34356. type
  34357. } = node;
  34358. if (!operator && type !== "TSTypeAssertion") {
  34359. return true;
  34360. }
  34361. const precedence = getPrecedence(operator);
  34362. const parentOperator = parent.operator;
  34363. const parentPrecedence = getPrecedence(parentOperator);
  34364. if (parentPrecedence > precedence) {
  34365. return true;
  34366. }
  34367. if (name === "right" && parentPrecedence === precedence) {
  34368. return true;
  34369. }
  34370. if (parentPrecedence === precedence && !shouldFlatten$1(parentOperator, operator)) {
  34371. return true;
  34372. }
  34373. if (parentPrecedence < precedence && operator === "%") {
  34374. return parentOperator === "+" || parentOperator === "-";
  34375. } // Add parenthesis when working with bitwise operators
  34376. // It's not strictly needed but helps with code understanding
  34377. if (isBitwiseOperator(parentOperator)) {
  34378. return true;
  34379. }
  34380. return false;
  34381. }
  34382. default:
  34383. return false;
  34384. }
  34385. case "SequenceExpression":
  34386. switch (parent.type) {
  34387. case "ReturnStatement":
  34388. return false;
  34389. case "ForStatement":
  34390. // Although parentheses wouldn't hurt around sequence
  34391. // expressions in the head of for loops, traditional style
  34392. // dictates that e.g. i++, j++ should not be wrapped with
  34393. // parentheses.
  34394. return false;
  34395. case "ExpressionStatement":
  34396. return name !== "expression";
  34397. case "ArrowFunctionExpression":
  34398. // We do need parentheses, but SequenceExpressions are handled
  34399. // specially when printing bodies of arrow functions.
  34400. return name !== "body";
  34401. default:
  34402. // Otherwise err on the side of overparenthesization, adding
  34403. // explicit exceptions above if this proves overzealous.
  34404. return true;
  34405. }
  34406. case "YieldExpression":
  34407. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  34408. return true;
  34409. }
  34410. // else fallthrough
  34411. case "AwaitExpression":
  34412. switch (parent.type) {
  34413. case "TaggedTemplateExpression":
  34414. case "UnaryExpression":
  34415. case "LogicalExpression":
  34416. case "SpreadElement":
  34417. case "SpreadProperty":
  34418. case "TSAsExpression":
  34419. case "TSNonNullExpression":
  34420. case "BindExpression":
  34421. return true;
  34422. case "MemberExpression":
  34423. case "OptionalMemberExpression":
  34424. return name === "object";
  34425. case "NewExpression":
  34426. case "CallExpression":
  34427. case "OptionalCallExpression":
  34428. return name === "callee";
  34429. case "ConditionalExpression":
  34430. return name === "test";
  34431. case "BinaryExpression":
  34432. {
  34433. if (!node.argument && parent.operator === "|>") {
  34434. return false;
  34435. }
  34436. return true;
  34437. }
  34438. default:
  34439. return false;
  34440. }
  34441. case "TSConditionalType":
  34442. if (name === "extendsType" && parent.type === "TSConditionalType") {
  34443. return true;
  34444. }
  34445. // fallthrough
  34446. case "TSFunctionType":
  34447. case "TSConstructorType":
  34448. if (name === "checkType" && parent.type === "TSConditionalType") {
  34449. return true;
  34450. }
  34451. // fallthrough
  34452. case "TSUnionType":
  34453. case "TSIntersectionType":
  34454. if ((parent.type === "TSUnionType" || parent.type === "TSIntersectionType") && parent.types.length > 1 && (!node.types || node.types.length > 1)) {
  34455. return true;
  34456. }
  34457. // fallthrough
  34458. case "TSInferType":
  34459. if (node.type === "TSInferType" && parent.type === "TSRestType") {
  34460. return false;
  34461. }
  34462. // fallthrough
  34463. case "TSTypeOperator":
  34464. return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || name === "objectType" && parent.type === "TSIndexedAccessType" || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && path.getParentNode(1).type.startsWith("TSJSDoc");
  34465. case "ArrayTypeAnnotation":
  34466. return parent.type === "NullableTypeAnnotation";
  34467. case "IntersectionTypeAnnotation":
  34468. case "UnionTypeAnnotation":
  34469. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  34470. case "NullableTypeAnnotation":
  34471. return parent.type === "ArrayTypeAnnotation" || name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  34472. case "FunctionTypeAnnotation":
  34473. {
  34474. const ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
  34475. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || name === "objectType" && (ancestor.type === "IndexedAccessType" || ancestor.type === "OptionalIndexedAccessType") || // We should check ancestor's parent to know whether the parentheses
  34476. // are really needed, but since ??T doesn't make sense this check
  34477. // will almost never be true.
  34478. ancestor.type === "NullableTypeAnnotation" || // See #5283
  34479. parent.type === "FunctionTypeParam" && parent.name === null && getFunctionParameters$4(node).some(param => param.typeAnnotation && param.typeAnnotation.type === "NullableTypeAnnotation");
  34480. }
  34481. case "OptionalIndexedAccessType":
  34482. return name === "objectType" && parent.type === "IndexedAccessType";
  34483. case "TypeofTypeAnnotation":
  34484. return name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
  34485. case "StringLiteral":
  34486. case "NumericLiteral":
  34487. case "Literal":
  34488. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && !parent.directive) {
  34489. // To avoid becoming a directive
  34490. const grandParent = path.getParentNode(1);
  34491. return grandParent.type === "Program" || grandParent.type === "BlockStatement";
  34492. }
  34493. return name === "object" && parent.type === "MemberExpression" && typeof node.value === "number";
  34494. case "AssignmentExpression":
  34495. {
  34496. const grandParent = path.getParentNode(1);
  34497. if (name === "body" && parent.type === "ArrowFunctionExpression") {
  34498. return true;
  34499. }
  34500. if (name === "key" && (parent.type === "ClassProperty" || parent.type === "PropertyDefinition") && parent.computed) {
  34501. return false;
  34502. }
  34503. if ((name === "init" || name === "update") && parent.type === "ForStatement") {
  34504. return false;
  34505. }
  34506. if (parent.type === "ExpressionStatement") {
  34507. return node.left.type === "ObjectPattern";
  34508. }
  34509. if (name === "key" && parent.type === "TSPropertySignature") {
  34510. return false;
  34511. }
  34512. if (parent.type === "AssignmentExpression") {
  34513. return false;
  34514. }
  34515. if (parent.type === "SequenceExpression" && grandParent && grandParent.type === "ForStatement" && (grandParent.init === parent || grandParent.update === parent)) {
  34516. return false;
  34517. }
  34518. if (name === "value" && parent.type === "Property" && grandParent && grandParent.type === "ObjectPattern" && grandParent.properties.includes(parent)) {
  34519. return false;
  34520. }
  34521. if (parent.type === "NGChainedExpression") {
  34522. return false;
  34523. }
  34524. return true;
  34525. }
  34526. case "ConditionalExpression":
  34527. switch (parent.type) {
  34528. case "TaggedTemplateExpression":
  34529. case "UnaryExpression":
  34530. case "SpreadElement":
  34531. case "SpreadProperty":
  34532. case "BinaryExpression":
  34533. case "LogicalExpression":
  34534. case "NGPipeExpression":
  34535. case "ExportDefaultDeclaration":
  34536. case "AwaitExpression":
  34537. case "JSXSpreadAttribute":
  34538. case "TSTypeAssertion":
  34539. case "TypeCastExpression":
  34540. case "TSAsExpression":
  34541. case "TSNonNullExpression":
  34542. return true;
  34543. case "NewExpression":
  34544. case "CallExpression":
  34545. case "OptionalCallExpression":
  34546. return name === "callee";
  34547. case "ConditionalExpression":
  34548. return name === "test";
  34549. case "MemberExpression":
  34550. case "OptionalMemberExpression":
  34551. return name === "object";
  34552. default:
  34553. return false;
  34554. }
  34555. case "FunctionExpression":
  34556. switch (parent.type) {
  34557. case "NewExpression":
  34558. case "CallExpression":
  34559. case "OptionalCallExpression":
  34560. // Not always necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  34561. // Is necessary if it is `expression` of `ExpressionStatement`.
  34562. return name === "callee";
  34563. case "TaggedTemplateExpression":
  34564. return true;
  34565. // This is basically a kind of IIFE.
  34566. default:
  34567. return false;
  34568. }
  34569. case "ArrowFunctionExpression":
  34570. switch (parent.type) {
  34571. case "BinaryExpression":
  34572. return parent.operator !== "|>" || node.extra && node.extra.parenthesized;
  34573. case "NewExpression":
  34574. case "CallExpression":
  34575. case "OptionalCallExpression":
  34576. return name === "callee";
  34577. case "MemberExpression":
  34578. case "OptionalMemberExpression":
  34579. return name === "object";
  34580. case "TSAsExpression":
  34581. case "TSNonNullExpression":
  34582. case "BindExpression":
  34583. case "TaggedTemplateExpression":
  34584. case "UnaryExpression":
  34585. case "LogicalExpression":
  34586. case "AwaitExpression":
  34587. case "TSTypeAssertion":
  34588. return true;
  34589. case "ConditionalExpression":
  34590. return name === "test";
  34591. default:
  34592. return false;
  34593. }
  34594. case "ClassExpression":
  34595. switch (parent.type) {
  34596. case "NewExpression":
  34597. return name === "callee";
  34598. default:
  34599. return false;
  34600. }
  34601. case "OptionalMemberExpression":
  34602. case "OptionalCallExpression":
  34603. {
  34604. const parentParent = path.getParentNode(1);
  34605. if (name === "object" && parent.type === "MemberExpression" || name === "callee" && (parent.type === "CallExpression" || parent.type === "NewExpression") || parent.type === "TSNonNullExpression" && parentParent.type === "MemberExpression" && parentParent.object === parent) {
  34606. return true;
  34607. }
  34608. }
  34609. // fallthrough
  34610. case "CallExpression":
  34611. case "MemberExpression":
  34612. case "TaggedTemplateExpression":
  34613. case "TSNonNullExpression":
  34614. if (name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression")) {
  34615. let object = node;
  34616. while (object) {
  34617. switch (object.type) {
  34618. case "CallExpression":
  34619. case "OptionalCallExpression":
  34620. return true;
  34621. case "MemberExpression":
  34622. case "OptionalMemberExpression":
  34623. case "BindExpression":
  34624. object = object.object;
  34625. break;
  34626. // tagged templates are basically member expressions from a grammar perspective
  34627. // see https://tc39.github.io/ecma262/#prod-MemberExpression
  34628. case "TaggedTemplateExpression":
  34629. object = object.tag;
  34630. break;
  34631. case "TSNonNullExpression":
  34632. object = object.expression;
  34633. break;
  34634. default:
  34635. return false;
  34636. }
  34637. }
  34638. }
  34639. return false;
  34640. case "BindExpression":
  34641. return name === "callee" && (parent.type === "BindExpression" || parent.type === "NewExpression") || name === "object" && isMemberExpression$7(parent);
  34642. case "NGPipeExpression":
  34643. if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" && // Preserve parens for compatibility with AngularJS expressions
  34644. !(node.extra && node.extra.parenthesized) || parent.type === "ArrayExpression" || isCallExpression$b(parent) && parent.arguments[name] === node || name === "right" && parent.type === "NGPipeExpression" || name === "property" && parent.type === "MemberExpression" || parent.type === "AssignmentExpression") {
  34645. return false;
  34646. }
  34647. return true;
  34648. case "JSXFragment":
  34649. case "JSXElement":
  34650. return name === "callee" || name === "left" && parent.type === "BinaryExpression" && parent.operator === "<" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "NewExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && !isCallExpression$b(parent) && !isObjectProperty$3(parent) && parent.type !== "ReturnStatement" && parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && parent.type !== "YieldExpression";
  34651. case "TypeAnnotation":
  34652. return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node);
  34653. }
  34654. return false;
  34655. }
  34656. function isStatement(node) {
  34657. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "PropertyDefinition" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
  34658. }
  34659. function isPathInForStatementInitializer(path) {
  34660. let i = 0;
  34661. let node = path.getValue();
  34662. while (node) {
  34663. const parent = path.getParentNode(i++);
  34664. if (parent && parent.type === "ForStatement" && parent.init === node) {
  34665. return true;
  34666. }
  34667. node = parent;
  34668. }
  34669. return false;
  34670. }
  34671. function includesFunctionTypeInObjectType(node) {
  34672. return hasNode$1(node, n1 => n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined) || undefined);
  34673. }
  34674. function endsWithRightBracket(node) {
  34675. switch (node.type) {
  34676. case "ObjectExpression":
  34677. return true;
  34678. default:
  34679. return false;
  34680. }
  34681. }
  34682. function isFollowedByRightBracket(path) {
  34683. const node = path.getValue();
  34684. const parent = path.getParentNode();
  34685. const name = path.getName();
  34686. switch (parent.type) {
  34687. case "NGPipeExpression":
  34688. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  34689. return path.callParent(isFollowedByRightBracket);
  34690. }
  34691. break;
  34692. case "ObjectProperty":
  34693. if (name === "value") {
  34694. const parentParent = path.getParentNode(1);
  34695. return getLast$i(parentParent.properties) === parent;
  34696. }
  34697. break;
  34698. case "BinaryExpression":
  34699. case "LogicalExpression":
  34700. if (name === "right") {
  34701. return path.callParent(isFollowedByRightBracket);
  34702. }
  34703. break;
  34704. case "ConditionalExpression":
  34705. if (name === "alternate") {
  34706. return path.callParent(isFollowedByRightBracket);
  34707. }
  34708. break;
  34709. case "UnaryExpression":
  34710. if (parent.prefix) {
  34711. return path.callParent(isFollowedByRightBracket);
  34712. }
  34713. break;
  34714. }
  34715. return false;
  34716. }
  34717. function shouldWrapFunctionForExportDefault(path, options) {
  34718. const node = path.getValue();
  34719. const parent = path.getParentNode();
  34720. if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
  34721. return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
  34722. // (e.g. `export default (function() {})();`)
  34723. // in this case we don't need to add extra parens
  34724. !needsParens(path, options);
  34725. }
  34726. if (!hasNakedLeftSide$2(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
  34727. return false;
  34728. }
  34729. return path.call(childPath => shouldWrapFunctionForExportDefault(childPath, options), ...getLeftSidePathName$1(path, node));
  34730. }
  34731. var needsParens_1 = needsParens;
  34732. function preprocess$8(ast, options) {
  34733. switch (options.parser) {
  34734. case "json":
  34735. case "json5":
  34736. case "json-stringify":
  34737. case "__js_expression":
  34738. case "__vue_expression":
  34739. return Object.assign(Object.assign({}, ast), {}, {
  34740. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  34741. node: ast,
  34742. comments: [],
  34743. rootMarker: options.rootMarker
  34744. });
  34745. default:
  34746. return ast;
  34747. }
  34748. }
  34749. var printPreprocess$3 = preprocess$8;
  34750. const {
  34751. builders: {
  34752. join: join$s,
  34753. line: line$x,
  34754. group: group$A,
  34755. softline: softline$q,
  34756. indent: indent$t
  34757. }
  34758. } = require$$7$3;
  34759. function printHtmlBinding$1(path, options, print) {
  34760. const node = path.getValue();
  34761. if (options.__onHtmlBindingRoot && path.getName() === null) {
  34762. options.__onHtmlBindingRoot(node, options);
  34763. }
  34764. if (node.type !== "File") {
  34765. return;
  34766. }
  34767. if (options.__isVueForBindingLeft) {
  34768. return path.call(functionDeclarationPath => {
  34769. const printed = join$s([",", line$x], functionDeclarationPath.map(print, "params"));
  34770. const {
  34771. params
  34772. } = functionDeclarationPath.getValue();
  34773. if (params.length === 1) {
  34774. return printed;
  34775. }
  34776. return ["(", indent$t([softline$q, group$A(printed)]), softline$q, ")"];
  34777. }, "program", "body", 0);
  34778. }
  34779. if (options.__isVueBindings) {
  34780. return path.call(functionDeclarationPath => join$s([",", line$x], functionDeclarationPath.map(print, "params")), "program", "body", 0);
  34781. }
  34782. } // based on https://github.com/prettier/prettier/blob/main/src/language-html/syntax-vue.js isVueEventBindingExpression()
  34783. function isVueEventBindingExpression$3(node) {
  34784. switch (node.type) {
  34785. case "MemberExpression":
  34786. switch (node.property.type) {
  34787. case "Identifier":
  34788. case "NumericLiteral":
  34789. case "StringLiteral":
  34790. return isVueEventBindingExpression$3(node.object);
  34791. }
  34792. return false;
  34793. case "Identifier":
  34794. return true;
  34795. default:
  34796. return false;
  34797. }
  34798. }
  34799. var htmlBinding = {
  34800. isVueEventBindingExpression: isVueEventBindingExpression$3,
  34801. printHtmlBinding: printHtmlBinding$1
  34802. };
  34803. const {
  34804. printComments: printComments$5
  34805. } = comments$4;
  34806. const {
  34807. getLast: getLast$h
  34808. } = util$8;
  34809. const {
  34810. builders: {
  34811. join: join$r,
  34812. line: line$w,
  34813. softline: softline$p,
  34814. group: group$z,
  34815. indent: indent$s,
  34816. align: align$4,
  34817. ifBreak: ifBreak$m,
  34818. indentIfBreak: indentIfBreak$3
  34819. },
  34820. utils: {
  34821. cleanDoc: cleanDoc$2,
  34822. getDocParts: getDocParts$6,
  34823. isConcat: isConcat$1
  34824. }
  34825. } = require$$7$3;
  34826. const {
  34827. hasLeadingOwnLineComment: hasLeadingOwnLineComment$3,
  34828. isBinaryish: isBinaryish$3,
  34829. isJsxNode: isJsxNode$5,
  34830. shouldFlatten,
  34831. hasComment: hasComment$g,
  34832. CommentCheckFlags: CommentCheckFlags$d,
  34833. isCallExpression: isCallExpression$a,
  34834. isMemberExpression: isMemberExpression$6,
  34835. isObjectProperty: isObjectProperty$2,
  34836. isEnabledHackPipeline
  34837. } = utils$5;
  34838. /** @typedef {import("../../document").Doc} Doc */
  34839. let uid = 0;
  34840. function printBinaryishExpression$2(path, options, print) {
  34841. const node = path.getValue();
  34842. const parent = path.getParentNode();
  34843. const parentParent = path.getParentNode(1);
  34844. const isInsideParenthesis = node !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "SwitchStatement" || parent.type === "DoWhileStatement");
  34845. const isHackPipeline = isEnabledHackPipeline(options) && node.operator === "|>";
  34846. const parts = printBinaryishExpressions(path, print, options,
  34847. /* isNested */
  34848. false, isInsideParenthesis); // if (
  34849. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  34850. // ) {
  34851. //
  34852. // looks super weird, we want to break the children if the parent breaks
  34853. //
  34854. // if (
  34855. // this.hasPlugin("dynamicImports") &&
  34856. // this.lookahead().type === tt.parenLeft
  34857. // ) {
  34858. if (isInsideParenthesis) {
  34859. return parts;
  34860. }
  34861. if (isHackPipeline) {
  34862. return group$z(parts);
  34863. } // Break between the parens in
  34864. // unaries or in a member or specific call expression, i.e.
  34865. //
  34866. // (
  34867. // a &&
  34868. // b &&
  34869. // c
  34870. // ).call()
  34871. if (isCallExpression$a(parent) && parent.callee === node || parent.type === "UnaryExpression" || isMemberExpression$6(parent) && !parent.computed) {
  34872. return group$z([indent$s([softline$p, ...parts]), softline$p]);
  34873. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  34874. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  34875. const shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "ThrowStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || node.operator !== "|" && parent.type === "JsExpressionRoot" || node.type !== "NGPipeExpression" && (parent.type === "NGRoot" && options.parser === "__ng_binding" || parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || node === parent.body && parent.type === "ArrowFunctionExpression" || node !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "ThrowStatement" && !isCallExpression$a(parentParent) || parent.type === "TemplateLiteral";
  34876. const shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "PropertyDefinition" || parent.type === "TSAbstractPropertyDefinition" || parent.type === "ClassPrivateProperty" || isObjectProperty$2(parent);
  34877. const samePrecedenceSubExpression = isBinaryish$3(node.left) && shouldFlatten(node.operator, node.left.operator);
  34878. if (shouldNotIndent || shouldInlineLogicalExpression$1(node) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression$1(node) && shouldIndentIfInlining) {
  34879. return group$z(parts);
  34880. }
  34881. if (parts.length === 0) {
  34882. return "";
  34883. } // If the right part is a JSX node, we include it in a separate group to
  34884. // prevent it breaking the whole chain, so we can print the expression like:
  34885. //
  34886. // foo && bar && (
  34887. // <Foo>
  34888. // <Bar />
  34889. // </Foo>
  34890. // )
  34891. const hasJsx = isJsxNode$5(node.right);
  34892. const firstGroupIndex = parts.findIndex(part => typeof part !== "string" && !Array.isArray(part) && part.type === "group"); // Separate the leftmost expression, possibly with its leading comments.
  34893. const headParts = parts.slice(0, firstGroupIndex === -1 ? 1 : firstGroupIndex + 1);
  34894. const rest = parts.slice(headParts.length, hasJsx ? -1 : undefined);
  34895. const groupId = Symbol("logicalChain-" + ++uid);
  34896. const chain = group$z([// Don't include the initial expression in the indentation
  34897. // level. The first item is guaranteed to be the first
  34898. // left-most expression.
  34899. ...headParts, indent$s(rest)], {
  34900. id: groupId
  34901. });
  34902. if (!hasJsx) {
  34903. return chain;
  34904. }
  34905. const jsxPart = getLast$h(parts);
  34906. return group$z([chain, indentIfBreak$3(jsxPart, {
  34907. groupId
  34908. })]);
  34909. } // For binary expressions to be consistent, we need to group
  34910. // subsequent operators with the same precedence level under a single
  34911. // group. Otherwise they will be nested such that some of them break
  34912. // onto new lines but not all. Operators with the same precedence
  34913. // level should either all break or not. Because we group them by
  34914. // precedence level and the AST is structured based on precedence
  34915. // level, things are naturally broken up correctly, i.e. `&&` is
  34916. // broken before `+`.
  34917. function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
  34918. const node = path.getValue(); // Simply print the node normally.
  34919. if (!isBinaryish$3(node)) {
  34920. return [group$z(print())];
  34921. }
  34922. /** @type{Doc[]} */
  34923. let parts = []; // We treat BinaryExpression and LogicalExpression nodes the same.
  34924. // Put all operators with the same precedence level in the same
  34925. // group. The reason we only need to do this with the `left`
  34926. // expression is because given an expression like `1 + 2 - 3`, it
  34927. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  34928. // is where the rest of the expression will exist. Binary
  34929. // expressions on the right side mean they have a difference
  34930. // precedence level and should be treated as a separate group, so
  34931. // print them normally. (This doesn't hold for the `**` operator,
  34932. // which is unique in that it is right-associative.)
  34933. if (shouldFlatten(node.operator, node.left.operator)) {
  34934. // Flatten them out by recursively calling this function.
  34935. parts = path.call(left => printBinaryishExpressions(left, print, options,
  34936. /* isNested */
  34937. true, isInsideParenthesis), "left");
  34938. } else {
  34939. parts.push(group$z(print("left")));
  34940. }
  34941. const shouldInline = shouldInlineLogicalExpression$1(node);
  34942. const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$3(options.originalText, node.right);
  34943. const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  34944. const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group$z(indent$s([softline$p, ": ", join$r([softline$p, ":", ifBreak$m(" ")], path.map(print, "arguments").map(arg => align$4(2, group$z(arg))))])) : "";
  34945. /** @type {Doc} */
  34946. let right;
  34947. if (shouldInline) {
  34948. right = [operator, " ", print("right"), rightSuffix];
  34949. } else {
  34950. const isHackPipeline = isEnabledHackPipeline(options) && operator === "|>";
  34951. const rightContent = isHackPipeline ? path.call(left => printBinaryishExpressions(left, print, options,
  34952. /* isNested */
  34953. true, isInsideParenthesis), "right") : print("right");
  34954. right = [lineBeforeOperator ? line$w : "", operator, lineBeforeOperator ? " " : line$w, rightContent, rightSuffix];
  34955. } // If there's only a single binary expression, we want to create a group
  34956. // in order to avoid having a small right part like -1 be on its own line.
  34957. const parent = path.getParentNode();
  34958. const shouldBreak = hasComment$g(node.left, CommentCheckFlags$d.Trailing | CommentCheckFlags$d.Line);
  34959. const shouldGroup = shouldBreak || !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  34960. parts.push(lineBeforeOperator ? "" : " ", shouldGroup ? group$z(right, {
  34961. shouldBreak
  34962. }) : right); // The root comments are already printed, but we need to manually print
  34963. // the other ones since we don't call the normal print on BinaryExpression,
  34964. // only for the left and right parts
  34965. if (isNested && hasComment$g(node)) {
  34966. const printed = cleanDoc$2(printComments$5(path, parts, options));
  34967. /* istanbul ignore else */
  34968. if (isConcat$1(printed) || printed.type === "fill") {
  34969. return getDocParts$6(printed);
  34970. }
  34971. return [printed];
  34972. }
  34973. return parts;
  34974. }
  34975. function shouldInlineLogicalExpression$1(node) {
  34976. if (node.type !== "LogicalExpression") {
  34977. return false;
  34978. }
  34979. if (node.right.type === "ObjectExpression" && node.right.properties.length > 0) {
  34980. return true;
  34981. }
  34982. if (node.right.type === "ArrayExpression" && node.right.elements.length > 0) {
  34983. return true;
  34984. }
  34985. if (isJsxNode$5(node.right)) {
  34986. return true;
  34987. }
  34988. return false;
  34989. }
  34990. var binaryish = {
  34991. printBinaryishExpression: printBinaryishExpression$2,
  34992. shouldInlineLogicalExpression: shouldInlineLogicalExpression$1
  34993. };
  34994. const {
  34995. builders: {
  34996. join: join$q,
  34997. line: line$v,
  34998. group: group$y
  34999. }
  35000. } = require$$7$3;
  35001. const {
  35002. hasNode,
  35003. hasComment: hasComment$f,
  35004. getComments: getComments$3
  35005. } = utils$5;
  35006. const {
  35007. printBinaryishExpression: printBinaryishExpression$1
  35008. } = binaryish;
  35009. /** @typedef {import("../../common/ast-path")} AstPath */
  35010. function printAngular$1(path, options, print) {
  35011. const node = path.getValue(); // Angular nodes always starts with `NG`
  35012. if (!node.type.startsWith("NG")) {
  35013. return;
  35014. }
  35015. switch (node.type) {
  35016. case "NGRoot":
  35017. return [print("node"), !hasComment$f(node.node) ? "" : " //" + getComments$3(node.node)[0].value.trimEnd()];
  35018. case "NGPipeExpression":
  35019. return printBinaryishExpression$1(path, options, print);
  35020. case "NGChainedExpression":
  35021. return group$y(join$q([";", line$v], path.map(childPath => hasNgSideEffect(childPath) ? print() : ["(", print(), ")"], "expressions")));
  35022. case "NGEmptyExpression":
  35023. return "";
  35024. case "NGQuotedExpression":
  35025. return [node.prefix, ": ", node.value.trim()];
  35026. case "NGMicrosyntax":
  35027. return path.map((childPath, index) => [index === 0 ? "" : isNgForOf(childPath.getValue(), index, node) ? " " : [";", line$v], print()], "body");
  35028. case "NGMicrosyntaxKey":
  35029. return /^[$_a-z][\w$]*(?:-[$_a-z][\w$])*$/i.test(node.name) ? node.name : JSON.stringify(node.name);
  35030. case "NGMicrosyntaxExpression":
  35031. return [print("expression"), node.alias === null ? "" : [" as ", print("alias")]];
  35032. case "NGMicrosyntaxKeyedExpression":
  35033. {
  35034. const index = path.getName();
  35035. const parentNode = path.getParentNode();
  35036. const shouldNotPrintColon = isNgForOf(node, index, parentNode) || (index === 1 && (node.key.name === "then" || node.key.name === "else") || index === 2 && node.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
  35037. return [print("key"), shouldNotPrintColon ? " " : ": ", print("expression")];
  35038. }
  35039. case "NGMicrosyntaxLet":
  35040. return ["let ", print("key"), node.value === null ? "" : [" = ", print("value")]];
  35041. case "NGMicrosyntaxAs":
  35042. return [print("key"), " as ", print("alias")];
  35043. default:
  35044. /* istanbul ignore next */
  35045. throw new Error(`Unknown Angular node type: ${JSON.stringify(node.type)}.`);
  35046. }
  35047. }
  35048. function isNgForOf(node, index, parentNode) {
  35049. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  35050. }
  35051. /** identify if an angular expression seems to have side effects */
  35052. /**
  35053. * @param {AstPath} path
  35054. * @returns {boolean}
  35055. */
  35056. function hasNgSideEffect(path) {
  35057. return hasNode(path.getValue(), node => {
  35058. switch (node.type) {
  35059. case undefined:
  35060. return false;
  35061. case "CallExpression":
  35062. case "OptionalCallExpression":
  35063. case "AssignmentExpression":
  35064. return true;
  35065. }
  35066. });
  35067. }
  35068. var angular = {
  35069. printAngular: printAngular$1
  35070. };
  35071. const {
  35072. printComments: printComments$4,
  35073. printDanglingComments: printDanglingComments$d
  35074. } = comments$4;
  35075. const {
  35076. builders: {
  35077. line: line$u,
  35078. hardline: hardline$w,
  35079. softline: softline$o,
  35080. group: group$x,
  35081. indent: indent$r,
  35082. conditionalGroup: conditionalGroup$4,
  35083. fill: fill$8,
  35084. ifBreak: ifBreak$l,
  35085. lineSuffixBoundary,
  35086. join: join$p
  35087. },
  35088. utils: {
  35089. willBreak: willBreak$5
  35090. }
  35091. } = require$$7$3;
  35092. const {
  35093. getLast: getLast$g,
  35094. getPreferredQuote: getPreferredQuote$1
  35095. } = util$8;
  35096. const {
  35097. isJsxNode: isJsxNode$4,
  35098. rawText: rawText$4,
  35099. isLiteral: isLiteral$2,
  35100. isCallExpression: isCallExpression$9,
  35101. isStringLiteral: isStringLiteral$4,
  35102. isBinaryish: isBinaryish$2,
  35103. hasComment: hasComment$e,
  35104. CommentCheckFlags: CommentCheckFlags$c,
  35105. hasNodeIgnoreComment
  35106. } = utils$5;
  35107. const pathNeedsParens$5 = needsParens_1;
  35108. const {
  35109. willPrintOwnComments
  35110. } = comments;
  35111. const isEmptyStringOrAnyLine = doc => doc === "" || doc === line$u || doc === hardline$w || doc === softline$o;
  35112. /**
  35113. * @typedef {import("../../common/ast-path")} AstPath
  35114. * @typedef {import("../types/estree").Node} Node
  35115. * @typedef {import("../types/estree").JSXElement} JSXElement
  35116. */
  35117. // JSX expands children from the inside-out, instead of the outside-in.
  35118. // This is both to break children before attributes,
  35119. // and to ensure that when children break, their parents do as well.
  35120. //
  35121. // Any element that is written without any newlines and fits on a single line
  35122. // is left that way.
  35123. // Not only that, any user-written-line containing multiple JSX siblings
  35124. // should also be kept on one line if possible,
  35125. // so each user-written-line is wrapped in its own group.
  35126. //
  35127. // Elements that contain newlines or don't fit on a single line (recursively)
  35128. // are fully-split, using hardline and shouldBreak: true.
  35129. //
  35130. // To support that case properly, all leading and trailing spaces
  35131. // are stripped from the list of children, and replaced with a single hardline.
  35132. function printJsxElementInternal(path, options, print) {
  35133. const node = path.getValue();
  35134. if (node.type === "JSXElement" && isEmptyJsxElement(node)) {
  35135. return [print("openingElement"), print("closingElement")];
  35136. }
  35137. const openingLines = node.type === "JSXElement" ? print("openingElement") : print("openingFragment");
  35138. const closingLines = node.type === "JSXElement" ? print("closingElement") : print("closingFragment");
  35139. if (node.children.length === 1 && node.children[0].type === "JSXExpressionContainer" && (node.children[0].expression.type === "TemplateLiteral" || node.children[0].expression.type === "TaggedTemplateExpression")) {
  35140. return [openingLines, ...path.map(print, "children"), closingLines];
  35141. } // Convert `{" "}` to text nodes containing a space.
  35142. // This makes it easy to turn them into `jsxWhitespace` which
  35143. // can then print as either a space or `{" "}` when breaking.
  35144. node.children = node.children.map(child => {
  35145. if (isJsxWhitespaceExpression(child)) {
  35146. return {
  35147. type: "JSXText",
  35148. value: " ",
  35149. raw: " "
  35150. };
  35151. }
  35152. return child;
  35153. });
  35154. const containsTag = node.children.some(isJsxNode$4);
  35155. const containsMultipleExpressions = node.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
  35156. const containsMultipleAttributes = node.type === "JSXElement" && node.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  35157. let forcedBreak = willBreak$5(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  35158. const isMdxBlock = path.getParentNode().rootMarker === "mdx";
  35159. const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  35160. const jsxWhitespace = isMdxBlock ? " " : ifBreak$l([rawJsxWhitespace, softline$o], " ");
  35161. const isFacebookTranslationTag = node.openingElement && node.openingElement.name && node.openingElement.name.name === "fbt";
  35162. const children = printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
  35163. const containsText = node.children.some(child => isMeaningfulJsxText(child)); // We can end up we multiple whitespace elements with empty string
  35164. // content between them.
  35165. // We need to remove empty whitespace and softlines before JSX whitespace
  35166. // to get the correct output.
  35167. for (let i = children.length - 2; i >= 0; i--) {
  35168. const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  35169. const isPairOfHardlines = children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === hardline$w;
  35170. const isLineFollowedByJsxWhitespace = (children[i] === softline$o || children[i] === hardline$w) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  35171. const isJsxWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$o || children[i + 2] === hardline$w);
  35172. const isDoubleJsxWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  35173. const isPairOfHardOrSoftLines = children[i] === softline$o && children[i + 1] === "" && children[i + 2] === hardline$w || children[i] === hardline$w && children[i + 1] === "" && children[i + 2] === softline$o;
  35174. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJsxWhitespace || isDoubleJsxWhitespace || isPairOfHardOrSoftLines) {
  35175. children.splice(i, 2);
  35176. } else if (isJsxWhitespaceFollowedByLine) {
  35177. children.splice(i + 1, 2);
  35178. }
  35179. } // Trim trailing lines (or empty strings)
  35180. while (children.length > 0 && isEmptyStringOrAnyLine(getLast$g(children))) {
  35181. children.pop();
  35182. } // Trim leading lines (or empty strings)
  35183. while (children.length > 1 && isEmptyStringOrAnyLine(children[0]) && isEmptyStringOrAnyLine(children[1])) {
  35184. children.shift();
  35185. children.shift();
  35186. } // Tweak how we format children if outputting this element over multiple lines.
  35187. // Also detect whether we will force this element to output over multiple lines.
  35188. const multilineChildren = [];
  35189. for (const [i, child] of children.entries()) {
  35190. // There are a number of situations where we need to ensure we display
  35191. // whitespace as `{" "}` when outputting this element over multiple lines.
  35192. if (child === jsxWhitespace) {
  35193. if (i === 1 && children[i - 1] === "") {
  35194. if (children.length === 2) {
  35195. // Solitary whitespace
  35196. multilineChildren.push(rawJsxWhitespace);
  35197. continue;
  35198. } // Leading whitespace
  35199. multilineChildren.push([rawJsxWhitespace, hardline$w]);
  35200. continue;
  35201. } else if (i === children.length - 1) {
  35202. // Trailing whitespace
  35203. multilineChildren.push(rawJsxWhitespace);
  35204. continue;
  35205. } else if (children[i - 1] === "" && children[i - 2] === hardline$w) {
  35206. // Whitespace after line break
  35207. multilineChildren.push(rawJsxWhitespace);
  35208. continue;
  35209. }
  35210. }
  35211. multilineChildren.push(child);
  35212. if (willBreak$5(child)) {
  35213. forcedBreak = true;
  35214. }
  35215. } // If there is text we use `fill` to fit as much onto each line as possible.
  35216. // When there is no text (just tags and expressions) we use `group`
  35217. // to output each on a separate line.
  35218. const content = containsText ? fill$8(multilineChildren) : group$x(multilineChildren, {
  35219. shouldBreak: true
  35220. });
  35221. if (isMdxBlock) {
  35222. return content;
  35223. }
  35224. const multiLineElem = group$x([openingLines, indent$r([hardline$w, content]), hardline$w, closingLines]);
  35225. if (forcedBreak) {
  35226. return multiLineElem;
  35227. }
  35228. return conditionalGroup$4([group$x([openingLines, ...children, closingLines]), multiLineElem]);
  35229. } // JSX Children are strange, mostly for two reasons:
  35230. // 1. JSX reads newlines into string values, instead of skipping them like JS
  35231. // 2. up to one whitespace between elements within a line is significant,
  35232. // but not between lines.
  35233. //
  35234. // Leading, trailing, and lone whitespace all need to
  35235. // turn themselves into the rather ugly `{' '}` when breaking.
  35236. //
  35237. // We print JSX using the `fill` doc primitive.
  35238. // This requires that we give it an array of alternating
  35239. // content and whitespace elements.
  35240. // To ensure this we add dummy `""` content elements as needed.
  35241. function printJsxChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
  35242. const parts = [];
  35243. path.each((childPath, i, children) => {
  35244. const child = childPath.getValue();
  35245. if (isLiteral$2(child)) {
  35246. const text = rawText$4(child); // Contains a non-whitespace character
  35247. if (isMeaningfulJsxText(child)) {
  35248. const words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  35249. if (words[0] === "") {
  35250. parts.push("");
  35251. words.shift();
  35252. if (/\n/.test(words[0])) {
  35253. const next = children[i + 1];
  35254. parts.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  35255. } else {
  35256. parts.push(jsxWhitespace);
  35257. }
  35258. words.shift();
  35259. }
  35260. let endWhitespace; // Ends with whitespace
  35261. if (getLast$g(words) === "") {
  35262. words.pop();
  35263. endWhitespace = words.pop();
  35264. } // This was whitespace only without a new line.
  35265. if (words.length === 0) {
  35266. return;
  35267. }
  35268. for (const [i, word] of words.entries()) {
  35269. if (i % 2 === 1) {
  35270. parts.push(line$u);
  35271. } else {
  35272. parts.push(word);
  35273. }
  35274. }
  35275. if (endWhitespace !== undefined) {
  35276. if (/\n/.test(endWhitespace)) {
  35277. const next = children[i + 1];
  35278. parts.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$g(parts), child, next));
  35279. } else {
  35280. parts.push(jsxWhitespace);
  35281. }
  35282. } else {
  35283. const next = children[i + 1];
  35284. parts.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$g(parts), child, next));
  35285. }
  35286. } else if (/\n/.test(text)) {
  35287. // Keep (up to one) blank line between tags/expressions/text.
  35288. // Note: We don't keep blank lines between text elements.
  35289. if (text.match(/\n/g).length > 1) {
  35290. parts.push("", hardline$w);
  35291. }
  35292. } else {
  35293. parts.push("", jsxWhitespace);
  35294. }
  35295. } else {
  35296. const printedChild = print();
  35297. parts.push(printedChild);
  35298. const next = children[i + 1];
  35299. const directlyFollowedByMeaningfulText = next && isMeaningfulJsxText(next);
  35300. if (directlyFollowedByMeaningfulText) {
  35301. const firstWord = trimJsxWhitespace(rawText$4(next)).split(matchJsxWhitespaceRegex)[0];
  35302. parts.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
  35303. } else {
  35304. parts.push(hardline$w);
  35305. }
  35306. }
  35307. }, "children");
  35308. return parts;
  35309. }
  35310. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  35311. if (isFacebookTranslationTag) {
  35312. return "";
  35313. }
  35314. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  35315. return child.length === 1 ? softline$o : hardline$w;
  35316. }
  35317. return softline$o;
  35318. }
  35319. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  35320. if (isFacebookTranslationTag) {
  35321. return hardline$w;
  35322. }
  35323. if (child.length === 1) {
  35324. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$w : softline$o;
  35325. }
  35326. return hardline$w;
  35327. }
  35328. function maybeWrapJsxElementInParens(path, elem, options) {
  35329. const parent = path.getParentNode();
  35330. /* istanbul ignore next */
  35331. if (!parent) {
  35332. return elem;
  35333. }
  35334. const NO_WRAP_PARENTS = {
  35335. ArrayExpression: true,
  35336. JSXAttribute: true,
  35337. JSXElement: true,
  35338. JSXExpressionContainer: true,
  35339. JSXFragment: true,
  35340. ExpressionStatement: true,
  35341. CallExpression: true,
  35342. OptionalCallExpression: true,
  35343. ConditionalExpression: true,
  35344. JsExpressionRoot: true
  35345. };
  35346. if (NO_WRAP_PARENTS[parent.type]) {
  35347. return elem;
  35348. }
  35349. const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallExpression$9, node => node.type === "JSXExpressionContainer");
  35350. const needsParens = pathNeedsParens$5(path, options);
  35351. return group$x([needsParens ? "" : ifBreak$l("("), indent$r([softline$o, elem]), softline$o, needsParens ? "" : ifBreak$l(")")], {
  35352. shouldBreak
  35353. });
  35354. }
  35355. function printJsxAttribute(path, options, print) {
  35356. const node = path.getValue();
  35357. const parts = [];
  35358. parts.push(print("name"));
  35359. if (node.value) {
  35360. let res;
  35361. if (isStringLiteral$4(node.value)) {
  35362. const raw = rawText$4(node.value); // Remove enclosing quotes and unescape
  35363. // all quotes so we get an accurate preferred quote
  35364. let final = raw.slice(1, -1).replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  35365. const {
  35366. escaped,
  35367. quote,
  35368. regex
  35369. } = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
  35370. final = final.replace(regex, escaped);
  35371. res = [quote, final, quote];
  35372. } else {
  35373. res = print("value");
  35374. }
  35375. parts.push("=", res);
  35376. }
  35377. return parts;
  35378. }
  35379. function printJsxExpressionContainer(path, options, print) {
  35380. const node = path.getValue();
  35381. const parent = path.getParentNode(0);
  35382. const shouldInline = node.expression.type === "JSXEmptyExpression" || !hasComment$e(node.expression) && (node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression" || node.expression.type === "ArrowFunctionExpression" || isCallExpression$9(node.expression) || node.expression.type === "FunctionExpression" || node.expression.type === "TemplateLiteral" || node.expression.type === "TaggedTemplateExpression" || node.expression.type === "DoExpression" || isJsxNode$4(parent) && (node.expression.type === "ConditionalExpression" || isBinaryish$2(node.expression)));
  35383. if (shouldInline) {
  35384. return group$x(["{", print("expression"), lineSuffixBoundary, "}"]);
  35385. }
  35386. return group$x(["{", indent$r([softline$o, print("expression")]), softline$o, lineSuffixBoundary, "}"]);
  35387. }
  35388. function printJsxOpeningElement(path, options, print) {
  35389. const node = path.getValue();
  35390. const nameHasComments = node.name && hasComment$e(node.name) || node.typeParameters && hasComment$e(node.typeParameters); // Don't break self-closing elements with no attributes and no comments
  35391. if (node.selfClosing && node.attributes.length === 0 && !nameHasComments) {
  35392. return ["<", print("name"), print("typeParameters"), " />"];
  35393. } // don't break up opening elements with a single long text attribute
  35394. if (node.attributes && node.attributes.length === 1 && node.attributes[0].value && isStringLiteral$4(node.attributes[0].value) && !node.attributes[0].value.value.includes("\n") && // We should break for the following cases:
  35395. // <div
  35396. // // comment
  35397. // attr="value"
  35398. // >
  35399. // <div
  35400. // attr="value"
  35401. // // comment
  35402. // >
  35403. !nameHasComments && !hasComment$e(node.attributes[0])) {
  35404. return group$x(["<", print("name"), print("typeParameters"), " ", ...path.map(print, "attributes"), node.selfClosing ? " />" : ">"]);
  35405. }
  35406. const lastAttrHasTrailingComments = node.attributes.length > 0 && hasComment$e(getLast$g(node.attributes), CommentCheckFlags$c.Trailing);
  35407. const bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  35408. // kept unbroken regardless of `bracketSameLine`.
  35409. // jsxBracketSameLine is deprecated in favour of bracketSameLine,
  35410. // but is still needed for backwards compatibility.
  35411. node.attributes.length === 0 && !nameHasComments || (options.bracketSameLine || options.jsxBracketSameLine) && ( // We should print the bracket in a new line for the following cases:
  35412. // <div
  35413. // // comment
  35414. // >
  35415. // <div
  35416. // attr // comment
  35417. // >
  35418. !nameHasComments || node.attributes.length > 0) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  35419. // string literal with newlines
  35420. const shouldBreak = node.attributes && node.attributes.some(attr => attr.value && isStringLiteral$4(attr.value) && attr.value.value.includes("\n"));
  35421. return group$x(["<", print("name"), print("typeParameters"), indent$r(path.map(() => [line$u, print()], "attributes")), node.selfClosing ? line$u : bracketSameLine ? ">" : softline$o, node.selfClosing ? "/>" : bracketSameLine ? "" : ">"], {
  35422. shouldBreak
  35423. });
  35424. }
  35425. function printJsxClosingElement(path, options, print) {
  35426. const node = path.getValue();
  35427. const parts = [];
  35428. parts.push("</");
  35429. const printed = print("name");
  35430. if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Line)) {
  35431. parts.push(indent$r([hardline$w, printed]), hardline$w);
  35432. } else if (hasComment$e(node.name, CommentCheckFlags$c.Leading | CommentCheckFlags$c.Block)) {
  35433. parts.push(" ", printed);
  35434. } else {
  35435. parts.push(printed);
  35436. }
  35437. parts.push(">");
  35438. return parts;
  35439. }
  35440. function printJsxOpeningClosingFragment(path, options
  35441. /*, print*/
  35442. ) {
  35443. const node = path.getValue();
  35444. const nodeHasComment = hasComment$e(node);
  35445. const hasOwnLineComment = hasComment$e(node, CommentCheckFlags$c.Line);
  35446. const isOpeningFragment = node.type === "JSXOpeningFragment";
  35447. return [isOpeningFragment ? "<" : "</", indent$r([hasOwnLineComment ? hardline$w : nodeHasComment && !isOpeningFragment ? " " : "", printDanglingComments$d(path, options, true)]), hasOwnLineComment ? hardline$w : "", ">"];
  35448. }
  35449. function printJsxElement(path, options, print) {
  35450. const elem = printComments$4(path, printJsxElementInternal(path, options, print), options);
  35451. return maybeWrapJsxElementInParens(path, elem, options);
  35452. }
  35453. function printJsxEmptyExpression(path, options
  35454. /*, print*/
  35455. ) {
  35456. const node = path.getValue();
  35457. const requiresHardline = hasComment$e(node, CommentCheckFlags$c.Line);
  35458. return [printDanglingComments$d(path, options,
  35459. /* sameIndent */
  35460. !requiresHardline), requiresHardline ? hardline$w : ""];
  35461. } // `JSXSpreadAttribute` and `JSXSpreadChild`
  35462. function printJsxSpreadAttribute(path, options, print) {
  35463. const node = path.getValue();
  35464. return ["{", path.call(p => {
  35465. const printed = ["...", print()];
  35466. const node = p.getValue();
  35467. if (!hasComment$e(node) || !willPrintOwnComments(p)) {
  35468. return printed;
  35469. }
  35470. return [indent$r([softline$o, printComments$4(p, printed, options)]), softline$o];
  35471. }, node.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"];
  35472. }
  35473. function printJsx$1(path, options, print) {
  35474. const node = path.getValue(); // JSX nodes always starts with `JSX`
  35475. if (!node.type.startsWith("JSX")) {
  35476. return;
  35477. }
  35478. switch (node.type) {
  35479. case "JSXAttribute":
  35480. return printJsxAttribute(path, options, print);
  35481. case "JSXIdentifier":
  35482. return String(node.name);
  35483. case "JSXNamespacedName":
  35484. return join$p(":", [print("namespace"), print("name")]);
  35485. case "JSXMemberExpression":
  35486. return join$p(".", [print("object"), print("property")]);
  35487. case "JSXSpreadAttribute":
  35488. return printJsxSpreadAttribute(path, options, print);
  35489. case "JSXSpreadChild":
  35490. {
  35491. // Same as `printJsxSpreadAttribute`
  35492. const printJsxSpreadChild = printJsxSpreadAttribute;
  35493. return printJsxSpreadChild(path, options, print);
  35494. }
  35495. case "JSXExpressionContainer":
  35496. return printJsxExpressionContainer(path, options, print);
  35497. case "JSXFragment":
  35498. case "JSXElement":
  35499. return printJsxElement(path, options, print);
  35500. case "JSXOpeningElement":
  35501. return printJsxOpeningElement(path, options, print);
  35502. case "JSXClosingElement":
  35503. return printJsxClosingElement(path, options, print);
  35504. case "JSXOpeningFragment":
  35505. case "JSXClosingFragment":
  35506. return printJsxOpeningClosingFragment(path, options
  35507. /*, print*/
  35508. );
  35509. case "JSXEmptyExpression":
  35510. return printJsxEmptyExpression(path, options
  35511. /*, print*/
  35512. );
  35513. case "JSXText":
  35514. /* istanbul ignore next */
  35515. throw new Error("JSXTest should be handled by JSXElement");
  35516. default:
  35517. /* istanbul ignore next */
  35518. throw new Error(`Unknown JSX node type: ${JSON.stringify(node.type)}.`);
  35519. }
  35520. } // Only space, newline, carriage return, and tab are treated as whitespace
  35521. // inside JSX.
  35522. const jsxWhitespaceChars = " \n\r\t";
  35523. const matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)");
  35524. const containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  35525. const trimJsxWhitespace = text => text.replace(new RegExp("(?:^" + matchJsxWhitespaceRegex.source + "|" + matchJsxWhitespaceRegex.source + "$)"), "");
  35526. /**
  35527. * @param {JSXElement} node
  35528. * @returns {boolean}
  35529. */
  35530. function isEmptyJsxElement(node) {
  35531. if (node.children.length === 0) {
  35532. return true;
  35533. }
  35534. if (node.children.length > 1) {
  35535. return false;
  35536. } // if there is one text child and does not contain any meaningful text
  35537. // we can treat the element as empty.
  35538. const child = node.children[0];
  35539. return isLiteral$2(child) && !isMeaningfulJsxText(child);
  35540. } // Meaningful if it contains non-whitespace characters,
  35541. // or it contains whitespace without a new line.
  35542. /**
  35543. * @param {Node} node
  35544. * @returns {boolean}
  35545. */
  35546. function isMeaningfulJsxText(node) {
  35547. return isLiteral$2(node) && (containsNonJsxWhitespaceRegex.test(rawText$4(node)) || !/\n/.test(rawText$4(node)));
  35548. } // Detect an expression node representing `{" "}`
  35549. function isJsxWhitespaceExpression(node) {
  35550. return node.type === "JSXExpressionContainer" && isLiteral$2(node.expression) && node.expression.value === " " && !hasComment$e(node.expression);
  35551. }
  35552. /**
  35553. * @param {AstPath} path
  35554. * @returns {boolean}
  35555. */
  35556. function hasJsxIgnoreComment$1(path) {
  35557. const node = path.getValue();
  35558. const parent = path.getParentNode();
  35559. if (!parent || !node || !isJsxNode$4(node) || !isJsxNode$4(parent)) {
  35560. return false;
  35561. } // Lookup the previous sibling, ignoring any empty JSXText elements
  35562. const index = parent.children.indexOf(node);
  35563. let prevSibling = null;
  35564. for (let i = index; i > 0; i--) {
  35565. const candidate = parent.children[i - 1];
  35566. if (candidate.type === "JSXText" && !isMeaningfulJsxText(candidate)) {
  35567. continue;
  35568. }
  35569. prevSibling = candidate;
  35570. break;
  35571. }
  35572. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && hasNodeIgnoreComment(prevSibling.expression);
  35573. }
  35574. var jsx = {
  35575. hasJsxIgnoreComment: hasJsxIgnoreComment$1,
  35576. printJsx: printJsx$1
  35577. };
  35578. var $ = _export;
  35579. var flattenIntoArray = flattenIntoArray_1;
  35580. var toObject = toObject$4;
  35581. var lengthOfArrayLike = lengthOfArrayLike$6;
  35582. var toIntegerOrInfinity = toIntegerOrInfinity$3;
  35583. var arraySpeciesCreate = arraySpeciesCreate$2;
  35584. // `Array.prototype.flat` method
  35585. // https://tc39.es/ecma262/#sec-array.prototype.flat
  35586. $({ target: 'Array', proto: true }, {
  35587. flat: function flat(/* depthArg = 1 */) {
  35588. var depthArg = arguments.length ? arguments[0] : undefined;
  35589. var O = toObject(this);
  35590. var sourceLen = lengthOfArrayLike(O);
  35591. var A = arraySpeciesCreate(O, 0);
  35592. A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
  35593. return A;
  35594. }
  35595. });
  35596. var internalObjectKeys = objectKeysInternal;
  35597. var enumBugKeys$1 = enumBugKeys$3;
  35598. // `Object.keys` method
  35599. // https://tc39.es/ecma262/#sec-object.keys
  35600. // eslint-disable-next-line es/no-object-keys -- safe
  35601. var objectKeys$1 = Object.keys || function keys(O) {
  35602. return internalObjectKeys(O, enumBugKeys$1);
  35603. };
  35604. var DESCRIPTORS = descriptors$1;
  35605. var definePropertyModule$1 = objectDefineProperty;
  35606. var anObject$1 = anObject$7;
  35607. var toIndexedObject = toIndexedObject$4;
  35608. var objectKeys = objectKeys$1;
  35609. // `Object.defineProperties` method
  35610. // https://tc39.es/ecma262/#sec-object.defineproperties
  35611. // eslint-disable-next-line es/no-object-defineproperties -- safe
  35612. var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  35613. anObject$1(O);
  35614. var props = toIndexedObject(Properties);
  35615. var keys = objectKeys(Properties);
  35616. var length = keys.length;
  35617. var index = 0;
  35618. var key;
  35619. while (length > index) definePropertyModule$1.f(O, key = keys[index++], props[key]);
  35620. return O;
  35621. };
  35622. var getBuiltIn = getBuiltIn$5;
  35623. var html$2 = getBuiltIn('document', 'documentElement');
  35624. /* global ActiveXObject -- old IE, WSH */
  35625. var anObject = anObject$7;
  35626. var defineProperties = objectDefineProperties;
  35627. var enumBugKeys = enumBugKeys$3;
  35628. var hiddenKeys = hiddenKeys$4;
  35629. var html$1 = html$2;
  35630. var documentCreateElement = documentCreateElement$1;
  35631. var sharedKey = sharedKey$2;
  35632. var GT = '>';
  35633. var LT = '<';
  35634. var PROTOTYPE = 'prototype';
  35635. var SCRIPT = 'script';
  35636. var IE_PROTO = sharedKey('IE_PROTO');
  35637. var EmptyConstructor = function () { /* empty */ };
  35638. var scriptTag = function (content) {
  35639. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  35640. };
  35641. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  35642. var NullProtoObjectViaActiveX = function (activeXDocument) {
  35643. activeXDocument.write(scriptTag(''));
  35644. activeXDocument.close();
  35645. var temp = activeXDocument.parentWindow.Object;
  35646. activeXDocument = null; // avoid memory leak
  35647. return temp;
  35648. };
  35649. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  35650. var NullProtoObjectViaIFrame = function () {
  35651. // Thrash, waste and sodomy: IE GC bug
  35652. var iframe = documentCreateElement('iframe');
  35653. var JS = 'java' + SCRIPT + ':';
  35654. var iframeDocument;
  35655. iframe.style.display = 'none';
  35656. html$1.appendChild(iframe);
  35657. // https://github.com/zloirock/core-js/issues/475
  35658. iframe.src = String(JS);
  35659. iframeDocument = iframe.contentWindow.document;
  35660. iframeDocument.open();
  35661. iframeDocument.write(scriptTag('document.F=Object'));
  35662. iframeDocument.close();
  35663. return iframeDocument.F;
  35664. };
  35665. // Check for document.domain and active x support
  35666. // No need to use active x approach when document.domain is not set
  35667. // see https://github.com/es-shims/es5-shim/issues/150
  35668. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  35669. // avoid IE GC bug
  35670. var activeXDocument;
  35671. var NullProtoObject = function () {
  35672. try {
  35673. activeXDocument = new ActiveXObject('htmlfile');
  35674. } catch (error) { /* ignore */ }
  35675. NullProtoObject = typeof document != 'undefined'
  35676. ? document.domain && activeXDocument
  35677. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  35678. : NullProtoObjectViaIFrame()
  35679. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  35680. var length = enumBugKeys.length;
  35681. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  35682. return NullProtoObject();
  35683. };
  35684. hiddenKeys[IE_PROTO] = true;
  35685. // `Object.create` method
  35686. // https://tc39.es/ecma262/#sec-object.create
  35687. var objectCreate = Object.create || function create(O, Properties) {
  35688. var result;
  35689. if (O !== null) {
  35690. EmptyConstructor[PROTOTYPE] = anObject(O);
  35691. result = new EmptyConstructor();
  35692. EmptyConstructor[PROTOTYPE] = null;
  35693. // add "__proto__" for Object.getPrototypeOf polyfill
  35694. result[IE_PROTO] = O;
  35695. } else result = NullProtoObject();
  35696. return Properties === undefined ? result : defineProperties(result, Properties);
  35697. };
  35698. var wellKnownSymbol = wellKnownSymbol$7;
  35699. var create = objectCreate;
  35700. var definePropertyModule = objectDefineProperty;
  35701. var UNSCOPABLES = wellKnownSymbol('unscopables');
  35702. var ArrayPrototype = Array.prototype;
  35703. // Array.prototype[@@unscopables]
  35704. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  35705. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  35706. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  35707. configurable: true,
  35708. value: create(null)
  35709. });
  35710. }
  35711. // add a key to Array.prototype[@@unscopables]
  35712. var addToUnscopables$1 = function (key) {
  35713. ArrayPrototype[UNSCOPABLES][key] = true;
  35714. };
  35715. // this method was added to unscopables after implementation
  35716. // in popular engines, so it's moved to a separate module
  35717. var addToUnscopables = addToUnscopables$1;
  35718. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  35719. addToUnscopables('flat');
  35720. const {
  35721. isNonEmptyArray: isNonEmptyArray$f
  35722. } = util$8;
  35723. const {
  35724. builders: {
  35725. indent: indent$q,
  35726. join: join$o,
  35727. line: line$t
  35728. }
  35729. } = require$$7$3;
  35730. const {
  35731. isFlowAnnotationComment: isFlowAnnotationComment$1
  35732. } = utils$5;
  35733. function printOptionalToken$9(path) {
  35734. const node = path.getValue();
  35735. if (!node.optional || // It's an optional computed method parsed by typescript-estree.
  35736. // "?" is printed in `printMethod`.
  35737. node.type === "Identifier" && node === path.getParentNode().key) {
  35738. return "";
  35739. }
  35740. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  35741. return "?.";
  35742. }
  35743. return "?";
  35744. }
  35745. function printFunctionTypeParameters$4(path, options, print) {
  35746. const fun = path.getValue();
  35747. if (fun.typeArguments) {
  35748. return print("typeArguments");
  35749. }
  35750. if (fun.typeParameters) {
  35751. return print("typeParameters");
  35752. }
  35753. return "";
  35754. }
  35755. function printTypeAnnotation$5(path, options, print) {
  35756. const node = path.getValue();
  35757. if (!node.typeAnnotation) {
  35758. return "";
  35759. }
  35760. const parentNode = path.getParentNode();
  35761. const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  35762. const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  35763. if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation)) {
  35764. return [" /*: ", print("typeAnnotation"), " */"];
  35765. }
  35766. return [isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", print("typeAnnotation")];
  35767. }
  35768. function printBindExpressionCallee$2(path, options, print) {
  35769. return ["::", print("callee")];
  35770. }
  35771. function printTypeScriptModifiers$2(path, options, print) {
  35772. const node = path.getValue();
  35773. if (!isNonEmptyArray$f(node.modifiers)) {
  35774. return "";
  35775. }
  35776. return [join$o(" ", path.map(print, "modifiers")), " "];
  35777. }
  35778. function adjustClause$1(node, clause, forceSpace) {
  35779. if (node.type === "EmptyStatement") {
  35780. return ";";
  35781. }
  35782. if (node.type === "BlockStatement" || forceSpace) {
  35783. return [" ", clause];
  35784. }
  35785. return indent$q([line$t, clause]);
  35786. }
  35787. function printRestSpread$2(path, options, print) {
  35788. return ["...", print("argument"), printTypeAnnotation$5(path, options, print)];
  35789. }
  35790. var misc$1 = {
  35791. printOptionalToken: printOptionalToken$9,
  35792. printFunctionTypeParameters: printFunctionTypeParameters$4,
  35793. printBindExpressionCallee: printBindExpressionCallee$2,
  35794. printTypeScriptModifiers: printTypeScriptModifiers$2,
  35795. printTypeAnnotation: printTypeAnnotation$5,
  35796. printRestSpread: printRestSpread$2,
  35797. adjustClause: adjustClause$1
  35798. };
  35799. const {
  35800. printDanglingComments: printDanglingComments$c
  35801. } = comments$4;
  35802. const {
  35803. builders: {
  35804. line: line$s,
  35805. softline: softline$n,
  35806. hardline: hardline$v,
  35807. group: group$w,
  35808. indent: indent$p,
  35809. ifBreak: ifBreak$k,
  35810. fill: fill$7
  35811. }
  35812. } = require$$7$3;
  35813. const {
  35814. getLast: getLast$f,
  35815. hasNewline: hasNewline$5
  35816. } = util$8;
  35817. const {
  35818. shouldPrintComma: shouldPrintComma$a,
  35819. hasComment: hasComment$d,
  35820. CommentCheckFlags: CommentCheckFlags$b,
  35821. isNextLineEmpty: isNextLineEmpty$b,
  35822. isNumericLiteral: isNumericLiteral$4,
  35823. isSignedNumericLiteral: isSignedNumericLiteral$1
  35824. } = utils$5;
  35825. const {
  35826. locStart: locStart$o
  35827. } = loc$6;
  35828. const {
  35829. printOptionalToken: printOptionalToken$8,
  35830. printTypeAnnotation: printTypeAnnotation$4
  35831. } = misc$1;
  35832. /** @typedef {import("../../document").Doc} Doc */
  35833. function printArray$1(path, options, print) {
  35834. const node = path.getValue();
  35835. /** @type{Doc[]} */
  35836. const parts = [];
  35837. const openBracket = node.type === "TupleExpression" ? "#[" : "[";
  35838. const closeBracket = "]";
  35839. if (node.elements.length === 0) {
  35840. if (!hasComment$d(node, CommentCheckFlags$b.Dangling)) {
  35841. parts.push(openBracket, closeBracket);
  35842. } else {
  35843. parts.push(group$w([openBracket, printDanglingComments$c(path, options), softline$n, closeBracket]));
  35844. }
  35845. } else {
  35846. const lastElem = getLast$f(node.elements);
  35847. const canHaveTrailingComma = !(lastElem && lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  35848. // changes its length based on the number of commas. The algorithm
  35849. // is that if the last argument is null, we need to force insert
  35850. // a comma to ensure JavaScript recognizes it.
  35851. // [,].length === 1
  35852. // [1,].length === 1
  35853. // [1,,].length === 2
  35854. //
  35855. // Note that getLast returns null if the array is empty, but
  35856. // we already check for an empty array just above so we are safe
  35857. const needsForcedTrailingComma = lastElem === null;
  35858. const groupId = Symbol("array");
  35859. const shouldBreak = !options.__inJestEach && node.elements.length > 1 && node.elements.every((element, i, elements) => {
  35860. const elementType = element && element.type;
  35861. if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") {
  35862. return false;
  35863. }
  35864. const nextElement = elements[i + 1];
  35865. if (nextElement && elementType !== nextElement.type) {
  35866. return false;
  35867. }
  35868. const itemsKey = elementType === "ArrayExpression" ? "elements" : "properties";
  35869. return element[itemsKey] && element[itemsKey].length > 1;
  35870. });
  35871. const shouldUseConciseFormatting = isConciselyPrintedArray$1(node, options);
  35872. const trailingComma = !canHaveTrailingComma ? "" : needsForcedTrailingComma ? "," : !shouldPrintComma$a(options) ? "" : shouldUseConciseFormatting ? ifBreak$k(",", "", {
  35873. groupId
  35874. }) : ifBreak$k(",");
  35875. parts.push(group$w([openBracket, indent$p([softline$n, shouldUseConciseFormatting ? printArrayItemsConcisely(path, options, print, trailingComma) : [printArrayItems$3(path, options, "elements", print), trailingComma], printDanglingComments$c(path, options,
  35876. /* sameIndent */
  35877. true)]), softline$n, closeBracket], {
  35878. shouldBreak,
  35879. id: groupId
  35880. }));
  35881. }
  35882. parts.push(printOptionalToken$8(path), printTypeAnnotation$4(path, options, print));
  35883. return parts;
  35884. }
  35885. function isConciselyPrintedArray$1(node, options) {
  35886. return node.elements.length > 1 && node.elements.every(element => element && (isNumericLiteral$4(element) || isSignedNumericLiteral$1(element) && !hasComment$d(element.argument)) && !hasComment$d(element, CommentCheckFlags$b.Trailing | CommentCheckFlags$b.Line, comment => !hasNewline$5(options.originalText, locStart$o(comment), {
  35887. backwards: true
  35888. })));
  35889. }
  35890. function printArrayItems$3(path, options, printPath, print) {
  35891. const printedElements = [];
  35892. let separatorParts = [];
  35893. path.each(childPath => {
  35894. printedElements.push(separatorParts, group$w(print()));
  35895. separatorParts = [",", line$s];
  35896. if (childPath.getValue() && isNextLineEmpty$b(childPath.getValue(), options)) {
  35897. separatorParts.push(softline$n);
  35898. }
  35899. }, printPath);
  35900. return printedElements;
  35901. }
  35902. function printArrayItemsConcisely(path, options, print, trailingComma) {
  35903. const parts = [];
  35904. path.each((childPath, i, elements) => {
  35905. const isLast = i === elements.length - 1;
  35906. parts.push([print(), isLast ? trailingComma : ","]);
  35907. if (!isLast) {
  35908. parts.push(isNextLineEmpty$b(childPath.getValue(), options) ? [hardline$v, hardline$v] : hasComment$d(elements[i + 1], CommentCheckFlags$b.Leading | CommentCheckFlags$b.Line) ? hardline$v : line$s);
  35909. }
  35910. }, "elements");
  35911. return fill$7(parts);
  35912. }
  35913. var array = {
  35914. printArray: printArray$1,
  35915. printArrayItems: printArrayItems$3,
  35916. isConciselyPrintedArray: isConciselyPrintedArray$1
  35917. };
  35918. const {
  35919. printDanglingComments: printDanglingComments$b
  35920. } = comments$4;
  35921. const {
  35922. getLast: getLast$e,
  35923. getPenultimate
  35924. } = util$8;
  35925. const {
  35926. getFunctionParameters: getFunctionParameters$3,
  35927. hasComment: hasComment$c,
  35928. CommentCheckFlags: CommentCheckFlags$a,
  35929. isFunctionCompositionArgs,
  35930. isJsxNode: isJsxNode$3,
  35931. isLongCurriedCallExpression: isLongCurriedCallExpression$1,
  35932. shouldPrintComma: shouldPrintComma$9,
  35933. getCallArguments: getCallArguments$3,
  35934. iterateCallArgumentsPath: iterateCallArgumentsPath$1,
  35935. isNextLineEmpty: isNextLineEmpty$a,
  35936. isCallExpression: isCallExpression$8,
  35937. isStringLiteral: isStringLiteral$3,
  35938. isObjectProperty: isObjectProperty$1
  35939. } = utils$5;
  35940. const {
  35941. builders: {
  35942. line: line$r,
  35943. hardline: hardline$u,
  35944. softline: softline$m,
  35945. group: group$v,
  35946. indent: indent$o,
  35947. conditionalGroup: conditionalGroup$3,
  35948. ifBreak: ifBreak$j,
  35949. breakParent: breakParent$9
  35950. },
  35951. utils: {
  35952. willBreak: willBreak$4
  35953. }
  35954. } = require$$7$3;
  35955. const {
  35956. ArgExpansionBailout: ArgExpansionBailout$2
  35957. } = errors;
  35958. const {
  35959. isConciselyPrintedArray
  35960. } = array;
  35961. function printCallArguments$2(path, options, print) {
  35962. const node = path.getValue();
  35963. const isDynamicImport = node.type === "ImportExpression";
  35964. const args = getCallArguments$3(node);
  35965. if (args.length === 0) {
  35966. return ["(", printDanglingComments$b(path, options,
  35967. /* sameIndent */
  35968. true), ")"];
  35969. } // useEffect(() => { ... }, [foo, bar, baz])
  35970. if (isReactHookCallWithDepsArray(args)) {
  35971. return ["(", print(["arguments", 0]), ", ", print(["arguments", 1]), ")"];
  35972. }
  35973. let anyArgEmptyLine = false;
  35974. let hasEmptyLineFollowingFirstArg = false;
  35975. const lastArgIndex = args.length - 1;
  35976. const printedArguments = [];
  35977. iterateCallArgumentsPath$1(path, (argPath, index) => {
  35978. const arg = argPath.getNode();
  35979. const parts = [print()];
  35980. if (index === lastArgIndex) ; else if (isNextLineEmpty$a(arg, options)) {
  35981. if (index === 0) {
  35982. hasEmptyLineFollowingFirstArg = true;
  35983. }
  35984. anyArgEmptyLine = true;
  35985. parts.push(",", hardline$u, hardline$u);
  35986. } else {
  35987. parts.push(",", line$r);
  35988. }
  35989. printedArguments.push(parts);
  35990. });
  35991. const maybeTrailingComma = // Dynamic imports cannot have trailing commas
  35992. !(isDynamicImport || node.callee && node.callee.type === "Import") && shouldPrintComma$9(options, "all") ? "," : "";
  35993. function allArgsBrokenOut() {
  35994. return group$v(["(", indent$o([line$r, ...printedArguments]), maybeTrailingComma, line$r, ")"], {
  35995. shouldBreak: true
  35996. });
  35997. }
  35998. if (anyArgEmptyLine || path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs(args)) {
  35999. return allArgsBrokenOut();
  36000. }
  36001. const shouldGroupFirst = shouldGroupFirstArg(args);
  36002. const shouldGroupLast = shouldGroupLastArg(args, options);
  36003. if (shouldGroupFirst || shouldGroupLast) {
  36004. if (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$4) : printedArguments.slice(0, -1).some(willBreak$4)) {
  36005. return allArgsBrokenOut();
  36006. } // We want to print the last argument with a special flag
  36007. let printedExpanded = [];
  36008. try {
  36009. path.try(() => {
  36010. iterateCallArgumentsPath$1(path, (argPath, i) => {
  36011. if (shouldGroupFirst && i === 0) {
  36012. printedExpanded = [[print([], {
  36013. expandFirstArg: true
  36014. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$u : line$r, hasEmptyLineFollowingFirstArg ? hardline$u : ""], ...printedArguments.slice(1)];
  36015. }
  36016. if (shouldGroupLast && i === lastArgIndex) {
  36017. printedExpanded = [...printedArguments.slice(0, -1), print([], {
  36018. expandLastArg: true
  36019. })];
  36020. }
  36021. });
  36022. });
  36023. } catch (caught) {
  36024. if (caught instanceof ArgExpansionBailout$2) {
  36025. return allArgsBrokenOut();
  36026. }
  36027. /* istanbul ignore next */
  36028. throw caught;
  36029. }
  36030. return [printedArguments.some(willBreak$4) ? breakParent$9 : "", conditionalGroup$3([["(", ...printedExpanded, ")"], shouldGroupFirst ? ["(", group$v(printedExpanded[0], {
  36031. shouldBreak: true
  36032. }), ...printedExpanded.slice(1), ")"] : ["(", ...printedArguments.slice(0, -1), group$v(getLast$e(printedExpanded), {
  36033. shouldBreak: true
  36034. }), ")"], allArgsBrokenOut()])];
  36035. }
  36036. const contents = ["(", indent$o([softline$m, ...printedArguments]), ifBreak$j(maybeTrailingComma), softline$m, ")"];
  36037. if (isLongCurriedCallExpression$1(path)) {
  36038. // By not wrapping the arguments in a group, the printer prioritizes
  36039. // breaking up these arguments rather than the args of the parent call.
  36040. return contents;
  36041. }
  36042. return group$v(contents, {
  36043. shouldBreak: printedArguments.some(willBreak$4) || anyArgEmptyLine
  36044. });
  36045. }
  36046. function couldGroupArg(arg, arrowChainRecursion = false) {
  36047. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || hasComment$c(arg)) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || hasComment$c(arg)) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
  36048. // https://github.com/prettier/prettier/issues/4070
  36049. // export class Thing implements OtherThing {
  36050. // do: (type: Type) => Provider<Prop> = memoize(
  36051. // (type: ObjectType): Provider<Opts> => {}
  36052. // );
  36053. // }
  36054. // https://github.com/prettier/prettier/issues/6099
  36055. // app.get("/", (req, res): void => {
  36056. // res.send("Hello World!");
  36057. // });
  36058. !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference" || // https://github.com/prettier/prettier/issues/7542
  36059. isNonEmptyBlockStatement(arg.body)) && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" && couldGroupArg(arg.body, true) || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || !arrowChainRecursion && (isCallExpression$8(arg.body) || arg.body.type === "ConditionalExpression") || isJsxNode$3(arg.body)) || arg.type === "DoExpression" || arg.type === "ModuleExpression";
  36060. }
  36061. function shouldGroupLastArg(args, options) {
  36062. const lastArg = getLast$e(args);
  36063. const penultimateArg = getPenultimate(args);
  36064. return !hasComment$c(lastArg, CommentCheckFlags$a.Leading) && !hasComment$c(lastArg, CommentCheckFlags$a.Trailing) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  36065. // disable last element expansion.
  36066. !penultimateArg || penultimateArg.type !== lastArg.type) && ( // useMemo(() => func(), [foo, bar, baz])
  36067. args.length !== 2 || penultimateArg.type !== "ArrowFunctionExpression" || lastArg.type !== "ArrayExpression") && !(args.length > 1 && lastArg.type === "ArrayExpression" && isConciselyPrintedArray(lastArg, options));
  36068. }
  36069. function shouldGroupFirstArg(args) {
  36070. if (args.length !== 2) {
  36071. return false;
  36072. }
  36073. const [firstArg, secondArg] = args;
  36074. if (firstArg.type === "ModuleExpression" && isTypeModuleObjectExpression(secondArg)) {
  36075. return true;
  36076. }
  36077. return !hasComment$c(firstArg) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
  36078. }
  36079. function isReactHookCallWithDepsArray(args) {
  36080. return args.length === 2 && args[0].type === "ArrowFunctionExpression" && getFunctionParameters$3(args[0]).length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.some(arg => hasComment$c(arg));
  36081. }
  36082. function isNonEmptyBlockStatement(node) {
  36083. return node.type === "BlockStatement" && (node.body.some(node => node.type !== "EmptyStatement") || hasComment$c(node, CommentCheckFlags$a.Dangling));
  36084. } // { type: "module" }
  36085. function isTypeModuleObjectExpression(node) {
  36086. return node.type === "ObjectExpression" && node.properties.length === 1 && isObjectProperty$1(node.properties[0]) && node.properties[0].key.type === "Identifier" && node.properties[0].key.name === "type" && isStringLiteral$3(node.properties[0].value) && node.properties[0].value.value === "module";
  36087. }
  36088. var callArguments = printCallArguments$2;
  36089. const {
  36090. builders: {
  36091. softline: softline$l,
  36092. group: group$u,
  36093. indent: indent$n,
  36094. label: label$2
  36095. }
  36096. } = require$$7$3;
  36097. const {
  36098. isNumericLiteral: isNumericLiteral$3,
  36099. isMemberExpression: isMemberExpression$5,
  36100. isCallExpression: isCallExpression$7
  36101. } = utils$5;
  36102. const {
  36103. printOptionalToken: printOptionalToken$7
  36104. } = misc$1;
  36105. function printMemberExpression$1(path, options, print) {
  36106. const node = path.getValue();
  36107. const parent = path.getParentNode();
  36108. let firstNonMemberParent;
  36109. let i = 0;
  36110. do {
  36111. firstNonMemberParent = path.getParentNode(i);
  36112. i++;
  36113. } while (firstNonMemberParent && (isMemberExpression$5(firstNonMemberParent) || firstNonMemberParent.type === "TSNonNullExpression"));
  36114. const objectDoc = print("object");
  36115. const lookupDoc = printMemberLookup$1(path, options, print);
  36116. const shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || node.computed || node.object.type === "Identifier" && node.property.type === "Identifier" && !isMemberExpression$5(parent) || (parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator") && (isCallExpression$7(node.object) && node.object.arguments.length > 0 || node.object.type === "TSNonNullExpression" && isCallExpression$7(node.object.expression) && node.object.expression.arguments.length > 0 || objectDoc.label === "member-chain");
  36117. return label$2(objectDoc.label === "member-chain" ? "member-chain" : "member", [objectDoc, shouldInline ? lookupDoc : group$u(indent$n([softline$l, lookupDoc]))]);
  36118. }
  36119. function printMemberLookup$1(path, options, print) {
  36120. const property = print("property");
  36121. const node = path.getValue();
  36122. const optional = printOptionalToken$7(path);
  36123. if (!node.computed) {
  36124. return [optional, ".", property];
  36125. }
  36126. if (!node.property || isNumericLiteral$3(node.property)) {
  36127. return [optional, "[", property, "]"];
  36128. }
  36129. return group$u([optional, "[", indent$n([softline$l, property]), softline$l, "]"]);
  36130. }
  36131. var member = {
  36132. printMemberExpression: printMemberExpression$1,
  36133. printMemberLookup: printMemberLookup$1
  36134. };
  36135. const {
  36136. printComments: printComments$3
  36137. } = comments$4;
  36138. const {
  36139. getLast: getLast$d,
  36140. isNextLineEmptyAfterIndex,
  36141. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1
  36142. } = util$8;
  36143. const pathNeedsParens$4 = needsParens_1;
  36144. const {
  36145. isCallExpression: isCallExpression$6,
  36146. isMemberExpression: isMemberExpression$4,
  36147. isFunctionOrArrowExpression,
  36148. isLongCurriedCallExpression,
  36149. isMemberish: isMemberish$1,
  36150. isNumericLiteral: isNumericLiteral$2,
  36151. isSimpleCallArgument,
  36152. hasComment: hasComment$b,
  36153. CommentCheckFlags: CommentCheckFlags$9,
  36154. isNextLineEmpty: isNextLineEmpty$9
  36155. } = utils$5;
  36156. const {
  36157. locEnd: locEnd$n
  36158. } = loc$6;
  36159. const {
  36160. builders: {
  36161. join: join$n,
  36162. hardline: hardline$t,
  36163. group: group$t,
  36164. indent: indent$m,
  36165. conditionalGroup: conditionalGroup$2,
  36166. breakParent: breakParent$8,
  36167. label: label$1
  36168. },
  36169. utils: {
  36170. willBreak: willBreak$3
  36171. }
  36172. } = require$$7$3;
  36173. const printCallArguments$1 = callArguments;
  36174. const {
  36175. printMemberLookup
  36176. } = member;
  36177. const {
  36178. printOptionalToken: printOptionalToken$6,
  36179. printFunctionTypeParameters: printFunctionTypeParameters$3,
  36180. printBindExpressionCallee: printBindExpressionCallee$1
  36181. } = misc$1; // We detect calls on member expressions specially to format a
  36182. // common pattern better. The pattern we are looking for is this:
  36183. //
  36184. // arr
  36185. // .map(x => x + 1)
  36186. // .filter(x => x > 10)
  36187. // .some(x => x % 2)
  36188. //
  36189. // The way it is structured in the AST is via a nested sequence of
  36190. // MemberExpression and CallExpression. We need to traverse the AST
  36191. // and make groups out of it to print it in the desired way.
  36192. function printMemberChain$1(path, options, print) {
  36193. const parent = path.getParentNode();
  36194. const isExpressionStatement = !parent || parent.type === "ExpressionStatement"; // The first phase is to linearize the AST by traversing it down.
  36195. //
  36196. // a().b()
  36197. // has the following AST structure:
  36198. // CallExpression(MemberExpression(CallExpression(Identifier)))
  36199. // and we transform it into
  36200. // [Identifier, CallExpression, MemberExpression, CallExpression]
  36201. const printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  36202. // the first group whether it is in parentheses or not
  36203. function shouldInsertEmptyLineAfter(node) {
  36204. const {
  36205. originalText
  36206. } = options;
  36207. const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$1(originalText, node, locEnd$n);
  36208. const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  36209. // line after that parenthesis
  36210. if (nextChar === ")") {
  36211. return nextCharIndex !== false && isNextLineEmptyAfterIndex(originalText, nextCharIndex + 1);
  36212. }
  36213. return isNextLineEmpty$9(node, options);
  36214. }
  36215. function rec(path) {
  36216. const node = path.getValue();
  36217. if (isCallExpression$6(node) && (isMemberish$1(node.callee) || isCallExpression$6(node.callee))) {
  36218. printedNodes.unshift({
  36219. node,
  36220. printed: [printComments$3(path, [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), printCallArguments$1(path, options, print)], options), shouldInsertEmptyLineAfter(node) ? hardline$t : ""]
  36221. });
  36222. path.call(callee => rec(callee), "callee");
  36223. } else if (isMemberish$1(node)) {
  36224. printedNodes.unshift({
  36225. node,
  36226. needsParens: pathNeedsParens$4(path, options),
  36227. printed: printComments$3(path, isMemberExpression$4(node) ? printMemberLookup(path, options, print) : printBindExpressionCallee$1(path, options, print), options)
  36228. });
  36229. path.call(object => rec(object), "object");
  36230. } else if (node.type === "TSNonNullExpression") {
  36231. printedNodes.unshift({
  36232. node,
  36233. printed: printComments$3(path, "!", options)
  36234. });
  36235. path.call(expression => rec(expression), "expression");
  36236. } else {
  36237. printedNodes.unshift({
  36238. node,
  36239. printed: print()
  36240. });
  36241. }
  36242. } // Note: the comments of the root node have already been printed, so we
  36243. // need to extract this first call without printing them as they would
  36244. // if handled inside of the recursive call.
  36245. const node = path.getValue();
  36246. printedNodes.unshift({
  36247. node,
  36248. printed: [printOptionalToken$6(path), printFunctionTypeParameters$3(path, options, print), printCallArguments$1(path, options, print)]
  36249. });
  36250. if (node.callee) {
  36251. path.call(callee => rec(callee), "callee");
  36252. } // Once we have a linear list of printed nodes, we want to create groups out
  36253. // of it.
  36254. //
  36255. // a().b.c().d().e
  36256. // will be grouped as
  36257. // [
  36258. // [Identifier, CallExpression],
  36259. // [MemberExpression, MemberExpression, CallExpression],
  36260. // [MemberExpression, CallExpression],
  36261. // [MemberExpression],
  36262. // ]
  36263. // so that we can print it as
  36264. // a()
  36265. // .b.c()
  36266. // .d()
  36267. // .e
  36268. // The first group is the first node followed by
  36269. // - as many CallExpression as possible
  36270. // < fn()()() >.something()
  36271. // - as many array accessors as possible
  36272. // < fn()[0][1][2] >.something()
  36273. // - then, as many MemberExpression as possible but the last one
  36274. // < this.items >.something()
  36275. const groups = [];
  36276. let currentGroup = [printedNodes[0]];
  36277. let i = 1;
  36278. for (; i < printedNodes.length; ++i) {
  36279. if (printedNodes[i].node.type === "TSNonNullExpression" || isCallExpression$6(printedNodes[i].node) || isMemberExpression$4(printedNodes[i].node) && printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
  36280. currentGroup.push(printedNodes[i]);
  36281. } else {
  36282. break;
  36283. }
  36284. }
  36285. if (!isCallExpression$6(printedNodes[0].node)) {
  36286. for (; i + 1 < printedNodes.length; ++i) {
  36287. if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
  36288. currentGroup.push(printedNodes[i]);
  36289. } else {
  36290. break;
  36291. }
  36292. }
  36293. }
  36294. groups.push(currentGroup);
  36295. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  36296. // a sequence of CallExpression. To compute it, we keep adding things to the
  36297. // group until we has seen a CallExpression in the past and reach a
  36298. // MemberExpression
  36299. let hasSeenCallExpression = false;
  36300. for (; i < printedNodes.length; ++i) {
  36301. if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
  36302. // [0] should be appended at the end of the group instead of the
  36303. // beginning of the next one
  36304. if (printedNodes[i].node.computed && isNumericLiteral$2(printedNodes[i].node.property)) {
  36305. currentGroup.push(printedNodes[i]);
  36306. continue;
  36307. }
  36308. groups.push(currentGroup);
  36309. currentGroup = [];
  36310. hasSeenCallExpression = false;
  36311. }
  36312. if (isCallExpression$6(printedNodes[i].node) || printedNodes[i].node.type === "ImportExpression") {
  36313. hasSeenCallExpression = true;
  36314. }
  36315. currentGroup.push(printedNodes[i]);
  36316. if (hasComment$b(printedNodes[i].node, CommentCheckFlags$9.Trailing)) {
  36317. groups.push(currentGroup);
  36318. currentGroup = [];
  36319. hasSeenCallExpression = false;
  36320. }
  36321. }
  36322. if (currentGroup.length > 0) {
  36323. groups.push(currentGroup);
  36324. } // There are cases like Object.keys(), Observable.of(), _.values() where
  36325. // they are the subject of all the chained calls and therefore should
  36326. // be kept on the same line:
  36327. //
  36328. // Object.keys(items)
  36329. // .filter(x => x)
  36330. // .map(x => x)
  36331. //
  36332. // In order to detect those cases, we use an heuristic: if the first
  36333. // node is an identifier with the name starting with a capital
  36334. // letter or just a sequence of _$. The rationale is that they are
  36335. // likely to be factories.
  36336. function isFactory(name) {
  36337. return /^[A-Z]|^[$_]+$/.test(name);
  36338. } // In case the Identifier is shorter than tab width, we can keep the
  36339. // first call in a single line, if it's an ExpressionStatement.
  36340. //
  36341. // d3.scaleLinear()
  36342. // .domain([0, 100])
  36343. // .range([0, width]);
  36344. //
  36345. function isShort(name) {
  36346. return name.length <= options.tabWidth;
  36347. }
  36348. function shouldNotWrap(groups) {
  36349. const hasComputed = groups[1].length > 0 && groups[1][0].node.computed;
  36350. if (groups[0].length === 1) {
  36351. const firstNode = groups[0][0].node;
  36352. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpressionStatement && isShort(firstNode.name) || hasComputed);
  36353. }
  36354. const lastNode = getLast$d(groups[0]).node;
  36355. return isMemberExpression$4(lastNode) && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  36356. }
  36357. const shouldMerge = groups.length >= 2 && !hasComment$b(groups[1][0].node) && shouldNotWrap(groups);
  36358. function printGroup(printedGroup) {
  36359. const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
  36360. // accordingly
  36361. if (printedGroup.length > 0 && getLast$d(printedGroup).needsParens) {
  36362. return ["(", ...printed, ")"];
  36363. }
  36364. return printed;
  36365. }
  36366. function printIndentedGroup(groups) {
  36367. /* istanbul ignore next */
  36368. if (groups.length === 0) {
  36369. return "";
  36370. }
  36371. return indent$m(group$t([hardline$t, join$n(hardline$t, groups.map(printGroup))]));
  36372. }
  36373. const printedGroups = groups.map(printGroup);
  36374. const oneLine = printedGroups;
  36375. const cutoff = shouldMerge ? 3 : 2;
  36376. const flatGroups = groups.flat();
  36377. const nodeHasComment = flatGroups.slice(1, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Leading)) || flatGroups.slice(0, -1).some(node => hasComment$b(node.node, CommentCheckFlags$9.Trailing)) || groups[cutoff] && hasComment$b(groups[cutoff][0].node, CommentCheckFlags$9.Leading); // If we only have a single `.`, we shouldn't do anything fancy and just
  36378. // render everything concatenated together.
  36379. if (groups.length <= cutoff && !nodeHasComment) {
  36380. if (isLongCurriedCallExpression(path)) {
  36381. return oneLine;
  36382. }
  36383. return group$t(oneLine);
  36384. } // Find out the last node in the first group and check if it has an
  36385. // empty line after
  36386. const lastNodeBeforeIndent = getLast$d(groups[shouldMerge ? 1 : 0]).node;
  36387. const shouldHaveEmptyLineBeforeIndent = !isCallExpression$6(lastNodeBeforeIndent) && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  36388. const expanded = [printGroup(groups[0]), shouldMerge ? groups.slice(1, 2).map(printGroup) : "", shouldHaveEmptyLineBeforeIndent ? hardline$t : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))];
  36389. const callExpressions = printedNodes.map(({
  36390. node
  36391. }) => node).filter(isCallExpression$6);
  36392. function lastGroupWillBreakAndOtherCallsHaveFunctionArguments() {
  36393. const lastGroupNode = getLast$d(getLast$d(groups)).node;
  36394. const lastGroupDoc = getLast$d(printedGroups);
  36395. return isCallExpression$6(lastGroupNode) && willBreak$3(lastGroupDoc) && callExpressions.slice(0, -1).some(node => node.arguments.some(isFunctionOrArrowExpression));
  36396. }
  36397. let result; // We don't want to print in one line if at least one of these conditions occurs:
  36398. // * the chain has comments,
  36399. // * the chain is an expression statement and all the arguments are literal-like ("fluent configuration" pattern),
  36400. // * the chain is longer than 2 calls and has non-trivial arguments or more than 2 arguments in any call but the first one,
  36401. // * any group but the last one has a hard line,
  36402. // * the last call's arguments have a hard line and other calls have non-trivial arguments.
  36403. if (nodeHasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$3) || lastGroupWillBreakAndOtherCallsHaveFunctionArguments()) {
  36404. result = group$t(expanded);
  36405. } else {
  36406. result = [// We only need to check `oneLine` because if `expanded` is chosen
  36407. // that means that the parent group has already been broken
  36408. // naturally
  36409. willBreak$3(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$8 : "", conditionalGroup$2([oneLine, expanded])];
  36410. }
  36411. return label$1("member-chain", result);
  36412. }
  36413. var memberChain = printMemberChain$1;
  36414. const {
  36415. builders: {
  36416. join: join$m,
  36417. group: group$s
  36418. }
  36419. } = require$$7$3;
  36420. const pathNeedsParens$3 = needsParens_1;
  36421. const {
  36422. getCallArguments: getCallArguments$2,
  36423. hasFlowAnnotationComment,
  36424. isCallExpression: isCallExpression$5,
  36425. isMemberish,
  36426. isStringLiteral: isStringLiteral$2,
  36427. isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$1,
  36428. isTestCall: isTestCall$2,
  36429. iterateCallArgumentsPath
  36430. } = utils$5;
  36431. const printMemberChain = memberChain;
  36432. const printCallArguments = callArguments;
  36433. const {
  36434. printOptionalToken: printOptionalToken$5,
  36435. printFunctionTypeParameters: printFunctionTypeParameters$2
  36436. } = misc$1;
  36437. function printCallExpression$2(path, options, print) {
  36438. const node = path.getValue();
  36439. const parentNode = path.getParentNode();
  36440. const isNew = node.type === "NewExpression";
  36441. const isDynamicImport = node.type === "ImportExpression";
  36442. const optional = printOptionalToken$5(path);
  36443. const args = getCallArguments$2(node);
  36444. if ( // Dangling comments are not handled, all these special cases should have arguments #9668
  36445. args.length > 0 && ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  36446. // define calls, as a unit.
  36447. // e.g. `define(["some/lib"], (lib) => {`
  36448. !isDynamicImport && !isNew && isCommonsJsOrAmdCall(node, parentNode) || // Template literals as single arguments
  36449. args.length === 1 && isTemplateOnItsOwnLine$1(args[0], options.originalText) || // Keep test declarations on a single line
  36450. // e.g. `it('long name', () => {`
  36451. !isNew && isTestCall$2(node, parentNode))) {
  36452. const printed = [];
  36453. iterateCallArgumentsPath(path, () => {
  36454. printed.push(print());
  36455. });
  36456. return [isNew ? "new " : "", print("callee"), optional, printFunctionTypeParameters$2(path, options, print), "(", join$m(", ", printed), ")"];
  36457. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  36458. // stay with the Identifier. For example:
  36459. //
  36460. // foo /*:: <SomeGeneric> */(bar);
  36461. //
  36462. // Here, we ensure that such comments stay between the Identifier and the Callee.
  36463. const isIdentifierWithFlowAnnotation = (options.parser === "babel" || options.parser === "babel-flow") && node.callee && node.callee.type === "Identifier" && hasFlowAnnotationComment(node.callee.trailingComments);
  36464. if (isIdentifierWithFlowAnnotation) {
  36465. node.callee.trailingComments[0].printed = true;
  36466. } // We detect calls on member lookups and possibly print them in a
  36467. // special chain format. See `printMemberChain` for more info.
  36468. if (!isDynamicImport && !isNew && isMemberish(node.callee) && !path.call(path => pathNeedsParens$3(path, options), "callee")) {
  36469. return printMemberChain(path, options, print);
  36470. }
  36471. const contents = [isNew ? "new " : "", isDynamicImport ? "import" : print("callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${node.callee.trailingComments[0].value.slice(2).trim()} */` : "", printFunctionTypeParameters$2(path, options, print), printCallArguments(path, options, print)]; // We group here when the callee is itself a call expression.
  36472. // See `isLongCurriedCallExpression` for more info.
  36473. if (isDynamicImport || isCallExpression$5(node.callee)) {
  36474. return group$s(contents);
  36475. }
  36476. return contents;
  36477. }
  36478. function isCommonsJsOrAmdCall(node, parentNode) {
  36479. if (node.callee.type !== "Identifier") {
  36480. return false;
  36481. }
  36482. if (node.callee.name === "require") {
  36483. return true;
  36484. }
  36485. if (node.callee.name === "define") {
  36486. const args = getCallArguments$2(node);
  36487. return parentNode.type === "ExpressionStatement" && (args.length === 1 || args.length === 2 && args[0].type === "ArrayExpression" || args.length === 3 && isStringLiteral$2(args[0]) && args[1].type === "ArrayExpression");
  36488. }
  36489. return false;
  36490. }
  36491. var callExpression = {
  36492. printCallExpression: printCallExpression$2
  36493. };
  36494. const {
  36495. isNonEmptyArray: isNonEmptyArray$e,
  36496. getStringWidth: getStringWidth$1
  36497. } = util$8;
  36498. const {
  36499. builders: {
  36500. line: line$q,
  36501. group: group$r,
  36502. indent: indent$l,
  36503. indentIfBreak: indentIfBreak$2
  36504. },
  36505. utils: {
  36506. cleanDoc: cleanDoc$1,
  36507. willBreak: willBreak$2,
  36508. canBreak
  36509. }
  36510. } = require$$7$3;
  36511. const {
  36512. hasLeadingOwnLineComment: hasLeadingOwnLineComment$2,
  36513. isBinaryish: isBinaryish$1,
  36514. isStringLiteral: isStringLiteral$1,
  36515. isLiteral: isLiteral$1,
  36516. isNumericLiteral: isNumericLiteral$1,
  36517. isCallExpression: isCallExpression$4,
  36518. isMemberExpression: isMemberExpression$3,
  36519. getCallArguments: getCallArguments$1,
  36520. rawText: rawText$3,
  36521. hasComment: hasComment$a,
  36522. isSignedNumericLiteral,
  36523. isObjectProperty
  36524. } = utils$5;
  36525. const {
  36526. shouldInlineLogicalExpression
  36527. } = binaryish;
  36528. const {
  36529. printCallExpression: printCallExpression$1
  36530. } = callExpression;
  36531. function printAssignment$3(path, options, print, leftDoc, operator, rightPropertyName) {
  36532. const layout = chooseLayout(path, options, print, leftDoc, rightPropertyName);
  36533. const rightDoc = print(rightPropertyName, {
  36534. assignmentLayout: layout
  36535. });
  36536. switch (layout) {
  36537. // First break after operator, then the sides are broken independently on their own lines
  36538. case "break-after-operator":
  36539. return group$r([group$r(leftDoc), operator, group$r(indent$l([line$q, rightDoc]))]);
  36540. // First break right-hand side, then left-hand side
  36541. case "never-break-after-operator":
  36542. return group$r([group$r(leftDoc), operator, " ", rightDoc]);
  36543. // First break right-hand side, then after operator
  36544. case "fluid":
  36545. {
  36546. const groupId = Symbol("assignment");
  36547. return group$r([group$r(leftDoc), operator, group$r(indent$l(line$q), {
  36548. id: groupId
  36549. }), indentIfBreak$2(rightDoc, {
  36550. groupId
  36551. })]);
  36552. }
  36553. case "break-lhs":
  36554. return group$r([leftDoc, operator, " ", group$r(rightDoc)]);
  36555. // Parts of assignment chains aren't wrapped in groups.
  36556. // Once one of them breaks, the chain breaks too.
  36557. case "chain":
  36558. return [group$r(leftDoc), operator, line$q, rightDoc];
  36559. case "chain-tail":
  36560. return [group$r(leftDoc), operator, indent$l([line$q, rightDoc])];
  36561. case "chain-tail-arrow-chain":
  36562. return [group$r(leftDoc), operator, rightDoc];
  36563. case "only-left":
  36564. return leftDoc;
  36565. }
  36566. }
  36567. function printAssignmentExpression$1(path, options, print) {
  36568. const node = path.getValue();
  36569. return printAssignment$3(path, options, print, print("left"), [" ", node.operator], "right");
  36570. }
  36571. function printVariableDeclarator$1(path, options, print) {
  36572. return printAssignment$3(path, options, print, print("id"), " =", "init");
  36573. }
  36574. function chooseLayout(path, options, print, leftDoc, rightPropertyName) {
  36575. const node = path.getValue();
  36576. const rightNode = node[rightPropertyName];
  36577. if (!rightNode) {
  36578. return "only-left";
  36579. } // Short assignment chains (only 2 segments) are NOT formatted as chains.
  36580. // 1) a = b = c; (expression statements)
  36581. // 2) var/let/const a = b = c;
  36582. const isTail = !isAssignment(rightNode);
  36583. const shouldUseChainFormatting = path.match(isAssignment, isAssignmentOrVariableDeclarator, node => !isTail || node.type !== "ExpressionStatement" && node.type !== "VariableDeclaration");
  36584. if (shouldUseChainFormatting) {
  36585. return !isTail ? "chain" : rightNode.type === "ArrowFunctionExpression" && rightNode.body.type === "ArrowFunctionExpression" ? "chain-tail-arrow-chain" : "chain-tail";
  36586. }
  36587. const isHeadOfLongChain = !isTail && isAssignment(rightNode.right);
  36588. if (isHeadOfLongChain || hasLeadingOwnLineComment$2(options.originalText, rightNode)) {
  36589. return "break-after-operator";
  36590. }
  36591. if (rightNode.type === "CallExpression" && rightNode.callee.name === "require" || // do not put values on a separate line from the key in json
  36592. options.parser === "json5" || options.parser === "json") {
  36593. return "never-break-after-operator";
  36594. }
  36595. if (isComplexDestructuring(node) || isComplexTypeAliasParams(node) || hasComplexTypeAnnotation(node) || isArrowFunctionVariableDeclarator$1(node) && canBreak(leftDoc)) {
  36596. return "break-lhs";
  36597. } // wrapping object properties with very short keys usually doesn't add much value
  36598. const hasShortKey = isObjectPropertyWithShortKey(node, leftDoc, options);
  36599. if (path.call(() => shouldBreakAfterOperator(path, options, print, hasShortKey), rightPropertyName)) {
  36600. return "break-after-operator";
  36601. }
  36602. if (hasShortKey || rightNode.type === "TemplateLiteral" || rightNode.type === "TaggedTemplateExpression" || rightNode.type === "BooleanLiteral" || isNumericLiteral$1(rightNode) || rightNode.type === "ClassExpression") {
  36603. return "never-break-after-operator";
  36604. }
  36605. return "fluid";
  36606. }
  36607. function shouldBreakAfterOperator(path, options, print, hasShortKey) {
  36608. const rightNode = path.getValue();
  36609. if (isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode)) {
  36610. return true;
  36611. }
  36612. switch (rightNode.type) {
  36613. case "StringLiteralTypeAnnotation":
  36614. case "SequenceExpression":
  36615. return true;
  36616. case "ConditionalExpression":
  36617. {
  36618. const {
  36619. test
  36620. } = rightNode;
  36621. return isBinaryish$1(test) && !shouldInlineLogicalExpression(test);
  36622. }
  36623. case "ClassExpression":
  36624. return isNonEmptyArray$e(rightNode.decorators);
  36625. }
  36626. if (hasShortKey) {
  36627. return false;
  36628. }
  36629. let node = rightNode;
  36630. const propertiesForPath = [];
  36631. for (;;) {
  36632. if (node.type === "UnaryExpression") {
  36633. node = node.argument;
  36634. propertiesForPath.push("argument");
  36635. } else if (node.type === "TSNonNullExpression") {
  36636. node = node.expression;
  36637. propertiesForPath.push("expression");
  36638. } else {
  36639. break;
  36640. }
  36641. }
  36642. if (isStringLiteral$1(node) || path.call(() => isPoorlyBreakableMemberOrCallChain(path, options, print), ...propertiesForPath)) {
  36643. return true;
  36644. }
  36645. return false;
  36646. } // prefer to break destructuring assignment
  36647. // if it includes default values or non-shorthand properties
  36648. function isComplexDestructuring(node) {
  36649. if (isAssignmentOrVariableDeclarator(node)) {
  36650. const leftNode = node.left || node.id;
  36651. return leftNode.type === "ObjectPattern" && leftNode.properties.length > 2 && leftNode.properties.some(property => isObjectProperty(property) && (!property.shorthand || property.value && property.value.type === "AssignmentPattern"));
  36652. }
  36653. return false;
  36654. }
  36655. function isAssignment(node) {
  36656. return node.type === "AssignmentExpression";
  36657. }
  36658. function isAssignmentOrVariableDeclarator(node) {
  36659. return isAssignment(node) || node.type === "VariableDeclarator";
  36660. }
  36661. function isComplexTypeAliasParams(node) {
  36662. const typeParams = getTypeParametersFromTypeAlias(node);
  36663. if (isNonEmptyArray$e(typeParams)) {
  36664. const constraintPropertyName = node.type === "TSTypeAliasDeclaration" ? "constraint" : "bound";
  36665. if (typeParams.length > 1 && typeParams.some(param => param[constraintPropertyName] || param.default)) {
  36666. return true;
  36667. }
  36668. }
  36669. return false;
  36670. }
  36671. function getTypeParametersFromTypeAlias(node) {
  36672. if (isTypeAlias(node) && node.typeParameters && node.typeParameters.params) {
  36673. return node.typeParameters.params;
  36674. }
  36675. return null;
  36676. }
  36677. function isTypeAlias(node) {
  36678. return node.type === "TSTypeAliasDeclaration" || node.type === "TypeAlias";
  36679. }
  36680. function hasComplexTypeAnnotation(node) {
  36681. if (node.type !== "VariableDeclarator") {
  36682. return false;
  36683. }
  36684. const {
  36685. typeAnnotation
  36686. } = node.id;
  36687. if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
  36688. return false;
  36689. }
  36690. const typeParams = getTypeParametersFromTypeReference(typeAnnotation.typeAnnotation);
  36691. return isNonEmptyArray$e(typeParams) && typeParams.length > 1 && typeParams.some(param => isNonEmptyArray$e(getTypeParametersFromTypeReference(param)) || param.type === "TSConditionalType");
  36692. }
  36693. function isArrowFunctionVariableDeclarator$1(node) {
  36694. return node.type === "VariableDeclarator" && node.init && node.init.type === "ArrowFunctionExpression";
  36695. }
  36696. function getTypeParametersFromTypeReference(node) {
  36697. if (isTypeReference(node) && node.typeParameters && node.typeParameters.params) {
  36698. return node.typeParameters.params;
  36699. }
  36700. return null;
  36701. }
  36702. function isTypeReference(node) {
  36703. return node.type === "TSTypeReference" || node.type === "GenericTypeAnnotation";
  36704. }
  36705. /**
  36706. * A chain with no calls at all or whose calls are all without arguments or with lone short arguments,
  36707. * excluding chains printed by `printMemberChain`
  36708. */
  36709. function isPoorlyBreakableMemberOrCallChain(path, options, print, deep = false) {
  36710. const node = path.getValue();
  36711. const goDeeper = () => isPoorlyBreakableMemberOrCallChain(path, options, print, true);
  36712. if (node.type === "TSNonNullExpression") {
  36713. return path.call(goDeeper, "expression");
  36714. }
  36715. if (isCallExpression$4(node)) {
  36716. /** @type {any} TODO */
  36717. const doc = printCallExpression$1(path, options, print);
  36718. if (doc.label === "member-chain") {
  36719. return false;
  36720. }
  36721. const args = getCallArguments$1(node);
  36722. const isPoorlyBreakableCall = args.length === 0 || args.length === 1 && isLoneShortArgument(args[0], options);
  36723. if (!isPoorlyBreakableCall) {
  36724. return false;
  36725. }
  36726. if (isCallExpressionWithComplexTypeArguments(node, print)) {
  36727. return false;
  36728. }
  36729. return path.call(goDeeper, "callee");
  36730. }
  36731. if (isMemberExpression$3(node)) {
  36732. return path.call(goDeeper, "object");
  36733. }
  36734. return deep && (node.type === "Identifier" || node.type === "ThisExpression");
  36735. }
  36736. const LONE_SHORT_ARGUMENT_THRESHOLD_RATE = 0.25;
  36737. function isLoneShortArgument(node, {
  36738. printWidth
  36739. }) {
  36740. if (hasComment$a(node)) {
  36741. return false;
  36742. }
  36743. const threshold = printWidth * LONE_SHORT_ARGUMENT_THRESHOLD_RATE;
  36744. if (node.type === "ThisExpression" || node.type === "Identifier" && node.name.length <= threshold || isSignedNumericLiteral(node) && !hasComment$a(node.argument)) {
  36745. return true;
  36746. }
  36747. const regexpPattern = node.type === "Literal" && "regex" in node && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
  36748. if (regexpPattern) {
  36749. return regexpPattern.length <= threshold;
  36750. }
  36751. if (isStringLiteral$1(node)) {
  36752. return rawText$3(node).length <= threshold;
  36753. }
  36754. if (node.type === "TemplateLiteral") {
  36755. return node.expressions.length === 0 && node.quasis[0].value.raw.length <= threshold && !node.quasis[0].value.raw.includes("\n");
  36756. }
  36757. return isLiteral$1(node);
  36758. }
  36759. function isObjectPropertyWithShortKey(node, keyDoc, options) {
  36760. if (!isObjectProperty(node)) {
  36761. return false;
  36762. } // TODO: for performance, it might make sense to use a more lightweight
  36763. // version of cleanDoc, such that it would stop once it detects that
  36764. // the doc can't be reduced to a string.
  36765. keyDoc = cleanDoc$1(keyDoc);
  36766. const MIN_OVERLAP_FOR_BREAK = 3; // ↓↓ - insufficient overlap for a line break
  36767. // key1: longValue1,
  36768. // ↓↓↓↓↓↓ - overlap is long enough to break
  36769. // key2abcd:
  36770. // longValue2
  36771. return typeof keyDoc === "string" && getStringWidth$1(keyDoc) < options.tabWidth + MIN_OVERLAP_FOR_BREAK;
  36772. }
  36773. function isCallExpressionWithComplexTypeArguments(node, print) {
  36774. const typeArgs = getTypeArgumentsFromCallExpression(node);
  36775. if (isNonEmptyArray$e(typeArgs)) {
  36776. if (typeArgs.length > 1) {
  36777. return true;
  36778. }
  36779. if (typeArgs.length === 1) {
  36780. const firstArg = typeArgs[0];
  36781. if (firstArg.type === "TSUnionType" || firstArg.type === "UnionTypeAnnotation" || firstArg.type === "TSIntersectionType" || firstArg.type === "IntersectionTypeAnnotation") {
  36782. return true;
  36783. }
  36784. }
  36785. const typeArgsKeyName = node.typeParameters ? "typeParameters" : "typeArguments";
  36786. if (willBreak$2(print(typeArgsKeyName))) {
  36787. return true;
  36788. }
  36789. }
  36790. return false;
  36791. }
  36792. function getTypeArgumentsFromCallExpression(node) {
  36793. return node.typeParameters && node.typeParameters.params || node.typeArguments && node.typeArguments.params;
  36794. }
  36795. var assignment = {
  36796. printVariableDeclarator: printVariableDeclarator$1,
  36797. printAssignmentExpression: printAssignmentExpression$1,
  36798. printAssignment: printAssignment$3,
  36799. isArrowFunctionVariableDeclarator: isArrowFunctionVariableDeclarator$1
  36800. };
  36801. const {
  36802. getNextNonSpaceNonCommentCharacter
  36803. } = util$8;
  36804. const {
  36805. printDanglingComments: printDanglingComments$a
  36806. } = comments$4;
  36807. const {
  36808. builders: {
  36809. line: line$p,
  36810. hardline: hardline$s,
  36811. softline: softline$k,
  36812. group: group$q,
  36813. indent: indent$k,
  36814. ifBreak: ifBreak$i
  36815. },
  36816. utils: {
  36817. removeLines: removeLines$2,
  36818. willBreak: willBreak$1
  36819. }
  36820. } = require$$7$3;
  36821. const {
  36822. getFunctionParameters: getFunctionParameters$2,
  36823. iterateFunctionParametersPath,
  36824. isSimpleType: isSimpleType$1,
  36825. isTestCall: isTestCall$1,
  36826. isTypeAnnotationAFunction,
  36827. isObjectType: isObjectType$2,
  36828. isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$1,
  36829. hasRestParameter,
  36830. shouldPrintComma: shouldPrintComma$8,
  36831. hasComment: hasComment$9,
  36832. isNextLineEmpty: isNextLineEmpty$8
  36833. } = utils$5;
  36834. const {
  36835. locEnd: locEnd$m
  36836. } = loc$6;
  36837. const {
  36838. ArgExpansionBailout: ArgExpansionBailout$1
  36839. } = errors;
  36840. const {
  36841. printFunctionTypeParameters: printFunctionTypeParameters$1
  36842. } = misc$1;
  36843. function printFunctionParameters$3(path, print, options, expandArg, printTypeParams) {
  36844. const functionNode = path.getValue();
  36845. const parameters = getFunctionParameters$2(functionNode);
  36846. const typeParams = printTypeParams ? printFunctionTypeParameters$1(path, options, print) : "";
  36847. if (parameters.length === 0) {
  36848. return [typeParams, "(", printDanglingComments$a(path, options,
  36849. /* sameIndent */
  36850. true, comment => getNextNonSpaceNonCommentCharacter(options.originalText, comment, locEnd$m) === ")"), ")"];
  36851. }
  36852. const parent = path.getParentNode();
  36853. const isParametersInTestCall = isTestCall$1(parent);
  36854. const shouldHugParameters = shouldHugFunctionParameters$1(functionNode);
  36855. const printed = [];
  36856. iterateFunctionParametersPath(path, (parameterPath, index) => {
  36857. const isLastParameter = index === parameters.length - 1;
  36858. if (isLastParameter && functionNode.rest) {
  36859. printed.push("...");
  36860. }
  36861. printed.push(print());
  36862. if (isLastParameter) {
  36863. return;
  36864. }
  36865. printed.push(",");
  36866. if (isParametersInTestCall || shouldHugParameters) {
  36867. printed.push(" ");
  36868. } else if (isNextLineEmpty$8(parameters[index], options)) {
  36869. printed.push(hardline$s, hardline$s);
  36870. } else {
  36871. printed.push(line$p);
  36872. }
  36873. }); // If the parent is a call with the first/last argument expansion and this is the
  36874. // params of the first/last argument, we don't want the arguments to break and instead
  36875. // want the whole expression to be on a new line.
  36876. //
  36877. // Good: Bad:
  36878. // verylongcall( verylongcall((
  36879. // (a, b) => { a,
  36880. // } b,
  36881. // ) ) => {
  36882. // })
  36883. if (expandArg) {
  36884. if (willBreak$1(typeParams) || willBreak$1(printed)) {
  36885. // Removing lines in this case leads to broken or ugly output
  36886. throw new ArgExpansionBailout$1();
  36887. }
  36888. return group$q([removeLines$2(typeParams), "(", removeLines$2(printed), ")"]);
  36889. } // Single object destructuring should hug
  36890. //
  36891. // function({
  36892. // a,
  36893. // b,
  36894. // c
  36895. // }) {}
  36896. const hasNotParameterDecorator = parameters.every(node => !node.decorators);
  36897. if (shouldHugParameters && hasNotParameterDecorator) {
  36898. return [typeParams, "(", ...printed, ")"];
  36899. } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  36900. if (isParametersInTestCall) {
  36901. return [typeParams, "(", ...printed, ")"];
  36902. }
  36903. const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent) || isTypeAnnotationAFunction(parent) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === functionNode) && parameters.length === 1 && parameters[0].name === null && // `type q = (this: string) => void;`
  36904. functionNode.this !== parameters[0] && parameters[0].typeAnnotation && functionNode.typeParameters === null && isSimpleType$1(parameters[0].typeAnnotation) && !functionNode.rest;
  36905. if (isFlowShorthandWithOneArg) {
  36906. if (options.arrowParens === "always") {
  36907. return ["(", ...printed, ")"];
  36908. }
  36909. return printed;
  36910. }
  36911. return [typeParams, "(", indent$k([softline$k, ...printed]), ifBreak$i(!hasRestParameter(functionNode) && shouldPrintComma$8(options, "all") ? "," : ""), softline$k, ")"];
  36912. }
  36913. function shouldHugFunctionParameters$1(node) {
  36914. if (!node) {
  36915. return false;
  36916. }
  36917. const parameters = getFunctionParameters$2(node);
  36918. if (parameters.length !== 1) {
  36919. return false;
  36920. }
  36921. const [parameter] = parameters;
  36922. return !hasComment$9(parameter) && (parameter.type === "ObjectPattern" || parameter.type === "ArrayPattern" || parameter.type === "Identifier" && parameter.typeAnnotation && (parameter.typeAnnotation.type === "TypeAnnotation" || parameter.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$2(parameter.typeAnnotation.typeAnnotation) || parameter.type === "FunctionTypeParam" && isObjectType$2(parameter.typeAnnotation) || parameter.type === "AssignmentPattern" && (parameter.left.type === "ObjectPattern" || parameter.left.type === "ArrayPattern") && (parameter.right.type === "Identifier" || parameter.right.type === "ObjectExpression" && parameter.right.properties.length === 0 || parameter.right.type === "ArrayExpression" && parameter.right.elements.length === 0));
  36923. }
  36924. function getReturnTypeNode(functionNode) {
  36925. let returnTypeNode;
  36926. if (functionNode.returnType) {
  36927. returnTypeNode = functionNode.returnType;
  36928. if (returnTypeNode.typeAnnotation) {
  36929. returnTypeNode = returnTypeNode.typeAnnotation;
  36930. }
  36931. } else if (functionNode.typeAnnotation) {
  36932. returnTypeNode = functionNode.typeAnnotation;
  36933. }
  36934. return returnTypeNode;
  36935. } // When parameters are grouped, the return type annotation breaks first.
  36936. function shouldGroupFunctionParameters$3(functionNode, returnTypeDoc) {
  36937. const returnTypeNode = getReturnTypeNode(functionNode);
  36938. if (!returnTypeNode) {
  36939. return false;
  36940. }
  36941. const typeParameters = functionNode.typeParameters && functionNode.typeParameters.params;
  36942. if (typeParameters) {
  36943. if (typeParameters.length > 1) {
  36944. return false;
  36945. }
  36946. if (typeParameters.length === 1) {
  36947. const typeParameter = typeParameters[0];
  36948. if (typeParameter.constraint || typeParameter.default) {
  36949. return false;
  36950. }
  36951. }
  36952. }
  36953. return getFunctionParameters$2(functionNode).length === 1 && (isObjectType$2(returnTypeNode) || willBreak$1(returnTypeDoc));
  36954. }
  36955. var functionParameters = {
  36956. printFunctionParameters: printFunctionParameters$3,
  36957. shouldHugFunctionParameters: shouldHugFunctionParameters$1,
  36958. shouldGroupFunctionParameters: shouldGroupFunctionParameters$3
  36959. };
  36960. const {
  36961. printComments: printComments$2,
  36962. printDanglingComments: printDanglingComments$9
  36963. } = comments$4;
  36964. const {
  36965. getLast: getLast$c,
  36966. isNonEmptyArray: isNonEmptyArray$d
  36967. } = util$8;
  36968. const {
  36969. builders: {
  36970. group: group$p,
  36971. join: join$l,
  36972. line: line$o,
  36973. softline: softline$j,
  36974. indent: indent$j,
  36975. align: align$3,
  36976. ifBreak: ifBreak$h
  36977. }
  36978. } = require$$7$3;
  36979. const pathNeedsParens$2 = needsParens_1;
  36980. const {
  36981. locStart: locStart$n
  36982. } = loc$6;
  36983. const {
  36984. isSimpleType,
  36985. isObjectType: isObjectType$1,
  36986. hasLeadingOwnLineComment: hasLeadingOwnLineComment$1,
  36987. isObjectTypePropertyAFunction,
  36988. shouldPrintComma: shouldPrintComma$7
  36989. } = utils$5;
  36990. const {
  36991. printAssignment: printAssignment$2
  36992. } = assignment;
  36993. const {
  36994. printFunctionParameters: printFunctionParameters$2,
  36995. shouldGroupFunctionParameters: shouldGroupFunctionParameters$2
  36996. } = functionParameters;
  36997. const {
  36998. printArrayItems: printArrayItems$2
  36999. } = array;
  37000. function shouldHugType$2(node) {
  37001. if (isSimpleType(node) || isObjectType$1(node)) {
  37002. return true;
  37003. }
  37004. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  37005. const voidCount = node.types.filter(node => node.type === "VoidTypeAnnotation" || node.type === "TSVoidKeyword" || node.type === "NullLiteralTypeAnnotation" || node.type === "TSNullKeyword").length;
  37006. const hasObject = node.types.some(node => node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  37007. node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference");
  37008. if (node.types.length - 1 === voidCount && hasObject) {
  37009. return true;
  37010. }
  37011. }
  37012. return false;
  37013. }
  37014. function printOpaqueType$1(path, options, print) {
  37015. const semi = options.semi ? ";" : "";
  37016. const node = path.getValue();
  37017. const parts = [];
  37018. parts.push("opaque type ", print("id"), print("typeParameters"));
  37019. if (node.supertype) {
  37020. parts.push(": ", print("supertype"));
  37021. }
  37022. if (node.impltype) {
  37023. parts.push(" = ", print("impltype"));
  37024. }
  37025. parts.push(semi);
  37026. return parts;
  37027. }
  37028. function printTypeAlias$2(path, options, print) {
  37029. const semi = options.semi ? ";" : "";
  37030. const node = path.getValue();
  37031. const parts = [];
  37032. if (node.declare) {
  37033. parts.push("declare ");
  37034. }
  37035. parts.push("type ", print("id"), print("typeParameters"));
  37036. const rightPropertyName = node.type === "TSTypeAliasDeclaration" ? "typeAnnotation" : "right";
  37037. return [printAssignment$2(path, options, print, parts, " =", rightPropertyName), semi];
  37038. } // `TSIntersectionType` and `IntersectionTypeAnnotation`
  37039. function printIntersectionType$2(path, options, print) {
  37040. const node = path.getValue();
  37041. const types = path.map(print, "types");
  37042. const result = [];
  37043. let wasIndented = false;
  37044. for (let i = 0; i < types.length; ++i) {
  37045. if (i === 0) {
  37046. result.push(types[i]);
  37047. } else if (isObjectType$1(node.types[i - 1]) && isObjectType$1(node.types[i])) {
  37048. // If both are objects, don't indent
  37049. result.push([" & ", wasIndented ? indent$j(types[i]) : types[i]]);
  37050. } else if (!isObjectType$1(node.types[i - 1]) && !isObjectType$1(node.types[i])) {
  37051. // If no object is involved, go to the next line if it breaks
  37052. result.push(indent$j([" &", line$o, types[i]]));
  37053. } else {
  37054. // If you go from object to non-object or vis-versa, then inline it
  37055. if (i > 1) {
  37056. wasIndented = true;
  37057. }
  37058. result.push(" & ", i > 1 ? indent$j(types[i]) : types[i]);
  37059. }
  37060. }
  37061. return group$p(result);
  37062. } // `TSUnionType` and `UnionTypeAnnotation`
  37063. function printUnionType$2(path, options, print) {
  37064. const node = path.getValue(); // single-line variation
  37065. // A | B | C
  37066. // multi-line variation
  37067. // | A
  37068. // | B
  37069. // | C
  37070. const parent = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  37071. const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name && path.getParentNode(1).this !== parent) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, node)); // {
  37072. // a: string
  37073. // } | null | void
  37074. // should be inlined and not be printed in the multi-line variant
  37075. const shouldHug = shouldHugType$2(node); // We want to align the children but without its comment, so it looks like
  37076. // | child1
  37077. // // comment
  37078. // | child2
  37079. const printed = path.map(typePath => {
  37080. let printedType = print();
  37081. if (!shouldHug) {
  37082. printedType = align$3(2, printedType);
  37083. }
  37084. return printComments$2(typePath, printedType, options);
  37085. }, "types");
  37086. if (shouldHug) {
  37087. return join$l(" | ", printed);
  37088. }
  37089. const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, node);
  37090. const code = [ifBreak$h([shouldAddStartLine ? line$o : "", "| "]), join$l([line$o, "| "], printed)];
  37091. if (pathNeedsParens$2(path, options)) {
  37092. return group$p([indent$j(code), softline$j]);
  37093. }
  37094. if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
  37095. return group$p([indent$j([ifBreak$h(["(", softline$j]), code]), softline$j, ifBreak$h(")")]);
  37096. }
  37097. return group$p(shouldIndent ? indent$j(code) : code);
  37098. } // `TSFunctionType` and `FunctionTypeAnnotation`
  37099. function printFunctionType$2(path, options, print) {
  37100. const node = path.getValue();
  37101. const parts = []; // FunctionTypeAnnotation is ambiguous:
  37102. // declare function foo(a: B): void; OR
  37103. // var A: (a: B) => void;
  37104. const parent = path.getParentNode(0);
  37105. const parentParent = path.getParentNode(1);
  37106. const parentParentParent = path.getParentNode(2);
  37107. let isArrowFunctionTypeAnnotation = node.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !parent.variance && !parent.optional && locStart$n(parent) === locStart$n(node) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
  37108. let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation"); // Sadly we can't put it inside of AstPath::needsColon because we are
  37109. // printing ":" as part of the expression and it would put parenthesis
  37110. // around :(
  37111. const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
  37112. if (isObjectTypePropertyAFunction(parent)) {
  37113. isArrowFunctionTypeAnnotation = true;
  37114. needsColon = true;
  37115. }
  37116. if (needsParens) {
  37117. parts.push("(");
  37118. }
  37119. const parametersDoc = printFunctionParameters$2(path, print, options,
  37120. /* expandArg */
  37121. false,
  37122. /* printTypeParams */
  37123. true); // The returnType is not wrapped in a TypeAnnotation, so the colon
  37124. // needs to be added separately.
  37125. const returnTypeDoc = node.returnType || node.predicate || node.typeAnnotation ? [isArrowFunctionTypeAnnotation ? " => " : ": ", print("returnType"), print("predicate"), print("typeAnnotation")] : "";
  37126. const shouldGroupParameters = shouldGroupFunctionParameters$2(node, returnTypeDoc);
  37127. parts.push(shouldGroupParameters ? group$p(parametersDoc) : parametersDoc);
  37128. if (returnTypeDoc) {
  37129. parts.push(returnTypeDoc);
  37130. }
  37131. if (needsParens) {
  37132. parts.push(")");
  37133. }
  37134. return group$p(parts);
  37135. } // `TSTupleType` and `TupleTypeAnnotation`
  37136. function printTupleType$2(path, options, print) {
  37137. const node = path.getValue();
  37138. const typesField = node.type === "TSTupleType" ? "elementTypes" : "types";
  37139. const types = node[typesField];
  37140. const isNonEmptyTuple = isNonEmptyArray$d(types);
  37141. const hasRest = isNonEmptyTuple && getLast$c(types).type === "TSRestType";
  37142. const bracketsDelimiterLine = isNonEmptyTuple ? softline$j : "";
  37143. return group$p(["[", indent$j([bracketsDelimiterLine, printArrayItems$2(path, options, typesField, print)]), ifBreak$h(isNonEmptyTuple && shouldPrintComma$7(options, "all") && !hasRest ? "," : ""), printDanglingComments$9(path, options,
  37144. /* sameIndent */
  37145. true), bracketsDelimiterLine, "]"]);
  37146. } // `TSIndexedAccessType`, `IndexedAccessType`, and `OptionalIndexedAccessType`
  37147. function printIndexedAccessType$2(path, options, print) {
  37148. const node = path.getValue();
  37149. const leftDelimiter = node.type === "OptionalIndexedAccessType" && node.optional ? "?.[" : "[";
  37150. return [print("objectType"), leftDelimiter, print("indexType"), "]"];
  37151. }
  37152. var typeAnnotation = {
  37153. printOpaqueType: printOpaqueType$1,
  37154. printTypeAlias: printTypeAlias$2,
  37155. printIntersectionType: printIntersectionType$2,
  37156. printUnionType: printUnionType$2,
  37157. printFunctionType: printFunctionType$2,
  37158. printTupleType: printTupleType$2,
  37159. printIndexedAccessType: printIndexedAccessType$2,
  37160. shouldHugType: shouldHugType$2
  37161. };
  37162. const {
  37163. printDanglingComments: printDanglingComments$8
  37164. } = comments$4;
  37165. const {
  37166. builders: {
  37167. join: join$k,
  37168. line: line$n,
  37169. hardline: hardline$r,
  37170. softline: softline$i,
  37171. group: group$o,
  37172. indent: indent$i,
  37173. ifBreak: ifBreak$g
  37174. }
  37175. } = require$$7$3;
  37176. const {
  37177. isTestCall,
  37178. hasComment: hasComment$8,
  37179. CommentCheckFlags: CommentCheckFlags$8,
  37180. isTSXFile,
  37181. shouldPrintComma: shouldPrintComma$6,
  37182. getFunctionParameters: getFunctionParameters$1,
  37183. isObjectType
  37184. } = utils$5;
  37185. const {
  37186. createGroupIdMapper: createGroupIdMapper$1
  37187. } = util$8;
  37188. const {
  37189. shouldHugType: shouldHugType$1
  37190. } = typeAnnotation;
  37191. const {
  37192. isArrowFunctionVariableDeclarator
  37193. } = assignment;
  37194. const getTypeParametersGroupId$2 = createGroupIdMapper$1("typeParameters");
  37195. function printTypeParameters$2(path, options, print, paramsKey) {
  37196. const node = path.getValue();
  37197. if (!node[paramsKey]) {
  37198. return "";
  37199. } // for TypeParameterDeclaration typeParameters is a single node
  37200. if (!Array.isArray(node[paramsKey])) {
  37201. return print(paramsKey);
  37202. }
  37203. const grandparent = path.getNode(2);
  37204. const isParameterInTestCall = grandparent && isTestCall(grandparent);
  37205. const isArrowFunctionVariable = path.match(node => !(node[paramsKey].length === 1 && isObjectType(node[paramsKey][0])), undefined, (node, name) => name === "typeAnnotation", node => node.type === "Identifier", isArrowFunctionVariableDeclarator);
  37206. const shouldInline = !isArrowFunctionVariable && (isParameterInTestCall || node[paramsKey].length === 0 || node[paramsKey].length === 1 && (node[paramsKey][0].type === "NullableTypeAnnotation" || shouldHugType$1(node[paramsKey][0])));
  37207. if (shouldInline) {
  37208. return ["<", join$k(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(path, options), ">"];
  37209. } // Keep comma if the file extension is .tsx and
  37210. // has one type parameter that isn't extend with any types.
  37211. // Because, otherwise formatted result will be invalid as tsx.
  37212. const trailingComma = node.type === "TSTypeParameterInstantiation" // https://github.com/microsoft/TypeScript/issues/21984
  37213. ? "" : getFunctionParameters$1(node).length === 1 && isTSXFile(options) && !node[paramsKey][0].constraint && path.getParentNode().type === "ArrowFunctionExpression" ? "," : shouldPrintComma$6(options, "all") ? ifBreak$g(",") : "";
  37214. return group$o(["<", indent$i([softline$i, join$k([",", line$n], path.map(print, paramsKey))]), trailingComma, softline$i, ">"], {
  37215. id: getTypeParametersGroupId$2(node)
  37216. });
  37217. }
  37218. function printDanglingCommentsForInline(path, options) {
  37219. const node = path.getValue();
  37220. if (!hasComment$8(node, CommentCheckFlags$8.Dangling)) {
  37221. return "";
  37222. }
  37223. const hasOnlyBlockComments = !hasComment$8(node, CommentCheckFlags$8.Line);
  37224. const printed = printDanglingComments$8(path, options,
  37225. /* sameIndent */
  37226. hasOnlyBlockComments);
  37227. if (hasOnlyBlockComments) {
  37228. return printed;
  37229. }
  37230. return [printed, hardline$r];
  37231. }
  37232. function printTypeParameter$2(path, options, print) {
  37233. const node = path.getValue();
  37234. const parts = [];
  37235. const parent = path.getParentNode();
  37236. if (parent.type === "TSMappedType") {
  37237. parts.push("[", print("name"));
  37238. if (node.constraint) {
  37239. parts.push(" in ", print("constraint"));
  37240. }
  37241. if (parent.nameType) {
  37242. parts.push(" as ", path.callParent(() => print("nameType")));
  37243. }
  37244. parts.push("]");
  37245. return parts;
  37246. }
  37247. if (node.variance) {
  37248. parts.push(print("variance"));
  37249. }
  37250. parts.push(print("name"));
  37251. if (node.bound) {
  37252. parts.push(": ", print("bound"));
  37253. }
  37254. if (node.constraint) {
  37255. parts.push(" extends ", print("constraint"));
  37256. }
  37257. if (node.default) {
  37258. parts.push(" = ", print("default"));
  37259. }
  37260. return parts;
  37261. }
  37262. var typeParameters = {
  37263. printTypeParameter: printTypeParameter$2,
  37264. printTypeParameters: printTypeParameters$2,
  37265. getTypeParametersGroupId: getTypeParametersGroupId$2
  37266. };
  37267. const {
  37268. printComments: printComments$1
  37269. } = comments$4;
  37270. const {
  37271. printString: printString$3,
  37272. printNumber: printNumber$3
  37273. } = util$8;
  37274. const {
  37275. isNumericLiteral,
  37276. isSimpleNumber,
  37277. isStringLiteral,
  37278. isStringPropSafeToUnquote,
  37279. rawText: rawText$2
  37280. } = utils$5;
  37281. const {
  37282. printAssignment: printAssignment$1
  37283. } = assignment;
  37284. const needsQuoteProps = new WeakMap();
  37285. function printPropertyKey$4(path, options, print) {
  37286. const node = path.getNode();
  37287. if (node.computed) {
  37288. return ["[", print("key"), "]"];
  37289. }
  37290. const parent = path.getParentNode();
  37291. const {
  37292. key
  37293. } = node; // flow has `Identifier` key, other parsers use `PrivateIdentifier` (ESTree) or `PrivateName`
  37294. if (node.type === "ClassPrivateProperty" && key.type === "Identifier") {
  37295. return ["#", print("key")];
  37296. }
  37297. if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
  37298. const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral(prop.key) && !isStringPropSafeToUnquote(prop, options));
  37299. needsQuoteProps.set(parent, objectHasStringProp);
  37300. }
  37301. if ((key.type === "Identifier" || isNumericLiteral(key) && isSimpleNumber(printNumber$3(rawText$2(key))) && // Avoid converting 999999999999999999999 to 1e+21, 0.99999999999999999 to 1 and 1.0 to 1.
  37302. String(key.value) === printNumber$3(rawText$2(key)) && // Quoting number keys is safe in JS and Flow, but not in TypeScript (as
  37303. // mentioned in `isStringPropSafeToUnquote`).
  37304. !(options.parser === "typescript" || options.parser === "babel-ts")) && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
  37305. // a -> "a"
  37306. // 1 -> "1"
  37307. // 1.5 -> "1.5"
  37308. const prop = printString$3(JSON.stringify(key.type === "Identifier" ? key.name : key.value.toString()), options);
  37309. return path.call(keyPath => printComments$1(keyPath, prop, options), "key");
  37310. }
  37311. if (isStringPropSafeToUnquote(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
  37312. // 'a' -> a
  37313. // '1' -> 1
  37314. // '1.5' -> 1.5
  37315. return path.call(keyPath => printComments$1(keyPath, /^\d/.test(key.value) ? printNumber$3(key.value) : key.value, options), "key");
  37316. }
  37317. return print("key");
  37318. }
  37319. function printProperty$1(path, options, print) {
  37320. const node = path.getValue();
  37321. if (node.shorthand) {
  37322. return print("value");
  37323. }
  37324. return printAssignment$1(path, options, print, printPropertyKey$4(path, options, print), ":", "value");
  37325. }
  37326. var property = {
  37327. printProperty: printProperty$1,
  37328. printPropertyKey: printPropertyKey$4
  37329. };
  37330. /** @typedef {import("../../document/doc-builders").Doc} Doc */
  37331. const assert$2 = require$$0__default$3["default"];
  37332. const {
  37333. printDanglingComments: printDanglingComments$7,
  37334. printCommentsSeparately
  37335. } = comments$4;
  37336. const getLast$b = getLast_1;
  37337. const {
  37338. getNextNonSpaceNonCommentCharacterIndex
  37339. } = util$8;
  37340. const {
  37341. builders: {
  37342. line: line$m,
  37343. softline: softline$h,
  37344. group: group$n,
  37345. indent: indent$h,
  37346. ifBreak: ifBreak$f,
  37347. hardline: hardline$q,
  37348. join: join$j,
  37349. indentIfBreak: indentIfBreak$1
  37350. },
  37351. utils: {
  37352. removeLines: removeLines$1,
  37353. willBreak
  37354. }
  37355. } = require$$7$3;
  37356. const {
  37357. ArgExpansionBailout
  37358. } = errors;
  37359. const {
  37360. getFunctionParameters,
  37361. hasLeadingOwnLineComment,
  37362. isFlowAnnotationComment,
  37363. isJsxNode: isJsxNode$2,
  37364. isTemplateOnItsOwnLine,
  37365. shouldPrintComma: shouldPrintComma$5,
  37366. startsWithNoLookaheadToken,
  37367. isBinaryish,
  37368. isLineComment: isLineComment$2,
  37369. hasComment: hasComment$7,
  37370. getComments: getComments$2,
  37371. CommentCheckFlags: CommentCheckFlags$7,
  37372. isCallLikeExpression,
  37373. isCallExpression: isCallExpression$3,
  37374. getCallArguments,
  37375. hasNakedLeftSide: hasNakedLeftSide$1,
  37376. getLeftSide
  37377. } = utils$5;
  37378. const {
  37379. locEnd: locEnd$l
  37380. } = loc$6;
  37381. const {
  37382. printFunctionParameters: printFunctionParameters$1,
  37383. shouldGroupFunctionParameters: shouldGroupFunctionParameters$1
  37384. } = functionParameters;
  37385. const {
  37386. printPropertyKey: printPropertyKey$3
  37387. } = property;
  37388. const {
  37389. printFunctionTypeParameters
  37390. } = misc$1;
  37391. function printFunction$2(path, print, options, args) {
  37392. const node = path.getValue();
  37393. let expandArg = false;
  37394. if ((node.type === "FunctionDeclaration" || node.type === "FunctionExpression") && args && args.expandLastArg) {
  37395. const parent = path.getParentNode();
  37396. if (isCallExpression$3(parent) && getCallArguments(parent).length > 1) {
  37397. expandArg = true;
  37398. }
  37399. }
  37400. const parts = []; // For TypeScript the TSDeclareFunction node shares the AST
  37401. // structure with FunctionDeclaration
  37402. if (node.type === "TSDeclareFunction" && node.declare) {
  37403. parts.push("declare ");
  37404. }
  37405. if (node.async) {
  37406. parts.push("async ");
  37407. }
  37408. if (node.generator) {
  37409. parts.push("function* ");
  37410. } else {
  37411. parts.push("function ");
  37412. }
  37413. if (node.id) {
  37414. parts.push(print("id"));
  37415. }
  37416. const parametersDoc = printFunctionParameters$1(path, print, options, expandArg);
  37417. const returnTypeDoc = printReturnType(path, print, options);
  37418. const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
  37419. parts.push(printFunctionTypeParameters(path, options, print), group$n([shouldGroupParameters ? group$n(parametersDoc) : parametersDoc, returnTypeDoc]), node.body ? " " : "", print("body"));
  37420. if (options.semi && (node.declare || !node.body)) {
  37421. parts.push(";");
  37422. }
  37423. return parts;
  37424. }
  37425. function printMethod$2(path, options, print) {
  37426. const node = path.getNode();
  37427. const {
  37428. kind
  37429. } = node;
  37430. const value = node.value || node;
  37431. const parts = [];
  37432. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  37433. if (value.async) {
  37434. parts.push("async ");
  37435. }
  37436. } else {
  37437. assert$2.ok(kind === "get" || kind === "set");
  37438. parts.push(kind, " ");
  37439. } // A `getter`/`setter` can't be a generator, but it's recoverable
  37440. if (value.generator) {
  37441. parts.push("*");
  37442. }
  37443. parts.push(printPropertyKey$3(path, options, print), node.optional || node.key.optional ? "?" : "");
  37444. if (node === value) {
  37445. parts.push(printMethodInternal$1(path, options, print));
  37446. } else if (value.type === "FunctionExpression") {
  37447. parts.push(path.call(path => printMethodInternal$1(path, options, print), "value"));
  37448. } else {
  37449. parts.push(print("value"));
  37450. }
  37451. return parts;
  37452. }
  37453. function printMethodInternal$1(path, options, print) {
  37454. const node = path.getNode();
  37455. const parametersDoc = printFunctionParameters$1(path, print, options);
  37456. const returnTypeDoc = printReturnType(path, print, options);
  37457. const shouldGroupParameters = shouldGroupFunctionParameters$1(node, returnTypeDoc);
  37458. const parts = [printFunctionTypeParameters(path, options, print), group$n([shouldGroupParameters ? group$n(parametersDoc) : parametersDoc, returnTypeDoc])];
  37459. if (node.body) {
  37460. parts.push(" ", print("body"));
  37461. } else {
  37462. parts.push(options.semi ? ";" : "");
  37463. }
  37464. return parts;
  37465. }
  37466. function printArrowFunctionSignature(path, options, print, args) {
  37467. const node = path.getValue();
  37468. const parts = [];
  37469. if (node.async) {
  37470. parts.push("async ");
  37471. }
  37472. if (shouldPrintParamsWithoutParens$1(path, options)) {
  37473. parts.push(print(["params", 0]));
  37474. } else {
  37475. const expandArg = args && (args.expandLastArg || args.expandFirstArg);
  37476. let returnTypeDoc = printReturnType(path, print, options);
  37477. if (expandArg) {
  37478. if (willBreak(returnTypeDoc)) {
  37479. throw new ArgExpansionBailout();
  37480. }
  37481. returnTypeDoc = group$n(removeLines$1(returnTypeDoc));
  37482. }
  37483. parts.push(group$n([printFunctionParameters$1(path, print, options, expandArg,
  37484. /* printTypeParams */
  37485. true), returnTypeDoc]));
  37486. }
  37487. const dangling = printDanglingComments$7(path, options,
  37488. /* sameIndent */
  37489. true, comment => {
  37490. const nextCharacter = getNextNonSpaceNonCommentCharacterIndex(options.originalText, comment, locEnd$l);
  37491. return nextCharacter !== false && options.originalText.slice(nextCharacter, nextCharacter + 2) === "=>";
  37492. });
  37493. if (dangling) {
  37494. parts.push(" ", dangling);
  37495. }
  37496. return parts;
  37497. }
  37498. function printArrowChain(path, args, signatures, shouldBreak, bodyDoc, tailNode) {
  37499. const name = path.getName();
  37500. const parent = path.getParentNode();
  37501. const isCallee = isCallLikeExpression(parent) && name === "callee";
  37502. const isAssignmentRhs = Boolean(args && args.assignmentLayout);
  37503. const shouldPutBodyOnSeparateLine = tailNode.body.type !== "BlockStatement" && tailNode.body.type !== "ObjectExpression" && tailNode.body.type !== "SequenceExpression";
  37504. const shouldBreakBeforeChain = isCallee && shouldPutBodyOnSeparateLine || args && args.assignmentLayout === "chain-tail-arrow-chain";
  37505. const groupId = Symbol("arrow-chain"); // We handle sequence expressions as the body of arrows specially,
  37506. // so that the required parentheses end up on their own lines.
  37507. if (tailNode.body.type === "SequenceExpression") {
  37508. bodyDoc = group$n(["(", indent$h([softline$h, bodyDoc]), softline$h, ")"]);
  37509. }
  37510. return group$n([group$n(indent$h([isCallee || isAssignmentRhs ? softline$h : "", group$n(join$j([" =>", line$m], signatures), {
  37511. shouldBreak
  37512. })]), {
  37513. id: groupId,
  37514. shouldBreak: shouldBreakBeforeChain
  37515. }), " =>", indentIfBreak$1(shouldPutBodyOnSeparateLine ? indent$h([line$m, bodyDoc]) : [" ", bodyDoc], {
  37516. groupId
  37517. }), isCallee ? ifBreak$f(softline$h, "", {
  37518. groupId
  37519. }) : ""]);
  37520. }
  37521. function printArrowFunction$1(path, options, print, args) {
  37522. let node = path.getValue();
  37523. /** @type {Doc[]} */
  37524. const signatures = [];
  37525. const body = [];
  37526. let chainShouldBreak = false;
  37527. (function rec() {
  37528. const doc = printArrowFunctionSignature(path, options, print, args);
  37529. if (signatures.length === 0) {
  37530. signatures.push(doc);
  37531. } else {
  37532. const {
  37533. leading,
  37534. trailing
  37535. } = printCommentsSeparately(path, options);
  37536. signatures.push([leading, doc]);
  37537. body.unshift(trailing);
  37538. }
  37539. chainShouldBreak = chainShouldBreak || // Always break the chain if:
  37540. node.returnType && getFunctionParameters(node).length > 0 || node.typeParameters || getFunctionParameters(node).some(param => param.type !== "Identifier");
  37541. if (node.body.type !== "ArrowFunctionExpression" || args && args.expandLastArg) {
  37542. body.unshift(print("body", args));
  37543. } else {
  37544. node = node.body;
  37545. path.call(rec, "body");
  37546. }
  37547. })();
  37548. if (signatures.length > 1) {
  37549. return printArrowChain(path, args, signatures, chainShouldBreak, body, node);
  37550. }
  37551. const parts = signatures;
  37552. parts.push(" =>"); // We want to always keep these types of nodes on the same line
  37553. // as the arrow.
  37554. if (!hasLeadingOwnLineComment(options.originalText, node.body) && (node.body.type === "ArrayExpression" || node.body.type === "ObjectExpression" || node.body.type === "BlockStatement" || isJsxNode$2(node.body) || isTemplateOnItsOwnLine(node.body, options.originalText) || node.body.type === "ArrowFunctionExpression" || node.body.type === "DoExpression")) {
  37555. return group$n([...parts, " ", body]);
  37556. } // We handle sequence expressions as the body of arrows specially,
  37557. // so that the required parentheses end up on their own lines.
  37558. if (node.body.type === "SequenceExpression") {
  37559. return group$n([...parts, group$n([" (", indent$h([softline$h, body]), softline$h, ")"])]);
  37560. } // if the arrow function is expanded as last argument, we are adding a
  37561. // level of indentation and need to add a softline to align the closing )
  37562. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  37563. // we should align the expression's closing } with the line with the opening {.
  37564. const shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !hasComment$7(node);
  37565. const printTrailingComma = args && args.expandLastArg && shouldPrintComma$5(options, "all"); // In order to avoid confusion between
  37566. // a => a ? a : a
  37567. // a <= a ? a : a
  37568. const shouldAddParens = node.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken(node.body,
  37569. /* forbidFunctionAndClass */
  37570. false);
  37571. return group$n([...parts, group$n([indent$h([line$m, shouldAddParens ? ifBreak$f("", "(") : "", body, shouldAddParens ? ifBreak$f("", ")") : ""]), shouldAddSoftLine ? [ifBreak$f(printTrailingComma ? "," : ""), softline$h] : ""])]);
  37572. }
  37573. function canPrintParamsWithoutParens(node) {
  37574. const parameters = getFunctionParameters(node);
  37575. return parameters.length === 1 && !node.typeParameters && !hasComment$7(node, CommentCheckFlags$7.Dangling) && parameters[0].type === "Identifier" && !parameters[0].typeAnnotation && !hasComment$7(parameters[0]) && !parameters[0].optional && !node.predicate && !node.returnType;
  37576. }
  37577. function shouldPrintParamsWithoutParens$1(path, options) {
  37578. if (options.arrowParens === "always") {
  37579. return false;
  37580. }
  37581. if (options.arrowParens === "avoid") {
  37582. const node = path.getValue();
  37583. return canPrintParamsWithoutParens(node);
  37584. } // Fallback default; should be unreachable
  37585. /* istanbul ignore next */
  37586. return false;
  37587. }
  37588. /** @returns {Doc} */
  37589. function printReturnType(path, print, options) {
  37590. const node = path.getValue();
  37591. const returnType = print("returnType");
  37592. if (node.returnType && isFlowAnnotationComment(options.originalText, node.returnType)) {
  37593. return [" /*: ", returnType, " */"];
  37594. }
  37595. const parts = [returnType]; // prepend colon to TypeScript type annotation
  37596. if (node.returnType && node.returnType.typeAnnotation) {
  37597. parts.unshift(": ");
  37598. }
  37599. if (node.predicate) {
  37600. // The return type will already add the colon, but otherwise we
  37601. // need to do it ourselves
  37602. parts.push(node.returnType ? " " : ": ", print("predicate"));
  37603. }
  37604. return parts;
  37605. } // `ReturnStatement` and `ThrowStatement`
  37606. function printReturnOrThrowArgument(path, options, print) {
  37607. const node = path.getValue();
  37608. const semi = options.semi ? ";" : "";
  37609. const parts = [];
  37610. if (node.argument) {
  37611. if (returnArgumentHasLeadingComment(options, node.argument)) {
  37612. parts.push([" (", indent$h([hardline$q, print("argument")]), hardline$q, ")"]);
  37613. } else if (isBinaryish(node.argument) || node.argument.type === "SequenceExpression") {
  37614. parts.push(group$n([ifBreak$f(" (", " "), indent$h([softline$h, print("argument")]), softline$h, ifBreak$f(")")]));
  37615. } else {
  37616. parts.push(" ", print("argument"));
  37617. }
  37618. }
  37619. const comments = getComments$2(node);
  37620. const lastComment = getLast$b(comments);
  37621. const isLastCommentLine = lastComment && isLineComment$2(lastComment);
  37622. if (isLastCommentLine) {
  37623. parts.push(semi);
  37624. }
  37625. if (hasComment$7(node, CommentCheckFlags$7.Dangling)) {
  37626. parts.push(" ", printDanglingComments$7(path, options,
  37627. /* sameIndent */
  37628. true));
  37629. }
  37630. if (!isLastCommentLine) {
  37631. parts.push(semi);
  37632. }
  37633. return parts;
  37634. }
  37635. function printReturnStatement$1(path, options, print) {
  37636. return ["return", printReturnOrThrowArgument(path, options, print)];
  37637. }
  37638. function printThrowStatement$1(path, options, print) {
  37639. return ["throw", printReturnOrThrowArgument(path, options, print)];
  37640. } // This recurses the return argument, looking for the first token
  37641. // (the leftmost leaf node) and, if it (or its parents) has any
  37642. // leadingComments, returns true (so it can be wrapped in parens).
  37643. function returnArgumentHasLeadingComment(options, argument) {
  37644. if (hasLeadingOwnLineComment(options.originalText, argument)) {
  37645. return true;
  37646. }
  37647. if (hasNakedLeftSide$1(argument)) {
  37648. let leftMost = argument;
  37649. let newLeftMost;
  37650. while (newLeftMost = getLeftSide(leftMost)) {
  37651. leftMost = newLeftMost;
  37652. if (hasLeadingOwnLineComment(options.originalText, leftMost)) {
  37653. return true;
  37654. }
  37655. }
  37656. }
  37657. return false;
  37658. }
  37659. var _function = {
  37660. printFunction: printFunction$2,
  37661. printArrowFunction: printArrowFunction$1,
  37662. printMethod: printMethod$2,
  37663. printReturnStatement: printReturnStatement$1,
  37664. printThrowStatement: printThrowStatement$1,
  37665. printMethodInternal: printMethodInternal$1,
  37666. shouldPrintParamsWithoutParens: shouldPrintParamsWithoutParens$1
  37667. };
  37668. const {
  37669. isNonEmptyArray: isNonEmptyArray$c,
  37670. hasNewline: hasNewline$4
  37671. } = util$8;
  37672. const {
  37673. builders: {
  37674. line: line$l,
  37675. hardline: hardline$p,
  37676. join: join$i,
  37677. breakParent: breakParent$7,
  37678. group: group$m
  37679. }
  37680. } = require$$7$3;
  37681. const {
  37682. locStart: locStart$m,
  37683. locEnd: locEnd$k
  37684. } = loc$6;
  37685. const {
  37686. getParentExportDeclaration: getParentExportDeclaration$1
  37687. } = utils$5;
  37688. function printClassMemberDecorators$1(path, options, print) {
  37689. const node = path.getValue();
  37690. return group$m([join$i(line$l, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$p : line$l]);
  37691. }
  37692. function printDecoratorsBeforeExport$1(path, options, print) {
  37693. // Export declarations are responsible for printing any decorators
  37694. // that logically apply to node.declaration.
  37695. return [join$i(hardline$p, path.map(print, "declaration", "decorators")), hardline$p];
  37696. }
  37697. function printDecorators$1(path, options, print) {
  37698. const node = path.getValue();
  37699. const {
  37700. decorators
  37701. } = node;
  37702. if (!isNonEmptyArray$c(decorators) || // If the parent node is an export declaration and the decorator
  37703. // was written before the export, the export will be responsible
  37704. // for printing the decorators.
  37705. hasDecoratorsBeforeExport$1(path.getParentNode())) {
  37706. return;
  37707. }
  37708. const shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  37709. return [getParentExportDeclaration$1(path) ? hardline$p : shouldBreak ? breakParent$7 : "", join$i(line$l, path.map(print, "decorators")), line$l];
  37710. }
  37711. function hasNewlineBetweenOrAfterDecorators(node, options) {
  37712. return node.decorators.some(decorator => hasNewline$4(options.originalText, locEnd$k(decorator)));
  37713. }
  37714. function hasDecoratorsBeforeExport$1(node) {
  37715. if (node.type !== "ExportDefaultDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "DeclareExportDeclaration") {
  37716. return false;
  37717. }
  37718. const decorators = node.declaration && node.declaration.decorators;
  37719. return isNonEmptyArray$c(decorators) && locStart$m(node, {
  37720. ignoreDecorators: true
  37721. }) > locStart$m(decorators[0]);
  37722. }
  37723. var decorators = {
  37724. printDecorators: printDecorators$1,
  37725. printClassMemberDecorators: printClassMemberDecorators$1,
  37726. printDecoratorsBeforeExport: printDecoratorsBeforeExport$1,
  37727. hasDecoratorsBeforeExport: hasDecoratorsBeforeExport$1
  37728. };
  37729. const {
  37730. isNonEmptyArray: isNonEmptyArray$b,
  37731. createGroupIdMapper
  37732. } = util$8;
  37733. const {
  37734. printComments,
  37735. printDanglingComments: printDanglingComments$6
  37736. } = comments$4;
  37737. const {
  37738. builders: {
  37739. join: join$h,
  37740. line: line$k,
  37741. hardline: hardline$o,
  37742. softline: softline$g,
  37743. group: group$l,
  37744. indent: indent$g,
  37745. ifBreak: ifBreak$e
  37746. }
  37747. } = require$$7$3;
  37748. const {
  37749. hasComment: hasComment$6,
  37750. CommentCheckFlags: CommentCheckFlags$6
  37751. } = utils$5;
  37752. const {
  37753. getTypeParametersGroupId: getTypeParametersGroupId$1
  37754. } = typeParameters;
  37755. const {
  37756. printMethod: printMethod$1
  37757. } = _function;
  37758. const {
  37759. printOptionalToken: printOptionalToken$4,
  37760. printTypeAnnotation: printTypeAnnotation$3
  37761. } = misc$1;
  37762. const {
  37763. printPropertyKey: printPropertyKey$2
  37764. } = property;
  37765. const {
  37766. printAssignment
  37767. } = assignment;
  37768. const {
  37769. printClassMemberDecorators
  37770. } = decorators;
  37771. function printClass$2(path, options, print) {
  37772. const node = path.getValue();
  37773. const parts = [];
  37774. if (node.declare) {
  37775. parts.push("declare ");
  37776. }
  37777. if (node.abstract) {
  37778. parts.push("abstract ");
  37779. }
  37780. parts.push("class"); // Keep old behaviour of extends in same line
  37781. // If there is only on extends and there are not comments
  37782. const groupMode = node.id && hasComment$6(node.id, CommentCheckFlags$6.Trailing) || node.superClass && hasComment$6(node.superClass) || isNonEmptyArray$b(node.extends) || // DeclareClass
  37783. isNonEmptyArray$b(node.mixins) || isNonEmptyArray$b(node.implements);
  37784. const partsGroup = [];
  37785. const extendsParts = [];
  37786. if (node.id) {
  37787. partsGroup.push(" ", print("id"));
  37788. }
  37789. partsGroup.push(print("typeParameters"));
  37790. if (node.superClass) {
  37791. const printed = ["extends ", printSuperClass(path, options, print), print("superTypeParameters")];
  37792. const printedWithComments = path.call(superClass => printComments(superClass, printed, options), "superClass");
  37793. if (groupMode) {
  37794. extendsParts.push(line$k, group$l(printedWithComments));
  37795. } else {
  37796. extendsParts.push(" ", printedWithComments);
  37797. }
  37798. } else {
  37799. extendsParts.push(printList(path, options, print, "extends"));
  37800. }
  37801. extendsParts.push(printList(path, options, print, "mixins"), printList(path, options, print, "implements"));
  37802. if (groupMode) {
  37803. let printedPartsGroup;
  37804. if (shouldIndentOnlyHeritageClauses(node)) {
  37805. printedPartsGroup = [...partsGroup, indent$g(extendsParts)];
  37806. } else {
  37807. printedPartsGroup = indent$g([...partsGroup, extendsParts]);
  37808. }
  37809. parts.push(group$l(printedPartsGroup, {
  37810. id: getHeritageGroupId(node)
  37811. }));
  37812. } else {
  37813. parts.push(...partsGroup, ...extendsParts);
  37814. }
  37815. parts.push(" ", print("body"));
  37816. return parts;
  37817. }
  37818. const getHeritageGroupId = createGroupIdMapper("heritageGroup");
  37819. function printHardlineAfterHeritage$2(node) {
  37820. return ifBreak$e(hardline$o, "", {
  37821. groupId: getHeritageGroupId(node)
  37822. });
  37823. }
  37824. function hasMultipleHeritage(node) {
  37825. return ["superClass", "extends", "mixins", "implements"].filter(key => Boolean(node[key])).length > 1;
  37826. }
  37827. function shouldIndentOnlyHeritageClauses(node) {
  37828. return node.typeParameters && !hasComment$6(node.typeParameters, CommentCheckFlags$6.Trailing | CommentCheckFlags$6.Line) && !hasMultipleHeritage(node);
  37829. }
  37830. function printList(path, options, print, listName) {
  37831. const node = path.getValue();
  37832. if (!isNonEmptyArray$b(node[listName])) {
  37833. return "";
  37834. }
  37835. const printedLeadingComments = printDanglingComments$6(path, options,
  37836. /* sameIndent */
  37837. true, ({
  37838. marker
  37839. }) => marker === listName);
  37840. return [shouldIndentOnlyHeritageClauses(node) ? ifBreak$e(" ", line$k, {
  37841. groupId: getTypeParametersGroupId$1(node.typeParameters)
  37842. }) : line$k, printedLeadingComments, printedLeadingComments && hardline$o, listName, group$l(indent$g([line$k, join$h([",", line$k], path.map(print, listName))]))];
  37843. }
  37844. function printSuperClass(path, options, print) {
  37845. const printed = print("superClass");
  37846. const parent = path.getParentNode();
  37847. if (parent.type === "AssignmentExpression") {
  37848. return group$l(ifBreak$e(["(", indent$g([softline$g, printed]), softline$g, ")"], printed));
  37849. }
  37850. return printed;
  37851. }
  37852. function printClassMethod$2(path, options, print) {
  37853. const node = path.getValue();
  37854. const parts = [];
  37855. if (isNonEmptyArray$b(node.decorators)) {
  37856. parts.push(printClassMemberDecorators(path, options, print));
  37857. }
  37858. if (node.accessibility) {
  37859. parts.push(node.accessibility + " ");
  37860. } // "readonly" and "declare" are supported by only "babel-ts"
  37861. // https://github.com/prettier/prettier/issues/9760
  37862. if (node.readonly) {
  37863. parts.push("readonly ");
  37864. }
  37865. if (node.declare) {
  37866. parts.push("declare ");
  37867. }
  37868. if (node.static) {
  37869. parts.push("static ");
  37870. }
  37871. if (node.type === "TSAbstractMethodDefinition" || node.abstract) {
  37872. parts.push("abstract ");
  37873. }
  37874. if (node.override) {
  37875. parts.push("override ");
  37876. }
  37877. parts.push(printMethod$1(path, options, print));
  37878. return parts;
  37879. }
  37880. function printClassProperty$2(path, options, print) {
  37881. const node = path.getValue();
  37882. const parts = [];
  37883. const semi = options.semi ? ";" : "";
  37884. if (isNonEmptyArray$b(node.decorators)) {
  37885. parts.push(printClassMemberDecorators(path, options, print));
  37886. }
  37887. if (node.accessibility) {
  37888. parts.push(node.accessibility + " ");
  37889. }
  37890. if (node.declare) {
  37891. parts.push("declare ");
  37892. }
  37893. if (node.static) {
  37894. parts.push("static ");
  37895. }
  37896. if (node.type === "TSAbstractPropertyDefinition" || node.abstract) {
  37897. parts.push("abstract ");
  37898. }
  37899. if (node.override) {
  37900. parts.push("override ");
  37901. }
  37902. if (node.readonly) {
  37903. parts.push("readonly ");
  37904. }
  37905. if (node.variance) {
  37906. parts.push(print("variance"));
  37907. }
  37908. parts.push(printPropertyKey$2(path, options, print), printOptionalToken$4(path), printTypeAnnotation$3(path, options, print));
  37909. return [printAssignment(path, options, print, parts, " =", "value"), semi];
  37910. }
  37911. var _class = {
  37912. printClass: printClass$2,
  37913. printClassMethod: printClassMethod$2,
  37914. printClassProperty: printClassProperty$2,
  37915. printHardlineAfterHeritage: printHardlineAfterHeritage$2
  37916. };
  37917. const {
  37918. isNonEmptyArray: isNonEmptyArray$a
  37919. } = util$8;
  37920. const {
  37921. builders: {
  37922. join: join$g,
  37923. line: line$j,
  37924. group: group$k,
  37925. indent: indent$f,
  37926. ifBreak: ifBreak$d
  37927. }
  37928. } = require$$7$3;
  37929. const {
  37930. hasComment: hasComment$5,
  37931. identity,
  37932. CommentCheckFlags: CommentCheckFlags$5
  37933. } = utils$5;
  37934. const {
  37935. getTypeParametersGroupId
  37936. } = typeParameters;
  37937. const {
  37938. printTypeScriptModifiers: printTypeScriptModifiers$1
  37939. } = misc$1;
  37940. function printInterface$2(path, options, print) {
  37941. const node = path.getValue();
  37942. const parts = [];
  37943. if (node.declare) {
  37944. parts.push("declare ");
  37945. }
  37946. if (node.type === "TSInterfaceDeclaration") {
  37947. parts.push(node.abstract ? "abstract " : "", printTypeScriptModifiers$1(path, options, print));
  37948. }
  37949. parts.push("interface");
  37950. const partsGroup = [];
  37951. const extendsParts = [];
  37952. if (node.type !== "InterfaceTypeAnnotation") {
  37953. partsGroup.push(" ", print("id"), print("typeParameters"));
  37954. }
  37955. const shouldIndentOnlyHeritageClauses = node.typeParameters && !hasComment$5(node.typeParameters, CommentCheckFlags$5.Trailing | CommentCheckFlags$5.Line);
  37956. if (isNonEmptyArray$a(node.extends)) {
  37957. extendsParts.push(shouldIndentOnlyHeritageClauses ? ifBreak$d(" ", line$j, {
  37958. groupId: getTypeParametersGroupId(node.typeParameters)
  37959. }) : line$j, "extends ", (node.extends.length === 1 ? identity : indent$f)(join$g([",", line$j], path.map(print, "extends"))));
  37960. }
  37961. if (node.id && hasComment$5(node.id, CommentCheckFlags$5.Trailing) || isNonEmptyArray$a(node.extends)) {
  37962. if (shouldIndentOnlyHeritageClauses) {
  37963. parts.push(group$k([...partsGroup, indent$f(extendsParts)]));
  37964. } else {
  37965. parts.push(group$k(indent$f([...partsGroup, ...extendsParts])));
  37966. }
  37967. } else {
  37968. parts.push(...partsGroup, ...extendsParts);
  37969. }
  37970. parts.push(" ", print("body"));
  37971. return group$k(parts);
  37972. }
  37973. var _interface = {
  37974. printInterface: printInterface$2
  37975. };
  37976. const {
  37977. isNonEmptyArray: isNonEmptyArray$9
  37978. } = util$8;
  37979. const {
  37980. builders: {
  37981. softline: softline$f,
  37982. group: group$j,
  37983. indent: indent$e,
  37984. join: join$f,
  37985. line: line$i,
  37986. ifBreak: ifBreak$c,
  37987. hardline: hardline$n
  37988. }
  37989. } = require$$7$3;
  37990. const {
  37991. printDanglingComments: printDanglingComments$5
  37992. } = comments$4;
  37993. const {
  37994. hasComment: hasComment$4,
  37995. CommentCheckFlags: CommentCheckFlags$4,
  37996. shouldPrintComma: shouldPrintComma$4,
  37997. needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$1
  37998. } = utils$5;
  37999. const {
  38000. locStart: locStart$l,
  38001. hasSameLoc
  38002. } = loc$6;
  38003. const {
  38004. hasDecoratorsBeforeExport,
  38005. printDecoratorsBeforeExport
  38006. } = decorators;
  38007. /**
  38008. * @typedef {import("../../document").Doc} Doc
  38009. */
  38010. function printImportDeclaration$1(path, options, print) {
  38011. const node = path.getValue();
  38012. const semi = options.semi ? ";" : "";
  38013. /** @type{Doc[]} */
  38014. const parts = [];
  38015. const {
  38016. importKind
  38017. } = node;
  38018. parts.push("import");
  38019. if (importKind && importKind !== "value") {
  38020. parts.push(" ", importKind);
  38021. }
  38022. parts.push(printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
  38023. return parts;
  38024. }
  38025. function printExportDeclaration$2(path, options, print) {
  38026. const node = path.getValue();
  38027. /** @type{Doc[]} */
  38028. const parts = []; // Only print decorators here if they were written before the export,
  38029. // otherwise they are printed by the node.declaration
  38030. if (hasDecoratorsBeforeExport(node)) {
  38031. parts.push(printDecoratorsBeforeExport(path, options, print));
  38032. }
  38033. const {
  38034. type,
  38035. exportKind,
  38036. declaration
  38037. } = node;
  38038. parts.push("export");
  38039. const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
  38040. if (isDefaultExport) {
  38041. parts.push(" default");
  38042. }
  38043. if (hasComment$4(node, CommentCheckFlags$4.Dangling)) {
  38044. parts.push(" ", printDanglingComments$5(path, options,
  38045. /* sameIndent */
  38046. true));
  38047. if (needsHardlineAfterDanglingComment$1(node)) {
  38048. parts.push(hardline$n);
  38049. }
  38050. }
  38051. if (declaration) {
  38052. parts.push(" ", print("declaration"));
  38053. } else {
  38054. parts.push(exportKind === "type" ? " type" : "", printModuleSpecifiers(path, options, print), printModuleSource(path, options, print), printImportAssertions(path, options, print));
  38055. }
  38056. if (shouldExportDeclarationPrintSemi(node, options)) {
  38057. parts.push(";");
  38058. }
  38059. return parts;
  38060. }
  38061. function printExportAllDeclaration$2(path, options, print) {
  38062. const node = path.getValue();
  38063. const semi = options.semi ? ";" : "";
  38064. /** @type{Doc[]} */
  38065. const parts = [];
  38066. const {
  38067. exportKind,
  38068. exported
  38069. } = node;
  38070. parts.push("export");
  38071. if (exportKind === "type") {
  38072. parts.push(" type");
  38073. }
  38074. parts.push(" *");
  38075. if (exported) {
  38076. parts.push(" as ", print("exported"));
  38077. }
  38078. parts.push(printModuleSource(path, options, print), printImportAssertions(path, options, print), semi);
  38079. return parts;
  38080. }
  38081. function shouldExportDeclarationPrintSemi(node, options) {
  38082. if (!options.semi) {
  38083. return false;
  38084. }
  38085. const {
  38086. type,
  38087. declaration
  38088. } = node;
  38089. const isDefaultExport = node.default || type === "ExportDefaultDeclaration";
  38090. if (!declaration) {
  38091. return true;
  38092. }
  38093. const {
  38094. type: declarationType
  38095. } = declaration;
  38096. if (isDefaultExport && declarationType !== "ClassDeclaration" && declarationType !== "FunctionDeclaration" && declarationType !== "TSInterfaceDeclaration" && declarationType !== "DeclareClass" && declarationType !== "DeclareFunction" && declarationType !== "TSDeclareFunction" && declarationType !== "EnumDeclaration") {
  38097. return true;
  38098. }
  38099. return false;
  38100. }
  38101. function printModuleSource(path, options, print) {
  38102. const node = path.getValue();
  38103. if (!node.source) {
  38104. return "";
  38105. }
  38106. /** @type{Doc[]} */
  38107. const parts = [];
  38108. if (!shouldNotPrintSpecifiers(node, options)) {
  38109. parts.push(" from");
  38110. }
  38111. parts.push(" ", print("source"));
  38112. return parts;
  38113. }
  38114. function printModuleSpecifiers(path, options, print) {
  38115. const node = path.getValue();
  38116. if (shouldNotPrintSpecifiers(node, options)) {
  38117. return "";
  38118. }
  38119. /** @type{Doc[]} */
  38120. const parts = [" "];
  38121. if (isNonEmptyArray$9(node.specifiers)) {
  38122. const standaloneSpecifiers = [];
  38123. const groupedSpecifiers = [];
  38124. path.each(() => {
  38125. const specifierType = path.getValue().type;
  38126. if (specifierType === "ExportNamespaceSpecifier" || specifierType === "ExportDefaultSpecifier" || specifierType === "ImportNamespaceSpecifier" || specifierType === "ImportDefaultSpecifier") {
  38127. standaloneSpecifiers.push(print());
  38128. } else if (specifierType === "ExportSpecifier" || specifierType === "ImportSpecifier") {
  38129. groupedSpecifiers.push(print());
  38130. } else {
  38131. /* istanbul ignore next */
  38132. throw new Error(`Unknown specifier type ${JSON.stringify(specifierType)}`);
  38133. }
  38134. }, "specifiers");
  38135. parts.push(join$f(", ", standaloneSpecifiers));
  38136. if (groupedSpecifiers.length > 0) {
  38137. if (standaloneSpecifiers.length > 0) {
  38138. parts.push(", ");
  38139. }
  38140. const canBreak = groupedSpecifiers.length > 1 || standaloneSpecifiers.length > 0 || node.specifiers.some(node => hasComment$4(node));
  38141. if (canBreak) {
  38142. parts.push(group$j(["{", indent$e([options.bracketSpacing ? line$i : softline$f, join$f([",", line$i], groupedSpecifiers)]), ifBreak$c(shouldPrintComma$4(options) ? "," : ""), options.bracketSpacing ? line$i : softline$f, "}"]));
  38143. } else {
  38144. parts.push(["{", options.bracketSpacing ? " " : "", ...groupedSpecifiers, options.bracketSpacing ? " " : "", "}"]);
  38145. }
  38146. }
  38147. } else {
  38148. parts.push("{}");
  38149. }
  38150. return parts;
  38151. }
  38152. function shouldNotPrintSpecifiers(node, options) {
  38153. const {
  38154. type,
  38155. importKind,
  38156. source,
  38157. specifiers
  38158. } = node;
  38159. if (type !== "ImportDeclaration" || isNonEmptyArray$9(specifiers) || importKind === "type") {
  38160. return false;
  38161. } // TODO: check tokens
  38162. return !/{\s*}/.test(options.originalText.slice(locStart$l(node), locStart$l(source)));
  38163. }
  38164. function printImportAssertions(path, options, print) {
  38165. const node = path.getNode();
  38166. if (isNonEmptyArray$9(node.assertions)) {
  38167. return [" assert {", options.bracketSpacing ? " " : "", join$f(", ", path.map(print, "assertions")), options.bracketSpacing ? " " : "", "}"];
  38168. }
  38169. return "";
  38170. }
  38171. function printModuleSpecifier$1(path, options, print) {
  38172. const node = path.getNode();
  38173. const {
  38174. type
  38175. } = node;
  38176. /** @type {Doc[]} */
  38177. const parts = [];
  38178. /** @type {"type" | "typeof" | "value"} */
  38179. const kind = type === "ImportSpecifier" ? node.importKind : node.exportKind;
  38180. if (kind && kind !== "value") {
  38181. parts.push(kind, " ");
  38182. }
  38183. const isImport = type.startsWith("Import");
  38184. const leftSideProperty = isImport ? "imported" : "local";
  38185. const rightSideProperty = isImport ? "local" : "exported";
  38186. let left = "";
  38187. let right = "";
  38188. if (type === "ExportNamespaceSpecifier" || type === "ImportNamespaceSpecifier") {
  38189. left = "*";
  38190. } else if (node[leftSideProperty]) {
  38191. left = print(leftSideProperty);
  38192. }
  38193. if (node[rightSideProperty] && (!node[leftSideProperty] || // import {a as a} from '.'
  38194. !hasSameLoc(node[leftSideProperty], node[rightSideProperty]))) {
  38195. right = print(rightSideProperty);
  38196. }
  38197. parts.push(left, left && right ? " as " : "", right);
  38198. return parts;
  38199. }
  38200. var module$1 = {
  38201. printImportDeclaration: printImportDeclaration$1,
  38202. printExportDeclaration: printExportDeclaration$2,
  38203. printExportAllDeclaration: printExportAllDeclaration$2,
  38204. printModuleSpecifier: printModuleSpecifier$1
  38205. };
  38206. const {
  38207. printDanglingComments: printDanglingComments$4
  38208. } = comments$4;
  38209. const {
  38210. builders: {
  38211. line: line$h,
  38212. softline: softline$e,
  38213. group: group$i,
  38214. indent: indent$d,
  38215. ifBreak: ifBreak$b,
  38216. hardline: hardline$m
  38217. }
  38218. } = require$$7$3;
  38219. const {
  38220. getLast: getLast$a,
  38221. hasNewlineInRange: hasNewlineInRange$2,
  38222. hasNewline: hasNewline$3,
  38223. isNonEmptyArray: isNonEmptyArray$8
  38224. } = util$8;
  38225. const {
  38226. shouldPrintComma: shouldPrintComma$3,
  38227. hasComment: hasComment$3,
  38228. getComments: getComments$1,
  38229. CommentCheckFlags: CommentCheckFlags$3,
  38230. isNextLineEmpty: isNextLineEmpty$7
  38231. } = utils$5;
  38232. const {
  38233. locStart: locStart$k,
  38234. locEnd: locEnd$j
  38235. } = loc$6;
  38236. const {
  38237. printOptionalToken: printOptionalToken$3,
  38238. printTypeAnnotation: printTypeAnnotation$2
  38239. } = misc$1;
  38240. const {
  38241. shouldHugFunctionParameters
  38242. } = functionParameters;
  38243. const {
  38244. shouldHugType
  38245. } = typeAnnotation;
  38246. const {
  38247. printHardlineAfterHeritage: printHardlineAfterHeritage$1
  38248. } = _class;
  38249. /** @typedef {import("../../document").Doc} Doc */
  38250. function printObject$3(path, options, print) {
  38251. const semi = options.semi ? ";" : "";
  38252. const node = path.getValue();
  38253. let propertiesField;
  38254. if (node.type === "TSTypeLiteral") {
  38255. propertiesField = "members";
  38256. } else if (node.type === "TSInterfaceBody") {
  38257. propertiesField = "body";
  38258. } else {
  38259. propertiesField = "properties";
  38260. }
  38261. const isTypeAnnotation = node.type === "ObjectTypeAnnotation";
  38262. const fields = [propertiesField];
  38263. if (isTypeAnnotation) {
  38264. fields.push("indexers", "callProperties", "internalSlots");
  38265. }
  38266. const firstProperty = fields.map(field => node[field][0]).sort((a, b) => locStart$k(a) - locStart$k(b))[0];
  38267. const parent = path.getParentNode(0);
  38268. const isFlowInterfaceLikeBody = isTypeAnnotation && parent && (parent.type === "InterfaceDeclaration" || parent.type === "DeclareInterface" || parent.type === "DeclareClass") && path.getName() === "body";
  38269. const shouldBreak = node.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || node.type === "ObjectPattern" && parent.type !== "FunctionDeclaration" && parent.type !== "FunctionExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "ObjectMethod" && parent.type !== "ClassMethod" && parent.type !== "ClassPrivateMethod" && parent.type !== "AssignmentPattern" && parent.type !== "CatchClause" && node.properties.some(property => property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern")) || node.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$2(options.originalText, locStart$k(node), locStart$k(firstProperty));
  38270. const separator = isFlowInterfaceLikeBody ? ";" : node.type === "TSInterfaceBody" || node.type === "TSTypeLiteral" ? ifBreak$b(semi, ";") : ",";
  38271. const leftBrace = node.type === "RecordExpression" ? "#{" : node.exact ? "{|" : "{";
  38272. const rightBrace = node.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  38273. // interleaved in the source code. So we need to reorder them before
  38274. // printing them.
  38275. const propsAndLoc = [];
  38276. for (const field of fields) {
  38277. path.each(childPath => {
  38278. const node = childPath.getValue();
  38279. propsAndLoc.push({
  38280. node,
  38281. printed: print(),
  38282. loc: locStart$k(node)
  38283. });
  38284. }, field);
  38285. }
  38286. if (fields.length > 1) {
  38287. propsAndLoc.sort((a, b) => a.loc - b.loc);
  38288. }
  38289. /** @type {Doc[]} */
  38290. let separatorParts = [];
  38291. const props = propsAndLoc.map(prop => {
  38292. const result = [...separatorParts, group$i(prop.printed)];
  38293. separatorParts = [separator, line$h];
  38294. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasComment$3(prop.node, CommentCheckFlags$3.PrettierIgnore)) {
  38295. separatorParts.shift();
  38296. }
  38297. if (isNextLineEmpty$7(prop.node, options)) {
  38298. separatorParts.push(hardline$m);
  38299. }
  38300. return result;
  38301. });
  38302. if (node.inexact) {
  38303. let printed;
  38304. if (hasComment$3(node, CommentCheckFlags$3.Dangling)) {
  38305. const hasLineComments = hasComment$3(node, CommentCheckFlags$3.Line);
  38306. const printedDanglingComments = printDanglingComments$4(path, options,
  38307. /* sameIndent */
  38308. true);
  38309. printed = [printedDanglingComments, hasLineComments || hasNewline$3(options.originalText, locEnd$j(getLast$a(getComments$1(node)))) ? hardline$m : line$h, "..."];
  38310. } else {
  38311. printed = ["..."];
  38312. }
  38313. props.push([...separatorParts, ...printed]);
  38314. }
  38315. const lastElem = getLast$a(node[propertiesField]);
  38316. const canHaveTrailingSeparator = !(node.inexact || lastElem && lastElem.type === "RestElement" || lastElem && (lastElem.type === "TSPropertySignature" || lastElem.type === "TSCallSignatureDeclaration" || lastElem.type === "TSMethodSignature" || lastElem.type === "TSConstructSignatureDeclaration") && hasComment$3(lastElem, CommentCheckFlags$3.PrettierIgnore));
  38317. let content;
  38318. if (props.length === 0) {
  38319. if (!hasComment$3(node, CommentCheckFlags$3.Dangling)) {
  38320. return [leftBrace, rightBrace, printTypeAnnotation$2(path, options, print)];
  38321. }
  38322. content = group$i([leftBrace, printDanglingComments$4(path, options), softline$e, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)]);
  38323. } else {
  38324. content = [isFlowInterfaceLikeBody && isNonEmptyArray$8(node.properties) ? printHardlineAfterHeritage$1(parent) : "", leftBrace, indent$d([options.bracketSpacing ? line$h : softline$e, ...props]), ifBreak$b(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$3(options)) ? separator : ""), options.bracketSpacing ? line$h : softline$e, rightBrace, printOptionalToken$3(path), printTypeAnnotation$2(path, options, print)];
  38325. } // If we inline the object as first argument of the parent, we don't want
  38326. // to create another group so that the object breaks before the return
  38327. // type
  38328. if (path.match(node => node.type === "ObjectPattern" && !node.decorators, (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || path.match(shouldHugType, (node, name) => name === "typeAnnotation", (node, name) => name === "typeAnnotation", (node, name, number) => shouldHugFunctionParameters(node) && (name === "params" || name === "parameters" || name === "this" || name === "rest") && number === 0) || // Assignment printing logic (printAssignment) is responsible
  38329. // for adding a group if needed
  38330. !shouldBreak && path.match(node => node.type === "ObjectPattern", node => node.type === "AssignmentExpression" || node.type === "VariableDeclarator")) {
  38331. return content;
  38332. }
  38333. return group$i(content, {
  38334. shouldBreak
  38335. });
  38336. }
  38337. var object$1 = {
  38338. printObject: printObject$3
  38339. };
  38340. /** @typedef {import("../../document").Doc} Doc */
  38341. const assert$1 = require$$0__default$3["default"];
  38342. const {
  38343. printDanglingComments: printDanglingComments$3
  38344. } = comments$4;
  38345. const {
  38346. printString: printString$2,
  38347. printNumber: printNumber$2
  38348. } = util$8;
  38349. const {
  38350. builders: {
  38351. hardline: hardline$l,
  38352. softline: softline$d,
  38353. group: group$h,
  38354. indent: indent$c
  38355. }
  38356. } = require$$7$3;
  38357. const {
  38358. getParentExportDeclaration,
  38359. isFunctionNotation,
  38360. isGetterOrSetter,
  38361. rawText: rawText$1,
  38362. shouldPrintComma: shouldPrintComma$2
  38363. } = utils$5;
  38364. const {
  38365. locStart: locStart$j,
  38366. locEnd: locEnd$i
  38367. } = loc$6;
  38368. const {
  38369. printClass: printClass$1
  38370. } = _class;
  38371. const {
  38372. printOpaqueType,
  38373. printTypeAlias: printTypeAlias$1,
  38374. printIntersectionType: printIntersectionType$1,
  38375. printUnionType: printUnionType$1,
  38376. printFunctionType: printFunctionType$1,
  38377. printTupleType: printTupleType$1,
  38378. printIndexedAccessType: printIndexedAccessType$1
  38379. } = typeAnnotation;
  38380. const {
  38381. printInterface: printInterface$1
  38382. } = _interface;
  38383. const {
  38384. printTypeParameter: printTypeParameter$1,
  38385. printTypeParameters: printTypeParameters$1
  38386. } = typeParameters;
  38387. const {
  38388. printExportDeclaration: printExportDeclaration$1,
  38389. printExportAllDeclaration: printExportAllDeclaration$1
  38390. } = module$1;
  38391. const {
  38392. printArrayItems: printArrayItems$1
  38393. } = array;
  38394. const {
  38395. printObject: printObject$2
  38396. } = object$1;
  38397. const {
  38398. printPropertyKey: printPropertyKey$1
  38399. } = property;
  38400. const {
  38401. printOptionalToken: printOptionalToken$2,
  38402. printTypeAnnotation: printTypeAnnotation$1,
  38403. printRestSpread: printRestSpread$1
  38404. } = misc$1;
  38405. function printFlow$1(path, options, print) {
  38406. const node = path.getValue();
  38407. const semi = options.semi ? ";" : "";
  38408. /** @type{Doc[]} */
  38409. const parts = [];
  38410. switch (node.type) {
  38411. case "DeclareClass":
  38412. return printFlowDeclaration(path, printClass$1(path, options, print));
  38413. case "DeclareFunction":
  38414. return printFlowDeclaration(path, ["function ", print("id"), node.predicate ? " " : "", print("predicate"), semi]);
  38415. case "DeclareModule":
  38416. return printFlowDeclaration(path, ["module ", print("id"), " ", print("body")]);
  38417. case "DeclareModuleExports":
  38418. return printFlowDeclaration(path, ["module.exports", ": ", print("typeAnnotation"), semi]);
  38419. case "DeclareVariable":
  38420. return printFlowDeclaration(path, ["var ", print("id"), semi]);
  38421. case "DeclareOpaqueType":
  38422. return printFlowDeclaration(path, printOpaqueType(path, options, print));
  38423. case "DeclareInterface":
  38424. return printFlowDeclaration(path, printInterface$1(path, options, print));
  38425. case "DeclareTypeAlias":
  38426. return printFlowDeclaration(path, printTypeAlias$1(path, options, print));
  38427. case "DeclareExportDeclaration":
  38428. return printFlowDeclaration(path, printExportDeclaration$1(path, options, print));
  38429. case "DeclareExportAllDeclaration":
  38430. return printFlowDeclaration(path, printExportAllDeclaration$1(path, options, print));
  38431. case "OpaqueType":
  38432. return printOpaqueType(path, options, print);
  38433. case "TypeAlias":
  38434. return printTypeAlias$1(path, options, print);
  38435. case "IntersectionTypeAnnotation":
  38436. return printIntersectionType$1(path, options, print);
  38437. case "UnionTypeAnnotation":
  38438. return printUnionType$1(path, options, print);
  38439. case "FunctionTypeAnnotation":
  38440. return printFunctionType$1(path, options, print);
  38441. case "TupleTypeAnnotation":
  38442. return printTupleType$1(path, options, print);
  38443. case "GenericTypeAnnotation":
  38444. return [print("id"), printTypeParameters$1(path, options, print, "typeParameters")];
  38445. case "IndexedAccessType":
  38446. case "OptionalIndexedAccessType":
  38447. return printIndexedAccessType$1(path, options, print);
  38448. // Type Annotations for Facebook Flow, typically stripped out or
  38449. // transformed away before printing.
  38450. case "TypeAnnotation":
  38451. return print("typeAnnotation");
  38452. case "TypeParameter":
  38453. return printTypeParameter$1(path, options, print);
  38454. case "TypeofTypeAnnotation":
  38455. return ["typeof ", print("argument")];
  38456. case "ExistsTypeAnnotation":
  38457. return "*";
  38458. case "EmptyTypeAnnotation":
  38459. return "empty";
  38460. case "MixedTypeAnnotation":
  38461. return "mixed";
  38462. case "ArrayTypeAnnotation":
  38463. return [print("elementType"), "[]"];
  38464. case "BooleanLiteralTypeAnnotation":
  38465. return String(node.value);
  38466. case "EnumDeclaration":
  38467. return ["enum ", print("id"), " ", print("body")];
  38468. case "EnumBooleanBody":
  38469. case "EnumNumberBody":
  38470. case "EnumStringBody":
  38471. case "EnumSymbolBody":
  38472. {
  38473. if (node.type === "EnumSymbolBody" || node.explicitType) {
  38474. let type = null;
  38475. switch (node.type) {
  38476. case "EnumBooleanBody":
  38477. type = "boolean";
  38478. break;
  38479. case "EnumNumberBody":
  38480. type = "number";
  38481. break;
  38482. case "EnumStringBody":
  38483. type = "string";
  38484. break;
  38485. case "EnumSymbolBody":
  38486. type = "symbol";
  38487. break;
  38488. }
  38489. parts.push("of ", type, " ");
  38490. }
  38491. if (node.members.length === 0 && !node.hasUnknownMembers) {
  38492. parts.push(group$h(["{", printDanglingComments$3(path, options), softline$d, "}"]));
  38493. } else {
  38494. const members = node.members.length > 0 ? [hardline$l, printArrayItems$1(path, options, "members", print), node.hasUnknownMembers || shouldPrintComma$2(options) ? "," : ""] : [];
  38495. parts.push(group$h(["{", indent$c([...members, ...(node.hasUnknownMembers ? [hardline$l, "..."] : [])]), printDanglingComments$3(path, options,
  38496. /* sameIndent */
  38497. true), hardline$l, "}"]));
  38498. }
  38499. return parts;
  38500. }
  38501. case "EnumBooleanMember":
  38502. case "EnumNumberMember":
  38503. case "EnumStringMember":
  38504. return [print("id"), " = ", typeof node.init === "object" ? print("init") : String(node.init)];
  38505. case "EnumDefaultedMember":
  38506. return print("id");
  38507. case "FunctionTypeParam":
  38508. {
  38509. const name = node.name ? print("name") : path.getParentNode().this === node ? "this" : "";
  38510. return [name, printOptionalToken$2(path), name ? ": " : "", print("typeAnnotation")];
  38511. }
  38512. case "InterfaceDeclaration":
  38513. case "InterfaceTypeAnnotation":
  38514. return printInterface$1(path, options, print);
  38515. case "ClassImplements":
  38516. case "InterfaceExtends":
  38517. return [print("id"), print("typeParameters")];
  38518. case "NullableTypeAnnotation":
  38519. return ["?", print("typeAnnotation")];
  38520. case "Variance":
  38521. {
  38522. const {
  38523. kind
  38524. } = node;
  38525. assert$1.ok(kind === "plus" || kind === "minus");
  38526. return kind === "plus" ? "+" : "-";
  38527. }
  38528. case "ObjectTypeCallProperty":
  38529. if (node.static) {
  38530. parts.push("static ");
  38531. }
  38532. parts.push(print("value"));
  38533. return parts;
  38534. case "ObjectTypeIndexer":
  38535. {
  38536. return [node.variance ? print("variance") : "", "[", print("id"), node.id ? ": " : "", print("key"), "]: ", print("value")];
  38537. }
  38538. case "ObjectTypeProperty":
  38539. {
  38540. let modifier = "";
  38541. if (node.proto) {
  38542. modifier = "proto ";
  38543. } else if (node.static) {
  38544. modifier = "static ";
  38545. }
  38546. return [modifier, isGetterOrSetter(node) ? node.kind + " " : "", node.variance ? print("variance") : "", printPropertyKey$1(path, options, print), printOptionalToken$2(path), isFunctionNotation(node) ? "" : ": ", print("value")];
  38547. }
  38548. case "ObjectTypeAnnotation":
  38549. return printObject$2(path, options, print);
  38550. case "ObjectTypeInternalSlot":
  38551. return [node.static ? "static " : "", "[[", print("id"), "]]", printOptionalToken$2(path), node.method ? "" : ": ", print("value")];
  38552. // Same as `RestElement`
  38553. case "ObjectTypeSpreadProperty":
  38554. return printRestSpread$1(path, options, print);
  38555. case "QualifiedTypeIdentifier":
  38556. return [print("qualification"), ".", print("id")];
  38557. case "StringLiteralTypeAnnotation":
  38558. return printString$2(rawText$1(node), options);
  38559. case "NumberLiteralTypeAnnotation":
  38560. assert$1.strictEqual(typeof node.value, "number");
  38561. // fall through
  38562. case "BigIntLiteralTypeAnnotation":
  38563. if (node.extra) {
  38564. return printNumber$2(node.extra.raw);
  38565. }
  38566. return printNumber$2(node.raw);
  38567. case "TypeCastExpression":
  38568. {
  38569. return ["(", print("expression"), printTypeAnnotation$1(path, options, print), ")"];
  38570. }
  38571. case "TypeParameterDeclaration":
  38572. case "TypeParameterInstantiation":
  38573. {
  38574. const printed = printTypeParameters$1(path, options, print, "params");
  38575. if (options.parser === "flow") {
  38576. const start = locStart$j(node);
  38577. const end = locEnd$i(node);
  38578. const commentStartIndex = options.originalText.lastIndexOf("/*", start);
  38579. const commentEndIndex = options.originalText.indexOf("*/", end);
  38580. if (commentStartIndex !== -1 && commentEndIndex !== -1) {
  38581. const comment = options.originalText.slice(commentStartIndex + 2, commentEndIndex).trim();
  38582. if (comment.startsWith("::") && !comment.includes("/*") && !comment.includes("*/")) {
  38583. return ["/*:: ", printed, " */"];
  38584. }
  38585. }
  38586. }
  38587. return printed;
  38588. }
  38589. case "InferredPredicate":
  38590. return "%checks";
  38591. // Unhandled types below. If encountered, nodes of these types should
  38592. // be either left alone or desugared into AST types that are fully
  38593. // supported by the pretty-printer.
  38594. case "DeclaredPredicate":
  38595. return ["%checks(", print("value"), ")"];
  38596. case "AnyTypeAnnotation":
  38597. return "any";
  38598. case "BooleanTypeAnnotation":
  38599. return "boolean";
  38600. case "BigIntTypeAnnotation":
  38601. return "bigint";
  38602. case "NullLiteralTypeAnnotation":
  38603. return "null";
  38604. case "NumberTypeAnnotation":
  38605. return "number";
  38606. case "SymbolTypeAnnotation":
  38607. return "symbol";
  38608. case "StringTypeAnnotation":
  38609. return "string";
  38610. case "VoidTypeAnnotation":
  38611. return "void";
  38612. case "ThisTypeAnnotation":
  38613. return "this";
  38614. // These types are unprintable because they serve as abstract
  38615. // supertypes for other (printable) types.
  38616. case "Node":
  38617. case "Printable":
  38618. case "SourceLocation":
  38619. case "Position":
  38620. case "Statement":
  38621. case "Function":
  38622. case "Pattern":
  38623. case "Expression":
  38624. case "Declaration":
  38625. case "Specifier":
  38626. case "NamedSpecifier":
  38627. case "Comment":
  38628. case "MemberTypeAnnotation": // Flow
  38629. case "Type":
  38630. /* istanbul ignore next */
  38631. throw new Error("unprintable type: " + JSON.stringify(node.type));
  38632. }
  38633. }
  38634. function printFlowDeclaration(path, printed) {
  38635. const parentExportDecl = getParentExportDeclaration(path);
  38636. if (parentExportDecl) {
  38637. assert$1.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  38638. return printed;
  38639. } // If the parent node has type DeclareExportDeclaration, then it
  38640. // will be responsible for printing the "declare" token. Otherwise
  38641. // it needs to be printed with this non-exported declaration node.
  38642. return ["declare ", printed];
  38643. }
  38644. var flow = {
  38645. printFlow: printFlow$1
  38646. };
  38647. const {
  38648. hasNewlineInRange: hasNewlineInRange$1
  38649. } = util$8;
  38650. const {
  38651. isJsxNode: isJsxNode$1,
  38652. isBlockComment: isBlockComment$2,
  38653. getComments,
  38654. isCallExpression: isCallExpression$2,
  38655. isMemberExpression: isMemberExpression$2
  38656. } = utils$5;
  38657. const {
  38658. locStart: locStart$i,
  38659. locEnd: locEnd$h
  38660. } = loc$6;
  38661. const {
  38662. builders: {
  38663. line: line$g,
  38664. softline: softline$c,
  38665. group: group$g,
  38666. indent: indent$b,
  38667. align: align$2,
  38668. ifBreak: ifBreak$a,
  38669. dedent: dedent$3,
  38670. breakParent: breakParent$6
  38671. }
  38672. } = require$$7$3;
  38673. /**
  38674. * @typedef {import("../../document").Doc} Doc
  38675. * @typedef {import("../../common/ast-path")} AstPath
  38676. *
  38677. * @typedef {any} Options - Prettier options (TBD ...)
  38678. */
  38679. // If we have nested conditional expressions, we want to print them in JSX mode
  38680. // if there's at least one JSXElement somewhere in the tree.
  38681. //
  38682. // A conditional expression chain like this should be printed in normal mode,
  38683. // because there aren't JSXElements anywhere in it:
  38684. //
  38685. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  38686. //
  38687. // But a conditional expression chain like this should be printed in JSX mode,
  38688. // because there is a JSXElement in the last ConditionalExpression:
  38689. //
  38690. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  38691. //
  38692. // This type of ConditionalExpression chain is structured like this in the AST:
  38693. //
  38694. // ConditionalExpression {
  38695. // test: ...,
  38696. // consequent: ...,
  38697. // alternate: ConditionalExpression {
  38698. // test: ...,
  38699. // consequent: ...,
  38700. // alternate: ConditionalExpression {
  38701. // test: ...,
  38702. // consequent: ...,
  38703. // alternate: ...,
  38704. // }
  38705. // }
  38706. // }
  38707. function conditionalExpressionChainContainsJsx(node) {
  38708. // Given this code:
  38709. //
  38710. // // Using a ConditionalExpression as the consequent is uncommon, but should
  38711. // // be handled.
  38712. // A ? B : C ? D : E ? F ? G : H : I
  38713. //
  38714. // which has this AST:
  38715. //
  38716. // ConditionalExpression {
  38717. // test: Identifier(A),
  38718. // consequent: Identifier(B),
  38719. // alternate: ConditionalExpression {
  38720. // test: Identifier(C),
  38721. // consequent: Identifier(D),
  38722. // alternate: ConditionalExpression {
  38723. // test: Identifier(E),
  38724. // consequent: ConditionalExpression {
  38725. // test: Identifier(F),
  38726. // consequent: Identifier(G),
  38727. // alternate: Identifier(H),
  38728. // },
  38729. // alternate: Identifier(I),
  38730. // }
  38731. // }
  38732. // }
  38733. //
  38734. // We don't care about whether each node was the test, consequent, or alternate
  38735. // We are only checking if there's any JSXElements inside.
  38736. const conditionalExpressions = [node];
  38737. for (let index = 0; index < conditionalExpressions.length; index++) {
  38738. const conditionalExpression = conditionalExpressions[index];
  38739. for (const property of ["test", "consequent", "alternate"]) {
  38740. const node = conditionalExpression[property];
  38741. if (isJsxNode$1(node)) {
  38742. return true;
  38743. }
  38744. if (node.type === "ConditionalExpression") {
  38745. conditionalExpressions.push(node);
  38746. }
  38747. }
  38748. }
  38749. return false;
  38750. }
  38751. function printTernaryTest(path, options, print) {
  38752. const node = path.getValue();
  38753. const isConditionalExpression = node.type === "ConditionalExpression";
  38754. const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
  38755. const parent = path.getParentNode();
  38756. const printed = isConditionalExpression ? print("test") : [print("checkType"), " ", "extends", " ", print("extendsType")];
  38757. /**
  38758. * a
  38759. * ? b
  38760. * : multiline
  38761. * test
  38762. * node
  38763. * ^^ align(2)
  38764. * ? d
  38765. * : e
  38766. */
  38767. if (parent.type === node.type && parent[alternateNodePropertyName] === node) {
  38768. return align$2(2, printed);
  38769. }
  38770. return printed;
  38771. }
  38772. const ancestorNameMap = new Map([["AssignmentExpression", "right"], ["VariableDeclarator", "init"], ["ReturnStatement", "argument"], ["ThrowStatement", "argument"], ["UnaryExpression", "argument"], ["YieldExpression", "argument"]]);
  38773. function shouldExtraIndentForConditionalExpression(path) {
  38774. const node = path.getValue();
  38775. if (node.type !== "ConditionalExpression") {
  38776. return false;
  38777. }
  38778. let parent;
  38779. let child = node;
  38780. for (let ancestorCount = 0; !parent; ancestorCount++) {
  38781. const node = path.getParentNode(ancestorCount);
  38782. if (isCallExpression$2(node) && node.callee === child || isMemberExpression$2(node) && node.object === child || node.type === "TSNonNullExpression" && node.expression === child) {
  38783. child = node;
  38784. continue;
  38785. } // Reached chain root
  38786. if (node.type === "NewExpression" && node.callee === child || node.type === "TSAsExpression" && node.expression === child) {
  38787. parent = path.getParentNode(ancestorCount + 1);
  38788. child = node;
  38789. } else {
  38790. parent = node;
  38791. }
  38792. } // Do not add indent to direct `ConditionalExpression`
  38793. if (child === node) {
  38794. return false;
  38795. }
  38796. return parent[ancestorNameMap.get(parent.type)] === child;
  38797. }
  38798. /**
  38799. * The following is the shared logic for
  38800. * ternary operators, namely ConditionalExpression
  38801. * and TSConditionalType
  38802. * @param {AstPath} path - The path to the ConditionalExpression/TSConditionalType node.
  38803. * @param {Options} options - Prettier options
  38804. * @param {Function} print - Print function to call recursively
  38805. * @returns {Doc}
  38806. */
  38807. function printTernary$2(path, options, print) {
  38808. const node = path.getValue();
  38809. const isConditionalExpression = node.type === "ConditionalExpression";
  38810. const consequentNodePropertyName = isConditionalExpression ? "consequent" : "trueType";
  38811. const alternateNodePropertyName = isConditionalExpression ? "alternate" : "falseType";
  38812. const testNodePropertyNames = isConditionalExpression ? ["test"] : ["checkType", "extendsType"];
  38813. const consequentNode = node[consequentNodePropertyName];
  38814. const alternateNode = node[alternateNodePropertyName];
  38815. const parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  38816. // See `tests/format/jsx/conditional-expression.js` for more info.
  38817. let jsxMode = false;
  38818. const parent = path.getParentNode();
  38819. const isParentTest = parent.type === node.type && testNodePropertyNames.some(prop => parent[prop] === node);
  38820. let forceNoIndent = parent.type === node.type && !isParentTest; // Find the outermost non-ConditionalExpression parent, and the outermost
  38821. // ConditionalExpression parent. We'll use these to determine if we should
  38822. // print in JSX mode.
  38823. let currentParent;
  38824. let previousParent;
  38825. let i = 0;
  38826. do {
  38827. previousParent = currentParent || node;
  38828. currentParent = path.getParentNode(i);
  38829. i++;
  38830. } while (currentParent && currentParent.type === node.type && testNodePropertyNames.every(prop => currentParent[prop] !== previousParent));
  38831. const firstNonConditionalParent = currentParent || parent;
  38832. const lastConditionalParent = previousParent;
  38833. if (isConditionalExpression && (isJsxNode$1(node[testNodePropertyNames[0]]) || isJsxNode$1(consequentNode) || isJsxNode$1(alternateNode) || conditionalExpressionChainContainsJsx(lastConditionalParent))) {
  38834. jsxMode = true;
  38835. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  38836. // parens when using ?: within JSX, because the parens are analogous to
  38837. // curly braces in an if statement.
  38838. const wrap = doc => [ifBreak$a("("), indent$b([softline$c, doc]), softline$c, ifBreak$a(")")]; // The only things we don't wrap are:
  38839. // * Nested conditional expressions in alternates
  38840. // * null
  38841. // * undefined
  38842. const isNil = node => node.type === "NullLiteral" || node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined";
  38843. parts.push(" ? ", isNil(consequentNode) ? print(consequentNodePropertyName) : wrap(print(consequentNodePropertyName)), " : ", alternateNode.type === node.type || isNil(alternateNode) ? print(alternateNodePropertyName) : wrap(print(alternateNodePropertyName)));
  38844. } else {
  38845. // normal mode
  38846. const part = [line$g, "? ", consequentNode.type === node.type ? ifBreak$a("", "(") : "", align$2(2, print(consequentNodePropertyName)), consequentNode.type === node.type ? ifBreak$a("", ")") : "", line$g, ": ", alternateNode.type === node.type ? print(alternateNodePropertyName) : align$2(2, print(alternateNodePropertyName))];
  38847. parts.push(parent.type !== node.type || parent[alternateNodePropertyName] === node || isParentTest ? part : options.useTabs ? dedent$3(indent$b(part)) : align$2(Math.max(0, options.tabWidth - 2), part));
  38848. } // We want a whole chain of ConditionalExpressions to all
  38849. // break if any of them break. That means we should only group around the
  38850. // outer-most ConditionalExpression.
  38851. const comments = [...testNodePropertyNames.map(propertyName => getComments(node[propertyName])), getComments(consequentNode), getComments(alternateNode)].flat();
  38852. const shouldBreak = comments.some(comment => isBlockComment$2(comment) && hasNewlineInRange$1(options.originalText, locStart$i(comment), locEnd$h(comment)));
  38853. const maybeGroup = doc => parent === firstNonConditionalParent ? group$g(doc, {
  38854. shouldBreak
  38855. }) : shouldBreak ? [doc, breakParent$6] : doc; // Break the closing paren to keep the chain right after it:
  38856. // (a
  38857. // ? b
  38858. // : c
  38859. // ).call()
  38860. const breakClosingParen = !jsxMode && (isMemberExpression$2(parent) || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
  38861. const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
  38862. const result = maybeGroup([printTernaryTest(path, options, print), forceNoIndent ? parts : indent$b(parts), isConditionalExpression && breakClosingParen && !shouldExtraIndent ? softline$c : ""]);
  38863. return isParentTest || shouldExtraIndent ? group$g([indent$b([softline$c, result]), softline$c]) : result;
  38864. }
  38865. var ternary = {
  38866. printTernary: printTernary$2
  38867. };
  38868. const {
  38869. builders: {
  38870. hardline: hardline$k
  38871. }
  38872. } = require$$7$3;
  38873. const pathNeedsParens$1 = needsParens_1;
  38874. const {
  38875. getLeftSidePathName,
  38876. hasNakedLeftSide,
  38877. isJsxNode,
  38878. isTheOnlyJsxElementInMarkdown: isTheOnlyJsxElementInMarkdown$1,
  38879. hasComment: hasComment$2,
  38880. CommentCheckFlags: CommentCheckFlags$2,
  38881. isNextLineEmpty: isNextLineEmpty$6
  38882. } = utils$5;
  38883. const {
  38884. shouldPrintParamsWithoutParens
  38885. } = _function;
  38886. /**
  38887. * @typedef {import("../../document").Doc} Doc
  38888. * @typedef {import("../../common/ast-path")} AstPath
  38889. */
  38890. function printStatementSequence(path, options, print, property) {
  38891. const node = path.getValue();
  38892. const parts = [];
  38893. const isClassBody = node.type === "ClassBody";
  38894. const lastStatement = getLastStatement(node[property]);
  38895. path.each((path, index, statements) => {
  38896. const node = path.getValue(); // Skip printing EmptyStatement nodes to avoid leaving stray
  38897. // semicolons lying around.
  38898. if (node.type === "EmptyStatement") {
  38899. return;
  38900. }
  38901. const printed = print(); // in no-semi mode, prepend statement with semicolon if it might break ASI
  38902. // don't prepend the only JSX element in a program with semicolon
  38903. if (!options.semi && !isClassBody && !isTheOnlyJsxElementInMarkdown$1(options, path) && statementNeedsASIProtection(path, options)) {
  38904. if (hasComment$2(node, CommentCheckFlags$2.Leading)) {
  38905. parts.push(print([], {
  38906. needsSemi: true
  38907. }));
  38908. } else {
  38909. parts.push(";", printed);
  38910. }
  38911. } else {
  38912. parts.push(printed);
  38913. }
  38914. if (!options.semi && isClassBody && isClassProperty(node) && // `ClassBody` don't allow `EmptyStatement`,
  38915. // so we can use `statements` to get next node
  38916. shouldPrintSemicolonAfterClassProperty(node, statements[index + 1])) {
  38917. parts.push(";");
  38918. }
  38919. if (node !== lastStatement) {
  38920. parts.push(hardline$k);
  38921. if (isNextLineEmpty$6(node, options)) {
  38922. parts.push(hardline$k);
  38923. }
  38924. }
  38925. }, property);
  38926. return parts;
  38927. }
  38928. function getLastStatement(statements) {
  38929. for (let i = statements.length - 1; i >= 0; i--) {
  38930. const statement = statements[i];
  38931. if (statement.type !== "EmptyStatement") {
  38932. return statement;
  38933. }
  38934. }
  38935. }
  38936. function statementNeedsASIProtection(path, options) {
  38937. const node = path.getNode();
  38938. if (node.type !== "ExpressionStatement") {
  38939. return false;
  38940. }
  38941. return path.call(childPath => expressionNeedsASIProtection(childPath, options), "expression");
  38942. }
  38943. function expressionNeedsASIProtection(path, options) {
  38944. const node = path.getValue();
  38945. switch (node.type) {
  38946. case "ParenthesizedExpression":
  38947. case "TypeCastExpression":
  38948. case "ArrayExpression":
  38949. case "ArrayPattern":
  38950. case "TemplateLiteral":
  38951. case "TemplateElement":
  38952. case "RegExpLiteral":
  38953. return true;
  38954. case "ArrowFunctionExpression":
  38955. {
  38956. if (!shouldPrintParamsWithoutParens(path, options)) {
  38957. return true;
  38958. }
  38959. break;
  38960. }
  38961. case "UnaryExpression":
  38962. {
  38963. const {
  38964. prefix,
  38965. operator
  38966. } = node;
  38967. if (prefix && (operator === "+" || operator === "-")) {
  38968. return true;
  38969. }
  38970. break;
  38971. }
  38972. case "BindExpression":
  38973. {
  38974. if (!node.object) {
  38975. return true;
  38976. }
  38977. break;
  38978. }
  38979. case "Literal":
  38980. {
  38981. if (node.regex) {
  38982. return true;
  38983. }
  38984. break;
  38985. }
  38986. default:
  38987. {
  38988. if (isJsxNode(node)) {
  38989. return true;
  38990. }
  38991. }
  38992. }
  38993. if (pathNeedsParens$1(path, options)) {
  38994. return true;
  38995. }
  38996. if (!hasNakedLeftSide(node)) {
  38997. return false;
  38998. }
  38999. return path.call(childPath => expressionNeedsASIProtection(childPath, options), ...getLeftSidePathName(path, node));
  39000. }
  39001. function printBody$1(path, options, print) {
  39002. return printStatementSequence(path, options, print, "body");
  39003. }
  39004. function printSwitchCaseConsequent$1(path, options, print) {
  39005. return printStatementSequence(path, options, print, "consequent");
  39006. }
  39007. const isClassProperty = ({
  39008. type
  39009. }) => type === "ClassProperty" || type === "PropertyDefinition" || type === "ClassPrivateProperty";
  39010. /**
  39011. * @returns {boolean}
  39012. */
  39013. function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
  39014. const name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  39015. // so isn't properly tested yet.
  39016. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  39017. return true;
  39018. }
  39019. if (!nextNode) {
  39020. return false;
  39021. }
  39022. if (nextNode.static || nextNode.accessibility // TypeScript
  39023. ) {
  39024. return false;
  39025. }
  39026. if (!nextNode.computed) {
  39027. const name = nextNode.key && nextNode.key.name;
  39028. if (name === "in" || name === "instanceof") {
  39029. return true;
  39030. }
  39031. } // Flow variance sigil +/- requires semi if there's no
  39032. // "declare" or "static" keyword before it.
  39033. if (isClassProperty(nextNode) && nextNode.variance && !nextNode.static && !nextNode.declare) {
  39034. return true;
  39035. }
  39036. switch (nextNode.type) {
  39037. case "ClassProperty":
  39038. case "PropertyDefinition":
  39039. case "TSAbstractPropertyDefinition":
  39040. return nextNode.computed;
  39041. case "MethodDefinition": // Flow
  39042. case "TSAbstractMethodDefinition": // TypeScript
  39043. case "ClassMethod":
  39044. case "ClassPrivateMethod":
  39045. {
  39046. // Babel
  39047. const isAsync = nextNode.value ? nextNode.value.async : nextNode.async;
  39048. if (isAsync || nextNode.kind === "get" || nextNode.kind === "set") {
  39049. return false;
  39050. }
  39051. const isGenerator = nextNode.value ? nextNode.value.generator : nextNode.generator;
  39052. if (nextNode.computed || isGenerator) {
  39053. return true;
  39054. }
  39055. return false;
  39056. }
  39057. case "TSIndexSignature":
  39058. return true;
  39059. }
  39060. /* istanbul ignore next */
  39061. return false;
  39062. }
  39063. var statement = {
  39064. printBody: printBody$1,
  39065. printSwitchCaseConsequent: printSwitchCaseConsequent$1
  39066. };
  39067. const {
  39068. printDanglingComments: printDanglingComments$2
  39069. } = comments$4;
  39070. const {
  39071. isNonEmptyArray: isNonEmptyArray$7
  39072. } = util$8;
  39073. const {
  39074. builders: {
  39075. hardline: hardline$j,
  39076. indent: indent$a
  39077. }
  39078. } = require$$7$3;
  39079. const {
  39080. hasComment: hasComment$1,
  39081. CommentCheckFlags: CommentCheckFlags$1,
  39082. isNextLineEmpty: isNextLineEmpty$5
  39083. } = utils$5;
  39084. const {
  39085. printHardlineAfterHeritage
  39086. } = _class;
  39087. const {
  39088. printBody
  39089. } = statement;
  39090. /** @typedef {import("../../document").Doc} Doc */
  39091. function printBlock$4(path, options, print) {
  39092. const node = path.getValue();
  39093. const parts = [];
  39094. if (node.type === "StaticBlock") {
  39095. parts.push("static ");
  39096. }
  39097. if (node.type === "ClassBody" && isNonEmptyArray$7(node.body)) {
  39098. const parent = path.getParentNode();
  39099. parts.push(printHardlineAfterHeritage(parent));
  39100. }
  39101. parts.push("{");
  39102. const printed = printBlockBody$1(path, options, print);
  39103. if (printed) {
  39104. parts.push(indent$a([hardline$j, printed]), hardline$j);
  39105. } else {
  39106. const parent = path.getParentNode();
  39107. const parentParent = path.getParentNode(1);
  39108. if (!(parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ObjectMethod" || parent.type === "ClassMethod" || parent.type === "ClassPrivateMethod" || parent.type === "ForStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement" || parent.type === "DoExpression" || parent.type === "CatchClause" && !parentParent.finalizer || parent.type === "TSModuleDeclaration" || parent.type === "TSDeclareFunction" || node.type === "StaticBlock" || node.type === "ClassBody")) {
  39109. parts.push(hardline$j);
  39110. }
  39111. }
  39112. parts.push("}");
  39113. return parts;
  39114. }
  39115. function printBlockBody$1(path, options, print) {
  39116. const node = path.getValue();
  39117. const nodeHasDirectives = isNonEmptyArray$7(node.directives);
  39118. const nodeHasBody = node.body.some(node => node.type !== "EmptyStatement");
  39119. const nodeHasComment = hasComment$1(node, CommentCheckFlags$1.Dangling);
  39120. if (!nodeHasDirectives && !nodeHasBody && !nodeHasComment) {
  39121. return "";
  39122. }
  39123. const parts = []; // Babel 6
  39124. if (nodeHasDirectives) {
  39125. path.each((childPath, index, directives) => {
  39126. parts.push(print());
  39127. if (index < directives.length - 1 || nodeHasBody || nodeHasComment) {
  39128. parts.push(hardline$j);
  39129. if (isNextLineEmpty$5(childPath.getValue(), options)) {
  39130. parts.push(hardline$j);
  39131. }
  39132. }
  39133. }, "directives");
  39134. }
  39135. if (nodeHasBody) {
  39136. parts.push(printBody(path, options, print));
  39137. }
  39138. if (nodeHasComment) {
  39139. parts.push(printDanglingComments$2(path, options,
  39140. /* sameIndent */
  39141. true));
  39142. }
  39143. if (node.type === "Program") {
  39144. const parent = path.getParentNode();
  39145. if (!parent || parent.type !== "ModuleExpression") {
  39146. parts.push(hardline$j);
  39147. }
  39148. }
  39149. return parts;
  39150. }
  39151. var block$1 = {
  39152. printBlock: printBlock$4,
  39153. printBlockBody: printBlockBody$1
  39154. };
  39155. const {
  39156. printDanglingComments: printDanglingComments$1
  39157. } = comments$4;
  39158. const {
  39159. hasNewlineInRange
  39160. } = util$8;
  39161. const {
  39162. builders: {
  39163. join: join$e,
  39164. line: line$f,
  39165. hardline: hardline$i,
  39166. softline: softline$b,
  39167. group: group$f,
  39168. indent: indent$9,
  39169. conditionalGroup: conditionalGroup$1,
  39170. ifBreak: ifBreak$9
  39171. }
  39172. } = require$$7$3;
  39173. const {
  39174. isLiteral,
  39175. getTypeScriptMappedTypeModifier,
  39176. shouldPrintComma: shouldPrintComma$1,
  39177. isCallExpression: isCallExpression$1,
  39178. isMemberExpression: isMemberExpression$1
  39179. } = utils$5;
  39180. const {
  39181. locStart: locStart$h,
  39182. locEnd: locEnd$g
  39183. } = loc$6;
  39184. const {
  39185. printOptionalToken: printOptionalToken$1,
  39186. printTypeScriptModifiers
  39187. } = misc$1;
  39188. const {
  39189. printTernary: printTernary$1
  39190. } = ternary;
  39191. const {
  39192. printFunctionParameters,
  39193. shouldGroupFunctionParameters
  39194. } = functionParameters;
  39195. const {
  39196. printTemplateLiteral: printTemplateLiteral$1
  39197. } = templateLiteral;
  39198. const {
  39199. printArrayItems
  39200. } = array;
  39201. const {
  39202. printObject: printObject$1
  39203. } = object$1;
  39204. const {
  39205. printClassProperty: printClassProperty$1,
  39206. printClassMethod: printClassMethod$1
  39207. } = _class;
  39208. const {
  39209. printTypeParameter,
  39210. printTypeParameters
  39211. } = typeParameters;
  39212. const {
  39213. printPropertyKey
  39214. } = property;
  39215. const {
  39216. printFunction: printFunction$1,
  39217. printMethodInternal
  39218. } = _function;
  39219. const {
  39220. printInterface
  39221. } = _interface;
  39222. const {
  39223. printBlock: printBlock$3
  39224. } = block$1;
  39225. const {
  39226. printTypeAlias,
  39227. printIntersectionType,
  39228. printUnionType,
  39229. printFunctionType,
  39230. printTupleType,
  39231. printIndexedAccessType
  39232. } = typeAnnotation;
  39233. function printTypescript$1(path, options, print) {
  39234. const node = path.getValue(); // TypeScript nodes always starts with `TS`
  39235. if (!node.type.startsWith("TS")) {
  39236. return;
  39237. }
  39238. if (node.type.endsWith("Keyword")) {
  39239. return node.type.slice(2, -7).toLowerCase();
  39240. }
  39241. const semi = options.semi ? ";" : "";
  39242. const parts = [];
  39243. switch (node.type) {
  39244. case "TSThisType":
  39245. return "this";
  39246. case "TSTypeAssertion":
  39247. {
  39248. const shouldBreakAfterCast = !(node.expression.type === "ArrayExpression" || node.expression.type === "ObjectExpression");
  39249. const castGroup = group$f(["<", indent$9([softline$b, print("typeAnnotation")]), softline$b, ">"]);
  39250. const exprContents = [ifBreak$9("("), indent$9([softline$b, print("expression")]), softline$b, ifBreak$9(")")];
  39251. if (shouldBreakAfterCast) {
  39252. return conditionalGroup$1([[castGroup, print("expression")], [castGroup, group$f(exprContents, {
  39253. shouldBreak: true
  39254. })], [castGroup, print("expression")]]);
  39255. }
  39256. return group$f([castGroup, print("expression")]);
  39257. }
  39258. case "TSDeclareFunction":
  39259. return printFunction$1(path, print, options);
  39260. case "TSExportAssignment":
  39261. return ["export = ", print("expression"), semi];
  39262. case "TSModuleBlock":
  39263. return printBlock$3(path, options, print);
  39264. case "TSInterfaceBody":
  39265. case "TSTypeLiteral":
  39266. return printObject$1(path, options, print);
  39267. case "TSTypeAliasDeclaration":
  39268. return printTypeAlias(path, options, print);
  39269. case "TSQualifiedName":
  39270. return join$e(".", [print("left"), print("right")]);
  39271. case "TSAbstractMethodDefinition":
  39272. case "TSDeclareMethod":
  39273. return printClassMethod$1(path, options, print);
  39274. case "TSAbstractPropertyDefinition":
  39275. return printClassProperty$1(path, options, print);
  39276. case "TSInterfaceHeritage":
  39277. case "TSExpressionWithTypeArguments":
  39278. // Babel AST
  39279. parts.push(print("expression"));
  39280. if (node.typeParameters) {
  39281. parts.push(print("typeParameters"));
  39282. }
  39283. return parts;
  39284. case "TSTemplateLiteralType":
  39285. return printTemplateLiteral$1(path, print, options);
  39286. case "TSNamedTupleMember":
  39287. return [print("label"), node.optional ? "?" : "", ": ", print("elementType")];
  39288. case "TSRestType":
  39289. return ["...", print("typeAnnotation")];
  39290. case "TSOptionalType":
  39291. return [print("typeAnnotation"), "?"];
  39292. case "TSInterfaceDeclaration":
  39293. return printInterface(path, options, print);
  39294. case "TSClassImplements":
  39295. return [print("expression"), print("typeParameters")];
  39296. case "TSTypeParameterDeclaration":
  39297. case "TSTypeParameterInstantiation":
  39298. return printTypeParameters(path, options, print, "params");
  39299. case "TSTypeParameter":
  39300. return printTypeParameter(path, options, print);
  39301. case "TSAsExpression":
  39302. {
  39303. parts.push(print("expression"), " as ", print("typeAnnotation"));
  39304. const parent = path.getParentNode();
  39305. if (isCallExpression$1(parent) && parent.callee === node || isMemberExpression$1(parent) && parent.object === node) {
  39306. return group$f([indent$9([softline$b, ...parts]), softline$b]);
  39307. }
  39308. return parts;
  39309. }
  39310. case "TSArrayType":
  39311. return [print("elementType"), "[]"];
  39312. case "TSPropertySignature":
  39313. {
  39314. if (node.readonly) {
  39315. parts.push("readonly ");
  39316. }
  39317. parts.push(printPropertyKey(path, options, print), printOptionalToken$1(path));
  39318. if (node.typeAnnotation) {
  39319. parts.push(": ", print("typeAnnotation"));
  39320. } // This isn't valid semantically, but it's in the AST so we can print it.
  39321. if (node.initializer) {
  39322. parts.push(" = ", print("initializer"));
  39323. }
  39324. return parts;
  39325. }
  39326. case "TSParameterProperty":
  39327. if (node.accessibility) {
  39328. parts.push(node.accessibility + " ");
  39329. }
  39330. if (node.export) {
  39331. parts.push("export ");
  39332. }
  39333. if (node.static) {
  39334. parts.push("static ");
  39335. }
  39336. if (node.override) {
  39337. parts.push("override ");
  39338. }
  39339. if (node.readonly) {
  39340. parts.push("readonly ");
  39341. }
  39342. parts.push(print("parameter"));
  39343. return parts;
  39344. case "TSTypeQuery":
  39345. return ["typeof ", print("exprName")];
  39346. case "TSIndexSignature":
  39347. {
  39348. const parent = path.getParentNode(); // The typescript parser accepts multiple parameters here. If you're
  39349. // using them, it makes sense to have a trailing comma. But if you
  39350. // aren't, this is more like a computed property name than an array.
  39351. // So we leave off the trailing comma when there's just one parameter.
  39352. const trailingComma = node.parameters.length > 1 ? ifBreak$9(shouldPrintComma$1(options) ? "," : "") : "";
  39353. const parametersGroup = group$f([indent$9([softline$b, join$e([", ", softline$b], path.map(print, "parameters"))]), trailingComma, softline$b]);
  39354. return [node.export ? "export " : "", node.accessibility ? [node.accessibility, " "] : "", node.static ? "static " : "", node.readonly ? "readonly " : "", node.declare ? "declare " : "", "[", node.parameters ? parametersGroup : "", node.typeAnnotation ? "]: " : "]", node.typeAnnotation ? print("typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""];
  39355. }
  39356. case "TSTypePredicate":
  39357. return [node.asserts ? "asserts " : "", print("parameterName"), node.typeAnnotation ? [" is ", print("typeAnnotation")] : ""];
  39358. case "TSNonNullExpression":
  39359. return [print("expression"), "!"];
  39360. case "TSImportType":
  39361. return [!node.isTypeOf ? "" : "typeof ", "import(", print(node.parameter ? "parameter" : "argument"), ")", !node.qualifier ? "" : [".", print("qualifier")], printTypeParameters(path, options, print, "typeParameters")];
  39362. case "TSLiteralType":
  39363. return print("literal");
  39364. case "TSIndexedAccessType":
  39365. return printIndexedAccessType(path, options, print);
  39366. case "TSConstructSignatureDeclaration":
  39367. case "TSCallSignatureDeclaration":
  39368. case "TSConstructorType":
  39369. {
  39370. if (node.type === "TSConstructorType" && node.abstract) {
  39371. parts.push("abstract ");
  39372. }
  39373. if (node.type !== "TSCallSignatureDeclaration") {
  39374. parts.push("new ");
  39375. }
  39376. parts.push(group$f(printFunctionParameters(path, print, options,
  39377. /* expandArg */
  39378. false,
  39379. /* printTypeParams */
  39380. true)));
  39381. if (node.returnType || node.typeAnnotation) {
  39382. const isType = node.type === "TSConstructorType";
  39383. parts.push(isType ? " => " : ": ", print("returnType"), print("typeAnnotation"));
  39384. }
  39385. return parts;
  39386. }
  39387. case "TSTypeOperator":
  39388. return [node.operator, " ", print("typeAnnotation")];
  39389. case "TSMappedType":
  39390. {
  39391. const shouldBreak = hasNewlineInRange(options.originalText, locStart$h(node), locEnd$g(node));
  39392. return group$f(["{", indent$9([options.bracketSpacing ? line$f : softline$b, node.readonly ? [getTypeScriptMappedTypeModifier(node.readonly, "readonly"), " "] : "", printTypeScriptModifiers(path, options, print), print("typeParameter"), node.optional ? getTypeScriptMappedTypeModifier(node.optional, "?") : "", node.typeAnnotation ? ": " : "", print("typeAnnotation"), ifBreak$9(semi)]), printDanglingComments$1(path, options,
  39393. /* sameIndent */
  39394. true), options.bracketSpacing ? line$f : softline$b, "}"], {
  39395. shouldBreak
  39396. });
  39397. }
  39398. case "TSMethodSignature":
  39399. {
  39400. const kind = node.kind && node.kind !== "method" ? `${node.kind} ` : "";
  39401. parts.push(node.accessibility ? [node.accessibility, " "] : "", kind, node.export ? "export " : "", node.static ? "static " : "", node.readonly ? "readonly " : "", // "abstract" and "declare" are supported by only "babel-ts"
  39402. // https://github.com/prettier/prettier/issues/9760
  39403. node.abstract ? "abstract " : "", node.declare ? "declare " : "", node.computed ? "[" : "", print("key"), node.computed ? "]" : "", printOptionalToken$1(path));
  39404. const parametersDoc = printFunctionParameters(path, print, options,
  39405. /* expandArg */
  39406. false,
  39407. /* printTypeParams */
  39408. true);
  39409. const returnTypePropertyName = node.returnType ? "returnType" : "typeAnnotation";
  39410. const returnTypeNode = node[returnTypePropertyName];
  39411. const returnTypeDoc = returnTypeNode ? print(returnTypePropertyName) : "";
  39412. const shouldGroupParameters = shouldGroupFunctionParameters(node, returnTypeDoc);
  39413. parts.push(shouldGroupParameters ? group$f(parametersDoc) : parametersDoc);
  39414. if (returnTypeNode) {
  39415. parts.push(": ", group$f(returnTypeDoc));
  39416. }
  39417. return group$f(parts);
  39418. }
  39419. case "TSNamespaceExportDeclaration":
  39420. parts.push("export as namespace ", print("id"));
  39421. if (options.semi) {
  39422. parts.push(";");
  39423. }
  39424. return group$f(parts);
  39425. case "TSEnumDeclaration":
  39426. if (node.declare) {
  39427. parts.push("declare ");
  39428. }
  39429. if (node.modifiers) {
  39430. parts.push(printTypeScriptModifiers(path, options, print));
  39431. }
  39432. if (node.const) {
  39433. parts.push("const ");
  39434. }
  39435. parts.push("enum ", print("id"), " ");
  39436. if (node.members.length === 0) {
  39437. parts.push(group$f(["{", printDanglingComments$1(path, options), softline$b, "}"]));
  39438. } else {
  39439. parts.push(group$f(["{", indent$9([hardline$i, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""]), printDanglingComments$1(path, options,
  39440. /* sameIndent */
  39441. true), hardline$i, "}"]));
  39442. }
  39443. return parts;
  39444. case "TSEnumMember":
  39445. parts.push(print("id"));
  39446. if (node.initializer) {
  39447. parts.push(" = ", print("initializer"));
  39448. }
  39449. return parts;
  39450. case "TSImportEqualsDeclaration":
  39451. if (node.isExport) {
  39452. parts.push("export ");
  39453. }
  39454. parts.push("import ");
  39455. if (node.importKind && node.importKind !== "value") {
  39456. parts.push(node.importKind, " ");
  39457. }
  39458. parts.push(print("id"), " = ", print("moduleReference"));
  39459. if (options.semi) {
  39460. parts.push(";");
  39461. }
  39462. return group$f(parts);
  39463. case "TSExternalModuleReference":
  39464. return ["require(", print("expression"), ")"];
  39465. case "TSModuleDeclaration":
  39466. {
  39467. const parent = path.getParentNode();
  39468. const isExternalModule = isLiteral(node.id);
  39469. const parentIsDeclaration = parent.type === "TSModuleDeclaration";
  39470. const bodyIsDeclaration = node.body && node.body.type === "TSModuleDeclaration";
  39471. if (parentIsDeclaration) {
  39472. parts.push(".");
  39473. } else {
  39474. if (node.declare) {
  39475. parts.push("declare ");
  39476. }
  39477. parts.push(printTypeScriptModifiers(path, options, print));
  39478. const textBetweenNodeAndItsId = options.originalText.slice(locStart$h(node), locStart$h(node.id)); // Global declaration looks like this:
  39479. // (declare)? global { ... }
  39480. const isGlobalDeclaration = node.id.type === "Identifier" && node.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  39481. if (!isGlobalDeclaration) {
  39482. parts.push(isExternalModule || /(?:^|\s)module(?:\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  39483. }
  39484. }
  39485. parts.push(print("id"));
  39486. if (bodyIsDeclaration) {
  39487. parts.push(print("body"));
  39488. } else if (node.body) {
  39489. parts.push(" ", group$f(print("body")));
  39490. } else {
  39491. parts.push(semi);
  39492. }
  39493. return parts;
  39494. }
  39495. case "TSConditionalType":
  39496. return printTernary$1(path, options, print);
  39497. case "TSInferType":
  39498. return ["infer", " ", print("typeParameter")];
  39499. case "TSIntersectionType":
  39500. return printIntersectionType(path, options, print);
  39501. case "TSUnionType":
  39502. return printUnionType(path, options, print);
  39503. case "TSFunctionType":
  39504. return printFunctionType(path, options, print);
  39505. case "TSTupleType":
  39506. return printTupleType(path, options, print);
  39507. case "TSTypeReference":
  39508. return [print("typeName"), printTypeParameters(path, options, print, "typeParameters")];
  39509. case "TSTypeAnnotation":
  39510. return print("typeAnnotation");
  39511. case "TSEmptyBodyFunctionExpression":
  39512. return printMethodInternal(path, options, print);
  39513. // These are not valid TypeScript. Printing them just for the sake of error recovery.
  39514. case "TSJSDocAllType":
  39515. return "*";
  39516. case "TSJSDocUnknownType":
  39517. return "?";
  39518. case "TSJSDocNullableType":
  39519. return ["?", print("typeAnnotation")];
  39520. case "TSJSDocNonNullableType":
  39521. return ["!", print("typeAnnotation")];
  39522. default:
  39523. /* istanbul ignore next */
  39524. throw new Error(`Unknown TypeScript node type: ${JSON.stringify(node.type)}.`);
  39525. }
  39526. }
  39527. var typescript = {
  39528. printTypescript: printTypescript$1
  39529. };
  39530. const {
  39531. hasNewline: hasNewline$2
  39532. } = util$8;
  39533. const {
  39534. builders: {
  39535. join: join$d,
  39536. hardline: hardline$h
  39537. },
  39538. utils: {
  39539. replaceTextEndOfLine: replaceTextEndOfLine$a
  39540. }
  39541. } = require$$7$3;
  39542. const {
  39543. isLineComment: isLineComment$1,
  39544. isBlockComment: isBlockComment$1
  39545. } = utils$5;
  39546. const {
  39547. locStart: locStart$g,
  39548. locEnd: locEnd$f
  39549. } = loc$6;
  39550. function printComment$2(commentPath, options) {
  39551. const comment = commentPath.getValue();
  39552. if (isLineComment$1(comment)) {
  39553. // Supports `//`, `#!`, `<!--`, and `-->`
  39554. return options.originalText.slice(locStart$g(comment), locEnd$f(comment)).trimEnd();
  39555. }
  39556. if (isBlockComment$1(comment)) {
  39557. if (isIndentableBlockComment(comment)) {
  39558. const printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  39559. // printed as a `lineSuffix` which causes the comments to be
  39560. // interleaved. See https://github.com/prettier/prettier/issues/4412
  39561. if (comment.trailing && !hasNewline$2(options.originalText, locStart$g(comment), {
  39562. backwards: true
  39563. })) {
  39564. return [hardline$h, printed];
  39565. }
  39566. return printed;
  39567. }
  39568. const commentEnd = locEnd$f(comment);
  39569. const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
  39570. return ["/*", replaceTextEndOfLine$a(comment.value), isInsideFlowComment ? "*-/" : "*/"];
  39571. }
  39572. /* istanbul ignore next */
  39573. throw new Error("Not a comment: " + JSON.stringify(comment));
  39574. }
  39575. function isIndentableBlockComment(comment) {
  39576. // If the comment has multiple lines and every line starts with a star
  39577. // we can fix the indentation of each line. The stars in the `/*` and
  39578. // `*/` delimiters are not included in the comment value, so add them
  39579. // back first.
  39580. const lines = `*${comment.value}*`.split("\n");
  39581. return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
  39582. }
  39583. function printIndentableBlockComment(comment) {
  39584. const lines = comment.value.split("\n");
  39585. return ["/*", join$d(hardline$h, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"];
  39586. }
  39587. var comment = {
  39588. printComment: printComment$2
  39589. };
  39590. const {
  39591. printString: printString$1,
  39592. printNumber: printNumber$1
  39593. } = util$8;
  39594. function printLiteral$1(path, options
  39595. /*, print*/
  39596. ) {
  39597. const node = path.getNode();
  39598. switch (node.type) {
  39599. case "RegExpLiteral":
  39600. // Babel 6 Literal split
  39601. return printRegex(node);
  39602. case "BigIntLiteral":
  39603. // babel: node.extra.raw, flow: node.bigint
  39604. return printBigInt(node.bigint || node.extra.raw);
  39605. case "NumericLiteral":
  39606. // Babel 6 Literal split
  39607. return printNumber$1(node.extra.raw);
  39608. case "StringLiteral":
  39609. // Babel 6 Literal split
  39610. return printString$1(node.extra.raw, options);
  39611. case "NullLiteral":
  39612. // Babel 6 Literal split
  39613. return "null";
  39614. case "BooleanLiteral":
  39615. // Babel 6 Literal split
  39616. return String(node.value);
  39617. case "DecimalLiteral":
  39618. return printNumber$1(node.value) + "m";
  39619. case "Literal":
  39620. {
  39621. if (node.regex) {
  39622. return printRegex(node.regex);
  39623. }
  39624. if (node.bigint) {
  39625. return printBigInt(node.raw);
  39626. }
  39627. if (node.decimal) {
  39628. return printNumber$1(node.decimal) + "m";
  39629. }
  39630. const {
  39631. value
  39632. } = node;
  39633. if (typeof value === "number") {
  39634. return printNumber$1(node.raw);
  39635. }
  39636. if (typeof value === "string") {
  39637. return printString$1(node.raw, options);
  39638. }
  39639. return String(value);
  39640. }
  39641. }
  39642. }
  39643. function printBigInt(raw) {
  39644. return raw.toLowerCase();
  39645. }
  39646. function printRegex({
  39647. pattern,
  39648. flags
  39649. }) {
  39650. flags = [...flags].sort().join("");
  39651. return `/${pattern}/${flags}`;
  39652. }
  39653. var literal = {
  39654. printLiteral: printLiteral$1
  39655. };
  39656. /** @typedef {import("../document").Doc} Doc */
  39657. // TODO(azz): anything that imports from main shouldn't be in a `language-*` dir.
  39658. const {
  39659. printDanglingComments
  39660. } = comments$4;
  39661. const {
  39662. hasNewline: hasNewline$1
  39663. } = util$8;
  39664. const {
  39665. builders: {
  39666. join: join$c,
  39667. line: line$e,
  39668. hardline: hardline$g,
  39669. softline: softline$a,
  39670. group: group$e,
  39671. indent: indent$8
  39672. },
  39673. utils: {
  39674. replaceTextEndOfLine: replaceTextEndOfLine$9
  39675. }
  39676. } = require$$7$3;
  39677. const embed$9 = embed_1$4;
  39678. const clean$b = clean_1$4;
  39679. const {
  39680. insertPragma: insertPragma$9
  39681. } = pragma$5;
  39682. const handleComments = comments;
  39683. const pathNeedsParens = needsParens_1;
  39684. const preprocess$7 = printPreprocess$3;
  39685. const {
  39686. hasFlowShorthandAnnotationComment,
  39687. hasComment,
  39688. CommentCheckFlags,
  39689. isTheOnlyJsxElementInMarkdown,
  39690. isBlockComment,
  39691. isLineComment,
  39692. isNextLineEmpty: isNextLineEmpty$4,
  39693. needsHardlineAfterDanglingComment,
  39694. rawText,
  39695. hasIgnoreComment,
  39696. isCallExpression,
  39697. isMemberExpression
  39698. } = utils$5;
  39699. const {
  39700. locStart: locStart$f,
  39701. locEnd: locEnd$e
  39702. } = loc$6;
  39703. const {
  39704. printHtmlBinding,
  39705. isVueEventBindingExpression: isVueEventBindingExpression$2
  39706. } = htmlBinding;
  39707. const {
  39708. printAngular
  39709. } = angular;
  39710. const {
  39711. printJsx,
  39712. hasJsxIgnoreComment
  39713. } = jsx;
  39714. const {
  39715. printFlow
  39716. } = flow;
  39717. const {
  39718. printTypescript
  39719. } = typescript;
  39720. const {
  39721. printOptionalToken,
  39722. printBindExpressionCallee,
  39723. printTypeAnnotation,
  39724. adjustClause,
  39725. printRestSpread
  39726. } = misc$1;
  39727. const {
  39728. printImportDeclaration,
  39729. printExportDeclaration,
  39730. printExportAllDeclaration,
  39731. printModuleSpecifier
  39732. } = module$1;
  39733. const {
  39734. printTernary
  39735. } = ternary;
  39736. const {
  39737. printTemplateLiteral
  39738. } = templateLiteral;
  39739. const {
  39740. printArray
  39741. } = array;
  39742. const {
  39743. printObject
  39744. } = object$1;
  39745. const {
  39746. printClass,
  39747. printClassMethod,
  39748. printClassProperty
  39749. } = _class;
  39750. const {
  39751. printProperty
  39752. } = property;
  39753. const {
  39754. printFunction,
  39755. printArrowFunction,
  39756. printMethod,
  39757. printReturnStatement,
  39758. printThrowStatement
  39759. } = _function;
  39760. const {
  39761. printCallExpression
  39762. } = callExpression;
  39763. const {
  39764. printVariableDeclarator,
  39765. printAssignmentExpression
  39766. } = assignment;
  39767. const {
  39768. printBinaryishExpression
  39769. } = binaryish;
  39770. const {
  39771. printSwitchCaseConsequent
  39772. } = statement;
  39773. const {
  39774. printMemberExpression
  39775. } = member;
  39776. const {
  39777. printBlock: printBlock$2,
  39778. printBlockBody
  39779. } = block$1;
  39780. const {
  39781. printComment: printComment$1
  39782. } = comment;
  39783. const {
  39784. printLiteral
  39785. } = literal;
  39786. const {
  39787. printDecorators
  39788. } = decorators;
  39789. function genericPrint$6(path, options, print, args) {
  39790. const printed = printPathNoParens(path, options, print, args);
  39791. if (!printed) {
  39792. return "";
  39793. }
  39794. const node = path.getValue();
  39795. const {
  39796. type
  39797. } = node; // Their decorators are handled themselves, and they can't have parentheses
  39798. if (type === "ClassMethod" || type === "ClassPrivateMethod" || type === "ClassProperty" || type === "PropertyDefinition" || type === "TSAbstractPropertyDefinition" || type === "ClassPrivateProperty" || type === "MethodDefinition" || type === "TSAbstractMethodDefinition" || type === "TSDeclareMethod") {
  39799. return printed;
  39800. }
  39801. const printedDecorators = printDecorators(path, options, print); // Nodes with decorators can't have parentheses and don't need leading semicolons
  39802. if (printedDecorators) {
  39803. return group$e([...printedDecorators, printed]);
  39804. }
  39805. const needsParens = pathNeedsParens(path, options);
  39806. if (!needsParens) {
  39807. return args && args.needsSemi ? [";", printed] : printed;
  39808. }
  39809. const parts = [args && args.needsSemi ? ";(" : "(", printed];
  39810. if (hasFlowShorthandAnnotationComment(node)) {
  39811. const [comment] = node.trailingComments;
  39812. parts.push(" /*", comment.value.trimStart(), "*/");
  39813. comment.printed = true;
  39814. }
  39815. parts.push(")");
  39816. return parts;
  39817. }
  39818. function printPathNoParens(path, options, print, args) {
  39819. const node = path.getValue();
  39820. const semi = options.semi ? ";" : "";
  39821. if (!node) {
  39822. return "";
  39823. }
  39824. if (typeof node === "string") {
  39825. return node;
  39826. }
  39827. for (const printer of [printLiteral, printHtmlBinding, printAngular, printJsx, printFlow, printTypescript]) {
  39828. const printed = printer(path, options, print);
  39829. if (typeof printed !== "undefined") {
  39830. return printed;
  39831. }
  39832. }
  39833. /** @type{Doc[]} */
  39834. let parts = [];
  39835. switch (node.type) {
  39836. case "JsExpressionRoot":
  39837. return print("node");
  39838. case "JsonRoot":
  39839. return [print("node"), hardline$g];
  39840. case "File":
  39841. // Print @babel/parser's InterpreterDirective here so that
  39842. // leading comments on the `Program` node get printed after the hashbang.
  39843. if (node.program && node.program.interpreter) {
  39844. parts.push(print(["program", "interpreter"]));
  39845. }
  39846. parts.push(print("program"));
  39847. return parts;
  39848. case "Program":
  39849. return printBlockBody(path, options, print);
  39850. // Babel extension.
  39851. case "EmptyStatement":
  39852. return "";
  39853. case "ExpressionStatement":
  39854. // Detect Flow and TypeScript directives
  39855. if (node.directive) {
  39856. return [printDirective(node.expression, options), semi];
  39857. }
  39858. if (options.parser === "__vue_event_binding") {
  39859. const parent = path.getParentNode();
  39860. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === node) {
  39861. return [print("expression"), isVueEventBindingExpression$2(node.expression) ? ";" : ""];
  39862. }
  39863. } // Do not append semicolon after the only JSX element in a program
  39864. return [print("expression"), isTheOnlyJsxElementInMarkdown(options, path) ? "" : semi];
  39865. // Babel non-standard node. Used for Closure-style type casts. See postprocess.js.
  39866. case "ParenthesizedExpression":
  39867. {
  39868. const shouldHug = !hasComment(node.expression) && (node.expression.type === "ObjectExpression" || node.expression.type === "ArrayExpression");
  39869. if (shouldHug) {
  39870. return ["(", print("expression"), ")"];
  39871. }
  39872. return group$e(["(", indent$8([softline$a, print("expression")]), softline$a, ")"]);
  39873. }
  39874. case "AssignmentExpression":
  39875. return printAssignmentExpression(path, options, print);
  39876. case "VariableDeclarator":
  39877. return printVariableDeclarator(path, options, print);
  39878. case "BinaryExpression":
  39879. case "LogicalExpression":
  39880. return printBinaryishExpression(path, options, print);
  39881. case "AssignmentPattern":
  39882. return [print("left"), " = ", print("right")];
  39883. case "OptionalMemberExpression":
  39884. case "MemberExpression":
  39885. {
  39886. return printMemberExpression(path, options, print);
  39887. }
  39888. case "MetaProperty":
  39889. return [print("meta"), ".", print("property")];
  39890. case "BindExpression":
  39891. if (node.object) {
  39892. parts.push(print("object"));
  39893. }
  39894. parts.push(group$e(indent$8([softline$a, printBindExpressionCallee(path, options, print)])));
  39895. return parts;
  39896. case "Identifier":
  39897. {
  39898. return [node.name, printOptionalToken(path), printTypeAnnotation(path, options, print)];
  39899. }
  39900. case "V8IntrinsicIdentifier":
  39901. return ["%", node.name];
  39902. case "SpreadElement":
  39903. case "SpreadElementPattern":
  39904. case "SpreadProperty":
  39905. case "SpreadPropertyPattern":
  39906. case "RestElement":
  39907. return printRestSpread(path, options, print);
  39908. case "FunctionDeclaration":
  39909. case "FunctionExpression":
  39910. return printFunction(path, print, options, args);
  39911. case "ArrowFunctionExpression":
  39912. return printArrowFunction(path, options, print, args);
  39913. case "YieldExpression":
  39914. parts.push("yield");
  39915. if (node.delegate) {
  39916. parts.push("*");
  39917. }
  39918. if (node.argument) {
  39919. parts.push(" ", print("argument"));
  39920. }
  39921. return parts;
  39922. case "AwaitExpression":
  39923. {
  39924. parts.push("await");
  39925. if (node.argument) {
  39926. parts.push(" ", print("argument"));
  39927. const parent = path.getParentNode();
  39928. if (isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node) {
  39929. parts = [indent$8([softline$a, ...parts]), softline$a];
  39930. const parentAwaitOrBlock = path.findAncestor(node => node.type === "AwaitExpression" || node.type === "BlockStatement");
  39931. if (!parentAwaitOrBlock || parentAwaitOrBlock.type !== "AwaitExpression") {
  39932. return group$e(parts);
  39933. }
  39934. }
  39935. }
  39936. return parts;
  39937. }
  39938. case "ExportDefaultDeclaration":
  39939. case "ExportNamedDeclaration":
  39940. return printExportDeclaration(path, options, print);
  39941. case "ExportAllDeclaration":
  39942. return printExportAllDeclaration(path, options, print);
  39943. case "ImportDeclaration":
  39944. return printImportDeclaration(path, options, print);
  39945. case "ImportSpecifier":
  39946. case "ExportSpecifier":
  39947. case "ImportNamespaceSpecifier":
  39948. case "ExportNamespaceSpecifier":
  39949. case "ImportDefaultSpecifier":
  39950. case "ExportDefaultSpecifier":
  39951. return printModuleSpecifier(path, options, print);
  39952. case "ImportAttribute":
  39953. return [print("key"), ": ", print("value")];
  39954. case "Import":
  39955. return "import";
  39956. case "BlockStatement":
  39957. case "StaticBlock":
  39958. case "ClassBody":
  39959. return printBlock$2(path, options, print);
  39960. case "ThrowStatement":
  39961. return printThrowStatement(path, options, print);
  39962. case "ReturnStatement":
  39963. return printReturnStatement(path, options, print);
  39964. case "NewExpression":
  39965. case "ImportExpression":
  39966. case "OptionalCallExpression":
  39967. case "CallExpression":
  39968. return printCallExpression(path, options, print);
  39969. case "ObjectExpression":
  39970. case "ObjectPattern":
  39971. case "RecordExpression":
  39972. return printObject(path, options, print);
  39973. // Babel 6
  39974. case "ObjectProperty": // Non-standard AST node type.
  39975. case "Property":
  39976. if (node.method || node.kind === "get" || node.kind === "set") {
  39977. return printMethod(path, options, print);
  39978. }
  39979. return printProperty(path, options, print);
  39980. case "ObjectMethod":
  39981. return printMethod(path, options, print);
  39982. case "Decorator":
  39983. return ["@", print("expression")];
  39984. case "ArrayExpression":
  39985. case "ArrayPattern":
  39986. case "TupleExpression":
  39987. return printArray(path, options, print);
  39988. case "SequenceExpression":
  39989. {
  39990. const parent = path.getParentNode(0);
  39991. if (parent.type === "ExpressionStatement" || parent.type === "ForStatement") {
  39992. // For ExpressionStatements and for-loop heads, which are among
  39993. // the few places a SequenceExpression appears unparenthesized, we want
  39994. // to indent expressions after the first.
  39995. const parts = [];
  39996. path.each((expressionPath, index) => {
  39997. if (index === 0) {
  39998. parts.push(print());
  39999. } else {
  40000. parts.push(",", indent$8([line$e, print()]));
  40001. }
  40002. }, "expressions");
  40003. return group$e(parts);
  40004. }
  40005. return group$e(join$c([",", line$e], path.map(print, "expressions")));
  40006. }
  40007. case "ThisExpression":
  40008. return "this";
  40009. case "Super":
  40010. return "super";
  40011. case "Directive":
  40012. return [print("value"), semi];
  40013. // Babel 6
  40014. case "DirectiveLiteral":
  40015. return printDirective(node, options);
  40016. case "UnaryExpression":
  40017. parts.push(node.operator);
  40018. if (/[a-z]$/.test(node.operator)) {
  40019. parts.push(" ");
  40020. }
  40021. if (hasComment(node.argument)) {
  40022. parts.push(group$e(["(", indent$8([softline$a, print("argument")]), softline$a, ")"]));
  40023. } else {
  40024. parts.push(print("argument"));
  40025. }
  40026. return parts;
  40027. case "UpdateExpression":
  40028. parts.push(print("argument"), node.operator);
  40029. if (node.prefix) {
  40030. parts.reverse();
  40031. }
  40032. return parts;
  40033. case "ConditionalExpression":
  40034. return printTernary(path, options, print);
  40035. case "VariableDeclaration":
  40036. {
  40037. const printed = path.map(print, "declarations"); // We generally want to terminate all variable declarations with a
  40038. // semicolon, except when they in the () part of for loops.
  40039. const parentNode = path.getParentNode();
  40040. const isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement";
  40041. const hasValue = node.declarations.some(decl => decl.init);
  40042. let firstVariable;
  40043. if (printed.length === 1 && !hasComment(node.declarations[0])) {
  40044. firstVariable = printed[0];
  40045. } else if (printed.length > 0) {
  40046. // Indent first var to comply with eslint one-var rule
  40047. firstVariable = indent$8(printed[0]);
  40048. }
  40049. parts = [node.declare ? "declare " : "", node.kind, firstVariable ? [" ", firstVariable] : "", indent$8(printed.slice(1).map(p => [",", hasValue && !isParentForLoop ? hardline$g : line$e, p]))];
  40050. if (!(isParentForLoop && parentNode.body !== node)) {
  40051. parts.push(semi);
  40052. }
  40053. return group$e(parts);
  40054. }
  40055. case "WithStatement":
  40056. return group$e(["with (", print("object"), ")", adjustClause(node.body, print("body"))]);
  40057. case "IfStatement":
  40058. {
  40059. const con = adjustClause(node.consequent, print("consequent"));
  40060. const opening = group$e(["if (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", con]);
  40061. parts.push(opening);
  40062. if (node.alternate) {
  40063. const commentOnOwnLine = hasComment(node.consequent, CommentCheckFlags.Trailing | CommentCheckFlags.Line) || needsHardlineAfterDanglingComment(node);
  40064. const elseOnSameLine = node.consequent.type === "BlockStatement" && !commentOnOwnLine;
  40065. parts.push(elseOnSameLine ? " " : hardline$g);
  40066. if (hasComment(node, CommentCheckFlags.Dangling)) {
  40067. parts.push(printDanglingComments(path, options, true), commentOnOwnLine ? hardline$g : " ");
  40068. }
  40069. parts.push("else", group$e(adjustClause(node.alternate, print("alternate"), node.alternate.type === "IfStatement")));
  40070. }
  40071. return parts;
  40072. }
  40073. case "ForStatement":
  40074. {
  40075. const body = adjustClause(node.body, print("body")); // We want to keep dangling comments above the loop to stay consistent.
  40076. // Any comment positioned between the for statement and the parentheses
  40077. // is going to be printed before the statement.
  40078. const dangling = printDanglingComments(path, options,
  40079. /* sameLine */
  40080. true);
  40081. const printedComments = dangling ? [dangling, softline$a] : "";
  40082. if (!node.init && !node.test && !node.update) {
  40083. return [printedComments, group$e(["for (;;)", body])];
  40084. }
  40085. return [printedComments, group$e(["for (", group$e([indent$8([softline$a, print("init"), ";", line$e, print("test"), ";", line$e, print("update")]), softline$a]), ")", body])];
  40086. }
  40087. case "WhileStatement":
  40088. return group$e(["while (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", adjustClause(node.body, print("body"))]);
  40089. case "ForInStatement":
  40090. return group$e(["for (", print("left"), " in ", print("right"), ")", adjustClause(node.body, print("body"))]);
  40091. case "ForOfStatement":
  40092. return group$e(["for", node.await ? " await" : "", " (", print("left"), " of ", print("right"), ")", adjustClause(node.body, print("body"))]);
  40093. case "DoWhileStatement":
  40094. {
  40095. const clause = adjustClause(node.body, print("body"));
  40096. const doBody = group$e(["do", clause]);
  40097. parts = [doBody];
  40098. if (node.body.type === "BlockStatement") {
  40099. parts.push(" ");
  40100. } else {
  40101. parts.push(hardline$g);
  40102. }
  40103. parts.push("while (", group$e([indent$8([softline$a, print("test")]), softline$a]), ")", semi);
  40104. return parts;
  40105. }
  40106. case "DoExpression":
  40107. return [node.async ? "async " : "", "do ", print("body")];
  40108. case "BreakStatement":
  40109. parts.push("break");
  40110. if (node.label) {
  40111. parts.push(" ", print("label"));
  40112. }
  40113. parts.push(semi);
  40114. return parts;
  40115. case "ContinueStatement":
  40116. parts.push("continue");
  40117. if (node.label) {
  40118. parts.push(" ", print("label"));
  40119. }
  40120. parts.push(semi);
  40121. return parts;
  40122. case "LabeledStatement":
  40123. if (node.body.type === "EmptyStatement") {
  40124. return [print("label"), ":;"];
  40125. }
  40126. return [print("label"), ": ", print("body")];
  40127. case "TryStatement":
  40128. return ["try ", print("block"), node.handler ? [" ", print("handler")] : "", node.finalizer ? [" finally ", print("finalizer")] : ""];
  40129. case "CatchClause":
  40130. if (node.param) {
  40131. const parameterHasComments = hasComment(node.param, comment => !isBlockComment(comment) || comment.leading && hasNewline$1(options.originalText, locEnd$e(comment)) || comment.trailing && hasNewline$1(options.originalText, locStart$f(comment), {
  40132. backwards: true
  40133. }));
  40134. const param = print("param");
  40135. return ["catch ", parameterHasComments ? ["(", indent$8([softline$a, param]), softline$a, ") "] : ["(", param, ") "], print("body")];
  40136. }
  40137. return ["catch ", print("body")];
  40138. // Note: ignoring n.lexical because it has no printing consequences.
  40139. case "SwitchStatement":
  40140. return [group$e(["switch (", indent$8([softline$a, print("discriminant")]), softline$a, ")"]), " {", node.cases.length > 0 ? indent$8([hardline$g, join$c(hardline$g, path.map((casePath, index, cases) => {
  40141. const caseNode = casePath.getValue();
  40142. return [print(), index !== cases.length - 1 && isNextLineEmpty$4(caseNode, options) ? hardline$g : ""];
  40143. }, "cases"))]) : "", hardline$g, "}"];
  40144. case "SwitchCase":
  40145. {
  40146. if (node.test) {
  40147. parts.push("case ", print("test"), ":");
  40148. } else {
  40149. parts.push("default:");
  40150. }
  40151. const consequent = node.consequent.filter(node => node.type !== "EmptyStatement");
  40152. if (consequent.length > 0) {
  40153. const cons = printSwitchCaseConsequent(path, options, print);
  40154. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? [" ", cons] : indent$8([hardline$g, cons]));
  40155. }
  40156. return parts;
  40157. }
  40158. // JSX extensions below.
  40159. case "DebuggerStatement":
  40160. return ["debugger", semi];
  40161. case "ClassDeclaration":
  40162. case "ClassExpression":
  40163. return printClass(path, options, print);
  40164. case "ClassMethod":
  40165. case "ClassPrivateMethod":
  40166. case "MethodDefinition":
  40167. return printClassMethod(path, options, print);
  40168. case "ClassProperty":
  40169. case "PropertyDefinition":
  40170. case "ClassPrivateProperty":
  40171. return printClassProperty(path, options, print);
  40172. case "TemplateElement":
  40173. return replaceTextEndOfLine$9(node.value.raw);
  40174. case "TemplateLiteral":
  40175. return printTemplateLiteral(path, print, options);
  40176. case "TaggedTemplateExpression":
  40177. return [print("tag"), print("typeParameters"), print("quasi")];
  40178. case "PrivateIdentifier":
  40179. return ["#", print("name")];
  40180. case "PrivateName":
  40181. return ["#", print("id")];
  40182. case "InterpreterDirective":
  40183. parts.push("#!", node.value, hardline$g);
  40184. if (isNextLineEmpty$4(node, options)) {
  40185. parts.push(hardline$g);
  40186. }
  40187. return parts;
  40188. // For hack-style pipeline
  40189. case "TopicReference":
  40190. return "%";
  40191. case "ArgumentPlaceholder":
  40192. return "?";
  40193. case "ModuleExpression":
  40194. {
  40195. parts.push("module {");
  40196. const printed = print("body");
  40197. if (printed) {
  40198. parts.push(indent$8([hardline$g, printed]), hardline$g);
  40199. }
  40200. parts.push("}");
  40201. return parts;
  40202. }
  40203. default:
  40204. /* istanbul ignore next */
  40205. throw new Error("unknown type: " + JSON.stringify(node.type));
  40206. }
  40207. }
  40208. function printDirective(node, options) {
  40209. const raw = rawText(node);
  40210. const rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  40211. // the quotes on a DirectiveLiteral.
  40212. if (rawContent.includes('"') || rawContent.includes("'")) {
  40213. return raw;
  40214. }
  40215. const enclosingQuote = options.singleQuote ? "'" : '"'; // Directives are exact code unit sequences, which means that you can't
  40216. // change the escape sequences they use.
  40217. // See https://github.com/prettier/prettier/issues/1555
  40218. // and https://tc39.github.io/ecma262/#directive-prologue
  40219. return enclosingQuote + rawContent + enclosingQuote;
  40220. }
  40221. function canAttachComment$1(node) {
  40222. return node.type && !isBlockComment(node) && !isLineComment(node) && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import" && // `babel-ts` don't have similar node for `class Foo { bar() /* bat */; }`
  40223. node.type !== "TSEmptyBodyFunctionExpression";
  40224. }
  40225. var printerEstree = {
  40226. preprocess: preprocess$7,
  40227. print: genericPrint$6,
  40228. embed: embed$9,
  40229. insertPragma: insertPragma$9,
  40230. massageAstNode: clean$b,
  40231. hasPrettierIgnore(path) {
  40232. return hasIgnoreComment(path) || hasJsxIgnoreComment(path);
  40233. },
  40234. willPrintOwnComments: handleComments.willPrintOwnComments,
  40235. canAttachComment: canAttachComment$1,
  40236. printComment: printComment$1,
  40237. isBlockComment,
  40238. handleComments: {
  40239. // TODO: Make this as default behavior
  40240. avoidAstMutation: true,
  40241. ownLine: handleComments.handleOwnLineComment,
  40242. endOfLine: handleComments.handleEndOfLineComment,
  40243. remaining: handleComments.handleRemainingComment
  40244. },
  40245. getCommentChildNodes: handleComments.getCommentChildNodes
  40246. };
  40247. const {
  40248. builders: {
  40249. hardline: hardline$f,
  40250. indent: indent$7,
  40251. join: join$b
  40252. }
  40253. } = require$$7$3;
  40254. const preprocess$6 = printPreprocess$3;
  40255. function genericPrint$5(path, options, print) {
  40256. const node = path.getValue();
  40257. switch (node.type) {
  40258. case "JsonRoot":
  40259. return [print("node"), hardline$f];
  40260. case "ArrayExpression":
  40261. {
  40262. if (node.elements.length === 0) {
  40263. return "[]";
  40264. }
  40265. const printed = path.map(() => path.getValue() === null ? "null" : print(), "elements");
  40266. return ["[", indent$7([hardline$f, join$b([",", hardline$f], printed)]), hardline$f, "]"];
  40267. }
  40268. case "ObjectExpression":
  40269. return node.properties.length === 0 ? "{}" : ["{", indent$7([hardline$f, join$b([",", hardline$f], path.map(print, "properties"))]), hardline$f, "}"];
  40270. case "ObjectProperty":
  40271. return [print("key"), ": ", print("value")];
  40272. case "UnaryExpression":
  40273. return [node.operator === "+" ? "" : node.operator, print("argument")];
  40274. case "NullLiteral":
  40275. return "null";
  40276. case "BooleanLiteral":
  40277. return node.value ? "true" : "false";
  40278. case "StringLiteral":
  40279. case "NumericLiteral":
  40280. return JSON.stringify(node.value);
  40281. case "Identifier":
  40282. {
  40283. const parent = path.getParentNode();
  40284. if (parent && parent.type === "ObjectProperty" && parent.key === node) {
  40285. return JSON.stringify(node.name);
  40286. }
  40287. return node.name;
  40288. }
  40289. case "TemplateLiteral":
  40290. // There is only one `TemplateElement`
  40291. return print(["quasis", 0]);
  40292. case "TemplateElement":
  40293. return JSON.stringify(node.value.cooked);
  40294. default:
  40295. /* istanbul ignore next */
  40296. throw new Error("unknown type: " + JSON.stringify(node.type));
  40297. }
  40298. }
  40299. const ignoredProperties$3 = new Set(["start", "end", "extra", "loc", "comments", "leadingComments", "trailingComments", "innerComments", "errors", "range", "tokens"]);
  40300. function clean$a(node, newNode
  40301. /*, parent*/
  40302. ) {
  40303. const {
  40304. type
  40305. } = node; // We print quoted key
  40306. if (type === "ObjectProperty" && node.key.type === "Identifier") {
  40307. newNode.key = {
  40308. type: "StringLiteral",
  40309. value: node.key.name
  40310. };
  40311. return;
  40312. }
  40313. if (type === "UnaryExpression" && node.operator === "+") {
  40314. return newNode.argument;
  40315. } // We print holes in array as `null`
  40316. if (type === "ArrayExpression") {
  40317. for (const [index, element] of node.elements.entries()) {
  40318. if (element === null) {
  40319. newNode.elements.splice(index, 0, {
  40320. type: "NullLiteral"
  40321. });
  40322. }
  40323. }
  40324. return;
  40325. } // We print `TemplateLiteral` as string
  40326. if (type === "TemplateLiteral") {
  40327. return {
  40328. type: "StringLiteral",
  40329. value: node.quasis[0].value.cooked
  40330. };
  40331. }
  40332. }
  40333. clean$a.ignoredProperties = ignoredProperties$3;
  40334. var printerEstreeJson = {
  40335. preprocess: preprocess$6,
  40336. print: genericPrint$5,
  40337. massageAstNode: clean$a
  40338. };
  40339. const CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  40340. var commonOptions$6 = {
  40341. bracketSpacing: {
  40342. since: "0.0.0",
  40343. category: CATEGORY_COMMON,
  40344. type: "boolean",
  40345. default: true,
  40346. description: "Print spaces between brackets.",
  40347. oppositeDescription: "Do not print spaces between brackets."
  40348. },
  40349. singleQuote: {
  40350. since: "0.0.0",
  40351. category: CATEGORY_COMMON,
  40352. type: "boolean",
  40353. default: false,
  40354. description: "Use single quotes instead of double quotes."
  40355. },
  40356. proseWrap: {
  40357. since: "1.8.2",
  40358. category: CATEGORY_COMMON,
  40359. type: "choice",
  40360. default: [{
  40361. since: "1.8.2",
  40362. value: true
  40363. }, {
  40364. since: "1.9.0",
  40365. value: "preserve"
  40366. }],
  40367. description: "How to wrap prose.",
  40368. choices: [{
  40369. since: "1.9.0",
  40370. value: "always",
  40371. description: "Wrap prose if it exceeds the print width."
  40372. }, {
  40373. since: "1.9.0",
  40374. value: "never",
  40375. description: "Do not wrap prose."
  40376. }, {
  40377. since: "1.9.0",
  40378. value: "preserve",
  40379. description: "Wrap prose as-is."
  40380. }]
  40381. },
  40382. bracketSameLine: {
  40383. since: "2.4.0",
  40384. category: CATEGORY_COMMON,
  40385. type: "boolean",
  40386. default: false,
  40387. description: "Put > of opening tags on the last line instead of on a new line."
  40388. }
  40389. };
  40390. const commonOptions$5 = commonOptions$6;
  40391. const CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  40392. var options$b = {
  40393. arrowParens: {
  40394. since: "1.9.0",
  40395. category: CATEGORY_JAVASCRIPT,
  40396. type: "choice",
  40397. default: [{
  40398. since: "1.9.0",
  40399. value: "avoid"
  40400. }, {
  40401. since: "2.0.0",
  40402. value: "always"
  40403. }],
  40404. description: "Include parentheses around a sole arrow function parameter.",
  40405. choices: [{
  40406. value: "always",
  40407. description: "Always include parens. Example: `(x) => x`"
  40408. }, {
  40409. value: "avoid",
  40410. description: "Omit parens when possible. Example: `x => x`"
  40411. }]
  40412. },
  40413. bracketSameLine: commonOptions$5.bracketSameLine,
  40414. bracketSpacing: commonOptions$5.bracketSpacing,
  40415. jsxBracketSameLine: {
  40416. since: "0.17.0",
  40417. category: CATEGORY_JAVASCRIPT,
  40418. type: "boolean",
  40419. description: "Put > on the last line instead of at a new line.",
  40420. deprecated: "2.4.0"
  40421. },
  40422. semi: {
  40423. since: "1.0.0",
  40424. category: CATEGORY_JAVASCRIPT,
  40425. type: "boolean",
  40426. default: true,
  40427. description: "Print semicolons.",
  40428. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  40429. },
  40430. singleQuote: commonOptions$5.singleQuote,
  40431. jsxSingleQuote: {
  40432. since: "1.15.0",
  40433. category: CATEGORY_JAVASCRIPT,
  40434. type: "boolean",
  40435. default: false,
  40436. description: "Use single quotes in JSX."
  40437. },
  40438. quoteProps: {
  40439. since: "1.17.0",
  40440. category: CATEGORY_JAVASCRIPT,
  40441. type: "choice",
  40442. default: "as-needed",
  40443. description: "Change when properties in objects are quoted.",
  40444. choices: [{
  40445. value: "as-needed",
  40446. description: "Only add quotes around object properties where required."
  40447. }, {
  40448. value: "consistent",
  40449. description: "If at least one property in an object requires quotes, quote all properties."
  40450. }, {
  40451. value: "preserve",
  40452. description: "Respect the input use of quotes in object properties."
  40453. }]
  40454. },
  40455. trailingComma: {
  40456. since: "0.0.0",
  40457. category: CATEGORY_JAVASCRIPT,
  40458. type: "choice",
  40459. default: [{
  40460. since: "0.0.0",
  40461. value: false
  40462. }, {
  40463. since: "0.19.0",
  40464. value: "none"
  40465. }, {
  40466. since: "2.0.0",
  40467. value: "es5"
  40468. }],
  40469. description: "Print trailing commas wherever possible when multi-line.",
  40470. choices: [{
  40471. value: "es5",
  40472. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  40473. }, {
  40474. value: "none",
  40475. description: "No trailing commas."
  40476. }, {
  40477. value: "all",
  40478. description: "Trailing commas wherever possible (including function arguments)."
  40479. }]
  40480. }
  40481. };
  40482. var require$$0$2 = require("./parser-babel.js");
  40483. var require$$1$1 = require("./parser-flow.js");
  40484. var require$$2$1 = require("./parser-typescript.js");
  40485. var require$$3$1 = require("./parser-angular.js");
  40486. var require$$4$6 = require("./parser-espree.js");
  40487. var require$$5$3 = require("./parser-meriyah.js");
  40488. var parsers$d = {
  40489. // JS - Babel
  40490. get babel() {
  40491. return require$$0$2.parsers.babel;
  40492. },
  40493. get "babel-flow"() {
  40494. return require$$0$2.parsers["babel-flow"];
  40495. },
  40496. get "babel-ts"() {
  40497. return require$$0$2.parsers["babel-ts"];
  40498. },
  40499. get json() {
  40500. return require$$0$2.parsers.json;
  40501. },
  40502. get json5() {
  40503. return require$$0$2.parsers.json5;
  40504. },
  40505. get "json-stringify"() {
  40506. return require$$0$2.parsers["json-stringify"];
  40507. },
  40508. get __js_expression() {
  40509. return require$$0$2.parsers.__js_expression;
  40510. },
  40511. get __vue_expression() {
  40512. return require$$0$2.parsers.__vue_expression;
  40513. },
  40514. get __vue_event_binding() {
  40515. return require$$0$2.parsers.__vue_event_binding;
  40516. },
  40517. // JS - Flow
  40518. get flow() {
  40519. return require$$1$1.parsers.flow;
  40520. },
  40521. // JS - TypeScript
  40522. get typescript() {
  40523. return require$$2$1.parsers.typescript;
  40524. },
  40525. // JS - Angular Action
  40526. get __ng_action() {
  40527. return require$$3$1.parsers.__ng_action;
  40528. },
  40529. // JS - Angular Binding
  40530. get __ng_binding() {
  40531. return require$$3$1.parsers.__ng_binding;
  40532. },
  40533. // JS - Angular Interpolation
  40534. get __ng_interpolation() {
  40535. return require$$3$1.parsers.__ng_interpolation;
  40536. },
  40537. // JS - Angular Directive
  40538. get __ng_directive() {
  40539. return require$$3$1.parsers.__ng_directive;
  40540. },
  40541. // JS - espree
  40542. get espree() {
  40543. return require$$4$6.parsers.espree;
  40544. },
  40545. // JS - meriyah
  40546. get meriyah() {
  40547. return require$$5$3.parsers.meriyah;
  40548. },
  40549. // JS - Babel Estree
  40550. get __babel_estree() {
  40551. return require$$0$2.parsers.__babel_estree;
  40552. }
  40553. };
  40554. var name$f = "JavaScript";
  40555. var type$f = "programming";
  40556. var tmScope$f = "source.js";
  40557. var aceMode$f = "javascript";
  40558. var codemirrorMode$b = "javascript";
  40559. var codemirrorMimeType$b = "text/javascript";
  40560. var color$a = "#f1e05a";
  40561. var aliases$6 = [
  40562. "js",
  40563. "node"
  40564. ];
  40565. var extensions$f = [
  40566. ".js",
  40567. "._js",
  40568. ".bones",
  40569. ".cjs",
  40570. ".es",
  40571. ".es6",
  40572. ".frag",
  40573. ".gs",
  40574. ".jake",
  40575. ".jsb",
  40576. ".jscad",
  40577. ".jsfl",
  40578. ".jsm",
  40579. ".jss",
  40580. ".jsx",
  40581. ".mjs",
  40582. ".njs",
  40583. ".pac",
  40584. ".sjs",
  40585. ".ssjs",
  40586. ".xsjs",
  40587. ".xsjslib"
  40588. ];
  40589. var filenames$4 = [
  40590. "Jakefile"
  40591. ];
  40592. var interpreters$1 = [
  40593. "chakra",
  40594. "d8",
  40595. "gjs",
  40596. "js",
  40597. "node",
  40598. "nodejs",
  40599. "qjs",
  40600. "rhino",
  40601. "v8",
  40602. "v8-shell"
  40603. ];
  40604. var languageId$f = 183;
  40605. var require$$5$2 = {
  40606. name: name$f,
  40607. type: type$f,
  40608. tmScope: tmScope$f,
  40609. aceMode: aceMode$f,
  40610. codemirrorMode: codemirrorMode$b,
  40611. codemirrorMimeType: codemirrorMimeType$b,
  40612. color: color$a,
  40613. aliases: aliases$6,
  40614. extensions: extensions$f,
  40615. filenames: filenames$4,
  40616. interpreters: interpreters$1,
  40617. languageId: languageId$f
  40618. };
  40619. var name$e = "TypeScript";
  40620. var type$e = "programming";
  40621. var color$9 = "#2b7489";
  40622. var aliases$5 = [
  40623. "ts"
  40624. ];
  40625. var interpreters = [
  40626. "deno",
  40627. "ts-node"
  40628. ];
  40629. var extensions$e = [
  40630. ".ts"
  40631. ];
  40632. var tmScope$e = "source.ts";
  40633. var aceMode$e = "typescript";
  40634. var codemirrorMode$a = "javascript";
  40635. var codemirrorMimeType$a = "application/typescript";
  40636. var languageId$e = 378;
  40637. var require$$6$1 = {
  40638. name: name$e,
  40639. type: type$e,
  40640. color: color$9,
  40641. aliases: aliases$5,
  40642. interpreters: interpreters,
  40643. extensions: extensions$e,
  40644. tmScope: tmScope$e,
  40645. aceMode: aceMode$e,
  40646. codemirrorMode: codemirrorMode$a,
  40647. codemirrorMimeType: codemirrorMimeType$a,
  40648. languageId: languageId$e
  40649. };
  40650. var name$d = "TSX";
  40651. var type$d = "programming";
  40652. var group$d = "TypeScript";
  40653. var extensions$d = [
  40654. ".tsx"
  40655. ];
  40656. var tmScope$d = "source.tsx";
  40657. var aceMode$d = "javascript";
  40658. var codemirrorMode$9 = "jsx";
  40659. var codemirrorMimeType$9 = "text/jsx";
  40660. var languageId$d = 94901924;
  40661. var require$$7$1 = {
  40662. name: name$d,
  40663. type: type$d,
  40664. group: group$d,
  40665. extensions: extensions$d,
  40666. tmScope: tmScope$d,
  40667. aceMode: aceMode$d,
  40668. codemirrorMode: codemirrorMode$9,
  40669. codemirrorMimeType: codemirrorMimeType$9,
  40670. languageId: languageId$d
  40671. };
  40672. var name$c = "JSON";
  40673. var type$c = "data";
  40674. var tmScope$c = "source.json";
  40675. var aceMode$c = "json";
  40676. var codemirrorMode$8 = "javascript";
  40677. var codemirrorMimeType$8 = "application/json";
  40678. var extensions$c = [
  40679. ".json",
  40680. ".avsc",
  40681. ".geojson",
  40682. ".gltf",
  40683. ".har",
  40684. ".ice",
  40685. ".JSON-tmLanguage",
  40686. ".jsonl",
  40687. ".mcmeta",
  40688. ".tfstate",
  40689. ".tfstate.backup",
  40690. ".topojson",
  40691. ".webapp",
  40692. ".webmanifest",
  40693. ".yy",
  40694. ".yyp"
  40695. ];
  40696. var filenames$3 = [
  40697. ".arcconfig",
  40698. ".htmlhintrc",
  40699. ".imgbotconfig",
  40700. ".tern-config",
  40701. ".tern-project",
  40702. ".watchmanconfig",
  40703. "Pipfile.lock",
  40704. "composer.lock",
  40705. "mcmod.info"
  40706. ];
  40707. var languageId$c = 174;
  40708. var require$$8 = {
  40709. name: name$c,
  40710. type: type$c,
  40711. tmScope: tmScope$c,
  40712. aceMode: aceMode$c,
  40713. codemirrorMode: codemirrorMode$8,
  40714. codemirrorMimeType: codemirrorMimeType$8,
  40715. extensions: extensions$c,
  40716. filenames: filenames$3,
  40717. languageId: languageId$c
  40718. };
  40719. var name$b = "JSON with Comments";
  40720. var type$b = "data";
  40721. var group$c = "JSON";
  40722. var tmScope$b = "source.js";
  40723. var aceMode$b = "javascript";
  40724. var codemirrorMode$7 = "javascript";
  40725. var codemirrorMimeType$7 = "text/javascript";
  40726. var aliases$4 = [
  40727. "jsonc"
  40728. ];
  40729. var extensions$b = [
  40730. ".jsonc",
  40731. ".sublime-build",
  40732. ".sublime-commands",
  40733. ".sublime-completions",
  40734. ".sublime-keymap",
  40735. ".sublime-macro",
  40736. ".sublime-menu",
  40737. ".sublime-mousemap",
  40738. ".sublime-project",
  40739. ".sublime-settings",
  40740. ".sublime-theme",
  40741. ".sublime-workspace",
  40742. ".sublime_metrics",
  40743. ".sublime_session"
  40744. ];
  40745. var filenames$2 = [
  40746. ".babelrc",
  40747. ".eslintrc.json",
  40748. ".jscsrc",
  40749. ".jshintrc",
  40750. ".jslintrc",
  40751. "api-extractor.json",
  40752. "devcontainer.json",
  40753. "jsconfig.json",
  40754. "language-configuration.json",
  40755. "tsconfig.json",
  40756. "tslint.json"
  40757. ];
  40758. var languageId$b = 423;
  40759. var require$$9 = {
  40760. name: name$b,
  40761. type: type$b,
  40762. group: group$c,
  40763. tmScope: tmScope$b,
  40764. aceMode: aceMode$b,
  40765. codemirrorMode: codemirrorMode$7,
  40766. codemirrorMimeType: codemirrorMimeType$7,
  40767. aliases: aliases$4,
  40768. extensions: extensions$b,
  40769. filenames: filenames$2,
  40770. languageId: languageId$b
  40771. };
  40772. var name$a = "JSON5";
  40773. var type$a = "data";
  40774. var extensions$a = [
  40775. ".json5"
  40776. ];
  40777. var tmScope$a = "source.js";
  40778. var aceMode$a = "javascript";
  40779. var codemirrorMode$6 = "javascript";
  40780. var codemirrorMimeType$6 = "application/json";
  40781. var languageId$a = 175;
  40782. var require$$10 = {
  40783. name: name$a,
  40784. type: type$a,
  40785. extensions: extensions$a,
  40786. tmScope: tmScope$a,
  40787. aceMode: aceMode$a,
  40788. codemirrorMode: codemirrorMode$6,
  40789. codemirrorMimeType: codemirrorMimeType$6,
  40790. languageId: languageId$a
  40791. };
  40792. const createLanguage$6 = createLanguage$7;
  40793. const estreePrinter = printerEstree;
  40794. const estreeJsonPrinter = printerEstreeJson;
  40795. const options$a = options$b;
  40796. const parsers$c = parsers$d;
  40797. const languages$7 = [createLanguage$6(require$$5$2, data => ({
  40798. since: "0.0.0",
  40799. parsers: ["babel", "espree", "meriyah", "babel-flow", "babel-ts", "flow", "typescript"],
  40800. vscodeLanguageIds: ["javascript", "mongo"],
  40801. interpreters: [...data.interpreters, // https://github.com/google/zx
  40802. "zx"],
  40803. extensions: [...data.extensions.filter(extension => extension !== ".jsx"), // WeiXin Script (Weixin Mini Programs)
  40804. // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
  40805. ".wxs"]
  40806. })), createLanguage$6(require$$5$2, () => ({
  40807. name: "Flow",
  40808. since: "0.0.0",
  40809. parsers: ["flow", "babel-flow"],
  40810. vscodeLanguageIds: ["javascript"],
  40811. aliases: [],
  40812. filenames: [],
  40813. extensions: [".js.flow"]
  40814. })), createLanguage$6(require$$5$2, () => ({
  40815. name: "JSX",
  40816. since: "0.0.0",
  40817. parsers: ["babel", "babel-flow", "babel-ts", "flow", "typescript", "espree", "meriyah"],
  40818. vscodeLanguageIds: ["javascriptreact"],
  40819. aliases: undefined,
  40820. filenames: undefined,
  40821. extensions: [".jsx"],
  40822. group: "JavaScript",
  40823. interpreters: undefined,
  40824. tmScope: "source.js.jsx",
  40825. aceMode: "javascript",
  40826. codemirrorMode: "jsx",
  40827. codemirrorMimeType: "text/jsx",
  40828. color: undefined
  40829. })), createLanguage$6(require$$6$1, data => ({
  40830. since: "1.4.0",
  40831. parsers: ["typescript", "babel-ts"],
  40832. vscodeLanguageIds: ["typescript"],
  40833. extensions: [...data.extensions, ".mts", ".cts"]
  40834. })), createLanguage$6(require$$7$1, () => ({
  40835. since: "1.4.0",
  40836. parsers: ["typescript", "babel-ts"],
  40837. vscodeLanguageIds: ["typescriptreact"]
  40838. })), createLanguage$6(require$$8, () => ({
  40839. name: "JSON.stringify",
  40840. since: "1.13.0",
  40841. parsers: ["json-stringify"],
  40842. vscodeLanguageIds: ["json"],
  40843. extensions: [],
  40844. // .json file defaults to json instead of json-stringify
  40845. filenames: ["package.json", "package-lock.json", "composer.json"]
  40846. })), createLanguage$6(require$$8, data => ({
  40847. since: "1.5.0",
  40848. parsers: ["json"],
  40849. vscodeLanguageIds: ["json"],
  40850. extensions: data.extensions.filter(extension => extension !== ".jsonl")
  40851. })), createLanguage$6(require$$9, data => ({
  40852. since: "1.5.0",
  40853. parsers: ["json"],
  40854. vscodeLanguageIds: ["jsonc"],
  40855. filenames: [...data.filenames, ".eslintrc"]
  40856. })), createLanguage$6(require$$10, () => ({
  40857. since: "1.13.0",
  40858. parsers: ["json5"],
  40859. vscodeLanguageIds: ["json5"]
  40860. }))];
  40861. const printers$5 = {
  40862. estree: estreePrinter,
  40863. "estree-json": estreeJsonPrinter
  40864. };
  40865. var languageJs = {
  40866. languages: languages$7,
  40867. options: options$a,
  40868. printers: printers$5,
  40869. parsers: parsers$c
  40870. };
  40871. const {
  40872. isFrontMatterNode: isFrontMatterNode$4
  40873. } = util$8;
  40874. const getLast$9 = getLast_1;
  40875. const ignoredProperties$2 = new Set(["raw", // front-matter
  40876. "raws", "sourceIndex", "source", "before", "after", "trailingComma"]);
  40877. function clean$9(ast, newObj, parent) {
  40878. if (isFrontMatterNode$4(ast) && ast.lang === "yaml") {
  40879. delete newObj.value;
  40880. }
  40881. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length > 0) {
  40882. // --insert-pragma
  40883. // first non-front-matter comment
  40884. if (parent.nodes[0] === ast || isFrontMatterNode$4(parent.nodes[0]) && parent.nodes[1] === ast) {
  40885. /**
  40886. * something
  40887. *
  40888. * @format
  40889. */
  40890. delete newObj.text; // standalone pragma
  40891. if (/^\*\s*@(?:format|prettier)\s*$/.test(ast.text)) {
  40892. return null;
  40893. }
  40894. } // Last comment is not parsed, when omitting semicolon, #8675
  40895. if (parent.type === "css-root" && getLast$9(parent.nodes) === ast) {
  40896. return null;
  40897. }
  40898. }
  40899. if (ast.type === "value-root") {
  40900. delete newObj.text;
  40901. }
  40902. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  40903. delete newObj.value;
  40904. }
  40905. if (ast.type === "css-rule") {
  40906. delete newObj.params;
  40907. }
  40908. if (ast.type === "selector-combinator") {
  40909. newObj.value = newObj.value.replace(/\s+/g, " ");
  40910. }
  40911. if (ast.type === "media-feature") {
  40912. newObj.value = newObj.value.replace(/ /g, "");
  40913. }
  40914. if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
  40915. newObj.value = newObj.value.toLowerCase();
  40916. }
  40917. if (ast.type === "css-decl") {
  40918. newObj.prop = newObj.prop.toLowerCase();
  40919. }
  40920. if (ast.type === "css-atrule" || ast.type === "css-import") {
  40921. newObj.name = newObj.name.toLowerCase();
  40922. }
  40923. if (ast.type === "value-number") {
  40924. newObj.unit = newObj.unit.toLowerCase();
  40925. }
  40926. 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) {
  40927. newObj.value = cleanCSSStrings(newObj.value);
  40928. }
  40929. if (ast.type === "selector-attribute") {
  40930. newObj.attribute = newObj.attribute.trim();
  40931. if (newObj.namespace) {
  40932. if (typeof newObj.namespace === "string") {
  40933. newObj.namespace = newObj.namespace.trim();
  40934. if (newObj.namespace.length === 0) {
  40935. newObj.namespace = true;
  40936. }
  40937. }
  40938. }
  40939. if (newObj.value) {
  40940. newObj.value = newObj.value.trim().replace(/^["']|["']$/g, "");
  40941. delete newObj.quoted;
  40942. }
  40943. }
  40944. 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) {
  40945. newObj.value = newObj.value.replace(/([\d+.Ee-]+)([A-Za-z]*)/g, (match, numStr, unit) => {
  40946. const num = Number(numStr);
  40947. return Number.isNaN(num) ? match : num + unit.toLowerCase();
  40948. });
  40949. }
  40950. if (ast.type === "selector-tag") {
  40951. const lowercasedValue = ast.value.toLowerCase();
  40952. if (["from", "to"].includes(lowercasedValue)) {
  40953. newObj.value = lowercasedValue;
  40954. }
  40955. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  40956. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  40957. delete newObj.value;
  40958. } // Workaround for SCSS nested properties
  40959. if (ast.type === "selector-unknown") {
  40960. delete newObj.value;
  40961. }
  40962. }
  40963. clean$9.ignoredProperties = ignoredProperties$2;
  40964. function cleanCSSStrings(value) {
  40965. return value.replace(/'/g, '"').replace(/\\([^\dA-Fa-f])/g, "$1");
  40966. }
  40967. var clean_1$3 = clean$9;
  40968. const {
  40969. builders: {
  40970. hardline: hardline$e,
  40971. markAsRoot: markAsRoot$3
  40972. }
  40973. } = require$$7$3;
  40974. function print$1(node, textToDoc) {
  40975. if (node.lang === "yaml") {
  40976. const value = node.value.trim();
  40977. const doc = value ? textToDoc(value, {
  40978. parser: "yaml"
  40979. }, {
  40980. stripTrailingHardline: true
  40981. }) : "";
  40982. return markAsRoot$3([node.startDelimiter, hardline$e, doc, doc ? hardline$e : "", node.endDelimiter]);
  40983. }
  40984. }
  40985. var print_1 = print$1;
  40986. const {
  40987. builders: {
  40988. hardline: hardline$d
  40989. }
  40990. } = require$$7$3;
  40991. const printFrontMatter$2 = print_1;
  40992. function embed$8(path, print, textToDoc
  40993. /*, options */
  40994. ) {
  40995. const node = path.getValue();
  40996. if (node.type === "front-matter") {
  40997. const doc = printFrontMatter$2(node, textToDoc);
  40998. return doc ? [doc, hardline$d] : "";
  40999. }
  41000. }
  41001. var embed_1$3 = embed$8;
  41002. const frontMatterRegex = new RegExp("^(?<startDelimiter>-{3}|\\+{3})" + // trailing spaces after delimiters are allowed
  41003. "(?<language>[^\\n]*)" + "\\n(?:|(?<value>.*?)\\n)" + // In some markdown processors such as pandoc,
  41004. // "..." can be used as the end delimiter for YAML front-matter.
  41005. // Adding `\.{3}` make the regex matches `+++\n...`, but we'll exclude it later
  41006. "(?<endDelimiter>\\k<startDelimiter>|\\.{3})" + "[^\\S\\n]*(?:\\n|$)", "s");
  41007. function parse(text) {
  41008. const match = text.match(frontMatterRegex);
  41009. if (!match) {
  41010. return {
  41011. content: text
  41012. };
  41013. }
  41014. const {
  41015. startDelimiter,
  41016. language,
  41017. value = "",
  41018. endDelimiter
  41019. } = match.groups;
  41020. let lang = language.trim() || "yaml";
  41021. if (startDelimiter === "+++") {
  41022. lang = "toml";
  41023. } // Only allow yaml to parse with a different end delimiter
  41024. if (lang !== "yaml" && startDelimiter !== endDelimiter) {
  41025. return {
  41026. content: text
  41027. };
  41028. }
  41029. const [raw] = match;
  41030. const frontMatter = {
  41031. type: "front-matter",
  41032. lang,
  41033. value,
  41034. startDelimiter,
  41035. endDelimiter,
  41036. raw: raw.replace(/\n$/, "")
  41037. };
  41038. return {
  41039. frontMatter,
  41040. content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
  41041. };
  41042. }
  41043. var parse_1 = parse;
  41044. const jsPragma = pragma$5;
  41045. const parseFrontMatter$1 = parse_1;
  41046. function hasPragma$3(text) {
  41047. return jsPragma.hasPragma(parseFrontMatter$1(text).content);
  41048. }
  41049. function insertPragma$8(text) {
  41050. const {
  41051. frontMatter,
  41052. content
  41053. } = parseFrontMatter$1(text);
  41054. return (frontMatter ? frontMatter.raw + "\n\n" : "") + jsPragma.insertPragma(content);
  41055. }
  41056. var pragma$4 = {
  41057. hasPragma: hasPragma$3,
  41058. insertPragma: insertPragma$8
  41059. };
  41060. const {
  41061. isNonEmptyArray: isNonEmptyArray$6
  41062. } = util$8;
  41063. const colorAdjusterFunctions = new Set(["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"]);
  41064. const moduleRuleNames = new Set(["import", "use", "forward"]);
  41065. function getAncestorCounter$1(path, typeOrTypes) {
  41066. const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
  41067. let counter = -1;
  41068. let ancestorNode;
  41069. while (ancestorNode = path.getParentNode(++counter)) {
  41070. if (types.includes(ancestorNode.type)) {
  41071. return counter;
  41072. }
  41073. }
  41074. return -1;
  41075. }
  41076. function getAncestorNode$2(path, typeOrTypes) {
  41077. const counter = getAncestorCounter$1(path, typeOrTypes);
  41078. return counter === -1 ? null : path.getParentNode(counter);
  41079. }
  41080. function getPropOfDeclNode$1(path) {
  41081. const declAncestorNode = getAncestorNode$2(path, "css-decl");
  41082. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  41083. }
  41084. function hasSCSSInterpolation(groupList) {
  41085. if (isNonEmptyArray$6(groupList)) {
  41086. for (let i = groupList.length - 1; i > 0; i--) {
  41087. // If we find `#{`, return true.
  41088. if (groupList[i].type === "word" && groupList[i].value === "{" && groupList[i - 1].type === "word" && groupList[i - 1].value.endsWith("#")) {
  41089. return true;
  41090. }
  41091. }
  41092. }
  41093. return false;
  41094. }
  41095. function hasStringOrFunction(groupList) {
  41096. if (isNonEmptyArray$6(groupList)) {
  41097. for (let i = 0; i < groupList.length; i++) {
  41098. if (groupList[i].type === "string" || groupList[i].type === "func") {
  41099. return true;
  41100. }
  41101. }
  41102. }
  41103. return false;
  41104. }
  41105. function isSCSS$1(parser, text) {
  41106. const hasExplicitParserChoice = parser === "less" || parser === "scss";
  41107. const IS_POSSIBLY_SCSS = /(?:\w\s*:\s*[^:}]+|#){|@import[^\n]+(?:url|,)/;
  41108. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  41109. }
  41110. function isSCSSVariable(node) {
  41111. return Boolean(node && node.type === "word" && node.value.startsWith("$"));
  41112. }
  41113. function isWideKeywords$1(value) {
  41114. return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
  41115. }
  41116. function isKeyframeAtRuleKeywords$1(path, value) {
  41117. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  41118. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
  41119. }
  41120. function maybeToLowerCase$1(value) {
  41121. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  41122. }
  41123. function insideValueFunctionNode$1(path, functionName) {
  41124. const funcAncestorNode = getAncestorNode$2(path, "value-func");
  41125. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  41126. }
  41127. function insideICSSRuleNode$1(path) {
  41128. const ruleAncestorNode = getAncestorNode$2(path, "css-rule");
  41129. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  41130. }
  41131. function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
  41132. const atRuleNames = Array.isArray(atRuleNameOrAtRuleNames) ? atRuleNameOrAtRuleNames : [atRuleNameOrAtRuleNames];
  41133. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  41134. return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
  41135. }
  41136. function insideURLFunctionInImportAtRuleNode$1(path) {
  41137. const node = path.getValue();
  41138. const atRuleAncestorNode = getAncestorNode$2(path, "css-atrule");
  41139. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  41140. }
  41141. function isURLFunctionNode$1(node) {
  41142. return node.type === "value-func" && node.value.toLowerCase() === "url";
  41143. }
  41144. function isLastNode$1(path, node) {
  41145. const parentNode = path.getParentNode();
  41146. /* istanbul ignore next */
  41147. if (!parentNode) {
  41148. return false;
  41149. }
  41150. const {
  41151. nodes
  41152. } = parentNode;
  41153. return nodes && nodes.indexOf(node) === nodes.length - 1;
  41154. }
  41155. function isDetachedRulesetDeclarationNode$1(node) {
  41156. // If a Less file ends up being parsed with the SCSS parser, Less
  41157. // variable declarations will be parsed as atrules with names ending
  41158. // with a colon, so keep the original case then.
  41159. /* istanbul ignore next */
  41160. if (!node.selector) {
  41161. return false;
  41162. }
  41163. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  41164. }
  41165. function isForKeywordNode$1(node) {
  41166. return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
  41167. }
  41168. function isIfElseKeywordNode$1(node) {
  41169. return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
  41170. }
  41171. function isEachKeywordNode$1(node) {
  41172. return node.type === "value-word" && node.value === "in";
  41173. }
  41174. function isMultiplicationNode$1(node) {
  41175. return node.type === "value-operator" && node.value === "*";
  41176. }
  41177. function isDivisionNode$1(node) {
  41178. return node.type === "value-operator" && node.value === "/";
  41179. }
  41180. function isAdditionNode$1(node) {
  41181. return node.type === "value-operator" && node.value === "+";
  41182. }
  41183. function isSubtractionNode$1(node) {
  41184. return node.type === "value-operator" && node.value === "-";
  41185. }
  41186. function isModuloNode(node) {
  41187. return node.type === "value-operator" && node.value === "%";
  41188. }
  41189. function isMathOperatorNode$1(node) {
  41190. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  41191. }
  41192. function isEqualityOperatorNode$1(node) {
  41193. return node.type === "value-word" && ["==", "!="].includes(node.value);
  41194. }
  41195. function isRelationalOperatorNode$1(node) {
  41196. return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
  41197. }
  41198. function isSCSSControlDirectiveNode$1(node) {
  41199. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
  41200. }
  41201. function isSCSSNestedPropertyNode(node) {
  41202. /* istanbul ignore next */
  41203. if (!node.selector) {
  41204. return false;
  41205. }
  41206. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  41207. }
  41208. function isDetachedRulesetCallNode$1(node) {
  41209. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  41210. }
  41211. function isTemplatePlaceholderNode$1(node) {
  41212. return node.name.startsWith("prettier-placeholder");
  41213. }
  41214. function isTemplatePropNode$1(node) {
  41215. return node.prop.startsWith("@prettier-placeholder");
  41216. }
  41217. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  41218. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  41219. }
  41220. function hasComposesNode$1(node) {
  41221. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  41222. }
  41223. function hasParensAroundNode$1(node) {
  41224. 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;
  41225. }
  41226. function hasEmptyRawBefore$1(node) {
  41227. return node.raws && node.raws.before === "";
  41228. }
  41229. function isKeyValuePairNode$1(node) {
  41230. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  41231. }
  41232. function isKeyValuePairInParenGroupNode(node) {
  41233. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  41234. }
  41235. function isSCSSMapItemNode$1(path) {
  41236. const node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
  41237. if (node.groups.length === 0) {
  41238. return false;
  41239. }
  41240. const parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  41241. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  41242. return false;
  41243. }
  41244. const declNode = getAncestorNode$2(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  41245. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  41246. return true;
  41247. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  41248. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  41249. return true;
  41250. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  41251. if (parentParentNode.type === "value-func") {
  41252. return true;
  41253. }
  41254. return false;
  41255. }
  41256. function isInlineValueCommentNode$1(node) {
  41257. return node.type === "value-comment" && node.inline;
  41258. }
  41259. function isHashNode$1(node) {
  41260. return node.type === "value-word" && node.value === "#";
  41261. }
  41262. function isLeftCurlyBraceNode$1(node) {
  41263. return node.type === "value-word" && node.value === "{";
  41264. }
  41265. function isRightCurlyBraceNode$1(node) {
  41266. return node.type === "value-word" && node.value === "}";
  41267. }
  41268. function isWordNode$1(node) {
  41269. return ["value-word", "value-atword"].includes(node.type);
  41270. }
  41271. function isColonNode$1(node) {
  41272. return node && node.type === "value-colon";
  41273. }
  41274. function isKeyInValuePairNode$1(node, parentNode) {
  41275. if (!isKeyValuePairNode$1(parentNode)) {
  41276. return false;
  41277. }
  41278. const {
  41279. groups
  41280. } = parentNode;
  41281. const index = groups.indexOf(node);
  41282. if (index === -1) {
  41283. return false;
  41284. }
  41285. return isColonNode$1(groups[index + 1]);
  41286. }
  41287. function isMediaAndSupportsKeywords$1(node) {
  41288. return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
  41289. }
  41290. function isColorAdjusterFuncNode$1(node) {
  41291. if (node.type !== "value-func") {
  41292. return false;
  41293. }
  41294. return colorAdjusterFunctions.has(node.value.toLowerCase());
  41295. } // TODO: only check `less` when we don't use `less` to parse `css`
  41296. function isLessParser$1(options) {
  41297. return options.parser === "css" || options.parser === "less";
  41298. }
  41299. function lastLineHasInlineComment$1(text) {
  41300. return /\/\//.test(text.split(/[\n\r]/).pop());
  41301. }
  41302. function stringifyNode(node) {
  41303. if (node.groups) {
  41304. const open = node.open && node.open.value ? node.open.value : "";
  41305. const groups = node.groups.reduce((previousValue, currentValue, index) => previousValue + stringifyNode(currentValue) + (node.groups[0].type === "comma_group" && index !== node.groups.length - 1 ? "," : ""), "");
  41306. const close = node.close && node.close.value ? node.close.value : "";
  41307. return open + groups + close;
  41308. }
  41309. const before = node.raws && node.raws.before ? node.raws.before : "";
  41310. const quote = node.raws && node.raws.quote ? node.raws.quote : "";
  41311. const atword = node.type === "atword" ? "@" : "";
  41312. const value = node.value ? node.value : "";
  41313. const unit = node.unit ? node.unit : "";
  41314. const group = node.group ? stringifyNode(node.group) : "";
  41315. const after = node.raws && node.raws.after ? node.raws.after : "";
  41316. return before + quote + atword + value + quote + unit + group + after;
  41317. }
  41318. function isAtWordPlaceholderNode$1(node) {
  41319. return node && node.type === "value-atword" && node.value.startsWith("prettier-placeholder-");
  41320. }
  41321. function isModuleRuleName(name) {
  41322. return moduleRuleNames.has(name);
  41323. }
  41324. function isConfigurationNode$1(node, parentNode) {
  41325. if (!node.open || node.open.value !== "(" || !node.close || node.close.value !== ")" || node.groups.some(group => group.type !== "value-comma_group")) {
  41326. return false;
  41327. }
  41328. if (parentNode.type === "value-comma_group") {
  41329. const prevIdx = parentNode.groups.indexOf(node) - 1;
  41330. const maybeWithNode = parentNode.groups[prevIdx];
  41331. if (maybeWithNode && maybeWithNode.type === "value-word" && maybeWithNode.value === "with") {
  41332. return true;
  41333. }
  41334. }
  41335. return false;
  41336. }
  41337. function isParenGroupNode$1(node) {
  41338. return node.type === "value-paren_group" && node.open && node.open.value === "(" && node.close && node.close.value === ")";
  41339. }
  41340. var utils$4 = {
  41341. getAncestorCounter: getAncestorCounter$1,
  41342. getAncestorNode: getAncestorNode$2,
  41343. getPropOfDeclNode: getPropOfDeclNode$1,
  41344. hasSCSSInterpolation,
  41345. hasStringOrFunction,
  41346. maybeToLowerCase: maybeToLowerCase$1,
  41347. insideValueFunctionNode: insideValueFunctionNode$1,
  41348. insideICSSRuleNode: insideICSSRuleNode$1,
  41349. insideAtRuleNode: insideAtRuleNode$1,
  41350. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  41351. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  41352. isWideKeywords: isWideKeywords$1,
  41353. isSCSS: isSCSS$1,
  41354. isSCSSVariable,
  41355. isLastNode: isLastNode$1,
  41356. isLessParser: isLessParser$1,
  41357. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  41358. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  41359. isRelationalOperatorNode: isRelationalOperatorNode$1,
  41360. isEqualityOperatorNode: isEqualityOperatorNode$1,
  41361. isMultiplicationNode: isMultiplicationNode$1,
  41362. isDivisionNode: isDivisionNode$1,
  41363. isAdditionNode: isAdditionNode$1,
  41364. isSubtractionNode: isSubtractionNode$1,
  41365. isModuloNode,
  41366. isMathOperatorNode: isMathOperatorNode$1,
  41367. isEachKeywordNode: isEachKeywordNode$1,
  41368. isForKeywordNode: isForKeywordNode$1,
  41369. isURLFunctionNode: isURLFunctionNode$1,
  41370. isIfElseKeywordNode: isIfElseKeywordNode$1,
  41371. hasComposesNode: hasComposesNode$1,
  41372. hasParensAroundNode: hasParensAroundNode$1,
  41373. hasEmptyRawBefore: hasEmptyRawBefore$1,
  41374. isSCSSNestedPropertyNode,
  41375. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  41376. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  41377. isTemplatePropNode: isTemplatePropNode$1,
  41378. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  41379. isKeyValuePairNode: isKeyValuePairNode$1,
  41380. isKeyValuePairInParenGroupNode,
  41381. isKeyInValuePairNode: isKeyInValuePairNode$1,
  41382. isSCSSMapItemNode: isSCSSMapItemNode$1,
  41383. isInlineValueCommentNode: isInlineValueCommentNode$1,
  41384. isHashNode: isHashNode$1,
  41385. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  41386. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  41387. isWordNode: isWordNode$1,
  41388. isColonNode: isColonNode$1,
  41389. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  41390. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
  41391. lastLineHasInlineComment: lastLineHasInlineComment$1,
  41392. stringifyNode,
  41393. isAtWordPlaceholderNode: isAtWordPlaceholderNode$1,
  41394. isModuleRuleName,
  41395. isConfigurationNode: isConfigurationNode$1,
  41396. isParenGroupNode: isParenGroupNode$1
  41397. };
  41398. var lineColumnToIndex$1 = function (lineColumn, text) {
  41399. let index = 0;
  41400. for (let i = 0; i < lineColumn.line - 1; ++i) {
  41401. index = text.indexOf("\n", index) + 1;
  41402. }
  41403. return index + lineColumn.column;
  41404. };
  41405. const lineColumnToIndex = lineColumnToIndex$1;
  41406. const {
  41407. getLast: getLast$8,
  41408. skipEverythingButNewLine
  41409. } = util$8;
  41410. function calculateLocStart(node, text) {
  41411. // value-* nodes have this
  41412. if (typeof node.sourceIndex === "number") {
  41413. return node.sourceIndex;
  41414. }
  41415. return node.source ? lineColumnToIndex(node.source.start, text) - 1 : null;
  41416. }
  41417. function calculateLocEnd(node, text) {
  41418. if (node.type === "css-comment" && node.inline) {
  41419. return skipEverythingButNewLine(text, node.source.startOffset);
  41420. }
  41421. const endNode = node.nodes && getLast$8(node.nodes);
  41422. if (endNode && node.source && !node.source.end) {
  41423. node = endNode;
  41424. }
  41425. if (node.source && node.source.end) {
  41426. return lineColumnToIndex(node.source.end, text);
  41427. }
  41428. return null;
  41429. }
  41430. function calculateLoc(node, text) {
  41431. if (node.source) {
  41432. node.source.startOffset = calculateLocStart(node, text);
  41433. node.source.endOffset = calculateLocEnd(node, text);
  41434. }
  41435. for (const key in node) {
  41436. const child = node[key];
  41437. if (key === "source" || !child || typeof child !== "object") {
  41438. continue;
  41439. }
  41440. if (child.type === "value-root" || child.type === "value-unknown") {
  41441. calculateValueNodeLoc(child, getValueRootOffset(node), child.text || child.value);
  41442. } else {
  41443. calculateLoc(child, text);
  41444. }
  41445. }
  41446. }
  41447. function calculateValueNodeLoc(node, rootOffset, text) {
  41448. if (node.source) {
  41449. node.source.startOffset = calculateLocStart(node, text) + rootOffset;
  41450. node.source.endOffset = calculateLocEnd(node, text) + rootOffset;
  41451. }
  41452. for (const key in node) {
  41453. const child = node[key];
  41454. if (key === "source" || !child || typeof child !== "object") {
  41455. continue;
  41456. }
  41457. calculateValueNodeLoc(child, rootOffset, text);
  41458. }
  41459. }
  41460. function getValueRootOffset(node) {
  41461. let result = node.source.startOffset;
  41462. if (typeof node.prop === "string") {
  41463. result += node.prop.length;
  41464. }
  41465. if (node.type === "css-atrule" && typeof node.name === "string") {
  41466. result += 1 + node.name.length + node.raws.afterName.match(/^\s*:?\s*/)[0].length;
  41467. }
  41468. if (node.type !== "css-atrule" && node.raws && typeof node.raws.between === "string") {
  41469. result += node.raws.between.length;
  41470. }
  41471. return result;
  41472. }
  41473. /**
  41474. * Workaround for a bug: quotes and asterisks in inline comments corrupt loc data of subsequent nodes.
  41475. * This function replaces the quotes and asterisks with spaces. Later, when the comments are printed,
  41476. * their content is extracted from the original text.
  41477. * - https://github.com/prettier/prettier/issues/7780
  41478. * - https://github.com/shellscape/postcss-less/issues/145
  41479. * - https://github.com/prettier/prettier/issues/8130
  41480. * @param text {string}
  41481. */
  41482. function replaceQuotesInInlineComments(text) {
  41483. /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
  41484. /** @type {State} */
  41485. let state = "initial";
  41486. /** @type {State} */
  41487. let stateToReturnFromQuotes = "initial";
  41488. let inlineCommentStartIndex;
  41489. let inlineCommentContainsQuotes = false;
  41490. const inlineCommentsToReplace = [];
  41491. for (let i = 0; i < text.length; i++) {
  41492. const c = text[i];
  41493. switch (state) {
  41494. case "initial":
  41495. if (c === "'") {
  41496. state = "single-quotes";
  41497. continue;
  41498. }
  41499. if (c === '"') {
  41500. state = "double-quotes";
  41501. continue;
  41502. }
  41503. if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
  41504. state = "url";
  41505. i += 3;
  41506. continue;
  41507. }
  41508. if (c === "*" && text[i - 1] === "/") {
  41509. state = "comment-block";
  41510. continue;
  41511. }
  41512. if (c === "/" && text[i - 1] === "/") {
  41513. state = "comment-inline";
  41514. inlineCommentStartIndex = i - 1;
  41515. continue;
  41516. }
  41517. continue;
  41518. case "single-quotes":
  41519. if (c === "'" && text[i - 1] !== "\\") {
  41520. state = stateToReturnFromQuotes;
  41521. stateToReturnFromQuotes = "initial";
  41522. }
  41523. if (c === "\n" || c === "\r") {
  41524. return text; // invalid input
  41525. }
  41526. continue;
  41527. case "double-quotes":
  41528. if (c === '"' && text[i - 1] !== "\\") {
  41529. state = stateToReturnFromQuotes;
  41530. stateToReturnFromQuotes = "initial";
  41531. }
  41532. if (c === "\n" || c === "\r") {
  41533. return text; // invalid input
  41534. }
  41535. continue;
  41536. case "url":
  41537. if (c === ")") {
  41538. state = "initial";
  41539. }
  41540. if (c === "\n" || c === "\r") {
  41541. return text; // invalid input
  41542. }
  41543. if (c === "'") {
  41544. state = "single-quotes";
  41545. stateToReturnFromQuotes = "url";
  41546. continue;
  41547. }
  41548. if (c === '"') {
  41549. state = "double-quotes";
  41550. stateToReturnFromQuotes = "url";
  41551. continue;
  41552. }
  41553. continue;
  41554. case "comment-block":
  41555. if (c === "/" && text[i - 1] === "*") {
  41556. state = "initial";
  41557. }
  41558. continue;
  41559. case "comment-inline":
  41560. if (c === '"' || c === "'" || c === "*") {
  41561. inlineCommentContainsQuotes = true;
  41562. }
  41563. if (c === "\n" || c === "\r") {
  41564. if (inlineCommentContainsQuotes) {
  41565. inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
  41566. }
  41567. state = "initial";
  41568. inlineCommentContainsQuotes = false;
  41569. }
  41570. continue;
  41571. }
  41572. }
  41573. for (const [start, end] of inlineCommentsToReplace) {
  41574. text = text.slice(0, start) + text.slice(start, end).replace(/["'*]/g, " ") + text.slice(end);
  41575. }
  41576. return text;
  41577. }
  41578. function locStart$e(node) {
  41579. return node.source.startOffset;
  41580. }
  41581. function locEnd$d(node) {
  41582. return node.source.endOffset;
  41583. }
  41584. var loc$5 = {
  41585. locStart: locStart$e,
  41586. locEnd: locEnd$d,
  41587. calculateLoc,
  41588. replaceQuotesInInlineComments
  41589. };
  41590. const getLast$7 = getLast_1;
  41591. const {
  41592. printNumber,
  41593. printString,
  41594. hasNewline,
  41595. isFrontMatterNode: isFrontMatterNode$3,
  41596. isNextLineEmpty: isNextLineEmpty$3,
  41597. isNonEmptyArray: isNonEmptyArray$5
  41598. } = util$8;
  41599. const {
  41600. builders: {
  41601. join: join$a,
  41602. line: line$d,
  41603. hardline: hardline$c,
  41604. softline: softline$9,
  41605. group: group$b,
  41606. fill: fill$6,
  41607. indent: indent$6,
  41608. dedent: dedent$2,
  41609. ifBreak: ifBreak$8,
  41610. breakParent: breakParent$5
  41611. },
  41612. utils: {
  41613. removeLines,
  41614. getDocParts: getDocParts$5
  41615. }
  41616. } = require$$7$3;
  41617. const clean$8 = clean_1$3;
  41618. const embed$7 = embed_1$3;
  41619. const {
  41620. insertPragma: insertPragma$7
  41621. } = pragma$4;
  41622. const {
  41623. getAncestorNode: getAncestorNode$1,
  41624. getPropOfDeclNode,
  41625. maybeToLowerCase,
  41626. insideValueFunctionNode,
  41627. insideICSSRuleNode,
  41628. insideAtRuleNode,
  41629. insideURLFunctionInImportAtRuleNode,
  41630. isKeyframeAtRuleKeywords,
  41631. isWideKeywords,
  41632. isSCSS,
  41633. isLastNode,
  41634. isLessParser,
  41635. isSCSSControlDirectiveNode,
  41636. isDetachedRulesetDeclarationNode,
  41637. isRelationalOperatorNode,
  41638. isEqualityOperatorNode,
  41639. isMultiplicationNode,
  41640. isDivisionNode,
  41641. isAdditionNode,
  41642. isSubtractionNode,
  41643. isMathOperatorNode,
  41644. isEachKeywordNode,
  41645. isForKeywordNode,
  41646. isURLFunctionNode,
  41647. isIfElseKeywordNode,
  41648. hasComposesNode,
  41649. hasParensAroundNode,
  41650. hasEmptyRawBefore,
  41651. isKeyValuePairNode,
  41652. isKeyInValuePairNode,
  41653. isDetachedRulesetCallNode,
  41654. isTemplatePlaceholderNode,
  41655. isTemplatePropNode,
  41656. isPostcssSimpleVarNode,
  41657. isSCSSMapItemNode,
  41658. isInlineValueCommentNode,
  41659. isHashNode,
  41660. isLeftCurlyBraceNode,
  41661. isRightCurlyBraceNode,
  41662. isWordNode,
  41663. isColonNode,
  41664. isMediaAndSupportsKeywords,
  41665. isColorAdjusterFuncNode,
  41666. lastLineHasInlineComment,
  41667. isAtWordPlaceholderNode,
  41668. isConfigurationNode,
  41669. isParenGroupNode
  41670. } = utils$4;
  41671. const {
  41672. locStart: locStart$d,
  41673. locEnd: locEnd$c
  41674. } = loc$5;
  41675. function shouldPrintComma(options) {
  41676. return options.trailingComma === "es5" || options.trailingComma === "all";
  41677. }
  41678. function genericPrint$4(path, options, print) {
  41679. const node = path.getValue();
  41680. /* istanbul ignore if */
  41681. if (!node) {
  41682. return "";
  41683. }
  41684. if (typeof node === "string") {
  41685. return node;
  41686. }
  41687. switch (node.type) {
  41688. case "front-matter":
  41689. return [node.raw, hardline$c];
  41690. case "css-root":
  41691. {
  41692. const nodes = printNodeSequence(path, options, print);
  41693. const after = node.raws.after.trim();
  41694. return [nodes, after ? ` ${after}` : "", getDocParts$5(nodes).length > 0 ? hardline$c : ""];
  41695. }
  41696. case "css-comment":
  41697. {
  41698. const isInlineComment = node.inline || node.raws.inline;
  41699. const text = options.originalText.slice(locStart$d(node), locEnd$c(node));
  41700. return isInlineComment ? text.trimEnd() : text;
  41701. }
  41702. case "css-rule":
  41703. {
  41704. return [print("selector"), node.important ? " !important" : "", node.nodes ? [node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment(node.selector.value) ? line$d : " ", "{", node.nodes.length > 0 ? indent$6([hardline$c, printNodeSequence(path, options, print)]) : "", hardline$c, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""] : ";"];
  41705. }
  41706. case "css-decl":
  41707. {
  41708. const parentNode = path.getParentNode();
  41709. const {
  41710. between: rawBetween
  41711. } = node.raws;
  41712. const trimmedBetween = rawBetween.trim();
  41713. const isColon = trimmedBetween === ":";
  41714. let value = hasComposesNode(node) ? removeLines(print("value")) : print("value");
  41715. if (!isColon && lastLineHasInlineComment(trimmedBetween)) {
  41716. value = indent$6([hardline$c, dedent$2(value)]);
  41717. }
  41718. return [node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path) ? node.prop : maybeToLowerCase(node.prop), trimmedBetween.startsWith("//") ? " " : "", trimmedBetween, node.extend ? "" : " ", isLessParser(options) && node.extend && node.selector ? ["extend(", print("selector"), ")"] : "", value, node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? [" {", indent$6([softline$9, printNodeSequence(path, options, print)]), softline$9, "}"] : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";" ? "" : options.__isHTMLStyleAttribute && isLastNode(path, node) ? ifBreak$8(";") : ";"];
  41719. }
  41720. case "css-atrule":
  41721. {
  41722. const parentNode = path.getParentNode();
  41723. const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode(node) && !parentNode.raws.semicolon && options.originalText[locEnd$c(node) - 1] !== ";";
  41724. if (isLessParser(options)) {
  41725. if (node.mixin) {
  41726. return [print("selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  41727. }
  41728. if (node.function) {
  41729. return [node.name, print("params"), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  41730. }
  41731. if (node.variable) {
  41732. return ["@", node.name, ": ", node.value ? print("value") : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? ["{", indent$6([node.nodes.length > 0 ? softline$9 : "", printNodeSequence(path, options, print)]), softline$9, "}"] : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  41733. }
  41734. }
  41735. return ["@", // If a Less file ends up being parsed with the SCSS parser, Less
  41736. // variable declarations will be parsed as at-rules with names ending
  41737. // with a colon, so keep the original case then.
  41738. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? [isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? [hardline$c, hardline$c] : /^\s*\n/.test(node.raws.afterName) ? hardline$c : " " : " ", print("params")] : "", node.selector ? indent$6([" ", print("selector")]) : "", node.value ? group$b([" ", print("value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$d : ""]) : node.name === "else" ? " " : "", node.nodes ? [isSCSSControlDirectiveNode(node) ? "" : node.selector && !node.selector.nodes && typeof node.selector.value === "string" && lastLineHasInlineComment(node.selector.value) || !node.selector && typeof node.params === "string" && lastLineHasInlineComment(node.params) ? line$d : " ", "{", indent$6([node.nodes.length > 0 ? softline$9 : "", printNodeSequence(path, options, print)]), softline$9, "}"] : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"];
  41739. }
  41740. // postcss-media-query-parser
  41741. case "media-query-list":
  41742. {
  41743. const parts = [];
  41744. path.each(childPath => {
  41745. const node = childPath.getValue();
  41746. if (node.type === "media-query" && node.value === "") {
  41747. return;
  41748. }
  41749. parts.push(print());
  41750. }, "nodes");
  41751. return group$b(indent$6(join$a(line$d, parts)));
  41752. }
  41753. case "media-query":
  41754. {
  41755. return [join$a(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","];
  41756. }
  41757. case "media-type":
  41758. {
  41759. return adjustNumbers(adjustStrings(node.value, options));
  41760. }
  41761. case "media-feature-expression":
  41762. {
  41763. if (!node.nodes) {
  41764. return node.value;
  41765. }
  41766. return ["(", ...path.map(print, "nodes"), ")"];
  41767. }
  41768. case "media-feature":
  41769. {
  41770. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  41771. }
  41772. case "media-colon":
  41773. {
  41774. return [node.value, " "];
  41775. }
  41776. case "media-value":
  41777. {
  41778. return adjustNumbers(adjustStrings(node.value, options));
  41779. }
  41780. case "media-keyword":
  41781. {
  41782. return adjustStrings(node.value, options);
  41783. }
  41784. case "media-url":
  41785. {
  41786. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/g, ")"), options);
  41787. }
  41788. case "media-unknown":
  41789. {
  41790. return node.value;
  41791. }
  41792. // postcss-selector-parser
  41793. case "selector-root":
  41794. {
  41795. return group$b([insideAtRuleNode(path, "custom-selector") ? [getAncestorNode$1(path, "css-atrule").customSelector, line$d] : "", join$a([",", insideAtRuleNode(path, ["extend", "custom-selector", "nest"]) ? line$d : hardline$c], path.map(print, "nodes"))]);
  41796. }
  41797. case "selector-selector":
  41798. {
  41799. return group$b(indent$6(path.map(print, "nodes")));
  41800. }
  41801. case "selector-comment":
  41802. {
  41803. return node.value;
  41804. }
  41805. case "selector-string":
  41806. {
  41807. return adjustStrings(node.value, options);
  41808. }
  41809. case "selector-tag":
  41810. {
  41811. const parentNode = path.getParentNode();
  41812. const index = parentNode && parentNode.nodes.indexOf(node);
  41813. const prevNode = index && parentNode.nodes[index - 1];
  41814. return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords(path, node.value) ? node.value.toLowerCase() : node.value)];
  41815. }
  41816. case "selector-id":
  41817. {
  41818. return ["#", node.value];
  41819. }
  41820. case "selector-class":
  41821. {
  41822. return [".", adjustNumbers(adjustStrings(node.value, options))];
  41823. }
  41824. case "selector-attribute":
  41825. {
  41826. return ["[", node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"];
  41827. }
  41828. case "selector-combinator":
  41829. {
  41830. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  41831. const parentNode = path.getParentNode();
  41832. const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$d;
  41833. return [leading, node.value, isLastNode(path, node) ? "" : " "];
  41834. }
  41835. const leading = node.value.trim().startsWith("(") ? line$d : "";
  41836. const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$d;
  41837. return [leading, value];
  41838. }
  41839. case "selector-universal":
  41840. {
  41841. return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.value];
  41842. }
  41843. case "selector-pseudo":
  41844. {
  41845. return [maybeToLowerCase(node.value), isNonEmptyArray$5(node.nodes) ? ["(", join$a(", ", path.map(print, "nodes")), ")"] : ""];
  41846. }
  41847. case "selector-nesting":
  41848. {
  41849. return node.value;
  41850. }
  41851. case "selector-unknown":
  41852. {
  41853. const ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property
  41854. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  41855. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  41856. } // originalText has to be used for Less, see replaceQuotesInInlineComments in loc.js
  41857. const parentNode = path.getParentNode();
  41858. if (parentNode.raws && parentNode.raws.selector) {
  41859. const start = locStart$d(parentNode);
  41860. const end = start + parentNode.raws.selector.length;
  41861. return options.originalText.slice(start, end).trim();
  41862. } // Same reason above
  41863. const grandParent = path.getParentNode(1);
  41864. if (parentNode.type === "value-paren_group" && grandParent && grandParent.type === "value-func" && grandParent.value === "selector") {
  41865. const start = locStart$d(parentNode.open) + 1;
  41866. const end = locEnd$c(parentNode.close) - 1;
  41867. const selector = options.originalText.slice(start, end).trim();
  41868. return lastLineHasInlineComment(selector) ? [breakParent$5, selector] : selector;
  41869. }
  41870. return node.value;
  41871. }
  41872. // postcss-values-parser
  41873. case "value-value":
  41874. case "value-root":
  41875. {
  41876. return print("group");
  41877. }
  41878. case "value-comment":
  41879. {
  41880. return options.originalText.slice(locStart$d(node), locEnd$c(node));
  41881. }
  41882. case "value-comma_group":
  41883. {
  41884. const parentNode = path.getParentNode();
  41885. const parentParentNode = path.getParentNode(1);
  41886. const declAncestorProp = getPropOfDeclNode(path);
  41887. const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  41888. const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  41889. const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  41890. const hasInlineComment = node.groups.some(node => isInlineValueCommentNode(node));
  41891. const printed = path.map(print, "groups");
  41892. const parts = [];
  41893. const insideURLFunction = insideValueFunctionNode(path, "url");
  41894. let insideSCSSInterpolationInString = false;
  41895. let didBreak = false;
  41896. for (let i = 0; i < node.groups.length; ++i) {
  41897. parts.push(printed[i]);
  41898. const iPrevNode = node.groups[i - 1];
  41899. const iNode = node.groups[i];
  41900. const iNextNode = node.groups[i + 1];
  41901. const iNextNextNode = node.groups[i + 2];
  41902. if (insideURLFunction) {
  41903. if (iNextNode && isAdditionNode(iNextNode) || isAdditionNode(iNode)) {
  41904. parts.push(" ");
  41905. }
  41906. continue;
  41907. } // Ignore SCSS @forward wildcard suffix
  41908. if (insideAtRuleNode(path, "forward") && iNode.type === "value-word" && iNode.value && iPrevNode !== undefined && iPrevNode.type === "value-word" && iPrevNode.value === "as" && iNextNode.type === "value-operator" && iNextNode.value === "*") {
  41909. continue;
  41910. } // Ignore after latest node (i.e. before semicolon)
  41911. if (!iNextNode) {
  41912. continue;
  41913. } // styled.div` background: var(--${one}); `
  41914. if (iNode.type === "value-word" && iNode.value.endsWith("-") && isAtWordPlaceholderNode(iNextNode)) {
  41915. continue;
  41916. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  41917. const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  41918. const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  41919. if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
  41920. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  41921. continue;
  41922. }
  41923. if (insideSCSSInterpolationInString) {
  41924. continue;
  41925. } // Ignore colon (i.e. `:`)
  41926. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  41927. continue;
  41928. } // Ignore `@` in Less (i.e. `@@var;`)
  41929. if (iNode.type === "value-atword" && iNode.value === "") {
  41930. continue;
  41931. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  41932. if (iNode.value === "~") {
  41933. continue;
  41934. } // Ignore escape `\`
  41935. if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
  41936. continue;
  41937. } // Ignore escaped `/`
  41938. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  41939. continue;
  41940. } // Ignore `\` (i.e. `$variable: \@small;`)
  41941. if (iNode.value === "\\") {
  41942. continue;
  41943. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  41944. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  41945. continue;
  41946. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  41947. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  41948. continue;
  41949. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  41950. if (iNode.value === "--" && isHashNode(iNextNode)) {
  41951. continue;
  41952. } // Formatting math operations
  41953. const isMathOperator = isMathOperatorNode(iNode);
  41954. const isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  41955. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  41956. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  41957. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  41958. continue;
  41959. } // absolute paths are only parsed as one token if they are part of url(/abs/path) call
  41960. // but if you have custom -fb-url(/abs/path/) then it is parsed as "division /" and rest
  41961. // of the path. We don't want to put a space after that first division in this case.
  41962. if (!iPrevNode && isDivisionNode(iNode)) {
  41963. continue;
  41964. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  41965. // due to the fact that it is not valid syntax
  41966. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  41967. if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  41968. continue;
  41969. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  41970. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  41971. const isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  41972. const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  41973. const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  41974. if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
  41975. continue;
  41976. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  41977. if (isInlineValueCommentNode(iNode)) {
  41978. if (parentNode.type === "value-paren_group") {
  41979. parts.push(dedent$2(hardline$c));
  41980. continue;
  41981. }
  41982. parts.push(hardline$c);
  41983. continue;
  41984. } // Handle keywords in SCSS control directive
  41985. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  41986. parts.push(" ");
  41987. continue;
  41988. } // At-rule `namespace` should be in one line
  41989. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  41990. parts.push(" ");
  41991. continue;
  41992. } // Formatting `grid` property
  41993. if (isGridValue) {
  41994. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  41995. parts.push(hardline$c);
  41996. didBreak = true;
  41997. } else {
  41998. parts.push(" ");
  41999. }
  42000. continue;
  42001. } // Add `space` before next math operation
  42002. // Note: `grip` property have `/` delimiter and it is not math operation, so
  42003. // `grid` property handles above
  42004. if (isNextMathOperator) {
  42005. parts.push(" ");
  42006. continue;
  42007. } // allow function(returns-list($list)...)
  42008. if (iNextNode && iNextNode.value === "...") {
  42009. continue;
  42010. }
  42011. if (isAtWordPlaceholderNode(iNode) && isAtWordPlaceholderNode(iNextNode) && locEnd$c(iNode) === locStart$d(iNextNode)) {
  42012. continue;
  42013. }
  42014. if (isAtWordPlaceholderNode(iNode) && isParenGroupNode(iNextNode) && locEnd$c(iNode) === locStart$d(iNextNode.open)) {
  42015. parts.push(softline$9);
  42016. continue;
  42017. }
  42018. if (iNode.value === "with" && isParenGroupNode(iNextNode)) {
  42019. parts.push(" ");
  42020. continue;
  42021. } // Be default all values go through `line`
  42022. parts.push(line$d);
  42023. }
  42024. if (hasInlineComment) {
  42025. parts.push(breakParent$5);
  42026. }
  42027. if (didBreak) {
  42028. parts.unshift(hardline$c);
  42029. }
  42030. if (isControlDirective) {
  42031. return group$b(indent$6(parts));
  42032. } // Indent is not needed for import url when url is very long
  42033. // and node has two groups
  42034. // when type is value-comma_group
  42035. // example @import url("verylongurl") projection,tv
  42036. if (insideURLFunctionInImportAtRuleNode(path)) {
  42037. return group$b(fill$6(parts));
  42038. }
  42039. return group$b(indent$6(fill$6(parts)));
  42040. }
  42041. case "value-paren_group":
  42042. {
  42043. const parentNode = path.getParentNode();
  42044. if (parentNode && isURLFunctionNode(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
  42045. return [node.open ? print("open") : "", join$a(",", path.map(print, "groups")), node.close ? print("close") : ""];
  42046. }
  42047. if (!node.open) {
  42048. const printed = path.map(print, "groups");
  42049. const res = [];
  42050. for (let i = 0; i < printed.length; i++) {
  42051. if (i !== 0) {
  42052. res.push([",", line$d]);
  42053. }
  42054. res.push(printed[i]);
  42055. }
  42056. return group$b(indent$6(fill$6(res)));
  42057. }
  42058. const isSCSSMapItem = isSCSSMapItemNode(path);
  42059. const lastItem = getLast$7(node.groups);
  42060. const isLastItemComment = lastItem && lastItem.type === "value-comment";
  42061. const isKey = isKeyInValuePairNode(node, parentNode);
  42062. const isConfiguration = isConfigurationNode(node, parentNode);
  42063. const shouldBreak = isConfiguration || isSCSSMapItem && !isKey;
  42064. const shouldDedent = isConfiguration || isKey;
  42065. const printed = group$b([node.open ? print("open") : "", indent$6([softline$9, join$a([",", line$d], path.map(childPath => {
  42066. const node = childPath.getValue();
  42067. const printed = print(); // Key/Value pair in open paren already indented
  42068. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[0].type !== "value-paren_group" && node.groups[2] && node.groups[2].type === "value-paren_group") {
  42069. const parts = getDocParts$5(printed.contents.contents);
  42070. parts[1] = group$b(parts[1]);
  42071. return group$b(dedent$2(printed));
  42072. }
  42073. return printed;
  42074. }, "groups"))]), ifBreak$8(!isLastItemComment && isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$9, node.close ? print("close") : ""], {
  42075. shouldBreak
  42076. });
  42077. return shouldDedent ? dedent$2(printed) : printed;
  42078. }
  42079. case "value-func":
  42080. {
  42081. return [node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", print("group")];
  42082. }
  42083. case "value-paren":
  42084. {
  42085. return node.value;
  42086. }
  42087. case "value-number":
  42088. {
  42089. return [printCssNumber(node.value), maybeToLowerCase(node.unit)];
  42090. }
  42091. case "value-operator":
  42092. {
  42093. return node.value;
  42094. }
  42095. case "value-word":
  42096. {
  42097. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  42098. return node.value.toLowerCase();
  42099. }
  42100. return node.value;
  42101. }
  42102. case "value-colon":
  42103. {
  42104. const parentNode = path.getParentNode();
  42105. const index = parentNode && parentNode.groups.indexOf(node);
  42106. const prevNode = index && parentNode.groups[index - 1];
  42107. return [node.value, // Don't add spaces on escaped colon `:`, e.g: grid-template-rows: [row-1-00\:00] auto;
  42108. prevNode && typeof prevNode.value === "string" && getLast$7(prevNode.value) === "\\" || // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  42109. insideValueFunctionNode(path, "url") ? "" : line$d];
  42110. }
  42111. // TODO: confirm this code is dead
  42112. /* istanbul ignore next */
  42113. case "value-comma":
  42114. {
  42115. return [node.value, " "];
  42116. }
  42117. case "value-string":
  42118. {
  42119. return printString(node.raws.quote + node.value + node.raws.quote, options);
  42120. }
  42121. case "value-atword":
  42122. {
  42123. return ["@", node.value];
  42124. }
  42125. case "value-unicode-range":
  42126. {
  42127. return node.value;
  42128. }
  42129. case "value-unknown":
  42130. {
  42131. return node.value;
  42132. }
  42133. default:
  42134. /* istanbul ignore next */
  42135. throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
  42136. }
  42137. }
  42138. function printNodeSequence(path, options, print) {
  42139. const parts = [];
  42140. path.each((pathChild, i, nodes) => {
  42141. const prevNode = nodes[i - 1];
  42142. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  42143. const childNode = pathChild.getValue();
  42144. parts.push(options.originalText.slice(locStart$d(childNode), locEnd$c(childNode)));
  42145. } else {
  42146. parts.push(print());
  42147. }
  42148. if (i !== nodes.length - 1) {
  42149. if (nodes[i + 1].type === "css-comment" && !hasNewline(options.originalText, locStart$d(nodes[i + 1]), {
  42150. backwards: true
  42151. }) && !isFrontMatterNode$3(nodes[i]) || nodes[i + 1].type === "css-atrule" && nodes[i + 1].name === "else" && nodes[i].type !== "css-comment") {
  42152. parts.push(" ");
  42153. } else {
  42154. parts.push(options.__isHTMLStyleAttribute ? line$d : hardline$c);
  42155. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), locEnd$c) && !isFrontMatterNode$3(nodes[i])) {
  42156. parts.push(hardline$c);
  42157. }
  42158. }
  42159. }
  42160. }, "nodes");
  42161. return parts;
  42162. }
  42163. const STRING_REGEX = /(["'])(?:(?!\1)[^\\]|\\.)*\1/gs;
  42164. const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[Ee][+-]?\d+)?/g;
  42165. const STANDARD_UNIT_REGEX = /[A-Za-z]+/g;
  42166. const WORD_PART_REGEX = /[$@]?[A-Z_a-z\u0080-\uFFFF][\w\u0080-\uFFFF-]*/g;
  42167. const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
  42168. function adjustStrings(value, options) {
  42169. return value.replace(STRING_REGEX, match => printString(match, options));
  42170. }
  42171. function quoteAttributeValue(value, options) {
  42172. const quote = options.singleQuote ? "'" : '"';
  42173. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  42174. }
  42175. function adjustNumbers(value) {
  42176. return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase(unit || "") : match);
  42177. }
  42178. function printCssNumber(rawNumber) {
  42179. return printNumber(rawNumber) // Remove trailing `.0`.
  42180. .replace(/\.0(?=$|e)/, "");
  42181. }
  42182. var printerPostcss = {
  42183. print: genericPrint$4,
  42184. embed: embed$7,
  42185. insertPragma: insertPragma$7,
  42186. massageAstNode: clean$8
  42187. };
  42188. const commonOptions$4 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  42189. var options$9 = {
  42190. singleQuote: commonOptions$4.singleQuote
  42191. };
  42192. var parsers$b = {
  42193. // TODO: switch these to just `postcss` and use `language` instead.
  42194. get css() {
  42195. return require("./parser-postcss.js").parsers.css;
  42196. },
  42197. get less() {
  42198. return require("./parser-postcss.js").parsers.less;
  42199. },
  42200. get scss() {
  42201. return require("./parser-postcss.js").parsers.scss;
  42202. }
  42203. };
  42204. var name$9 = "CSS";
  42205. var type$9 = "markup";
  42206. var tmScope$9 = "source.css";
  42207. var aceMode$9 = "css";
  42208. var codemirrorMode$5 = "css";
  42209. var codemirrorMimeType$5 = "text/css";
  42210. var color$8 = "#563d7c";
  42211. var extensions$9 = [
  42212. ".css"
  42213. ];
  42214. var languageId$9 = 50;
  42215. var require$$4$5 = {
  42216. name: name$9,
  42217. type: type$9,
  42218. tmScope: tmScope$9,
  42219. aceMode: aceMode$9,
  42220. codemirrorMode: codemirrorMode$5,
  42221. codemirrorMimeType: codemirrorMimeType$5,
  42222. color: color$8,
  42223. extensions: extensions$9,
  42224. languageId: languageId$9
  42225. };
  42226. var name$8 = "PostCSS";
  42227. var type$8 = "markup";
  42228. var tmScope$8 = "source.postcss";
  42229. var group$a = "CSS";
  42230. var extensions$8 = [
  42231. ".pcss",
  42232. ".postcss"
  42233. ];
  42234. var aceMode$8 = "text";
  42235. var languageId$8 = 262764437;
  42236. var require$$5$1 = {
  42237. name: name$8,
  42238. type: type$8,
  42239. tmScope: tmScope$8,
  42240. group: group$a,
  42241. extensions: extensions$8,
  42242. aceMode: aceMode$8,
  42243. languageId: languageId$8
  42244. };
  42245. var name$7 = "Less";
  42246. var type$7 = "markup";
  42247. var color$7 = "#1d365d";
  42248. var extensions$7 = [
  42249. ".less"
  42250. ];
  42251. var tmScope$7 = "source.css.less";
  42252. var aceMode$7 = "less";
  42253. var codemirrorMode$4 = "css";
  42254. var codemirrorMimeType$4 = "text/css";
  42255. var languageId$7 = 198;
  42256. var require$$6 = {
  42257. name: name$7,
  42258. type: type$7,
  42259. color: color$7,
  42260. extensions: extensions$7,
  42261. tmScope: tmScope$7,
  42262. aceMode: aceMode$7,
  42263. codemirrorMode: codemirrorMode$4,
  42264. codemirrorMimeType: codemirrorMimeType$4,
  42265. languageId: languageId$7
  42266. };
  42267. var name$6 = "SCSS";
  42268. var type$6 = "markup";
  42269. var color$6 = "#c6538c";
  42270. var tmScope$6 = "source.css.scss";
  42271. var aceMode$6 = "scss";
  42272. var codemirrorMode$3 = "css";
  42273. var codemirrorMimeType$3 = "text/x-scss";
  42274. var extensions$6 = [
  42275. ".scss"
  42276. ];
  42277. var languageId$6 = 329;
  42278. var require$$7 = {
  42279. name: name$6,
  42280. type: type$6,
  42281. color: color$6,
  42282. tmScope: tmScope$6,
  42283. aceMode: aceMode$6,
  42284. codemirrorMode: codemirrorMode$3,
  42285. codemirrorMimeType: codemirrorMimeType$3,
  42286. extensions: extensions$6,
  42287. languageId: languageId$6
  42288. };
  42289. const createLanguage$5 = createLanguage$7;
  42290. const printer$5 = printerPostcss;
  42291. const options$8 = options$9;
  42292. const parsers$a = parsers$b;
  42293. const languages$6 = [createLanguage$5(require$$4$5, data => ({
  42294. since: "1.4.0",
  42295. parsers: ["css"],
  42296. vscodeLanguageIds: ["css"],
  42297. extensions: [...data.extensions, // `WeiXin Style Sheets`(Weixin Mini Programs)
  42298. // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
  42299. ".wxss"]
  42300. })), createLanguage$5(require$$5$1, () => ({
  42301. since: "1.4.0",
  42302. parsers: ["css"],
  42303. vscodeLanguageIds: ["postcss"]
  42304. })), createLanguage$5(require$$6, () => ({
  42305. since: "1.4.0",
  42306. parsers: ["less"],
  42307. vscodeLanguageIds: ["less"]
  42308. })), createLanguage$5(require$$7, () => ({
  42309. since: "1.4.0",
  42310. parsers: ["scss"],
  42311. vscodeLanguageIds: ["scss"]
  42312. }))];
  42313. const printers$4 = {
  42314. postcss: printer$5
  42315. };
  42316. var languageCss = {
  42317. languages: languages$6,
  42318. options: options$8,
  42319. printers: printers$4,
  42320. parsers: parsers$a
  42321. };
  42322. function locStart$c(node) {
  42323. return node.loc.start.offset;
  42324. }
  42325. function locEnd$b(node) {
  42326. return node.loc.end.offset;
  42327. }
  42328. var loc$4 = {
  42329. locStart: locStart$c,
  42330. locEnd: locEnd$b
  42331. };
  42332. function clean$7(ast, newNode
  42333. /*, parent*/
  42334. ) {
  42335. // (Glimmer/HTML) ignore TextNode
  42336. if (ast.type === "TextNode") {
  42337. const trimmed = ast.chars.trim();
  42338. if (!trimmed) {
  42339. return null;
  42340. }
  42341. newNode.chars = trimmed.replace(/[\t\n\f\r ]+/g, " ");
  42342. } // `class` is reformatted
  42343. if (ast.type === "AttrNode" && ast.name.toLowerCase() === "class") {
  42344. delete newNode.value;
  42345. }
  42346. }
  42347. clean$7.ignoredProperties = new Set(["loc", "selfClosing"]);
  42348. var clean_1$2 = clean$7;
  42349. var require$$0$1 = [
  42350. "area",
  42351. "base",
  42352. "basefont",
  42353. "bgsound",
  42354. "br",
  42355. "col",
  42356. "command",
  42357. "embed",
  42358. "frame",
  42359. "hr",
  42360. "image",
  42361. "img",
  42362. "input",
  42363. "isindex",
  42364. "keygen",
  42365. "link",
  42366. "menuitem",
  42367. "meta",
  42368. "nextid",
  42369. "param",
  42370. "source",
  42371. "track",
  42372. "wbr"
  42373. ];
  42374. const htmlVoidElements = require$$0$1;
  42375. const getLast$6 = getLast_1;
  42376. function isLastNodeOfSiblings$1(path) {
  42377. const node = path.getValue();
  42378. const parentNode = path.getParentNode(0);
  42379. if (isParentOfSomeType$1(path, ["ElementNode"]) && getLast$6(parentNode.children) === node) {
  42380. return true;
  42381. }
  42382. if (isParentOfSomeType$1(path, ["Block"]) && getLast$6(parentNode.body) === node) {
  42383. return true;
  42384. }
  42385. return false;
  42386. }
  42387. function isUppercase(string) {
  42388. return string.toUpperCase() === string;
  42389. }
  42390. function isGlimmerComponent(node) {
  42391. return isNodeOfSomeType$1(node, ["ElementNode"]) && typeof node.tag === "string" && node.tag[0] !== ":" && (isUppercase(node.tag[0]) || node.tag.includes("."));
  42392. }
  42393. const voidTags = new Set(htmlVoidElements);
  42394. function isVoid$1(node) {
  42395. return isGlimmerComponent(node) && node.children.every(node => isWhitespaceNode$1(node)) || voidTags.has(node.tag);
  42396. }
  42397. function isWhitespaceNode$1(node) {
  42398. return isNodeOfSomeType$1(node, ["TextNode"]) && !/\S/.test(node.chars);
  42399. }
  42400. function isNodeOfSomeType$1(node, types) {
  42401. return node && types.includes(node.type);
  42402. }
  42403. function isParentOfSomeType$1(path, types) {
  42404. const parentNode = path.getParentNode(0);
  42405. return isNodeOfSomeType$1(parentNode, types);
  42406. }
  42407. function isPreviousNodeOfSomeType$1(path, types) {
  42408. const previousNode = getPreviousNode$1(path);
  42409. return isNodeOfSomeType$1(previousNode, types);
  42410. }
  42411. function isNextNodeOfSomeType$1(path, types) {
  42412. const nextNode = getNextNode$1(path);
  42413. return isNodeOfSomeType$1(nextNode, types);
  42414. }
  42415. function getSiblingNode(path, offset) {
  42416. const node = path.getValue();
  42417. const parentNode = path.getParentNode(0) || {};
  42418. const children = parentNode.children || parentNode.body || parentNode.parts || [];
  42419. const index = children.indexOf(node);
  42420. return index !== -1 && children[index + offset];
  42421. }
  42422. function getPreviousNode$1(path, lookBack = 1) {
  42423. return getSiblingNode(path, -lookBack);
  42424. }
  42425. function getNextNode$1(path) {
  42426. return getSiblingNode(path, 1);
  42427. }
  42428. function isPrettierIgnoreNode(node) {
  42429. return isNodeOfSomeType$1(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
  42430. }
  42431. function hasPrettierIgnore$8(path) {
  42432. const node = path.getValue();
  42433. const previousPreviousNode = getPreviousNode$1(path, 2);
  42434. return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
  42435. }
  42436. var utils$3 = {
  42437. getNextNode: getNextNode$1,
  42438. getPreviousNode: getPreviousNode$1,
  42439. hasPrettierIgnore: hasPrettierIgnore$8,
  42440. isLastNodeOfSiblings: isLastNodeOfSiblings$1,
  42441. isNextNodeOfSomeType: isNextNodeOfSomeType$1,
  42442. isNodeOfSomeType: isNodeOfSomeType$1,
  42443. isParentOfSomeType: isParentOfSomeType$1,
  42444. isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
  42445. isVoid: isVoid$1,
  42446. isWhitespaceNode: isWhitespaceNode$1
  42447. };
  42448. const {
  42449. builders: {
  42450. dedent: dedent$1,
  42451. fill: fill$5,
  42452. group: group$9,
  42453. hardline: hardline$b,
  42454. ifBreak: ifBreak$7,
  42455. indent: indent$5,
  42456. join: join$9,
  42457. line: line$c,
  42458. softline: softline$8
  42459. },
  42460. utils: {
  42461. getDocParts: getDocParts$4,
  42462. replaceTextEndOfLine: replaceTextEndOfLine$8
  42463. }
  42464. } = require$$7$3;
  42465. const {
  42466. getPreferredQuote,
  42467. isNonEmptyArray: isNonEmptyArray$4
  42468. } = util$8;
  42469. const {
  42470. locStart: locStart$b,
  42471. locEnd: locEnd$a
  42472. } = loc$4;
  42473. const clean$6 = clean_1$2;
  42474. const {
  42475. getNextNode,
  42476. getPreviousNode,
  42477. hasPrettierIgnore: hasPrettierIgnore$7,
  42478. isLastNodeOfSiblings,
  42479. isNextNodeOfSomeType,
  42480. isNodeOfSomeType,
  42481. isParentOfSomeType,
  42482. isPreviousNodeOfSomeType,
  42483. isVoid,
  42484. isWhitespaceNode
  42485. } = utils$3;
  42486. const NEWLINES_TO_PRESERVE_MAX = 2; // Formatter based on @glimmerjs/syntax's built-in test formatter:
  42487. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  42488. function print(path, options, print) {
  42489. const node = path.getValue();
  42490. /* istanbul ignore if*/
  42491. if (!node) {
  42492. return "";
  42493. }
  42494. if (hasPrettierIgnore$7(path)) {
  42495. return options.originalText.slice(locStart$b(node), locEnd$a(node));
  42496. }
  42497. const favoriteQuote = options.singleQuote ? "'" : '"';
  42498. switch (node.type) {
  42499. case "Block":
  42500. case "Program":
  42501. case "Template":
  42502. {
  42503. return group$9(path.map(print, "body"));
  42504. }
  42505. case "ElementNode":
  42506. {
  42507. const startingTag = group$9(printStartingTag(path, print));
  42508. const escapeNextElementNode = options.htmlWhitespaceSensitivity === "ignore" && isNextNodeOfSomeType(path, ["ElementNode"]) ? softline$8 : "";
  42509. if (isVoid(node)) {
  42510. return [startingTag, escapeNextElementNode];
  42511. }
  42512. const endingTag = ["</", node.tag, ">"];
  42513. if (node.children.length === 0) {
  42514. return [startingTag, indent$5(endingTag), escapeNextElementNode];
  42515. }
  42516. if (options.htmlWhitespaceSensitivity === "ignore") {
  42517. return [startingTag, indent$5(printChildren$5(path, options, print)), hardline$b, indent$5(endingTag), escapeNextElementNode];
  42518. }
  42519. return [startingTag, indent$5(group$9(printChildren$5(path, options, print))), indent$5(endingTag), escapeNextElementNode];
  42520. }
  42521. case "BlockStatement":
  42522. {
  42523. const pp = path.getParentNode(1);
  42524. const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === node && pp.inverse.body[0].path.parts[0] === "if";
  42525. if (isElseIf) {
  42526. return [printElseIfBlock(path, print), printProgram(path, print, options), printInverse(path, print, options)];
  42527. }
  42528. return [printOpenBlock(path, print), group$9([printProgram(path, print, options), printInverse(path, print, options), printCloseBlock(path, print, options)])];
  42529. }
  42530. case "ElementModifierStatement":
  42531. {
  42532. return group$9(["{{", printPathAndParams(path, print), "}}"]);
  42533. }
  42534. case "MustacheStatement":
  42535. {
  42536. return group$9([printOpeningMustache(node), printPathAndParams(path, print), printClosingMustache(node)]);
  42537. }
  42538. case "SubExpression":
  42539. {
  42540. return group$9(["(", printSubExpressionPathAndParams(path, print), softline$8, ")"]);
  42541. }
  42542. case "AttrNode":
  42543. {
  42544. const isText = node.value.type === "TextNode";
  42545. const isEmptyText = isText && node.value.chars === ""; // If the text is empty and the value's loc start and end offsets are the
  42546. // same, there is no value for this AttrNode and it should be printed
  42547. // without the `=""`. Example: `<img data-test>` -> `<img data-test>`
  42548. if (isEmptyText && locStart$b(node.value) === locEnd$a(node.value)) {
  42549. return node.name;
  42550. } // Let's assume quotes inside the content of text nodes are already
  42551. // properly escaped with entities, otherwise the parse wouldn't have parsed them.
  42552. const quote = isText ? getPreferredQuote(node.value.chars, favoriteQuote).quote : node.value.type === "ConcatStatement" ? getPreferredQuote(node.value.parts.filter(part => part.type === "TextNode").map(part => part.chars).join(""), favoriteQuote).quote : "";
  42553. const valueDoc = print("value");
  42554. return [node.name, "=", quote, node.name === "class" && quote ? group$9(indent$5(valueDoc)) : valueDoc, quote];
  42555. }
  42556. case "ConcatStatement":
  42557. {
  42558. return path.map(print, "parts");
  42559. }
  42560. case "Hash":
  42561. {
  42562. return join$9(line$c, path.map(print, "pairs"));
  42563. }
  42564. case "HashPair":
  42565. {
  42566. return [node.key, "=", print("value")];
  42567. }
  42568. case "TextNode":
  42569. {
  42570. /* if `{{my-component}}` (or any text containing "{{")
  42571. * makes it to the TextNode, it means it was escaped,
  42572. * so let's print it escaped, ie.; `\{{my-component}}` */
  42573. let text = node.chars.replace(/{{/g, "\\{{");
  42574. const attrName = getCurrentAttributeName(path);
  42575. if (attrName) {
  42576. // TODO: format style and srcset attributes
  42577. if (attrName === "class") {
  42578. const formattedClasses = text.trim().split(/\s+/).join(" ");
  42579. let leadingSpace = false;
  42580. let trailingSpace = false;
  42581. if (isParentOfSomeType(path, ["ConcatStatement"])) {
  42582. if (isPreviousNodeOfSomeType(path, ["MustacheStatement"]) && /^\s/.test(text)) {
  42583. leadingSpace = true;
  42584. }
  42585. if (isNextNodeOfSomeType(path, ["MustacheStatement"]) && /\s$/.test(text) && formattedClasses !== "") {
  42586. trailingSpace = true;
  42587. }
  42588. }
  42589. return [leadingSpace ? line$c : "", formattedClasses, trailingSpace ? line$c : ""];
  42590. }
  42591. return replaceTextEndOfLine$8(text);
  42592. }
  42593. const whitespacesOnlyRE = /^[\t\n\f\r ]*$/;
  42594. const isWhitespaceOnly = whitespacesOnlyRE.test(text);
  42595. const isFirstElement = !getPreviousNode(path);
  42596. const isLastElement = !getNextNode(path);
  42597. if (options.htmlWhitespaceSensitivity !== "ignore") {
  42598. // https://infra.spec.whatwg.org/#ascii-whitespace
  42599. const leadingWhitespacesRE = /^[\t\n\f\r ]*/;
  42600. const trailingWhitespacesRE = /[\t\n\f\r ]*$/; // let's remove the file's final newline
  42601. // https://github.com/ember-cli/ember-new-output/blob/1a04c67ddd02ccb35e0ff41bb5cbce34b31173ef/.editorconfig#L16
  42602. const shouldTrimTrailingNewlines = isLastElement && isParentOfSomeType(path, ["Template"]);
  42603. const shouldTrimLeadingNewlines = isFirstElement && isParentOfSomeType(path, ["Template"]);
  42604. if (isWhitespaceOnly) {
  42605. if (shouldTrimLeadingNewlines || shouldTrimTrailingNewlines) {
  42606. return "";
  42607. }
  42608. let breaks = [line$c];
  42609. const newlines = countNewLines(text);
  42610. if (newlines) {
  42611. breaks = generateHardlines(newlines);
  42612. }
  42613. if (isLastNodeOfSiblings(path)) {
  42614. breaks = breaks.map(newline => dedent$1(newline));
  42615. }
  42616. return breaks;
  42617. }
  42618. const [lead] = text.match(leadingWhitespacesRE);
  42619. const [tail] = text.match(trailingWhitespacesRE);
  42620. let leadBreaks = [];
  42621. if (lead) {
  42622. leadBreaks = [line$c];
  42623. const leadingNewlines = countNewLines(lead);
  42624. if (leadingNewlines) {
  42625. leadBreaks = generateHardlines(leadingNewlines);
  42626. }
  42627. text = text.replace(leadingWhitespacesRE, "");
  42628. }
  42629. let trailBreaks = [];
  42630. if (tail) {
  42631. if (!shouldTrimTrailingNewlines) {
  42632. trailBreaks = [line$c];
  42633. const trailingNewlines = countNewLines(tail);
  42634. if (trailingNewlines) {
  42635. trailBreaks = generateHardlines(trailingNewlines);
  42636. }
  42637. if (isLastNodeOfSiblings(path)) {
  42638. trailBreaks = trailBreaks.map(hardline => dedent$1(hardline));
  42639. }
  42640. }
  42641. text = text.replace(trailingWhitespacesRE, "");
  42642. }
  42643. return [...leadBreaks, fill$5(getTextValueParts$3(text)), ...trailBreaks];
  42644. }
  42645. const lineBreaksCount = countNewLines(text);
  42646. let leadingLineBreaksCount = countLeadingNewLines(text);
  42647. let trailingLineBreaksCount = countTrailingNewLines(text);
  42648. if ((isFirstElement || isLastElement) && isWhitespaceOnly && isParentOfSomeType(path, ["Block", "ElementNode", "Template"])) {
  42649. return "";
  42650. }
  42651. if (isWhitespaceOnly && lineBreaksCount) {
  42652. leadingLineBreaksCount = Math.min(lineBreaksCount, NEWLINES_TO_PRESERVE_MAX);
  42653. trailingLineBreaksCount = 0;
  42654. } else {
  42655. if (isNextNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
  42656. trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
  42657. }
  42658. if (isPreviousNodeOfSomeType(path, ["BlockStatement", "ElementNode"])) {
  42659. leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
  42660. }
  42661. }
  42662. let leadingSpace = "";
  42663. let trailingSpace = "";
  42664. if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType(path, ["MustacheStatement"])) {
  42665. trailingSpace = " ";
  42666. }
  42667. if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType(path, ["MustacheStatement"])) {
  42668. leadingSpace = " ";
  42669. }
  42670. if (isFirstElement) {
  42671. leadingLineBreaksCount = 0;
  42672. leadingSpace = "";
  42673. }
  42674. if (isLastElement) {
  42675. trailingLineBreaksCount = 0;
  42676. trailingSpace = "";
  42677. }
  42678. text = text.replace(/^[\t\n\f\r ]+/g, leadingSpace).replace(/[\t\n\f\r ]+$/, trailingSpace);
  42679. return [...generateHardlines(leadingLineBreaksCount), fill$5(getTextValueParts$3(text)), ...generateHardlines(trailingLineBreaksCount)];
  42680. }
  42681. case "MustacheCommentStatement":
  42682. {
  42683. const start = locStart$b(node);
  42684. const end = locEnd$a(node); // Starts with `{{~`
  42685. const isLeftWhiteSpaceSensitive = options.originalText.charAt(start + 2) === "~"; // Ends with `{{~`
  42686. const isRightWhitespaceSensitive = options.originalText.charAt(end - 3) === "~";
  42687. const dashes = node.value.includes("}}") ? "--" : "";
  42688. return ["{{", isLeftWhiteSpaceSensitive ? "~" : "", "!", dashes, node.value, dashes, isRightWhitespaceSensitive ? "~" : "", "}}"];
  42689. }
  42690. case "PathExpression":
  42691. {
  42692. return node.original;
  42693. }
  42694. case "BooleanLiteral":
  42695. {
  42696. return String(node.value);
  42697. }
  42698. case "CommentStatement":
  42699. {
  42700. return ["<!--", node.value, "-->"];
  42701. }
  42702. case "StringLiteral":
  42703. {
  42704. if (needsOppositeQuote(path)) {
  42705. const printFavoriteQuote = !options.singleQuote ? "'" : '"';
  42706. return printStringLiteral(node.value, printFavoriteQuote);
  42707. }
  42708. return printStringLiteral(node.value, favoriteQuote);
  42709. }
  42710. case "NumberLiteral":
  42711. {
  42712. return String(node.value);
  42713. }
  42714. case "UndefinedLiteral":
  42715. {
  42716. return "undefined";
  42717. }
  42718. case "NullLiteral":
  42719. {
  42720. return "null";
  42721. }
  42722. /* istanbul ignore next */
  42723. default:
  42724. throw new Error("unknown glimmer type: " + JSON.stringify(node.type));
  42725. }
  42726. }
  42727. /* ElementNode print helpers */
  42728. function sortByLoc(a, b) {
  42729. return locStart$b(a) - locStart$b(b);
  42730. }
  42731. function printStartingTag(path, print) {
  42732. const node = path.getValue();
  42733. const types = ["attributes", "modifiers", "comments"].filter(property => isNonEmptyArray$4(node[property]));
  42734. const attributes = types.flatMap(type => node[type]).sort(sortByLoc);
  42735. for (const attributeType of types) {
  42736. path.each(attributePath => {
  42737. const index = attributes.indexOf(attributePath.getValue());
  42738. attributes.splice(index, 1, [line$c, print()]);
  42739. }, attributeType);
  42740. }
  42741. if (isNonEmptyArray$4(node.blockParams)) {
  42742. attributes.push(line$c, printBlockParams(node));
  42743. }
  42744. return ["<", node.tag, indent$5(attributes), printStartingTagEndMarker(node)];
  42745. }
  42746. function printChildren$5(path, options, print) {
  42747. const node = path.getValue();
  42748. const isEmpty = node.children.every(node => isWhitespaceNode(node));
  42749. if (options.htmlWhitespaceSensitivity === "ignore" && isEmpty) {
  42750. return "";
  42751. }
  42752. return path.map((childPath, childIndex) => {
  42753. const printedChild = print();
  42754. if (childIndex === 0 && options.htmlWhitespaceSensitivity === "ignore") {
  42755. return [softline$8, printedChild];
  42756. }
  42757. return printedChild;
  42758. }, "children");
  42759. }
  42760. function printStartingTagEndMarker(node) {
  42761. if (isVoid(node)) {
  42762. return ifBreak$7([softline$8, "/>"], [" />", softline$8]);
  42763. }
  42764. return ifBreak$7([softline$8, ">"], ">");
  42765. }
  42766. /* MustacheStatement print helpers */
  42767. function printOpeningMustache(node) {
  42768. const mustache = node.escaped === false ? "{{{" : "{{";
  42769. const strip = node.strip && node.strip.open ? "~" : "";
  42770. return [mustache, strip];
  42771. }
  42772. function printClosingMustache(node) {
  42773. const mustache = node.escaped === false ? "}}}" : "}}";
  42774. const strip = node.strip && node.strip.close ? "~" : "";
  42775. return [strip, mustache];
  42776. }
  42777. /* BlockStatement print helpers */
  42778. function printOpeningBlockOpeningMustache(node) {
  42779. const opening = printOpeningMustache(node);
  42780. const strip = node.openStrip.open ? "~" : "";
  42781. return [opening, strip, "#"];
  42782. }
  42783. function printOpeningBlockClosingMustache(node) {
  42784. const closing = printClosingMustache(node);
  42785. const strip = node.openStrip.close ? "~" : "";
  42786. return [strip, closing];
  42787. }
  42788. function printClosingBlockOpeningMustache(node) {
  42789. const opening = printOpeningMustache(node);
  42790. const strip = node.closeStrip.open ? "~" : "";
  42791. return [opening, strip, "/"];
  42792. }
  42793. function printClosingBlockClosingMustache(node) {
  42794. const closing = printClosingMustache(node);
  42795. const strip = node.closeStrip.close ? "~" : "";
  42796. return [strip, closing];
  42797. }
  42798. function printInverseBlockOpeningMustache(node) {
  42799. const opening = printOpeningMustache(node);
  42800. const strip = node.inverseStrip.open ? "~" : "";
  42801. return [opening, strip];
  42802. }
  42803. function printInverseBlockClosingMustache(node) {
  42804. const closing = printClosingMustache(node);
  42805. const strip = node.inverseStrip.close ? "~" : "";
  42806. return [strip, closing];
  42807. }
  42808. function printOpenBlock(path, print) {
  42809. const node = path.getValue();
  42810. const openingMustache = printOpeningBlockOpeningMustache(node);
  42811. const closingMustache = printOpeningBlockClosingMustache(node);
  42812. const attributes = [printPath(path, print)];
  42813. const params = printParams(path, print);
  42814. if (params) {
  42815. attributes.push(line$c, params);
  42816. }
  42817. if (isNonEmptyArray$4(node.program.blockParams)) {
  42818. const block = printBlockParams(node.program);
  42819. attributes.push(line$c, block);
  42820. }
  42821. return group$9([openingMustache, indent$5(attributes), softline$8, closingMustache]);
  42822. }
  42823. function printElseBlock(node, options) {
  42824. return [options.htmlWhitespaceSensitivity === "ignore" ? hardline$b : "", printInverseBlockOpeningMustache(node), "else", printInverseBlockClosingMustache(node)];
  42825. }
  42826. function printElseIfBlock(path, print) {
  42827. const parentNode = path.getParentNode(1);
  42828. return [printInverseBlockOpeningMustache(parentNode), "else if ", printParams(path, print), printInverseBlockClosingMustache(parentNode)];
  42829. }
  42830. function printCloseBlock(path, print, options) {
  42831. const node = path.getValue();
  42832. if (options.htmlWhitespaceSensitivity === "ignore") {
  42833. const escape = blockStatementHasOnlyWhitespaceInProgram(node) ? softline$8 : hardline$b;
  42834. return [escape, printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
  42835. }
  42836. return [printClosingBlockOpeningMustache(node), print("path"), printClosingBlockClosingMustache(node)];
  42837. }
  42838. function blockStatementHasOnlyWhitespaceInProgram(node) {
  42839. return isNodeOfSomeType(node, ["BlockStatement"]) && node.program.body.every(node => isWhitespaceNode(node));
  42840. }
  42841. function blockStatementHasElseIf(node) {
  42842. return blockStatementHasElse(node) && node.inverse.body.length === 1 && isNodeOfSomeType(node.inverse.body[0], ["BlockStatement"]) && node.inverse.body[0].path.parts[0] === "if";
  42843. }
  42844. function blockStatementHasElse(node) {
  42845. return isNodeOfSomeType(node, ["BlockStatement"]) && node.inverse;
  42846. }
  42847. function printProgram(path, print, options) {
  42848. const node = path.getValue();
  42849. if (blockStatementHasOnlyWhitespaceInProgram(node)) {
  42850. return "";
  42851. }
  42852. const program = print("program");
  42853. if (options.htmlWhitespaceSensitivity === "ignore") {
  42854. return indent$5([hardline$b, program]);
  42855. }
  42856. return indent$5(program);
  42857. }
  42858. function printInverse(path, print, options) {
  42859. const node = path.getValue();
  42860. const inverse = print("inverse");
  42861. const printed = options.htmlWhitespaceSensitivity === "ignore" ? [hardline$b, inverse] : inverse;
  42862. if (blockStatementHasElseIf(node)) {
  42863. return printed;
  42864. }
  42865. if (blockStatementHasElse(node)) {
  42866. return [printElseBlock(node, options), indent$5(printed)];
  42867. }
  42868. return "";
  42869. }
  42870. /* TextNode print helpers */
  42871. function getTextValueParts$3(value) {
  42872. return getDocParts$4(join$9(line$c, splitByHtmlWhitespace$1(value)));
  42873. }
  42874. function splitByHtmlWhitespace$1(string) {
  42875. return string.split(/[\t\n\f\r ]+/);
  42876. }
  42877. function getCurrentAttributeName(path) {
  42878. for (let depth = 0; depth < 2; depth++) {
  42879. const parentNode = path.getParentNode(depth);
  42880. if (parentNode && parentNode.type === "AttrNode") {
  42881. return parentNode.name.toLowerCase();
  42882. }
  42883. }
  42884. }
  42885. function countNewLines(string) {
  42886. /* istanbul ignore next */
  42887. string = typeof string === "string" ? string : "";
  42888. return string.split("\n").length - 1;
  42889. }
  42890. function countLeadingNewLines(string) {
  42891. /* istanbul ignore next */
  42892. string = typeof string === "string" ? string : "";
  42893. const newLines = (string.match(/^([^\S\n\r]*[\n\r])+/g) || [])[0] || "";
  42894. return countNewLines(newLines);
  42895. }
  42896. function countTrailingNewLines(string) {
  42897. /* istanbul ignore next */
  42898. string = typeof string === "string" ? string : "";
  42899. const newLines = (string.match(/([\n\r][^\S\n\r]*)+$/g) || [])[0] || "";
  42900. return countNewLines(newLines);
  42901. }
  42902. function generateHardlines(number = 0) {
  42903. return Array.from({
  42904. length: Math.min(number, NEWLINES_TO_PRESERVE_MAX)
  42905. }).fill(hardline$b);
  42906. }
  42907. /* StringLiteral print helpers */
  42908. /** @typedef {import("../common/util").Quote} Quote */
  42909. /**
  42910. * Prints a string literal with the correct surrounding quotes based on
  42911. * `options.singleQuote` and the number of escaped quotes contained in
  42912. * the string literal. This function is the glimmer equivalent of `printString`
  42913. * in `common/util`, but has differences because of the way escaped characters
  42914. * are treated in hbs string literals.
  42915. * @param {string} stringLiteral - the string literal value
  42916. * @param {Quote} favoriteQuote - the user's preferred quote: `'` or `"`
  42917. */
  42918. function printStringLiteral(stringLiteral, favoriteQuote) {
  42919. const {
  42920. quote,
  42921. regex
  42922. } = getPreferredQuote(stringLiteral, favoriteQuote);
  42923. return [quote, stringLiteral.replace(regex, `\\${quote}`), quote];
  42924. }
  42925. function needsOppositeQuote(path) {
  42926. let index = 0;
  42927. let parentNode = path.getParentNode(index);
  42928. while (parentNode && isNodeOfSomeType(parentNode, ["SubExpression"])) {
  42929. index++;
  42930. parentNode = path.getParentNode(index);
  42931. }
  42932. if (parentNode && isNodeOfSomeType(path.getParentNode(index + 1), ["ConcatStatement"]) && isNodeOfSomeType(path.getParentNode(index + 2), ["AttrNode"])) {
  42933. return true;
  42934. }
  42935. return false;
  42936. }
  42937. /* SubExpression print helpers */
  42938. function printSubExpressionPathAndParams(path, print) {
  42939. const p = printPath(path, print);
  42940. const params = printParams(path, print);
  42941. if (!params) {
  42942. return p;
  42943. }
  42944. return indent$5([p, line$c, group$9(params)]);
  42945. }
  42946. /* misc. print helpers */
  42947. function printPathAndParams(path, print) {
  42948. const p = printPath(path, print);
  42949. const params = printParams(path, print);
  42950. if (!params) {
  42951. return p;
  42952. }
  42953. return [indent$5([p, line$c, params]), softline$8];
  42954. }
  42955. function printPath(path, print) {
  42956. return print("path");
  42957. }
  42958. function printParams(path, print) {
  42959. const node = path.getValue();
  42960. const parts = [];
  42961. if (node.params.length > 0) {
  42962. const params = path.map(print, "params");
  42963. parts.push(...params);
  42964. }
  42965. if (node.hash && node.hash.pairs.length > 0) {
  42966. const hash = print("hash");
  42967. parts.push(hash);
  42968. }
  42969. if (parts.length === 0) {
  42970. return "";
  42971. }
  42972. return join$9(line$c, parts);
  42973. }
  42974. function printBlockParams(node) {
  42975. return ["as |", node.blockParams.join(" "), "|"];
  42976. }
  42977. var printerGlimmer = {
  42978. print,
  42979. massageAstNode: clean$6
  42980. };
  42981. var parsers$9 = {
  42982. get glimmer() {
  42983. return require("./parser-glimmer.js").parsers.glimmer;
  42984. }
  42985. };
  42986. var name$5 = "Handlebars";
  42987. var type$5 = "markup";
  42988. var color$5 = "#f7931e";
  42989. var aliases$3 = [
  42990. "hbs",
  42991. "htmlbars"
  42992. ];
  42993. var extensions$5 = [
  42994. ".handlebars",
  42995. ".hbs"
  42996. ];
  42997. var tmScope$5 = "text.html.handlebars";
  42998. var aceMode$5 = "handlebars";
  42999. var languageId$5 = 155;
  43000. var require$$3 = {
  43001. name: name$5,
  43002. type: type$5,
  43003. color: color$5,
  43004. aliases: aliases$3,
  43005. extensions: extensions$5,
  43006. tmScope: tmScope$5,
  43007. aceMode: aceMode$5,
  43008. languageId: languageId$5
  43009. };
  43010. const createLanguage$4 = createLanguage$7;
  43011. const printer$4 = printerGlimmer;
  43012. const parsers$8 = parsers$9;
  43013. const languages$5 = [createLanguage$4(require$$3, () => ({
  43014. since: "2.3.0",
  43015. parsers: ["glimmer"],
  43016. vscodeLanguageIds: ["handlebars"]
  43017. }))];
  43018. const printers$3 = {
  43019. glimmer: printer$4
  43020. };
  43021. var languageHandlebars = {
  43022. languages: languages$5,
  43023. printers: printers$3,
  43024. parsers: parsers$8
  43025. };
  43026. function hasPragma$2(text) {
  43027. return /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/.test(text);
  43028. }
  43029. function insertPragma$6(text) {
  43030. return "# @format\n\n" + text;
  43031. }
  43032. var pragma$3 = {
  43033. hasPragma: hasPragma$2,
  43034. insertPragma: insertPragma$6
  43035. };
  43036. function locStart$a(node) {
  43037. if (typeof node.start === "number") {
  43038. return node.start;
  43039. }
  43040. return node.loc && node.loc.start;
  43041. }
  43042. function locEnd$9(node) {
  43043. if (typeof node.end === "number") {
  43044. return node.end;
  43045. }
  43046. return node.loc && node.loc.end;
  43047. }
  43048. var loc$3 = {
  43049. locStart: locStart$a,
  43050. locEnd: locEnd$9
  43051. };
  43052. const {
  43053. builders: {
  43054. join: join$8,
  43055. hardline: hardline$a,
  43056. line: line$b,
  43057. softline: softline$7,
  43058. group: group$8,
  43059. indent: indent$4,
  43060. ifBreak: ifBreak$6
  43061. }
  43062. } = require$$7$3;
  43063. const {
  43064. isNextLineEmpty: isNextLineEmpty$2,
  43065. isNonEmptyArray: isNonEmptyArray$3
  43066. } = util$8;
  43067. const {
  43068. insertPragma: insertPragma$5
  43069. } = pragma$3;
  43070. const {
  43071. locStart: locStart$9,
  43072. locEnd: locEnd$8
  43073. } = loc$3;
  43074. function genericPrint$3(path, options, print) {
  43075. const node = path.getValue();
  43076. if (!node) {
  43077. return "";
  43078. }
  43079. if (typeof node === "string") {
  43080. return node;
  43081. }
  43082. switch (node.kind) {
  43083. case "Document":
  43084. {
  43085. const parts = [];
  43086. path.each((pathChild, index, definitions) => {
  43087. parts.push(print());
  43088. if (index !== definitions.length - 1) {
  43089. parts.push(hardline$a);
  43090. if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), locEnd$8)) {
  43091. parts.push(hardline$a);
  43092. }
  43093. }
  43094. }, "definitions");
  43095. return [...parts, hardline$a];
  43096. }
  43097. case "OperationDefinition":
  43098. {
  43099. const hasOperation = options.originalText[locStart$9(node)] !== "{";
  43100. const hasName = Boolean(node.name);
  43101. return [hasOperation ? node.operation : "", hasOperation && hasName ? [" ", print("name")] : "", hasOperation && !hasName && isNonEmptyArray$3(node.variableDefinitions) ? " " : "", isNonEmptyArray$3(node.variableDefinitions) ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "variableDefinitions"))]), softline$7, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? !hasOperation && !hasName ? "" : " " : "", print("selectionSet")];
  43102. }
  43103. case "FragmentDefinition":
  43104. {
  43105. return ["fragment ", print("name"), isNonEmptyArray$3(node.variableDefinitions) ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "variableDefinitions"))]), softline$7, ")"]) : "", " on ", print("typeCondition"), printDirectives(path, print, node), " ", print("selectionSet")];
  43106. }
  43107. case "SelectionSet":
  43108. {
  43109. return ["{", indent$4([hardline$a, join$8(hardline$a, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))]), hardline$a, "}"];
  43110. }
  43111. case "Field":
  43112. {
  43113. return group$8([node.alias ? [print("alias"), ": "] : "", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", printDirectives(path, print, node), node.selectionSet ? " " : "", print("selectionSet")]);
  43114. }
  43115. case "Name":
  43116. {
  43117. return node.value;
  43118. }
  43119. case "StringValue":
  43120. {
  43121. if (node.block) {
  43122. return ['"""', hardline$a, join$8(hardline$a, node.value.replace(/"""/g, "\\$&").split("\n")), hardline$a, '"""'];
  43123. }
  43124. return ['"', node.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"'];
  43125. }
  43126. case "IntValue":
  43127. case "FloatValue":
  43128. case "EnumValue":
  43129. {
  43130. return node.value;
  43131. }
  43132. case "BooleanValue":
  43133. {
  43134. return node.value ? "true" : "false";
  43135. }
  43136. case "NullValue":
  43137. {
  43138. return "null";
  43139. }
  43140. case "Variable":
  43141. {
  43142. return ["$", print("name")];
  43143. }
  43144. case "ListValue":
  43145. {
  43146. return group$8(["[", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "values"))]), softline$7, "]"]);
  43147. }
  43148. case "ObjectValue":
  43149. {
  43150. return group$8(["{", options.bracketSpacing && node.fields.length > 0 ? " " : "", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.map(print, "fields"))]), softline$7, ifBreak$6("", options.bracketSpacing && node.fields.length > 0 ? " " : ""), "}"]);
  43151. }
  43152. case "ObjectField":
  43153. case "Argument":
  43154. {
  43155. return [print("name"), ": ", print("value")];
  43156. }
  43157. case "Directive":
  43158. {
  43159. return ["@", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : ""];
  43160. }
  43161. case "NamedType":
  43162. {
  43163. return print("name");
  43164. }
  43165. case "VariableDefinition":
  43166. {
  43167. return [print("variable"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
  43168. }
  43169. case "ObjectTypeExtension":
  43170. case "ObjectTypeDefinition":
  43171. {
  43172. return [print("description"), node.description ? hardline$a : "", node.kind === "ObjectTypeExtension" ? "extend " : "", "type ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  43173. }
  43174. case "FieldDefinition":
  43175. {
  43176. return [print("description"), node.description ? hardline$a : "", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", ": ", print("type"), printDirectives(path, print, node)];
  43177. }
  43178. case "DirectiveDefinition":
  43179. {
  43180. return [print("description"), node.description ? hardline$a : "", "directive ", "@", print("name"), node.arguments.length > 0 ? group$8(["(", indent$4([softline$7, join$8([ifBreak$6("", ", "), softline$7], path.call(argsPath => printSequence(argsPath, options, print), "arguments"))]), softline$7, ")"]) : "", node.repeatable ? " repeatable" : "", " on ", join$8(" | ", path.map(print, "locations"))];
  43181. }
  43182. case "EnumTypeExtension":
  43183. case "EnumTypeDefinition":
  43184. {
  43185. return [print("description"), node.description ? hardline$a : "", node.kind === "EnumTypeExtension" ? "extend " : "", "enum ", print("name"), printDirectives(path, print, node), node.values.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))]), hardline$a, "}"] : ""];
  43186. }
  43187. case "EnumValueDefinition":
  43188. {
  43189. return [print("description"), node.description ? hardline$a : "", print("name"), printDirectives(path, print, node)];
  43190. }
  43191. case "InputValueDefinition":
  43192. {
  43193. return [print("description"), node.description ? node.description.block ? hardline$a : line$b : "", print("name"), ": ", print("type"), node.defaultValue ? [" = ", print("defaultValue")] : "", printDirectives(path, print, node)];
  43194. }
  43195. case "InputObjectTypeExtension":
  43196. case "InputObjectTypeDefinition":
  43197. {
  43198. return [print("description"), node.description ? hardline$a : "", node.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", print("name"), printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  43199. }
  43200. case "SchemaDefinition":
  43201. {
  43202. return ["schema", printDirectives(path, print, node), " {", node.operationTypes.length > 0 ? indent$4([hardline$a, join$8(hardline$a, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))]) : "", hardline$a, "}"];
  43203. }
  43204. case "OperationTypeDefinition":
  43205. {
  43206. return [print("operation"), ": ", print("type")];
  43207. }
  43208. case "InterfaceTypeExtension":
  43209. case "InterfaceTypeDefinition":
  43210. {
  43211. return [print("description"), node.description ? hardline$a : "", node.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", print("name"), node.interfaces.length > 0 ? [" implements ", ...printInterfaces(path, options, print)] : "", printDirectives(path, print, node), node.fields.length > 0 ? [" {", indent$4([hardline$a, join$8(hardline$a, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))]), hardline$a, "}"] : ""];
  43212. }
  43213. case "FragmentSpread":
  43214. {
  43215. return ["...", print("name"), printDirectives(path, print, node)];
  43216. }
  43217. case "InlineFragment":
  43218. {
  43219. return ["...", node.typeCondition ? [" on ", print("typeCondition")] : "", printDirectives(path, print, node), " ", print("selectionSet")];
  43220. }
  43221. case "UnionTypeExtension":
  43222. case "UnionTypeDefinition":
  43223. {
  43224. return group$8([print("description"), node.description ? hardline$a : "", group$8([node.kind === "UnionTypeExtension" ? "extend " : "", "union ", print("name"), printDirectives(path, print, node), node.types.length > 0 ? [" =", ifBreak$6("", " "), indent$4([ifBreak$6([line$b, " "]), join$8([line$b, "| "], path.map(print, "types"))])] : ""])]);
  43225. }
  43226. case "ScalarTypeExtension":
  43227. case "ScalarTypeDefinition":
  43228. {
  43229. return [print("description"), node.description ? hardline$a : "", node.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", print("name"), printDirectives(path, print, node)];
  43230. }
  43231. case "NonNullType":
  43232. {
  43233. return [print("type"), "!"];
  43234. }
  43235. case "ListType":
  43236. {
  43237. return ["[", print("type"), "]"];
  43238. }
  43239. default:
  43240. /* istanbul ignore next */
  43241. throw new Error("unknown graphql type: " + JSON.stringify(node.kind));
  43242. }
  43243. }
  43244. function printDirectives(path, print, node) {
  43245. if (node.directives.length === 0) {
  43246. return "";
  43247. }
  43248. const printed = join$8(line$b, path.map(print, "directives"));
  43249. if (node.kind === "FragmentDefinition" || node.kind === "OperationDefinition") {
  43250. return group$8([line$b, printed]);
  43251. }
  43252. return [" ", group$8(indent$4([softline$7, printed]))];
  43253. }
  43254. function printSequence(sequencePath, options, print) {
  43255. const count = sequencePath.getValue().length;
  43256. return sequencePath.map((path, i) => {
  43257. const printed = print();
  43258. if (isNextLineEmpty$2(options.originalText, path.getValue(), locEnd$8) && i < count - 1) {
  43259. return [printed, hardline$a];
  43260. }
  43261. return printed;
  43262. });
  43263. }
  43264. function canAttachComment(node) {
  43265. return node.kind && node.kind !== "Comment";
  43266. }
  43267. function printComment(commentPath) {
  43268. const comment = commentPath.getValue();
  43269. if (comment.kind === "Comment") {
  43270. return "#" + comment.value.trimEnd();
  43271. }
  43272. /* istanbul ignore next */
  43273. throw new Error("Not a comment: " + JSON.stringify(comment));
  43274. }
  43275. function printInterfaces(path, options, print) {
  43276. const node = path.getNode();
  43277. const parts = [];
  43278. const {
  43279. interfaces
  43280. } = node;
  43281. const printed = path.map(node => print(node), "interfaces");
  43282. for (let index = 0; index < interfaces.length; index++) {
  43283. const interfaceNode = interfaces[index];
  43284. parts.push(printed[index]);
  43285. const nextInterfaceNode = interfaces[index + 1];
  43286. if (nextInterfaceNode) {
  43287. const textBetween = options.originalText.slice(interfaceNode.loc.end, nextInterfaceNode.loc.start);
  43288. const hasComment = textBetween.includes("#");
  43289. const separator = textBetween.replace(/#.*/g, "").trim();
  43290. parts.push(separator === "," ? "," : " &", hasComment ? line$b : " ");
  43291. }
  43292. }
  43293. return parts;
  43294. }
  43295. function
  43296. /*node, newNode , parent*/
  43297. clean$5() {}
  43298. clean$5.ignoredProperties = new Set(["loc", "comments"]);
  43299. function hasPrettierIgnore$6(path) {
  43300. const node = path.getValue();
  43301. return node && Array.isArray(node.comments) && node.comments.some(comment => comment.value.trim() === "prettier-ignore");
  43302. }
  43303. var printerGraphql = {
  43304. print: genericPrint$3,
  43305. massageAstNode: clean$5,
  43306. hasPrettierIgnore: hasPrettierIgnore$6,
  43307. insertPragma: insertPragma$5,
  43308. printComment,
  43309. canAttachComment
  43310. };
  43311. const commonOptions$3 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  43312. var options$7 = {
  43313. bracketSpacing: commonOptions$3.bracketSpacing
  43314. };
  43315. var parsers$7 = {
  43316. get graphql() {
  43317. return require("./parser-graphql.js").parsers.graphql;
  43318. }
  43319. };
  43320. var name$4 = "GraphQL";
  43321. var type$4 = "data";
  43322. var color$4 = "#e10098";
  43323. var extensions$4 = [
  43324. ".graphql",
  43325. ".gql",
  43326. ".graphqls"
  43327. ];
  43328. var tmScope$4 = "source.graphql";
  43329. var aceMode$4 = "text";
  43330. var languageId$4 = 139;
  43331. var require$$4$4 = {
  43332. name: name$4,
  43333. type: type$4,
  43334. color: color$4,
  43335. extensions: extensions$4,
  43336. tmScope: tmScope$4,
  43337. aceMode: aceMode$4,
  43338. languageId: languageId$4
  43339. };
  43340. const createLanguage$3 = createLanguage$7;
  43341. const printer$3 = printerGraphql;
  43342. const options$6 = options$7;
  43343. const parsers$6 = parsers$7;
  43344. const languages$4 = [createLanguage$3(require$$4$4, () => ({
  43345. since: "1.5.0",
  43346. parsers: ["graphql"],
  43347. vscodeLanguageIds: ["graphql"]
  43348. }))];
  43349. const printers$2 = {
  43350. graphql: printer$3
  43351. };
  43352. var languageGraphql = {
  43353. languages: languages$4,
  43354. options: options$6,
  43355. printers: printers$2,
  43356. parsers: parsers$6
  43357. };
  43358. function locStart$8(node) {
  43359. return node.position.start.offset;
  43360. }
  43361. function locEnd$7(node) {
  43362. return node.position.end.offset;
  43363. }
  43364. var loc$2 = {
  43365. locStart: locStart$8,
  43366. locEnd: locEnd$7
  43367. };
  43368. var require$$2 = {
  43369. "cjkPattern": "(?:[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d])(?:[\\ufe00-\\ufe0f]|\\udb40[\\udd00-\\uddef])?",
  43370. "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]",
  43371. "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
  43372. };
  43373. const {
  43374. getLast: getLast$5
  43375. } = util$8;
  43376. const {
  43377. locStart: locStart$7,
  43378. locEnd: locEnd$6
  43379. } = loc$2;
  43380. const {
  43381. cjkPattern,
  43382. kPattern,
  43383. punctuationPattern: punctuationPattern$1
  43384. } = require$$2;
  43385. const INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "esComment", "strong", "delete", "wikiLink", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  43386. const INLINE_NODE_WRAPPER_TYPES$1 = [...INLINE_NODE_TYPES$1, "tableCell", "paragraph", "heading"];
  43387. const kRegex = new RegExp(kPattern);
  43388. const punctuationRegex = new RegExp(punctuationPattern$1);
  43389. /**
  43390. * split text into whitespaces and words
  43391. * @param {string} text
  43392. */
  43393. function splitText$2(text, options) {
  43394. const KIND_NON_CJK = "non-cjk";
  43395. const KIND_CJ_LETTER = "cj-letter";
  43396. const KIND_K_LETTER = "k-letter";
  43397. const KIND_CJK_PUNCTUATION = "cjk-punctuation";
  43398. /** @type {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} */
  43399. const nodes = [];
  43400. const tokens = (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([\t\n ]+)/);
  43401. for (const [index, token] of tokens.entries()) {
  43402. // whitespace
  43403. if (index % 2 === 1) {
  43404. nodes.push({
  43405. type: "whitespace",
  43406. value: /\n/.test(token) ? "\n" : " "
  43407. });
  43408. continue;
  43409. } // word separated by whitespace
  43410. if ((index === 0 || index === tokens.length - 1) && token === "") {
  43411. continue;
  43412. }
  43413. const innerTokens = token.split(new RegExp(`(${cjkPattern})`));
  43414. for (const [innerIndex, innerToken] of innerTokens.entries()) {
  43415. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  43416. continue;
  43417. } // non-CJK word
  43418. if (innerIndex % 2 === 0) {
  43419. if (innerToken !== "") {
  43420. appendNode({
  43421. type: "word",
  43422. value: innerToken,
  43423. kind: KIND_NON_CJK,
  43424. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  43425. hasTrailingPunctuation: punctuationRegex.test(getLast$5(innerToken))
  43426. });
  43427. }
  43428. continue;
  43429. } // CJK character
  43430. appendNode(punctuationRegex.test(innerToken) ? {
  43431. type: "word",
  43432. value: innerToken,
  43433. kind: KIND_CJK_PUNCTUATION,
  43434. hasLeadingPunctuation: true,
  43435. hasTrailingPunctuation: true
  43436. } : {
  43437. type: "word",
  43438. value: innerToken,
  43439. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  43440. hasLeadingPunctuation: false,
  43441. hasTrailingPunctuation: false
  43442. });
  43443. }
  43444. }
  43445. return nodes;
  43446. function appendNode(node) {
  43447. const lastNode = getLast$5(nodes);
  43448. if (lastNode && lastNode.type === "word") {
  43449. 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) {
  43450. nodes.push({
  43451. type: "whitespace",
  43452. value: " "
  43453. });
  43454. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  43455. ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
  43456. nodes.push({
  43457. type: "whitespace",
  43458. value: ""
  43459. });
  43460. }
  43461. }
  43462. nodes.push(node);
  43463. function isBetween(kind1, kind2) {
  43464. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  43465. }
  43466. }
  43467. }
  43468. function getOrderedListItemInfo$1(orderListItem, originalText) {
  43469. const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
  43470. return {
  43471. numberText,
  43472. marker,
  43473. leadingSpaces
  43474. };
  43475. }
  43476. function hasGitDiffFriendlyOrderedList$1(node, options) {
  43477. if (!node.ordered) {
  43478. return false;
  43479. }
  43480. if (node.children.length < 2) {
  43481. return false;
  43482. }
  43483. const firstNumber = Number(getOrderedListItemInfo$1(node.children[0], options.originalText).numberText);
  43484. const secondNumber = Number(getOrderedListItemInfo$1(node.children[1], options.originalText).numberText);
  43485. if (firstNumber === 0 && node.children.length > 2) {
  43486. const thirdNumber = Number(getOrderedListItemInfo$1(node.children[2], options.originalText).numberText);
  43487. return secondNumber === 1 && thirdNumber === 1;
  43488. }
  43489. return secondNumber === 1;
  43490. } // The final new line should not include in value
  43491. // https://github.com/remarkjs/remark/issues/512
  43492. function getFencedCodeBlockValue$2(node, originalText) {
  43493. const {
  43494. value
  43495. } = node;
  43496. if (node.position.end.offset === originalText.length && value.endsWith("\n") && // Code block has no end mark
  43497. originalText.endsWith("\n")) {
  43498. return value.slice(0, -1);
  43499. }
  43500. return value;
  43501. }
  43502. function mapAst$1(ast, handler) {
  43503. return function preorder(node, index, parentStack) {
  43504. const newNode = Object.assign({}, handler(node, index, parentStack));
  43505. if (newNode.children) {
  43506. newNode.children = newNode.children.map((child, index) => preorder(child, index, [newNode, ...parentStack]));
  43507. }
  43508. return newNode;
  43509. }(ast, null, []);
  43510. }
  43511. function isAutolink$1(node) {
  43512. if (!node || node.type !== "link" || node.children.length !== 1) {
  43513. return false;
  43514. }
  43515. const child = node.children[0];
  43516. return child && locStart$7(node) === locStart$7(child) && locEnd$6(node) === locEnd$6(child);
  43517. }
  43518. var utils$2 = {
  43519. mapAst: mapAst$1,
  43520. splitText: splitText$2,
  43521. punctuationPattern: punctuationPattern$1,
  43522. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  43523. getOrderedListItemInfo: getOrderedListItemInfo$1,
  43524. hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
  43525. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  43526. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1,
  43527. isAutolink: isAutolink$1
  43528. };
  43529. const {
  43530. inferParserByLanguage: inferParserByLanguage$1,
  43531. getMaxContinuousCount: getMaxContinuousCount$1
  43532. } = util$8;
  43533. const {
  43534. builders: {
  43535. hardline: hardline$9,
  43536. markAsRoot: markAsRoot$2
  43537. },
  43538. utils: {
  43539. replaceEndOfLine
  43540. }
  43541. } = require$$7$3;
  43542. const printFrontMatter$1 = print_1;
  43543. const {
  43544. getFencedCodeBlockValue: getFencedCodeBlockValue$1
  43545. } = utils$2;
  43546. function embed$6(path, print, textToDoc, options) {
  43547. const node = path.getValue();
  43548. if (node.type === "code" && node.lang !== null) {
  43549. const parser = inferParserByLanguage$1(node.lang, options);
  43550. if (parser) {
  43551. const styleUnit = options.__inJsTemplate ? "~" : "`";
  43552. const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount$1(node.value, styleUnit) + 1));
  43553. const newOptions = {
  43554. parser
  43555. };
  43556. if (node.lang === "tsx") {
  43557. newOptions.filepath = "dummy.tsx";
  43558. }
  43559. const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), newOptions, {
  43560. stripTrailingHardline: true
  43561. });
  43562. return markAsRoot$2([style, node.lang, node.meta ? " " + node.meta : "", hardline$9, replaceEndOfLine(doc), hardline$9, style]);
  43563. }
  43564. }
  43565. switch (node.type) {
  43566. case "front-matter":
  43567. return printFrontMatter$1(node, textToDoc);
  43568. // MDX
  43569. case "importExport":
  43570. return [textToDoc(node.value, {
  43571. parser: "babel"
  43572. }, {
  43573. stripTrailingHardline: true
  43574. }), hardline$9];
  43575. case "jsx":
  43576. return textToDoc(`<$>${node.value}</$>`, {
  43577. parser: "__js_expression",
  43578. rootMarker: "mdx"
  43579. }, {
  43580. stripTrailingHardline: true
  43581. });
  43582. }
  43583. return null;
  43584. }
  43585. var embed_1$2 = embed$6;
  43586. const parseFrontMatter = parse_1;
  43587. const pragmas = ["format", "prettier"];
  43588. function startWithPragma$1(text) {
  43589. const pragma = `@(${pragmas.join("|")})`;
  43590. const regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `{\\s*\\/\\*\\s*${pragma}\\s*\\*\\/\\s*}`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
  43591. const matched = text.match(regex);
  43592. return matched && matched.index === 0;
  43593. }
  43594. var pragma$2 = {
  43595. startWithPragma: startWithPragma$1,
  43596. hasPragma: text => startWithPragma$1(parseFrontMatter(text).content.trimStart()),
  43597. insertPragma: text => {
  43598. const extracted = parseFrontMatter(text);
  43599. const pragma = `<!-- @${pragmas[0]} -->`;
  43600. return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
  43601. }
  43602. };
  43603. const getLast$4 = getLast_1;
  43604. const {
  43605. getOrderedListItemInfo,
  43606. mapAst,
  43607. splitText: splitText$1
  43608. } = utils$2; // 0x0 ~ 0x10ffff
  43609. const isSingleCharRegex = /^.$/su;
  43610. function preprocess$5(ast, options) {
  43611. ast = restoreUnescapedCharacter(ast, options);
  43612. ast = mergeContinuousTexts(ast);
  43613. ast = transformInlineCode(ast);
  43614. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  43615. ast = markAlignedList(ast, options);
  43616. ast = splitTextIntoSentences(ast, options);
  43617. ast = transformImportExport(ast);
  43618. ast = mergeContinuousImportExport(ast);
  43619. return ast;
  43620. }
  43621. function transformImportExport(ast) {
  43622. return mapAst(ast, node => {
  43623. if (node.type !== "import" && node.type !== "export") {
  43624. return node;
  43625. }
  43626. return Object.assign(Object.assign({}, node), {}, {
  43627. type: "importExport"
  43628. });
  43629. });
  43630. }
  43631. function transformInlineCode(ast) {
  43632. return mapAst(ast, node => {
  43633. if (node.type !== "inlineCode") {
  43634. return node;
  43635. }
  43636. return Object.assign(Object.assign({}, node), {}, {
  43637. value: node.value.replace(/\s+/g, " ")
  43638. });
  43639. });
  43640. }
  43641. function restoreUnescapedCharacter(ast, options) {
  43642. return mapAst(ast, node => node.type !== "text" || node.value === "*" || node.value === "_" || // handle these cases in printer
  43643. !isSingleCharRegex.test(node.value) || node.position.end.offset - node.position.start.offset === node.value.length ? node : Object.assign(Object.assign({}, node), {}, {
  43644. value: options.originalText.slice(node.position.start.offset, node.position.end.offset)
  43645. }));
  43646. }
  43647. function mergeContinuousImportExport(ast) {
  43648. return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
  43649. type: "importExport",
  43650. value: prevNode.value + "\n\n" + node.value,
  43651. position: {
  43652. start: prevNode.position.start,
  43653. end: node.position.end
  43654. }
  43655. }));
  43656. }
  43657. function mergeChildren(ast, shouldMerge, mergeNode) {
  43658. return mapAst(ast, node => {
  43659. if (!node.children) {
  43660. return node;
  43661. }
  43662. const children = node.children.reduce((current, child) => {
  43663. const lastChild = getLast$4(current);
  43664. if (lastChild && shouldMerge(lastChild, child)) {
  43665. current.splice(-1, 1, mergeNode(lastChild, child));
  43666. } else {
  43667. current.push(child);
  43668. }
  43669. return current;
  43670. }, []);
  43671. return Object.assign(Object.assign({}, node), {}, {
  43672. children
  43673. });
  43674. });
  43675. }
  43676. function mergeContinuousTexts(ast) {
  43677. return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
  43678. type: "text",
  43679. value: prevNode.value + node.value,
  43680. position: {
  43681. start: prevNode.position.start,
  43682. end: node.position.end
  43683. }
  43684. }));
  43685. }
  43686. function splitTextIntoSentences(ast, options) {
  43687. return mapAst(ast, (node, index, [parentNode]) => {
  43688. if (node.type !== "text") {
  43689. return node;
  43690. }
  43691. let {
  43692. value
  43693. } = node;
  43694. if (parentNode.type === "paragraph") {
  43695. if (index === 0) {
  43696. value = value.trimStart();
  43697. }
  43698. if (index === parentNode.children.length - 1) {
  43699. value = value.trimEnd();
  43700. }
  43701. }
  43702. return {
  43703. type: "sentence",
  43704. position: node.position,
  43705. children: splitText$1(value, options)
  43706. };
  43707. });
  43708. }
  43709. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  43710. return mapAst(ast, (node, index, parentStack) => {
  43711. if (node.type === "code") {
  43712. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  43713. const isIndented = /^\n?(?: {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  43714. node.isIndented = isIndented;
  43715. if (isIndented) {
  43716. for (let i = 0; i < parentStack.length; i++) {
  43717. const parent = parentStack[i]; // no need to check checked items
  43718. if (parent.hasIndentedCodeblock) {
  43719. break;
  43720. }
  43721. if (parent.type === "list") {
  43722. parent.hasIndentedCodeblock = true;
  43723. }
  43724. }
  43725. }
  43726. }
  43727. return node;
  43728. });
  43729. }
  43730. function markAlignedList(ast, options) {
  43731. return mapAst(ast, (node, index, parentStack) => {
  43732. if (node.type === "list" && node.children.length > 0) {
  43733. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  43734. for (let i = 0; i < parentStack.length; i++) {
  43735. const parent = parentStack[i];
  43736. if (parent.type === "list" && !parent.isAligned) {
  43737. node.isAligned = false;
  43738. return node;
  43739. }
  43740. }
  43741. node.isAligned = isAligned(node);
  43742. }
  43743. return node;
  43744. });
  43745. function getListItemStart(listItem) {
  43746. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  43747. }
  43748. function isAligned(list) {
  43749. if (!list.ordered) {
  43750. /**
  43751. * - 123
  43752. * - 123
  43753. */
  43754. return true;
  43755. }
  43756. const [firstItem, secondItem] = list.children;
  43757. const firstInfo = getOrderedListItemInfo(firstItem, options.originalText);
  43758. if (firstInfo.leadingSpaces.length > 1) {
  43759. /**
  43760. * 1. 123
  43761. *
  43762. * 1. 123
  43763. * 1. 123
  43764. */
  43765. return true;
  43766. }
  43767. const firstStart = getListItemStart(firstItem);
  43768. if (firstStart === -1) {
  43769. /**
  43770. * 1.
  43771. *
  43772. * 1.
  43773. * 1.
  43774. */
  43775. return false;
  43776. }
  43777. if (list.children.length === 1) {
  43778. /**
  43779. * aligned:
  43780. *
  43781. * 11. 123
  43782. *
  43783. * not aligned:
  43784. *
  43785. * 1. 123
  43786. */
  43787. return firstStart % options.tabWidth === 0;
  43788. }
  43789. const secondStart = getListItemStart(secondItem);
  43790. if (firstStart !== secondStart) {
  43791. /**
  43792. * 11. 123
  43793. * 1. 123
  43794. *
  43795. * 1. 123
  43796. * 11. 123
  43797. */
  43798. return false;
  43799. }
  43800. if (firstStart % options.tabWidth === 0) {
  43801. /**
  43802. * 11. 123
  43803. * 12. 123
  43804. */
  43805. return true;
  43806. }
  43807. /**
  43808. * aligned:
  43809. *
  43810. * 11. 123
  43811. * 1. 123
  43812. *
  43813. * not aligned:
  43814. *
  43815. * 1. 123
  43816. * 2. 123
  43817. */
  43818. const secondInfo = getOrderedListItemInfo(secondItem, options.originalText);
  43819. return secondInfo.leadingSpaces.length > 1;
  43820. }
  43821. }
  43822. var printPreprocess$2 = preprocess$5;
  43823. const {
  43824. isFrontMatterNode: isFrontMatterNode$2
  43825. } = util$8;
  43826. const {
  43827. startWithPragma
  43828. } = pragma$2;
  43829. const ignoredProperties$1 = new Set(["position", "raw" // front-matter
  43830. ]);
  43831. function clean$4(ast, newObj, parent) {
  43832. // for codeblock
  43833. if (ast.type === "front-matter" || ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  43834. delete newObj.value;
  43835. }
  43836. if (ast.type === "list") {
  43837. delete newObj.isAligned;
  43838. }
  43839. if (ast.type === "list" || ast.type === "listItem") {
  43840. delete newObj.spread;
  43841. delete newObj.loose;
  43842. } // texts can be splitted or merged
  43843. if (ast.type === "text") {
  43844. return null;
  43845. }
  43846. if (ast.type === "inlineCode") {
  43847. newObj.value = ast.value.replace(/[\t\n ]+/g, " ");
  43848. }
  43849. if (ast.type === "wikiLink") {
  43850. newObj.value = ast.value.trim().replace(/[\t\n]+/g, " ");
  43851. }
  43852. if (ast.type === "definition" || ast.type === "linkReference") {
  43853. newObj.label = ast.label.trim().replace(/[\t\n ]+/g, " ").toLowerCase();
  43854. }
  43855. if ((ast.type === "definition" || ast.type === "link" || ast.type === "image") && ast.title) {
  43856. newObj.title = ast.title.replace(/\\(["')])/g, "$1");
  43857. } // for insert pragma
  43858. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || isFrontMatterNode$2(parent.children[0]) && parent.children[1] === ast) && ast.type === "html" && startWithPragma(ast.value)) {
  43859. return null;
  43860. }
  43861. }
  43862. clean$4.ignoredProperties = ignoredProperties$1;
  43863. var clean_1$1 = clean$4;
  43864. const {
  43865. getLast: getLast$3,
  43866. getMinNotPresentContinuousCount,
  43867. getMaxContinuousCount,
  43868. getStringWidth,
  43869. isNonEmptyArray: isNonEmptyArray$2
  43870. } = util$8;
  43871. const {
  43872. builders: {
  43873. breakParent: breakParent$4,
  43874. join: join$7,
  43875. line: line$a,
  43876. literalline: literalline$3,
  43877. markAsRoot: markAsRoot$1,
  43878. hardline: hardline$8,
  43879. softline: softline$6,
  43880. ifBreak: ifBreak$5,
  43881. fill: fill$4,
  43882. align: align$1,
  43883. indent: indent$3,
  43884. group: group$7,
  43885. hardlineWithoutBreakParent
  43886. },
  43887. utils: {
  43888. normalizeDoc,
  43889. replaceTextEndOfLine: replaceTextEndOfLine$7
  43890. },
  43891. printer: {
  43892. printDocToString
  43893. }
  43894. } = require$$7$3;
  43895. const embed$5 = embed_1$2;
  43896. const {
  43897. insertPragma: insertPragma$4
  43898. } = pragma$2;
  43899. const {
  43900. locStart: locStart$6,
  43901. locEnd: locEnd$5
  43902. } = loc$2;
  43903. const preprocess$4 = printPreprocess$2;
  43904. const clean$3 = clean_1$1;
  43905. const {
  43906. getFencedCodeBlockValue,
  43907. hasGitDiffFriendlyOrderedList,
  43908. splitText,
  43909. punctuationPattern,
  43910. INLINE_NODE_TYPES,
  43911. INLINE_NODE_WRAPPER_TYPES,
  43912. isAutolink
  43913. } = utils$2;
  43914. /**
  43915. * @typedef {import("../document").Doc} Doc
  43916. */
  43917. const TRAILING_HARDLINE_NODES = new Set(["importExport"]);
  43918. const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link", "wikiLink"];
  43919. const SIBLING_NODE_TYPES = new Set(["listItem", "definition", "footnoteDefinition"]);
  43920. function genericPrint$2(path, options, print) {
  43921. const node = path.getValue();
  43922. if (shouldRemainTheSameContent(path)) {
  43923. return splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options));
  43924. }
  43925. switch (node.type) {
  43926. case "front-matter":
  43927. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  43928. case "root":
  43929. if (node.children.length === 0) {
  43930. return "";
  43931. }
  43932. return [normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.has(getLastDescendantNode$2(node).type) ? hardline$8 : ""];
  43933. case "paragraph":
  43934. return printChildren$4(path, options, print, {
  43935. postprocessor: fill$4
  43936. });
  43937. case "sentence":
  43938. return printChildren$4(path, options, print);
  43939. case "word":
  43940. {
  43941. let escapedValue = node.value.replace(/\*/g, "\\$&") // escape all `*`
  43942. .replace(new RegExp([`(^|${punctuationPattern})(_+)`, `(_+)(${punctuationPattern}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_")); // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  43943. const isFirstSentence = (node, name, index) => node.type === "sentence" && index === 0;
  43944. const isLastChildAutolink = (node, name, index) => isAutolink(node.children[index - 1]);
  43945. if (escapedValue !== node.value && (path.match(undefined, isFirstSentence, isLastChildAutolink) || path.match(undefined, isFirstSentence, (node, name, index) => node.type === "emphasis" && index === 0, isLastChildAutolink))) {
  43946. // backslash is parsed as part of autolinks, so we need to remove it
  43947. escapedValue = escapedValue.replace(/^(\\?[*_])+/, prefix => prefix.replace(/\\/g, ""));
  43948. }
  43949. return escapedValue;
  43950. }
  43951. case "whitespace":
  43952. {
  43953. const parentNode = path.getParentNode();
  43954. const index = parentNode.children.indexOf(node);
  43955. const nextNode = parentNode.children[index + 1];
  43956. const proseWrap = // leading char that may cause different syntax
  43957. nextNode && /^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(nextNode.value) ? "never" : options.proseWrap;
  43958. return printLine(path, node.value, {
  43959. proseWrap
  43960. });
  43961. }
  43962. case "emphasis":
  43963. {
  43964. let style;
  43965. if (isAutolink(node.children[0])) {
  43966. style = options.originalText[node.position.start.offset];
  43967. } else {
  43968. const parentNode = path.getParentNode();
  43969. const index = parentNode.children.indexOf(node);
  43970. const prevNode = parentNode.children[index - 1];
  43971. const nextNode = parentNode.children[index + 1];
  43972. const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
  43973. prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && getLast$3(prevNode.children).type === "word" && !getLast$3(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
  43974. style = hasPrevOrNextWord || getAncestorNode(path, "emphasis") ? "*" : "_";
  43975. }
  43976. return [style, printChildren$4(path, options, print), style];
  43977. }
  43978. case "strong":
  43979. return ["**", printChildren$4(path, options, print), "**"];
  43980. case "delete":
  43981. return ["~~", printChildren$4(path, options, print), "~~"];
  43982. case "inlineCode":
  43983. {
  43984. const backtickCount = getMinNotPresentContinuousCount(node.value, "`");
  43985. const style = "`".repeat(backtickCount || 1);
  43986. const gap = backtickCount && !/^\s/.test(node.value) ? " " : "";
  43987. return [style, gap, node.value, gap, style];
  43988. }
  43989. case "wikiLink":
  43990. {
  43991. let contents = "";
  43992. if (options.proseWrap === "preserve") {
  43993. contents = node.value;
  43994. } else {
  43995. contents = node.value.replace(/[\t\n]+/g, " ");
  43996. }
  43997. return ["[[", contents, "]]"];
  43998. }
  43999. case "link":
  44000. switch (options.originalText[node.position.start.offset]) {
  44001. case "<":
  44002. {
  44003. const mailto = "mailto:";
  44004. const url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  44005. 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;
  44006. return ["<", url, ">"];
  44007. }
  44008. case "[":
  44009. return ["[", printChildren$4(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
  44010. default:
  44011. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  44012. }
  44013. case "image":
  44014. return ["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"];
  44015. case "blockquote":
  44016. return ["> ", align$1("> ", printChildren$4(path, options, print))];
  44017. case "heading":
  44018. return ["#".repeat(node.depth) + " ", printChildren$4(path, options, print)];
  44019. case "code":
  44020. {
  44021. if (node.isIndented) {
  44022. // indented code block
  44023. const alignment = " ".repeat(4);
  44024. return align$1(alignment, [alignment, ...replaceTextEndOfLine$7(node.value, hardline$8)]);
  44025. } // fenced code block
  44026. const styleUnit = options.__inJsTemplate ? "~" : "`";
  44027. const style = styleUnit.repeat(Math.max(3, getMaxContinuousCount(node.value, styleUnit) + 1));
  44028. return [style, node.lang || "", node.meta ? " " + node.meta : "", hardline$8, ...replaceTextEndOfLine$7(getFencedCodeBlockValue(node, options.originalText), hardline$8), hardline$8, style];
  44029. }
  44030. case "html":
  44031. {
  44032. const parentNode = path.getParentNode();
  44033. const value = parentNode.type === "root" && getLast$3(parentNode.children) === node ? node.value.trimEnd() : node.value;
  44034. const isHtmlComment = /^<!--.*-->$/s.test(value);
  44035. return replaceTextEndOfLine$7(value, // @ts-expect-error
  44036. isHtmlComment ? hardline$8 : markAsRoot$1(literalline$3));
  44037. }
  44038. case "list":
  44039. {
  44040. const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
  44041. const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList(node, options);
  44042. return printChildren$4(path, options, print, {
  44043. processor: (childPath, index) => {
  44044. const prefix = getPrefix();
  44045. const childNode = childPath.getValue();
  44046. if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
  44047. return [prefix, printListItem(childPath, options, print, prefix)];
  44048. }
  44049. return [prefix, align$1(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))];
  44050. function getPrefix() {
  44051. const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  44052. return node.isAligned ||
  44053. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  44054. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  44055. }
  44056. }
  44057. });
  44058. }
  44059. case "thematicBreak":
  44060. {
  44061. const counter = getAncestorCounter(path, "list");
  44062. if (counter === -1) {
  44063. return "---";
  44064. }
  44065. const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
  44066. return nthSiblingIndex % 2 === 0 ? "***" : "---";
  44067. }
  44068. case "linkReference":
  44069. return ["[", printChildren$4(path, options, print), "]", node.referenceType === "full" ? ["[", node.identifier, "]"] : node.referenceType === "collapsed" ? "[]" : ""];
  44070. case "imageReference":
  44071. switch (node.referenceType) {
  44072. case "full":
  44073. return ["![", node.alt || "", "][", node.identifier, "]"];
  44074. default:
  44075. return ["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""];
  44076. }
  44077. case "definition":
  44078. {
  44079. const lineOrSpace = options.proseWrap === "always" ? line$a : " ";
  44080. return group$7(["[", node.identifier, "]:", indent$3([lineOrSpace, printUrl(node.url), node.title === null ? "" : [lineOrSpace, printTitle(node.title, options, false)]])]);
  44081. }
  44082. // `footnote` requires `.use(footnotes, {inlineNotes: true})`, we are not using this option
  44083. // https://github.com/remarkjs/remark-footnotes#optionsinlinenotes
  44084. /* istanbul ignore next */
  44085. case "footnote":
  44086. return ["[^", printChildren$4(path, options, print), "]"];
  44087. case "footnoteReference":
  44088. return ["[^", node.identifier, "]"];
  44089. case "footnoteDefinition":
  44090. {
  44091. const nextNode = path.getParentNode().children[path.getName() + 1];
  44092. const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
  44093. return ["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$4(path, options, print) : group$7([align$1(" ".repeat(4), printChildren$4(path, options, print, {
  44094. processor: (childPath, index) => index === 0 ? group$7([softline$6, print()]) : print()
  44095. })), nextNode && nextNode.type === "footnoteDefinition" ? softline$6 : ""])];
  44096. }
  44097. case "table":
  44098. return printTable(path, options, print);
  44099. case "tableCell":
  44100. return printChildren$4(path, options, print);
  44101. case "break":
  44102. return /\s/.test(options.originalText[node.position.start.offset]) ? [" ", markAsRoot$1(literalline$3)] : ["\\", hardline$8];
  44103. case "liquidNode":
  44104. return replaceTextEndOfLine$7(node.value, hardline$8);
  44105. // MDX
  44106. // fallback to the original text if multiparser failed
  44107. // or `embeddedLanguageFormatting: "off"`
  44108. case "importExport":
  44109. return [node.value, hardline$8];
  44110. case "esComment":
  44111. return ["{/* ", node.value, " */}"];
  44112. case "jsx":
  44113. return node.value;
  44114. case "math":
  44115. return ["$$", hardline$8, node.value ? [...replaceTextEndOfLine$7(node.value, hardline$8), hardline$8] : "", "$$"];
  44116. case "inlineMath":
  44117. {
  44118. // remark-math trims content but we don't want to remove whitespaces
  44119. // since it's very possible that it's recognized as math accidentally
  44120. return options.originalText.slice(locStart$6(node), locEnd$5(node));
  44121. }
  44122. case "tableRow": // handled in "table"
  44123. case "listItem": // handled in "list"
  44124. default:
  44125. /* istanbul ignore next */
  44126. throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
  44127. }
  44128. }
  44129. function printListItem(path, options, print, listPrefix) {
  44130. const node = path.getValue();
  44131. const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  44132. return [prefix, printChildren$4(path, options, print, {
  44133. processor: (childPath, index) => {
  44134. if (index === 0 && childPath.getValue().type !== "list") {
  44135. return align$1(" ".repeat(prefix.length), print());
  44136. }
  44137. const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  44138. );
  44139. return [alignment, align$1(alignment, print())];
  44140. }
  44141. })];
  44142. }
  44143. function alignListPrefix(prefix, options) {
  44144. const additionalSpaces = getAdditionalSpaces();
  44145. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  44146. );
  44147. function getAdditionalSpaces() {
  44148. const restSpaces = prefix.length % options.tabWidth;
  44149. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  44150. }
  44151. }
  44152. function getNthListSiblingIndex(node, parentNode) {
  44153. return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
  44154. }
  44155. function getNthSiblingIndex(node, parentNode, condition) {
  44156. let index = -1;
  44157. for (const childNode of parentNode.children) {
  44158. if (childNode.type === node.type && condition(childNode)) {
  44159. index++;
  44160. } else {
  44161. index = -1;
  44162. }
  44163. if (childNode === node) {
  44164. return index;
  44165. }
  44166. }
  44167. }
  44168. function getAncestorCounter(path, typeOrTypes) {
  44169. const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes];
  44170. let counter = -1;
  44171. let ancestorNode;
  44172. while (ancestorNode = path.getParentNode(++counter)) {
  44173. if (types.includes(ancestorNode.type)) {
  44174. return counter;
  44175. }
  44176. }
  44177. return -1;
  44178. }
  44179. function getAncestorNode(path, typeOrTypes) {
  44180. const counter = getAncestorCounter(path, typeOrTypes);
  44181. return counter === -1 ? null : path.getParentNode(counter);
  44182. }
  44183. function printLine(path, value, options) {
  44184. if (options.proseWrap === "preserve" && value === "\n") {
  44185. return hardline$8;
  44186. }
  44187. const isBreakable = options.proseWrap === "always" && !getAncestorNode(path, SINGLE_LINE_NODE_TYPES);
  44188. return value !== "" ? isBreakable ? line$a : " " : isBreakable ? softline$6 : "";
  44189. }
  44190. function printTable(path, options, print) {
  44191. const node = path.getValue();
  44192. const columnMaxWidths = []; // { [rowIndex: number]: { [columnIndex: number]: {text: string, width: number} } }
  44193. const contents = path.map(rowPath => rowPath.map((cellPath, columnIndex) => {
  44194. const text = printDocToString(print(), options).formatted;
  44195. const width = getStringWidth(text);
  44196. columnMaxWidths[columnIndex] = Math.max(columnMaxWidths[columnIndex] || 3, // minimum width = 3 (---, :--, :-:, --:)
  44197. width);
  44198. return {
  44199. text,
  44200. width
  44201. };
  44202. }, "children"), "children");
  44203. const alignedTable = printTableContents(
  44204. /* isCompact */
  44205. false);
  44206. if (options.proseWrap !== "never") {
  44207. return [breakParent$4, alignedTable];
  44208. } // Only if the --prose-wrap never is set and it exceeds the print width.
  44209. const compactTable = printTableContents(
  44210. /* isCompact */
  44211. true);
  44212. return [breakParent$4, group$7(ifBreak$5(compactTable, alignedTable))];
  44213. function printTableContents(isCompact) {
  44214. /** @type{Doc[]} */
  44215. const parts = [printRow(contents[0], isCompact), printAlign(isCompact)];
  44216. if (contents.length > 1) {
  44217. parts.push(join$7(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents, isCompact))));
  44218. }
  44219. return join$7(hardlineWithoutBreakParent, parts);
  44220. }
  44221. function printAlign(isCompact) {
  44222. const align = columnMaxWidths.map((width, index) => {
  44223. const align = node.align[index];
  44224. const first = align === "center" || align === "left" ? ":" : "-";
  44225. const last = align === "center" || align === "right" ? ":" : "-";
  44226. const middle = isCompact ? "-" : "-".repeat(width - 2);
  44227. return `${first}${middle}${last}`;
  44228. });
  44229. return `| ${align.join(" | ")} |`;
  44230. }
  44231. function printRow(rowContents, isCompact) {
  44232. const columns = rowContents.map(({
  44233. text,
  44234. width
  44235. }, columnIndex) => {
  44236. if (isCompact) {
  44237. return text;
  44238. }
  44239. const spaces = columnMaxWidths[columnIndex] - width;
  44240. const align = node.align[columnIndex];
  44241. let before = 0;
  44242. if (align === "right") {
  44243. before = spaces;
  44244. } else if (align === "center") {
  44245. before = Math.floor(spaces / 2);
  44246. }
  44247. const after = spaces - before;
  44248. return `${" ".repeat(before)}${text}${" ".repeat(after)}`;
  44249. });
  44250. return `| ${columns.join(" | ")} |`;
  44251. }
  44252. }
  44253. function printRoot(path, options, print) {
  44254. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  44255. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  44256. const ignoreRanges = [];
  44257. /** @type {IgnorePosition | null} */
  44258. let ignoreStart = null;
  44259. const {
  44260. children
  44261. } = path.getValue();
  44262. for (const [index, childNode] of children.entries()) {
  44263. switch (isPrettierIgnore$2(childNode)) {
  44264. case "start":
  44265. if (ignoreStart === null) {
  44266. ignoreStart = {
  44267. index,
  44268. offset: childNode.position.end.offset
  44269. };
  44270. }
  44271. break;
  44272. case "end":
  44273. if (ignoreStart !== null) {
  44274. ignoreRanges.push({
  44275. start: ignoreStart,
  44276. end: {
  44277. index,
  44278. offset: childNode.position.start.offset
  44279. }
  44280. });
  44281. ignoreStart = null;
  44282. }
  44283. break;
  44284. }
  44285. }
  44286. return printChildren$4(path, options, print, {
  44287. processor: (childPath, index) => {
  44288. if (ignoreRanges.length > 0) {
  44289. const ignoreRange = ignoreRanges[0];
  44290. if (index === ignoreRange.start.index) {
  44291. return [children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value];
  44292. }
  44293. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  44294. return false;
  44295. }
  44296. if (index === ignoreRange.end.index) {
  44297. ignoreRanges.shift();
  44298. return false;
  44299. }
  44300. }
  44301. return print();
  44302. }
  44303. });
  44304. }
  44305. function printChildren$4(path, options, print, events = {}) {
  44306. const {
  44307. postprocessor
  44308. } = events;
  44309. const processor = events.processor || (() => print());
  44310. const node = path.getValue();
  44311. const parts = [];
  44312. let lastChildNode;
  44313. path.each((childPath, index) => {
  44314. const childNode = childPath.getValue();
  44315. const result = processor(childPath, index);
  44316. if (result !== false) {
  44317. const data = {
  44318. parts,
  44319. prevNode: lastChildNode,
  44320. parentNode: node,
  44321. options
  44322. };
  44323. if (shouldPrePrintHardline(childNode, data)) {
  44324. parts.push(hardline$8); // Can't find a case to pass `shouldPrePrintTripleHardline`
  44325. /* istanbul ignore next */
  44326. if (lastChildNode && TRAILING_HARDLINE_NODES.has(lastChildNode.type)) {
  44327. if (shouldPrePrintTripleHardline(childNode, data)) {
  44328. parts.push(hardline$8);
  44329. }
  44330. } else {
  44331. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  44332. parts.push(hardline$8);
  44333. }
  44334. if (shouldPrePrintTripleHardline(childNode, data)) {
  44335. parts.push(hardline$8);
  44336. }
  44337. }
  44338. }
  44339. parts.push(result);
  44340. lastChildNode = childNode;
  44341. }
  44342. }, "children");
  44343. return postprocessor ? postprocessor(parts) : parts;
  44344. }
  44345. function getLastDescendantNode$2(node) {
  44346. let current = node;
  44347. while (isNonEmptyArray$2(current.children)) {
  44348. current = getLast$3(current.children);
  44349. }
  44350. return current;
  44351. }
  44352. /** @return {false | 'next' | 'start' | 'end'} */
  44353. function isPrettierIgnore$2(node) {
  44354. let match;
  44355. if (node.type === "html") {
  44356. match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  44357. } else {
  44358. let comment;
  44359. if (node.type === "esComment") {
  44360. comment = node;
  44361. } else if (node.type === "paragraph" && node.children.length === 1 && node.children[0].type === "esComment") {
  44362. comment = node.children[0];
  44363. }
  44364. if (comment) {
  44365. match = comment.value.match(/^prettier-ignore(?:-(start|end))?$/);
  44366. }
  44367. }
  44368. return match ? match[1] ? match[1] : "next" : false;
  44369. }
  44370. function shouldPrePrintHardline(node, data) {
  44371. const isFirstNode = data.parts.length === 0;
  44372. const isInlineNode = INLINE_NODE_TYPES.includes(node.type);
  44373. const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.includes(data.parentNode.type);
  44374. return !isFirstNode && !isInlineNode && !isInlineHTML;
  44375. }
  44376. function shouldPrePrintDoubleHardline(node, data) {
  44377. const isSequence = (data.prevNode && data.prevNode.type) === node.type;
  44378. const isSiblingNode = isSequence && SIBLING_NODE_TYPES.has(node.type);
  44379. const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  44380. const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  44381. const isPrevNodePrettierIgnore = isPrettierIgnore$2(data.prevNode) === "next";
  44382. const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  44383. const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
  44384. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
  44385. }
  44386. function shouldPrePrintTripleHardline(node, data) {
  44387. const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  44388. const isIndentedCode = node.type === "code" && node.isIndented;
  44389. return isPrevNodeList && isIndentedCode;
  44390. }
  44391. function shouldRemainTheSameContent(path) {
  44392. const ancestorNode = getAncestorNode(path, ["linkReference", "imageReference"]);
  44393. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  44394. }
  44395. /**
  44396. * @param {string} url
  44397. * @param {string[] | string} [dangerousCharOrChars]
  44398. * @returns {string}
  44399. */
  44400. function printUrl(url, dangerousCharOrChars = []) {
  44401. const dangerousChars = [" ", ...(Array.isArray(dangerousCharOrChars) ? dangerousCharOrChars : [dangerousCharOrChars])];
  44402. return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
  44403. }
  44404. function printTitle(title, options, printSpace = true) {
  44405. if (!title) {
  44406. return "";
  44407. }
  44408. if (printSpace) {
  44409. return " " + printTitle(title, options, false);
  44410. } // title is escaped after `remark-parse` v7
  44411. title = title.replace(/\\(["')])/g, "$1");
  44412. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  44413. return `(${title})`; // avoid escaped quotes
  44414. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  44415. const singleCount = title.split("'").length - 1;
  44416. const doubleCount = title.split('"').length - 1;
  44417. const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  44418. title = title.replace(/\\/, "\\\\");
  44419. title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
  44420. return `${quote}${title}${quote}`;
  44421. }
  44422. function clamp(value, min, max) {
  44423. return value < min ? min : value > max ? max : value;
  44424. }
  44425. function hasPrettierIgnore$5(path) {
  44426. const index = Number(path.getName());
  44427. if (index === 0) {
  44428. return false;
  44429. }
  44430. const prevNode = path.getParentNode().children[index - 1];
  44431. return isPrettierIgnore$2(prevNode) === "next";
  44432. }
  44433. var printerMarkdown = {
  44434. preprocess: preprocess$4,
  44435. print: genericPrint$2,
  44436. embed: embed$5,
  44437. massageAstNode: clean$3,
  44438. hasPrettierIgnore: hasPrettierIgnore$5,
  44439. insertPragma: insertPragma$4
  44440. };
  44441. const commonOptions$2 = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  44442. var options$5 = {
  44443. proseWrap: commonOptions$2.proseWrap,
  44444. singleQuote: commonOptions$2.singleQuote
  44445. };
  44446. var parsers$5 = {
  44447. /* istanbul ignore next */
  44448. get remark() {
  44449. return require("./parser-markdown.js").parsers.remark;
  44450. },
  44451. get markdown() {
  44452. return require("./parser-markdown.js").parsers.remark;
  44453. },
  44454. get mdx() {
  44455. return require("./parser-markdown.js").parsers.mdx;
  44456. }
  44457. };
  44458. var name$3 = "Markdown";
  44459. var type$3 = "prose";
  44460. var color$3 = "#083fa1";
  44461. var aliases$2 = [
  44462. "pandoc"
  44463. ];
  44464. var aceMode$3 = "markdown";
  44465. var codemirrorMode$2 = "gfm";
  44466. var codemirrorMimeType$2 = "text/x-gfm";
  44467. var wrap = true;
  44468. var extensions$3 = [
  44469. ".md",
  44470. ".markdown",
  44471. ".mdown",
  44472. ".mdwn",
  44473. ".mdx",
  44474. ".mkd",
  44475. ".mkdn",
  44476. ".mkdown",
  44477. ".ronn",
  44478. ".scd",
  44479. ".workbook"
  44480. ];
  44481. var filenames$1 = [
  44482. "contents.lr"
  44483. ];
  44484. var tmScope$3 = "source.gfm";
  44485. var languageId$3 = 222;
  44486. var require$$4$3 = {
  44487. name: name$3,
  44488. type: type$3,
  44489. color: color$3,
  44490. aliases: aliases$2,
  44491. aceMode: aceMode$3,
  44492. codemirrorMode: codemirrorMode$2,
  44493. codemirrorMimeType: codemirrorMimeType$2,
  44494. wrap: wrap,
  44495. extensions: extensions$3,
  44496. filenames: filenames$1,
  44497. tmScope: tmScope$3,
  44498. languageId: languageId$3
  44499. };
  44500. const createLanguage$2 = createLanguage$7;
  44501. const printer$2 = printerMarkdown;
  44502. const options$4 = options$5;
  44503. const parsers$4 = parsers$5;
  44504. const languages$3 = [createLanguage$2(require$$4$3, data => ({
  44505. since: "1.8.0",
  44506. parsers: ["markdown"],
  44507. vscodeLanguageIds: ["markdown"],
  44508. filenames: [...data.filenames, "README"],
  44509. extensions: data.extensions.filter(extension => extension !== ".mdx")
  44510. })), createLanguage$2(require$$4$3, () => ({
  44511. name: "MDX",
  44512. since: "1.15.0",
  44513. parsers: ["mdx"],
  44514. vscodeLanguageIds: ["mdx"],
  44515. filenames: [],
  44516. extensions: [".mdx"]
  44517. }))];
  44518. const printers$1 = {
  44519. mdast: printer$2
  44520. };
  44521. var languageMarkdown = {
  44522. languages: languages$3,
  44523. options: options$4,
  44524. printers: printers$1,
  44525. parsers: parsers$4
  44526. };
  44527. const {
  44528. isFrontMatterNode: isFrontMatterNode$1
  44529. } = util$8;
  44530. const ignoredProperties = new Set(["sourceSpan", "startSourceSpan", "endSourceSpan", "nameSpan", "valueSpan"]);
  44531. function clean$2(ast, newNode) {
  44532. if (ast.type === "text" || ast.type === "comment") {
  44533. return null;
  44534. } // may be formatted by multiparser
  44535. if (isFrontMatterNode$1(ast) || ast.type === "yaml" || ast.type === "toml") {
  44536. return null;
  44537. }
  44538. if (ast.type === "attribute") {
  44539. delete newNode.value;
  44540. }
  44541. if (ast.type === "docType") {
  44542. delete newNode.value;
  44543. }
  44544. }
  44545. clean$2.ignoredProperties = ignoredProperties;
  44546. var clean_1 = clean$2;
  44547. var require$$0 = [
  44548. "a",
  44549. "abbr",
  44550. "acronym",
  44551. "address",
  44552. "applet",
  44553. "area",
  44554. "article",
  44555. "aside",
  44556. "audio",
  44557. "b",
  44558. "base",
  44559. "basefont",
  44560. "bdi",
  44561. "bdo",
  44562. "bgsound",
  44563. "big",
  44564. "blink",
  44565. "blockquote",
  44566. "body",
  44567. "br",
  44568. "button",
  44569. "canvas",
  44570. "caption",
  44571. "center",
  44572. "cite",
  44573. "code",
  44574. "col",
  44575. "colgroup",
  44576. "command",
  44577. "content",
  44578. "data",
  44579. "datalist",
  44580. "dd",
  44581. "del",
  44582. "details",
  44583. "dfn",
  44584. "dialog",
  44585. "dir",
  44586. "div",
  44587. "dl",
  44588. "dt",
  44589. "element",
  44590. "em",
  44591. "embed",
  44592. "fieldset",
  44593. "figcaption",
  44594. "figure",
  44595. "font",
  44596. "footer",
  44597. "form",
  44598. "frame",
  44599. "frameset",
  44600. "h1",
  44601. "h2",
  44602. "h3",
  44603. "h4",
  44604. "h5",
  44605. "h6",
  44606. "head",
  44607. "header",
  44608. "hgroup",
  44609. "hr",
  44610. "html",
  44611. "i",
  44612. "iframe",
  44613. "image",
  44614. "img",
  44615. "input",
  44616. "ins",
  44617. "isindex",
  44618. "kbd",
  44619. "keygen",
  44620. "label",
  44621. "legend",
  44622. "li",
  44623. "link",
  44624. "listing",
  44625. "main",
  44626. "map",
  44627. "mark",
  44628. "marquee",
  44629. "math",
  44630. "menu",
  44631. "menuitem",
  44632. "meta",
  44633. "meter",
  44634. "multicol",
  44635. "nav",
  44636. "nextid",
  44637. "nobr",
  44638. "noembed",
  44639. "noframes",
  44640. "noscript",
  44641. "object",
  44642. "ol",
  44643. "optgroup",
  44644. "option",
  44645. "output",
  44646. "p",
  44647. "param",
  44648. "picture",
  44649. "plaintext",
  44650. "pre",
  44651. "progress",
  44652. "q",
  44653. "rb",
  44654. "rbc",
  44655. "rp",
  44656. "rt",
  44657. "rtc",
  44658. "ruby",
  44659. "s",
  44660. "samp",
  44661. "script",
  44662. "section",
  44663. "select",
  44664. "shadow",
  44665. "slot",
  44666. "small",
  44667. "source",
  44668. "spacer",
  44669. "span",
  44670. "strike",
  44671. "strong",
  44672. "style",
  44673. "sub",
  44674. "summary",
  44675. "sup",
  44676. "svg",
  44677. "table",
  44678. "tbody",
  44679. "td",
  44680. "template",
  44681. "textarea",
  44682. "tfoot",
  44683. "th",
  44684. "thead",
  44685. "time",
  44686. "title",
  44687. "tr",
  44688. "track",
  44689. "tt",
  44690. "u",
  44691. "ul",
  44692. "var",
  44693. "video",
  44694. "wbr",
  44695. "xmp"
  44696. ];
  44697. var a = [
  44698. "accesskey",
  44699. "charset",
  44700. "coords",
  44701. "download",
  44702. "href",
  44703. "hreflang",
  44704. "name",
  44705. "ping",
  44706. "referrerpolicy",
  44707. "rel",
  44708. "rev",
  44709. "shape",
  44710. "tabindex",
  44711. "target",
  44712. "type"
  44713. ];
  44714. var abbr = [
  44715. "title"
  44716. ];
  44717. var applet = [
  44718. "align",
  44719. "alt",
  44720. "archive",
  44721. "code",
  44722. "codebase",
  44723. "height",
  44724. "hspace",
  44725. "name",
  44726. "object",
  44727. "vspace",
  44728. "width"
  44729. ];
  44730. var area = [
  44731. "accesskey",
  44732. "alt",
  44733. "coords",
  44734. "download",
  44735. "href",
  44736. "hreflang",
  44737. "nohref",
  44738. "ping",
  44739. "referrerpolicy",
  44740. "rel",
  44741. "shape",
  44742. "tabindex",
  44743. "target",
  44744. "type"
  44745. ];
  44746. var audio = [
  44747. "autoplay",
  44748. "controls",
  44749. "crossorigin",
  44750. "loop",
  44751. "muted",
  44752. "preload",
  44753. "src"
  44754. ];
  44755. var base = [
  44756. "href",
  44757. "target"
  44758. ];
  44759. var basefont = [
  44760. "color",
  44761. "face",
  44762. "size"
  44763. ];
  44764. var bdo = [
  44765. "dir"
  44766. ];
  44767. var blockquote = [
  44768. "cite"
  44769. ];
  44770. var body = [
  44771. "alink",
  44772. "background",
  44773. "bgcolor",
  44774. "link",
  44775. "text",
  44776. "vlink"
  44777. ];
  44778. var br = [
  44779. "clear"
  44780. ];
  44781. var button = [
  44782. "accesskey",
  44783. "autofocus",
  44784. "disabled",
  44785. "form",
  44786. "formaction",
  44787. "formenctype",
  44788. "formmethod",
  44789. "formnovalidate",
  44790. "formtarget",
  44791. "name",
  44792. "tabindex",
  44793. "type",
  44794. "value"
  44795. ];
  44796. var canvas = [
  44797. "height",
  44798. "width"
  44799. ];
  44800. var caption = [
  44801. "align"
  44802. ];
  44803. var col = [
  44804. "align",
  44805. "char",
  44806. "charoff",
  44807. "span",
  44808. "valign",
  44809. "width"
  44810. ];
  44811. var colgroup = [
  44812. "align",
  44813. "char",
  44814. "charoff",
  44815. "span",
  44816. "valign",
  44817. "width"
  44818. ];
  44819. var data = [
  44820. "value"
  44821. ];
  44822. var del = [
  44823. "cite",
  44824. "datetime"
  44825. ];
  44826. var details = [
  44827. "open"
  44828. ];
  44829. var dfn = [
  44830. "title"
  44831. ];
  44832. var dialog = [
  44833. "open"
  44834. ];
  44835. var dir = [
  44836. "compact"
  44837. ];
  44838. var div = [
  44839. "align"
  44840. ];
  44841. var dl = [
  44842. "compact"
  44843. ];
  44844. var embed$4 = [
  44845. "height",
  44846. "src",
  44847. "type",
  44848. "width"
  44849. ];
  44850. var fieldset = [
  44851. "disabled",
  44852. "form",
  44853. "name"
  44854. ];
  44855. var font = [
  44856. "color",
  44857. "face",
  44858. "size"
  44859. ];
  44860. var form = [
  44861. "accept",
  44862. "accept-charset",
  44863. "action",
  44864. "autocomplete",
  44865. "enctype",
  44866. "method",
  44867. "name",
  44868. "novalidate",
  44869. "target"
  44870. ];
  44871. var frame = [
  44872. "frameborder",
  44873. "longdesc",
  44874. "marginheight",
  44875. "marginwidth",
  44876. "name",
  44877. "noresize",
  44878. "scrolling",
  44879. "src"
  44880. ];
  44881. var frameset = [
  44882. "cols",
  44883. "rows"
  44884. ];
  44885. var h1 = [
  44886. "align"
  44887. ];
  44888. var h2 = [
  44889. "align"
  44890. ];
  44891. var h3 = [
  44892. "align"
  44893. ];
  44894. var h4 = [
  44895. "align"
  44896. ];
  44897. var h5 = [
  44898. "align"
  44899. ];
  44900. var h6 = [
  44901. "align"
  44902. ];
  44903. var head = [
  44904. "profile"
  44905. ];
  44906. var hr = [
  44907. "align",
  44908. "noshade",
  44909. "size",
  44910. "width"
  44911. ];
  44912. var html = [
  44913. "manifest",
  44914. "version"
  44915. ];
  44916. var iframe = [
  44917. "align",
  44918. "allow",
  44919. "allowfullscreen",
  44920. "allowpaymentrequest",
  44921. "allowusermedia",
  44922. "frameborder",
  44923. "height",
  44924. "loading",
  44925. "longdesc",
  44926. "marginheight",
  44927. "marginwidth",
  44928. "name",
  44929. "referrerpolicy",
  44930. "sandbox",
  44931. "scrolling",
  44932. "src",
  44933. "srcdoc",
  44934. "width"
  44935. ];
  44936. var img = [
  44937. "align",
  44938. "alt",
  44939. "border",
  44940. "crossorigin",
  44941. "decoding",
  44942. "height",
  44943. "hspace",
  44944. "ismap",
  44945. "loading",
  44946. "longdesc",
  44947. "name",
  44948. "referrerpolicy",
  44949. "sizes",
  44950. "src",
  44951. "srcset",
  44952. "usemap",
  44953. "vspace",
  44954. "width"
  44955. ];
  44956. var input = [
  44957. "accept",
  44958. "accesskey",
  44959. "align",
  44960. "alt",
  44961. "autocomplete",
  44962. "autofocus",
  44963. "checked",
  44964. "dirname",
  44965. "disabled",
  44966. "form",
  44967. "formaction",
  44968. "formenctype",
  44969. "formmethod",
  44970. "formnovalidate",
  44971. "formtarget",
  44972. "height",
  44973. "ismap",
  44974. "list",
  44975. "max",
  44976. "maxlength",
  44977. "min",
  44978. "minlength",
  44979. "multiple",
  44980. "name",
  44981. "pattern",
  44982. "placeholder",
  44983. "readonly",
  44984. "required",
  44985. "size",
  44986. "src",
  44987. "step",
  44988. "tabindex",
  44989. "title",
  44990. "type",
  44991. "usemap",
  44992. "value",
  44993. "width"
  44994. ];
  44995. var ins = [
  44996. "cite",
  44997. "datetime"
  44998. ];
  44999. var isindex = [
  45000. "prompt"
  45001. ];
  45002. var label = [
  45003. "accesskey",
  45004. "for",
  45005. "form"
  45006. ];
  45007. var legend = [
  45008. "accesskey",
  45009. "align"
  45010. ];
  45011. var li = [
  45012. "type",
  45013. "value"
  45014. ];
  45015. var link = [
  45016. "as",
  45017. "charset",
  45018. "color",
  45019. "crossorigin",
  45020. "disabled",
  45021. "href",
  45022. "hreflang",
  45023. "imagesizes",
  45024. "imagesrcset",
  45025. "integrity",
  45026. "media",
  45027. "nonce",
  45028. "referrerpolicy",
  45029. "rel",
  45030. "rev",
  45031. "sizes",
  45032. "target",
  45033. "title",
  45034. "type"
  45035. ];
  45036. var map = [
  45037. "name"
  45038. ];
  45039. var menu = [
  45040. "compact"
  45041. ];
  45042. var meta = [
  45043. "charset",
  45044. "content",
  45045. "http-equiv",
  45046. "name",
  45047. "scheme"
  45048. ];
  45049. var meter = [
  45050. "high",
  45051. "low",
  45052. "max",
  45053. "min",
  45054. "optimum",
  45055. "value"
  45056. ];
  45057. var object = [
  45058. "align",
  45059. "archive",
  45060. "border",
  45061. "classid",
  45062. "codebase",
  45063. "codetype",
  45064. "data",
  45065. "declare",
  45066. "form",
  45067. "height",
  45068. "hspace",
  45069. "name",
  45070. "standby",
  45071. "tabindex",
  45072. "type",
  45073. "typemustmatch",
  45074. "usemap",
  45075. "vspace",
  45076. "width"
  45077. ];
  45078. var ol = [
  45079. "compact",
  45080. "reversed",
  45081. "start",
  45082. "type"
  45083. ];
  45084. var optgroup = [
  45085. "disabled",
  45086. "label"
  45087. ];
  45088. var option = [
  45089. "disabled",
  45090. "label",
  45091. "selected",
  45092. "value"
  45093. ];
  45094. var output = [
  45095. "for",
  45096. "form",
  45097. "name"
  45098. ];
  45099. var p = [
  45100. "align"
  45101. ];
  45102. var param = [
  45103. "name",
  45104. "type",
  45105. "value",
  45106. "valuetype"
  45107. ];
  45108. var pre = [
  45109. "width"
  45110. ];
  45111. var progress = [
  45112. "max",
  45113. "value"
  45114. ];
  45115. var q = [
  45116. "cite"
  45117. ];
  45118. var script = [
  45119. "async",
  45120. "charset",
  45121. "crossorigin",
  45122. "defer",
  45123. "integrity",
  45124. "language",
  45125. "nomodule",
  45126. "nonce",
  45127. "referrerpolicy",
  45128. "src",
  45129. "type"
  45130. ];
  45131. var select = [
  45132. "autocomplete",
  45133. "autofocus",
  45134. "disabled",
  45135. "form",
  45136. "multiple",
  45137. "name",
  45138. "required",
  45139. "size",
  45140. "tabindex"
  45141. ];
  45142. var slot = [
  45143. "name"
  45144. ];
  45145. var source = [
  45146. "media",
  45147. "sizes",
  45148. "src",
  45149. "srcset",
  45150. "type"
  45151. ];
  45152. var style = [
  45153. "media",
  45154. "nonce",
  45155. "title",
  45156. "type"
  45157. ];
  45158. var table = [
  45159. "align",
  45160. "bgcolor",
  45161. "border",
  45162. "cellpadding",
  45163. "cellspacing",
  45164. "frame",
  45165. "rules",
  45166. "summary",
  45167. "width"
  45168. ];
  45169. var tbody = [
  45170. "align",
  45171. "char",
  45172. "charoff",
  45173. "valign"
  45174. ];
  45175. var td = [
  45176. "abbr",
  45177. "align",
  45178. "axis",
  45179. "bgcolor",
  45180. "char",
  45181. "charoff",
  45182. "colspan",
  45183. "headers",
  45184. "height",
  45185. "nowrap",
  45186. "rowspan",
  45187. "scope",
  45188. "valign",
  45189. "width"
  45190. ];
  45191. var textarea = [
  45192. "accesskey",
  45193. "autocomplete",
  45194. "autofocus",
  45195. "cols",
  45196. "dirname",
  45197. "disabled",
  45198. "form",
  45199. "maxlength",
  45200. "minlength",
  45201. "name",
  45202. "placeholder",
  45203. "readonly",
  45204. "required",
  45205. "rows",
  45206. "tabindex",
  45207. "wrap"
  45208. ];
  45209. var tfoot = [
  45210. "align",
  45211. "char",
  45212. "charoff",
  45213. "valign"
  45214. ];
  45215. var th = [
  45216. "abbr",
  45217. "align",
  45218. "axis",
  45219. "bgcolor",
  45220. "char",
  45221. "charoff",
  45222. "colspan",
  45223. "headers",
  45224. "height",
  45225. "nowrap",
  45226. "rowspan",
  45227. "scope",
  45228. "valign",
  45229. "width"
  45230. ];
  45231. var thead = [
  45232. "align",
  45233. "char",
  45234. "charoff",
  45235. "valign"
  45236. ];
  45237. var time = [
  45238. "datetime"
  45239. ];
  45240. var tr = [
  45241. "align",
  45242. "bgcolor",
  45243. "char",
  45244. "charoff",
  45245. "valign"
  45246. ];
  45247. var track = [
  45248. "default",
  45249. "kind",
  45250. "label",
  45251. "src",
  45252. "srclang"
  45253. ];
  45254. var ul = [
  45255. "compact",
  45256. "type"
  45257. ];
  45258. var video = [
  45259. "autoplay",
  45260. "controls",
  45261. "crossorigin",
  45262. "height",
  45263. "loop",
  45264. "muted",
  45265. "playsinline",
  45266. "poster",
  45267. "preload",
  45268. "src",
  45269. "width"
  45270. ];
  45271. var require$$1 = {
  45272. "*": [
  45273. "accesskey",
  45274. "autocapitalize",
  45275. "autofocus",
  45276. "class",
  45277. "contenteditable",
  45278. "dir",
  45279. "draggable",
  45280. "enterkeyhint",
  45281. "hidden",
  45282. "id",
  45283. "inputmode",
  45284. "is",
  45285. "itemid",
  45286. "itemprop",
  45287. "itemref",
  45288. "itemscope",
  45289. "itemtype",
  45290. "lang",
  45291. "nonce",
  45292. "slot",
  45293. "spellcheck",
  45294. "style",
  45295. "tabindex",
  45296. "title",
  45297. "translate"
  45298. ],
  45299. a: a,
  45300. abbr: abbr,
  45301. applet: applet,
  45302. area: area,
  45303. audio: audio,
  45304. base: base,
  45305. basefont: basefont,
  45306. bdo: bdo,
  45307. blockquote: blockquote,
  45308. body: body,
  45309. br: br,
  45310. button: button,
  45311. canvas: canvas,
  45312. caption: caption,
  45313. col: col,
  45314. colgroup: colgroup,
  45315. data: data,
  45316. del: del,
  45317. details: details,
  45318. dfn: dfn,
  45319. dialog: dialog,
  45320. dir: dir,
  45321. div: div,
  45322. dl: dl,
  45323. embed: embed$4,
  45324. fieldset: fieldset,
  45325. font: font,
  45326. form: form,
  45327. frame: frame,
  45328. frameset: frameset,
  45329. h1: h1,
  45330. h2: h2,
  45331. h3: h3,
  45332. h4: h4,
  45333. h5: h5,
  45334. h6: h6,
  45335. head: head,
  45336. hr: hr,
  45337. html: html,
  45338. iframe: iframe,
  45339. img: img,
  45340. input: input,
  45341. ins: ins,
  45342. isindex: isindex,
  45343. label: label,
  45344. legend: legend,
  45345. li: li,
  45346. link: link,
  45347. map: map,
  45348. menu: menu,
  45349. meta: meta,
  45350. meter: meter,
  45351. object: object,
  45352. ol: ol,
  45353. optgroup: optgroup,
  45354. option: option,
  45355. output: output,
  45356. p: p,
  45357. param: param,
  45358. pre: pre,
  45359. progress: progress,
  45360. q: q,
  45361. script: script,
  45362. select: select,
  45363. slot: slot,
  45364. source: source,
  45365. style: style,
  45366. table: table,
  45367. tbody: tbody,
  45368. td: td,
  45369. textarea: textarea,
  45370. tfoot: tfoot,
  45371. th: th,
  45372. thead: thead,
  45373. time: time,
  45374. tr: tr,
  45375. track: track,
  45376. ul: ul,
  45377. video: video
  45378. };
  45379. var require$$4$2 = {
  45380. "CSS_DISPLAY_TAGS": {
  45381. "area": "none",
  45382. "base": "none",
  45383. "basefont": "none",
  45384. "datalist": "none",
  45385. "head": "none",
  45386. "link": "none",
  45387. "meta": "none",
  45388. "noembed": "none",
  45389. "noframes": "none",
  45390. "param": "block",
  45391. "rp": "none",
  45392. "script": "block",
  45393. "source": "block",
  45394. "style": "none",
  45395. "template": "inline",
  45396. "track": "block",
  45397. "title": "none",
  45398. "html": "block",
  45399. "body": "block",
  45400. "address": "block",
  45401. "blockquote": "block",
  45402. "center": "block",
  45403. "div": "block",
  45404. "figure": "block",
  45405. "figcaption": "block",
  45406. "footer": "block",
  45407. "form": "block",
  45408. "header": "block",
  45409. "hr": "block",
  45410. "legend": "block",
  45411. "listing": "block",
  45412. "main": "block",
  45413. "p": "block",
  45414. "plaintext": "block",
  45415. "pre": "block",
  45416. "xmp": "block",
  45417. "slot": "contents",
  45418. "ruby": "ruby",
  45419. "rt": "ruby-text",
  45420. "article": "block",
  45421. "aside": "block",
  45422. "h1": "block",
  45423. "h2": "block",
  45424. "h3": "block",
  45425. "h4": "block",
  45426. "h5": "block",
  45427. "h6": "block",
  45428. "hgroup": "block",
  45429. "nav": "block",
  45430. "section": "block",
  45431. "dir": "block",
  45432. "dd": "block",
  45433. "dl": "block",
  45434. "dt": "block",
  45435. "ol": "block",
  45436. "ul": "block",
  45437. "li": "list-item",
  45438. "table": "table",
  45439. "caption": "table-caption",
  45440. "colgroup": "table-column-group",
  45441. "col": "table-column",
  45442. "thead": "table-header-group",
  45443. "tbody": "table-row-group",
  45444. "tfoot": "table-footer-group",
  45445. "tr": "table-row",
  45446. "td": "table-cell",
  45447. "th": "table-cell",
  45448. "fieldset": "block",
  45449. "button": "inline-block",
  45450. "details": "block",
  45451. "summary": "block",
  45452. "dialog": "block",
  45453. "meter": "inline-block",
  45454. "progress": "inline-block",
  45455. "object": "inline-block",
  45456. "video": "inline-block",
  45457. "audio": "inline-block",
  45458. "select": "inline-block",
  45459. "option": "block",
  45460. "optgroup": "block"
  45461. },
  45462. "CSS_DISPLAY_DEFAULT": "inline",
  45463. "CSS_WHITE_SPACE_TAGS": {
  45464. "listing": "pre",
  45465. "plaintext": "pre",
  45466. "pre": "pre",
  45467. "xmp": "pre",
  45468. "nobr": "nowrap",
  45469. "table": "initial",
  45470. "textarea": "pre-wrap"
  45471. },
  45472. "CSS_WHITE_SPACE_DEFAULT": "normal"
  45473. };
  45474. /**
  45475. * @typedef {import("../common/ast-path")} AstPath
  45476. */
  45477. const htmlTagNames = require$$0;
  45478. const htmlElementAttributes = require$$1;
  45479. const {
  45480. inferParserByLanguage,
  45481. isFrontMatterNode
  45482. } = util$8;
  45483. const {
  45484. builders: {
  45485. line: line$9,
  45486. hardline: hardline$7,
  45487. join: join$6
  45488. },
  45489. utils: {
  45490. getDocParts: getDocParts$3,
  45491. replaceTextEndOfLine: replaceTextEndOfLine$6
  45492. }
  45493. } = require$$7$3;
  45494. const {
  45495. CSS_DISPLAY_TAGS,
  45496. CSS_DISPLAY_DEFAULT,
  45497. CSS_WHITE_SPACE_TAGS,
  45498. CSS_WHITE_SPACE_DEFAULT
  45499. } = require$$4$2;
  45500. const HTML_TAGS = arrayToMap(htmlTagNames);
  45501. const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes, arrayToMap); // https://infra.spec.whatwg.org/#ascii-whitespace
  45502. const HTML_WHITESPACE = new Set(["\t", "\n", "\f", "\r", " "]);
  45503. const htmlTrimStart = string => string.replace(/^[\t\n\f\r ]+/, "");
  45504. const htmlTrimEnd = string => string.replace(/[\t\n\f\r ]+$/, "");
  45505. const htmlTrim$1 = string => htmlTrimStart(htmlTrimEnd(string));
  45506. const htmlTrimLeadingBlankLines = string => string.replace(/^[\t\f\r ]*?\n/g, "");
  45507. const htmlTrimPreserveIndentation$1 = string => htmlTrimLeadingBlankLines(htmlTrimEnd(string));
  45508. const splitByHtmlWhitespace = string => string.split(/[\t\n\f\r ]+/);
  45509. const getLeadingHtmlWhitespace = string => string.match(/^[\t\n\f\r ]*/)[0];
  45510. const getLeadingAndTrailingHtmlWhitespace$1 = string => {
  45511. const [, leadingWhitespace, text, trailingWhitespace] = string.match(/^([\t\n\f\r ]*)(.*?)([\t\n\f\r ]*)$/s);
  45512. return {
  45513. leadingWhitespace,
  45514. trailingWhitespace,
  45515. text
  45516. };
  45517. };
  45518. const hasHtmlWhitespace$1 = string => /[\t\n\f\r ]/.test(string);
  45519. function arrayToMap(array) {
  45520. const map = Object.create(null);
  45521. for (const value of array) {
  45522. map[value] = true;
  45523. }
  45524. return map;
  45525. }
  45526. function mapObject(object, fn) {
  45527. const newObject = Object.create(null);
  45528. for (const [key, value] of Object.entries(object)) {
  45529. newObject[key] = fn(value, key);
  45530. }
  45531. return newObject;
  45532. }
  45533. function shouldPreserveContent$2(node, options) {
  45534. // unterminated node in ie conditional comment
  45535. // e.g. <!--[if lt IE 9]><html><![endif]-->
  45536. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  45537. return true;
  45538. } // incomplete html in ie conditional comment
  45539. // e.g. <!--[if lt IE 9]></div><![endif]-->
  45540. if (node.type === "ieConditionalComment" && !node.complete) {
  45541. return true;
  45542. } // TODO: handle non-text children in <pre>
  45543. if (isPreLikeNode$1(node) && node.children.some(child => child.type !== "text" && child.type !== "interpolation")) {
  45544. return true;
  45545. }
  45546. if (isVueNonHtmlBlock$1(node, options) && !isScriptLikeTag$2(node) && node.type !== "interpolation") {
  45547. return true;
  45548. }
  45549. return false;
  45550. }
  45551. function hasPrettierIgnore$4(node) {
  45552. /* istanbul ignore next */
  45553. if (node.type === "attribute") {
  45554. return false;
  45555. }
  45556. /* istanbul ignore next */
  45557. if (!node.parent) {
  45558. return false;
  45559. }
  45560. if (typeof node.index !== "number" || node.index === 0) {
  45561. return false;
  45562. }
  45563. const prevNode = node.parent.children[node.index - 1];
  45564. return isPrettierIgnore$1(prevNode);
  45565. }
  45566. function isPrettierIgnore$1(node) {
  45567. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  45568. }
  45569. /** there's no opening/closing tag or it's considered not breakable */
  45570. function isTextLikeNode$2(node) {
  45571. return node.type === "text" || node.type === "comment";
  45572. }
  45573. function isScriptLikeTag$2(node) {
  45574. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style" || isUnknownNamespace(node) && (node.name === "script" || node.name === "style"));
  45575. }
  45576. function canHaveInterpolation$1(node) {
  45577. return node.children && !isScriptLikeTag$2(node);
  45578. }
  45579. function isWhitespaceSensitiveNode$1(node) {
  45580. return isScriptLikeTag$2(node) || node.type === "interpolation" || isIndentationSensitiveNode$1(node);
  45581. }
  45582. function isIndentationSensitiveNode$1(node) {
  45583. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  45584. }
  45585. function isLeadingSpaceSensitiveNode$1(node, options) {
  45586. const isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  45587. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  45588. return node.type === "interpolation";
  45589. }
  45590. return isLeadingSpaceSensitive;
  45591. function _isLeadingSpaceSensitiveNode() {
  45592. if (isFrontMatterNode(node)) {
  45593. return false;
  45594. }
  45595. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  45596. return true;
  45597. }
  45598. if (!node.parent || node.parent.cssDisplay === "none") {
  45599. return false;
  45600. }
  45601. if (isPreLikeNode$1(node.parent)) {
  45602. return true;
  45603. }
  45604. if (!node.prev && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  45605. return false;
  45606. }
  45607. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  45608. return false;
  45609. }
  45610. return true;
  45611. }
  45612. }
  45613. function isTrailingSpaceSensitiveNode$1(node, options) {
  45614. if (isFrontMatterNode(node)) {
  45615. return false;
  45616. }
  45617. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  45618. return true;
  45619. }
  45620. if (!node.parent || node.parent.cssDisplay === "none") {
  45621. return false;
  45622. }
  45623. if (isPreLikeNode$1(node.parent)) {
  45624. return true;
  45625. }
  45626. if (!node.next && (node.parent.type === "root" || isPreLikeNode$1(node) && node.parent || isScriptLikeTag$2(node.parent) || isVueCustomBlock$1(node.parent, options) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  45627. return false;
  45628. }
  45629. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  45630. return false;
  45631. }
  45632. return true;
  45633. }
  45634. function isDanglingSpaceSensitiveNode$1(node) {
  45635. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$2(node);
  45636. }
  45637. function forceNextEmptyLine$1(node) {
  45638. return isFrontMatterNode(node) || node.next && node.sourceSpan.end && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  45639. }
  45640. /** firstChild leadingSpaces and lastChild trailingSpaces */
  45641. function forceBreakContent$1(node) {
  45642. return forceBreakChildren$1(node) || node.type === "element" && node.children.length > 0 && (["body", "script", "style"].includes(node.name) || node.children.some(child => hasNonTextChild(child))) || node.firstChild && node.firstChild === node.lastChild && node.firstChild.type !== "text" && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  45643. }
  45644. /** spaces between children */
  45645. function forceBreakChildren$1(node) {
  45646. return node.type === "element" && node.children.length > 0 && (["html", "head", "ul", "ol", "select"].includes(node.name) || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
  45647. }
  45648. function preferHardlineAsLeadingSpaces$1(node) {
  45649. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  45650. }
  45651. function preferHardlineAsTrailingSpaces(node) {
  45652. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  45653. }
  45654. function hasSurroundingLineBreak(node) {
  45655. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  45656. }
  45657. function hasLeadingLineBreak(node) {
  45658. 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);
  45659. }
  45660. function hasTrailingLineBreak(node) {
  45661. return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan && node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
  45662. }
  45663. function preferHardlineAsSurroundingSpaces(node) {
  45664. switch (node.type) {
  45665. case "ieConditionalComment":
  45666. case "comment":
  45667. case "directive":
  45668. return true;
  45669. case "element":
  45670. return ["script", "select"].includes(node.name);
  45671. }
  45672. return false;
  45673. }
  45674. function getLastDescendant$1(node) {
  45675. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  45676. }
  45677. function hasNonTextChild(node) {
  45678. return node.children && node.children.some(child => child.type !== "text");
  45679. }
  45680. function _inferScriptParser(node) {
  45681. const {
  45682. type,
  45683. lang
  45684. } = node.attrMap;
  45685. if (type === "module" || type === "text/javascript" || type === "text/babel" || type === "application/javascript" || lang === "jsx") {
  45686. return "babel";
  45687. }
  45688. if (type === "application/x-typescript" || lang === "ts" || lang === "tsx") {
  45689. return "typescript";
  45690. }
  45691. if (type === "text/markdown") {
  45692. return "markdown";
  45693. }
  45694. if (type === "text/html") {
  45695. return "html";
  45696. }
  45697. if (type && (type.endsWith("json") || type.endsWith("importmap"))) {
  45698. return "json";
  45699. }
  45700. if (type === "text/x-handlebars-template") {
  45701. return "glimmer";
  45702. }
  45703. }
  45704. function inferStyleParser(node) {
  45705. const {
  45706. lang
  45707. } = node.attrMap;
  45708. if (!lang || lang === "postcss" || lang === "css") {
  45709. return "css";
  45710. }
  45711. if (lang === "scss") {
  45712. return "scss";
  45713. }
  45714. if (lang === "less") {
  45715. return "less";
  45716. }
  45717. }
  45718. function inferScriptParser$1(node, options) {
  45719. if (node.name === "script" && !node.attrMap.src) {
  45720. if (!node.attrMap.lang && !node.attrMap.type) {
  45721. return "babel";
  45722. }
  45723. return _inferScriptParser(node);
  45724. }
  45725. if (node.name === "style") {
  45726. return inferStyleParser(node);
  45727. }
  45728. if (options && isVueNonHtmlBlock$1(node, options)) {
  45729. return _inferScriptParser(node) || !("src" in node.attrMap) && inferParserByLanguage(node.attrMap.lang, options);
  45730. }
  45731. }
  45732. function isBlockLikeCssDisplay(cssDisplay) {
  45733. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  45734. }
  45735. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  45736. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  45737. }
  45738. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  45739. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  45740. }
  45741. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  45742. return !isBlockLikeCssDisplay(cssDisplay);
  45743. }
  45744. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  45745. return !isBlockLikeCssDisplay(cssDisplay);
  45746. }
  45747. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  45748. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  45749. }
  45750. function isPreLikeNode$1(node) {
  45751. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  45752. }
  45753. /**
  45754. * @param {AstPath} path
  45755. * @param {(any) => boolean} predicate
  45756. */
  45757. function countParents$1(path, predicate) {
  45758. let counter = 0;
  45759. for (let i = path.stack.length - 1; i >= 0; i--) {
  45760. const value = path.stack[i];
  45761. if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
  45762. counter++;
  45763. }
  45764. }
  45765. return counter;
  45766. }
  45767. function hasParent(node, fn) {
  45768. let current = node;
  45769. while (current) {
  45770. if (fn(current)) {
  45771. return true;
  45772. }
  45773. current = current.parent;
  45774. }
  45775. return false;
  45776. }
  45777. function getNodeCssStyleDisplay$1(node, options) {
  45778. if (node.prev && node.prev.type === "comment") {
  45779. // <!-- display: block -->
  45780. const match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  45781. if (match) {
  45782. return match[1];
  45783. }
  45784. }
  45785. let isInSvgForeignObject = false;
  45786. if (node.type === "element" && node.namespace === "svg") {
  45787. if (hasParent(node, parent => parent.fullName === "svg:foreignObject")) {
  45788. isInSvgForeignObject = true;
  45789. } else {
  45790. return node.name === "svg" ? "inline-block" : "block";
  45791. }
  45792. }
  45793. switch (options.htmlWhitespaceSensitivity) {
  45794. case "strict":
  45795. return "inline";
  45796. case "ignore":
  45797. return "block";
  45798. default:
  45799. {
  45800. // See https://github.com/prettier/prettier/issues/8151
  45801. if (options.parser === "vue" && node.parent && node.parent.type === "root") {
  45802. return "block";
  45803. }
  45804. return node.type === "element" && (!node.namespace || isInSvgForeignObject || isUnknownNamespace(node)) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  45805. }
  45806. }
  45807. }
  45808. function isUnknownNamespace(node) {
  45809. return node.type === "element" && !node.hasExplicitNamespace && !["html", "svg"].includes(node.namespace);
  45810. }
  45811. function getNodeCssStyleWhiteSpace(node) {
  45812. return node.type === "element" && (!node.namespace || isUnknownNamespace(node)) && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  45813. }
  45814. function getMinIndentation(text) {
  45815. let minIndentation = Number.POSITIVE_INFINITY;
  45816. for (const lineText of text.split("\n")) {
  45817. if (lineText.length === 0) {
  45818. continue;
  45819. }
  45820. if (!HTML_WHITESPACE.has(lineText[0])) {
  45821. return 0;
  45822. }
  45823. const indentation = getLeadingHtmlWhitespace(lineText).length;
  45824. if (lineText.length === indentation) {
  45825. continue;
  45826. }
  45827. if (indentation < minIndentation) {
  45828. minIndentation = indentation;
  45829. }
  45830. }
  45831. return minIndentation === Number.POSITIVE_INFINITY ? 0 : minIndentation;
  45832. }
  45833. function dedentString$1(text, minIndent = getMinIndentation(text)) {
  45834. return minIndent === 0 ? text : text.split("\n").map(lineText => lineText.slice(minIndent)).join("\n");
  45835. }
  45836. function countChars$1(text, char) {
  45837. let counter = 0;
  45838. for (let i = 0; i < text.length; i++) {
  45839. if (text[i] === char) {
  45840. counter++;
  45841. }
  45842. }
  45843. return counter;
  45844. }
  45845. function unescapeQuoteEntities$2(text) {
  45846. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  45847. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  45848. // See https://vue-loader.vuejs.org/spec.html for detail
  45849. const vueRootElementsSet = new Set(["template", "style", "script"]);
  45850. function isVueCustomBlock$1(node, options) {
  45851. return isVueSfcBlock(node, options) && !vueRootElementsSet.has(node.fullName);
  45852. }
  45853. function isVueSfcBlock(node, options) {
  45854. return options.parser === "vue" && node.type === "element" && node.parent.type === "root" && node.fullName.toLowerCase() !== "html";
  45855. }
  45856. function isVueNonHtmlBlock$1(node, options) {
  45857. return isVueSfcBlock(node, options) && (isVueCustomBlock$1(node, options) || node.attrMap.lang && node.attrMap.lang !== "html");
  45858. }
  45859. function isVueSlotAttribute$1(attribute) {
  45860. const attributeName = attribute.fullName;
  45861. return attributeName.charAt(0) === "#" || attributeName === "slot-scope" || attributeName === "v-slot" || attributeName.startsWith("v-slot:");
  45862. }
  45863. function isVueSfcBindingsAttribute$1(attribute, options) {
  45864. const element = attribute.parent;
  45865. if (!isVueSfcBlock(element, options)) {
  45866. return false;
  45867. }
  45868. const tagName = element.fullName;
  45869. const attributeName = attribute.fullName;
  45870. return (// https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md
  45871. tagName === "script" && attributeName === "setup" || // https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-style-variables.md
  45872. tagName === "style" && attributeName === "vars"
  45873. );
  45874. }
  45875. function getTextValueParts$2(node, value = node.value) {
  45876. return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceTextEndOfLine$6(value) : replaceTextEndOfLine$6(dedentString$1(htmlTrimPreserveIndentation$1(value)), hardline$7) : getDocParts$3(join$6(line$9, splitByHtmlWhitespace(value)));
  45877. }
  45878. var utils$1 = {
  45879. HTML_ELEMENT_ATTRIBUTES,
  45880. HTML_TAGS,
  45881. htmlTrim: htmlTrim$1,
  45882. htmlTrimPreserveIndentation: htmlTrimPreserveIndentation$1,
  45883. hasHtmlWhitespace: hasHtmlWhitespace$1,
  45884. getLeadingAndTrailingHtmlWhitespace: getLeadingAndTrailingHtmlWhitespace$1,
  45885. canHaveInterpolation: canHaveInterpolation$1,
  45886. countChars: countChars$1,
  45887. countParents: countParents$1,
  45888. dedentString: dedentString$1,
  45889. forceBreakChildren: forceBreakChildren$1,
  45890. forceBreakContent: forceBreakContent$1,
  45891. forceNextEmptyLine: forceNextEmptyLine$1,
  45892. getLastDescendant: getLastDescendant$1,
  45893. getNodeCssStyleDisplay: getNodeCssStyleDisplay$1,
  45894. getNodeCssStyleWhiteSpace,
  45895. hasPrettierIgnore: hasPrettierIgnore$4,
  45896. inferScriptParser: inferScriptParser$1,
  45897. isVueCustomBlock: isVueCustomBlock$1,
  45898. isVueNonHtmlBlock: isVueNonHtmlBlock$1,
  45899. isVueSlotAttribute: isVueSlotAttribute$1,
  45900. isVueSfcBindingsAttribute: isVueSfcBindingsAttribute$1,
  45901. isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode$1,
  45902. isIndentationSensitiveNode: isIndentationSensitiveNode$1,
  45903. isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode$1,
  45904. isPreLikeNode: isPreLikeNode$1,
  45905. isScriptLikeTag: isScriptLikeTag$2,
  45906. isTextLikeNode: isTextLikeNode$2,
  45907. isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode$1,
  45908. isWhitespaceSensitiveNode: isWhitespaceSensitiveNode$1,
  45909. isUnknownNamespace,
  45910. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  45911. preferHardlineAsTrailingSpaces,
  45912. shouldPreserveContent: shouldPreserveContent$2,
  45913. unescapeQuoteEntities: unescapeQuoteEntities$2,
  45914. getTextValueParts: getTextValueParts$2
  45915. };
  45916. var parse_util = {};
  45917. var chars = {};
  45918. (function (exports) {
  45919. /**
  45920. * @license
  45921. * Copyright Google Inc. All Rights Reserved.
  45922. *
  45923. * Use of this source code is governed by an MIT-style license that can be
  45924. * found in the LICENSE file at https://angular.io/license
  45925. */
  45926. Object.defineProperty(exports, "__esModule", {
  45927. value: true
  45928. });
  45929. exports.$EOF = 0;
  45930. exports.$BSPACE = 8;
  45931. exports.$TAB = 9;
  45932. exports.$LF = 10;
  45933. exports.$VTAB = 11;
  45934. exports.$FF = 12;
  45935. exports.$CR = 13;
  45936. exports.$SPACE = 32;
  45937. exports.$BANG = 33;
  45938. exports.$DQ = 34;
  45939. exports.$HASH = 35;
  45940. exports.$$ = 36;
  45941. exports.$PERCENT = 37;
  45942. exports.$AMPERSAND = 38;
  45943. exports.$SQ = 39;
  45944. exports.$LPAREN = 40;
  45945. exports.$RPAREN = 41;
  45946. exports.$STAR = 42;
  45947. exports.$PLUS = 43;
  45948. exports.$COMMA = 44;
  45949. exports.$MINUS = 45;
  45950. exports.$PERIOD = 46;
  45951. exports.$SLASH = 47;
  45952. exports.$COLON = 58;
  45953. exports.$SEMICOLON = 59;
  45954. exports.$LT = 60;
  45955. exports.$EQ = 61;
  45956. exports.$GT = 62;
  45957. exports.$QUESTION = 63;
  45958. exports.$0 = 48;
  45959. exports.$7 = 55;
  45960. exports.$9 = 57;
  45961. exports.$A = 65;
  45962. exports.$E = 69;
  45963. exports.$F = 70;
  45964. exports.$X = 88;
  45965. exports.$Z = 90;
  45966. exports.$LBRACKET = 91;
  45967. exports.$BACKSLASH = 92;
  45968. exports.$RBRACKET = 93;
  45969. exports.$CARET = 94;
  45970. exports.$_ = 95;
  45971. exports.$a = 97;
  45972. exports.$b = 98;
  45973. exports.$e = 101;
  45974. exports.$f = 102;
  45975. exports.$n = 110;
  45976. exports.$r = 114;
  45977. exports.$t = 116;
  45978. exports.$u = 117;
  45979. exports.$v = 118;
  45980. exports.$x = 120;
  45981. exports.$z = 122;
  45982. exports.$LBRACE = 123;
  45983. exports.$BAR = 124;
  45984. exports.$RBRACE = 125;
  45985. exports.$NBSP = 160;
  45986. exports.$PIPE = 124;
  45987. exports.$TILDA = 126;
  45988. exports.$AT = 64;
  45989. exports.$BT = 96;
  45990. function isWhitespace(code) {
  45991. return code >= exports.$TAB && code <= exports.$SPACE || code == exports.$NBSP;
  45992. }
  45993. exports.isWhitespace = isWhitespace;
  45994. function isDigit(code) {
  45995. return exports.$0 <= code && code <= exports.$9;
  45996. }
  45997. exports.isDigit = isDigit;
  45998. function isAsciiLetter(code) {
  45999. return code >= exports.$a && code <= exports.$z || code >= exports.$A && code <= exports.$Z;
  46000. }
  46001. exports.isAsciiLetter = isAsciiLetter;
  46002. function isAsciiHexDigit(code) {
  46003. return code >= exports.$a && code <= exports.$f || code >= exports.$A && code <= exports.$F || isDigit(code);
  46004. }
  46005. exports.isAsciiHexDigit = isAsciiHexDigit;
  46006. function isNewLine(code) {
  46007. return code === exports.$LF || code === exports.$CR;
  46008. }
  46009. exports.isNewLine = isNewLine;
  46010. function isOctalDigit(code) {
  46011. return exports.$0 <= code && code <= exports.$7;
  46012. }
  46013. exports.isOctalDigit = isOctalDigit;
  46014. })(chars);
  46015. var compile_metadata = {};
  46016. var static_symbol = {};
  46017. /**
  46018. * @license
  46019. * Copyright Google Inc. All Rights Reserved.
  46020. *
  46021. * Use of this source code is governed by an MIT-style license that can be
  46022. * found in the LICENSE file at https://angular.io/license
  46023. */
  46024. Object.defineProperty(static_symbol, "__esModule", {
  46025. value: true
  46026. });
  46027. /**
  46028. * A token representing the a reference to a static type.
  46029. *
  46030. * This token is unique for a filePath and name and can be used as a hash table key.
  46031. */
  46032. class StaticSymbol {
  46033. constructor(filePath, name, members) {
  46034. this.filePath = filePath;
  46035. this.name = name;
  46036. this.members = members;
  46037. }
  46038. assertNoMembers() {
  46039. if (this.members.length) {
  46040. throw new Error(`Illegal state: symbol without members expected, but got ${JSON.stringify(this)}.`);
  46041. }
  46042. }
  46043. }
  46044. static_symbol.StaticSymbol = StaticSymbol;
  46045. /**
  46046. * A cache of static symbol used by the StaticReflector to return the same symbol for the
  46047. * same symbol values.
  46048. */
  46049. class StaticSymbolCache {
  46050. constructor() {
  46051. this.cache = new Map();
  46052. }
  46053. get(declarationFile, name, members) {
  46054. members = members || [];
  46055. const memberSuffix = members.length ? `.${members.join('.')}` : '';
  46056. const key = `"${declarationFile}".${name}${memberSuffix}`;
  46057. let result = this.cache.get(key);
  46058. if (!result) {
  46059. result = new StaticSymbol(declarationFile, name, members);
  46060. this.cache.set(key, result);
  46061. }
  46062. return result;
  46063. }
  46064. }
  46065. static_symbol.StaticSymbolCache = StaticSymbolCache;
  46066. var util = {};
  46067. /**
  46068. * @license
  46069. * Copyright Google Inc. All Rights Reserved.
  46070. *
  46071. * Use of this source code is governed by an MIT-style license that can be
  46072. * found in the LICENSE file at https://angular.io/license
  46073. */
  46074. Object.defineProperty(util, "__esModule", {
  46075. value: true
  46076. });
  46077. const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  46078. function dashCaseToCamelCase(input) {
  46079. return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
  46080. }
  46081. util.dashCaseToCamelCase = dashCaseToCamelCase;
  46082. function splitAtColon(input, defaultValues) {
  46083. return _splitAt(input, ':', defaultValues);
  46084. }
  46085. util.splitAtColon = splitAtColon;
  46086. function splitAtPeriod(input, defaultValues) {
  46087. return _splitAt(input, '.', defaultValues);
  46088. }
  46089. util.splitAtPeriod = splitAtPeriod;
  46090. function _splitAt(input, character, defaultValues) {
  46091. const characterIndex = input.indexOf(character);
  46092. if (characterIndex == -1) return defaultValues;
  46093. return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
  46094. }
  46095. function visitValue(value, visitor, context) {
  46096. if (Array.isArray(value)) {
  46097. return visitor.visitArray(value, context);
  46098. }
  46099. if (isStrictStringMap(value)) {
  46100. return visitor.visitStringMap(value, context);
  46101. }
  46102. if (value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') {
  46103. return visitor.visitPrimitive(value, context);
  46104. }
  46105. return visitor.visitOther(value, context);
  46106. }
  46107. util.visitValue = visitValue;
  46108. function isDefined(val) {
  46109. return val !== null && val !== undefined;
  46110. }
  46111. util.isDefined = isDefined;
  46112. function noUndefined(val) {
  46113. return val === undefined ? null : val;
  46114. }
  46115. util.noUndefined = noUndefined;
  46116. class ValueTransformer {
  46117. visitArray(arr, context) {
  46118. return arr.map(value => visitValue(value, this, context));
  46119. }
  46120. visitStringMap(map, context) {
  46121. const result = {};
  46122. Object.keys(map).forEach(key => {
  46123. result[key] = visitValue(map[key], this, context);
  46124. });
  46125. return result;
  46126. }
  46127. visitPrimitive(value, context) {
  46128. return value;
  46129. }
  46130. visitOther(value, context) {
  46131. return value;
  46132. }
  46133. }
  46134. util.ValueTransformer = ValueTransformer;
  46135. util.SyncAsync = {
  46136. assertSync: value => {
  46137. if (isPromise(value)) {
  46138. throw new Error(`Illegal state: value cannot be a promise`);
  46139. }
  46140. return value;
  46141. },
  46142. then: (value, cb) => {
  46143. return isPromise(value) ? value.then(cb) : cb(value);
  46144. },
  46145. all: syncAsyncValues => {
  46146. return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : syncAsyncValues;
  46147. }
  46148. };
  46149. function error(msg) {
  46150. throw new Error(`Internal Error: ${msg}`);
  46151. }
  46152. util.error = error;
  46153. function syntaxError(msg, parseErrors) {
  46154. const error = Error(msg);
  46155. error[ERROR_SYNTAX_ERROR] = true;
  46156. if (parseErrors) error[ERROR_PARSE_ERRORS] = parseErrors;
  46157. return error;
  46158. }
  46159. util.syntaxError = syntaxError;
  46160. const ERROR_SYNTAX_ERROR = 'ngSyntaxError';
  46161. const ERROR_PARSE_ERRORS = 'ngParseErrors';
  46162. function isSyntaxError(error) {
  46163. return error[ERROR_SYNTAX_ERROR];
  46164. }
  46165. util.isSyntaxError = isSyntaxError;
  46166. function getParseErrors(error) {
  46167. return error[ERROR_PARSE_ERRORS] || [];
  46168. }
  46169. util.getParseErrors = getParseErrors; // Escape characters that have a special meaning in Regular Expressions
  46170. function escapeRegExp(s) {
  46171. return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  46172. }
  46173. util.escapeRegExp = escapeRegExp;
  46174. const STRING_MAP_PROTO = Object.getPrototypeOf({});
  46175. function isStrictStringMap(obj) {
  46176. return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
  46177. }
  46178. function utf8Encode(str) {
  46179. let encoded = '';
  46180. for (let index = 0; index < str.length; index++) {
  46181. let codePoint = str.charCodeAt(index); // decode surrogate
  46182. // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  46183. if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > index + 1) {
  46184. const low = str.charCodeAt(index + 1);
  46185. if (low >= 0xdc00 && low <= 0xdfff) {
  46186. index++;
  46187. codePoint = (codePoint - 0xd800 << 10) + low - 0xdc00 + 0x10000;
  46188. }
  46189. }
  46190. if (codePoint <= 0x7f) {
  46191. encoded += String.fromCharCode(codePoint);
  46192. } else if (codePoint <= 0x7ff) {
  46193. encoded += String.fromCharCode(codePoint >> 6 & 0x1F | 0xc0, codePoint & 0x3f | 0x80);
  46194. } else if (codePoint <= 0xffff) {
  46195. encoded += String.fromCharCode(codePoint >> 12 | 0xe0, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
  46196. } else if (codePoint <= 0x1fffff) {
  46197. encoded += String.fromCharCode(codePoint >> 18 & 0x07 | 0xf0, codePoint >> 12 & 0x3f | 0x80, codePoint >> 6 & 0x3f | 0x80, codePoint & 0x3f | 0x80);
  46198. }
  46199. }
  46200. return encoded;
  46201. }
  46202. util.utf8Encode = utf8Encode;
  46203. function stringify(token) {
  46204. if (typeof token === 'string') {
  46205. return token;
  46206. }
  46207. if (token instanceof Array) {
  46208. return '[' + token.map(stringify).join(', ') + ']';
  46209. }
  46210. if (token == null) {
  46211. return '' + token;
  46212. }
  46213. if (token.overriddenName) {
  46214. return `${token.overriddenName}`;
  46215. }
  46216. if (token.name) {
  46217. return `${token.name}`;
  46218. }
  46219. if (!token.toString) {
  46220. return 'object';
  46221. } // WARNING: do not try to `JSON.stringify(token)` here
  46222. // see https://github.com/angular/angular/issues/23440
  46223. const res = token.toString();
  46224. if (res == null) {
  46225. return '' + res;
  46226. }
  46227. const newLineIndex = res.indexOf('\n');
  46228. return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
  46229. }
  46230. util.stringify = stringify;
  46231. /**
  46232. * Lazily retrieves the reference value from a forwardRef.
  46233. */
  46234. function resolveForwardRef(type) {
  46235. if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
  46236. return type();
  46237. } else {
  46238. return type;
  46239. }
  46240. }
  46241. util.resolveForwardRef = resolveForwardRef;
  46242. /**
  46243. * Determine if the argument is shaped like a Promise
  46244. */
  46245. function isPromise(obj) {
  46246. // allow any Promise/A+ compliant thenable.
  46247. // It's up to the caller to ensure that obj.then conforms to the spec
  46248. return !!obj && typeof obj.then === 'function';
  46249. }
  46250. util.isPromise = isPromise;
  46251. class Version {
  46252. constructor(full) {
  46253. this.full = full;
  46254. const splits = full.split('.');
  46255. this.major = splits[0];
  46256. this.minor = splits[1];
  46257. this.patch = splits.slice(2).join('.');
  46258. }
  46259. }
  46260. util.Version = Version;
  46261. const __window = typeof window !== 'undefined' && window;
  46262. const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self;
  46263. const __global = typeof global$1 !== 'undefined' && global$1; // Check __global first, because in Node tests both __global and __window may be defined and _global
  46264. // should be __global in that case.
  46265. const _global = __global || __window || __self;
  46266. var global$1 = util.global = _global;
  46267. (function (exports) {
  46268. /**
  46269. * @license
  46270. * Copyright Google Inc. All Rights Reserved.
  46271. *
  46272. * Use of this source code is governed by an MIT-style license that can be
  46273. * found in the LICENSE file at https://angular.io/license
  46274. */
  46275. Object.defineProperty(exports, "__esModule", {
  46276. value: true
  46277. });
  46278. const static_symbol_1 = static_symbol;
  46279. const util_1 = util; // group 0: "[prop] or (event) or @trigger"
  46280. // group 1: "prop" from "[prop]"
  46281. // group 2: "event" from "(event)"
  46282. // group 3: "@trigger" from "@trigger"
  46283. const HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
  46284. function sanitizeIdentifier(name) {
  46285. return name.replace(/\W/g, '_');
  46286. }
  46287. exports.sanitizeIdentifier = sanitizeIdentifier;
  46288. let _anonymousTypeIndex = 0;
  46289. function identifierName(compileIdentifier) {
  46290. if (!compileIdentifier || !compileIdentifier.reference) {
  46291. return null;
  46292. }
  46293. const ref = compileIdentifier.reference;
  46294. if (ref instanceof static_symbol_1.StaticSymbol) {
  46295. return ref.name;
  46296. }
  46297. if (ref['__anonymousType']) {
  46298. return ref['__anonymousType'];
  46299. }
  46300. let identifier = util_1.stringify(ref);
  46301. if (identifier.indexOf('(') >= 0) {
  46302. // case: anonymous functions!
  46303. identifier = `anonymous_${_anonymousTypeIndex++}`;
  46304. ref['__anonymousType'] = identifier;
  46305. } else {
  46306. identifier = sanitizeIdentifier(identifier);
  46307. }
  46308. return identifier;
  46309. }
  46310. exports.identifierName = identifierName;
  46311. function identifierModuleUrl(compileIdentifier) {
  46312. const ref = compileIdentifier.reference;
  46313. if (ref instanceof static_symbol_1.StaticSymbol) {
  46314. return ref.filePath;
  46315. } // Runtime type
  46316. return `./${util_1.stringify(ref)}`;
  46317. }
  46318. exports.identifierModuleUrl = identifierModuleUrl;
  46319. function viewClassName(compType, embeddedTemplateIndex) {
  46320. return `View_${identifierName({
  46321. reference: compType
  46322. })}_${embeddedTemplateIndex}`;
  46323. }
  46324. exports.viewClassName = viewClassName;
  46325. function rendererTypeName(compType) {
  46326. return `RenderType_${identifierName({
  46327. reference: compType
  46328. })}`;
  46329. }
  46330. exports.rendererTypeName = rendererTypeName;
  46331. function hostViewClassName(compType) {
  46332. return `HostView_${identifierName({
  46333. reference: compType
  46334. })}`;
  46335. }
  46336. exports.hostViewClassName = hostViewClassName;
  46337. function componentFactoryName(compType) {
  46338. return `${identifierName({
  46339. reference: compType
  46340. })}NgFactory`;
  46341. }
  46342. exports.componentFactoryName = componentFactoryName;
  46343. var CompileSummaryKind;
  46344. (function (CompileSummaryKind) {
  46345. CompileSummaryKind[CompileSummaryKind["Pipe"] = 0] = "Pipe";
  46346. CompileSummaryKind[CompileSummaryKind["Directive"] = 1] = "Directive";
  46347. CompileSummaryKind[CompileSummaryKind["NgModule"] = 2] = "NgModule";
  46348. CompileSummaryKind[CompileSummaryKind["Injectable"] = 3] = "Injectable";
  46349. })(CompileSummaryKind = exports.CompileSummaryKind || (exports.CompileSummaryKind = {}));
  46350. function tokenName(token) {
  46351. return token.value != null ? sanitizeIdentifier(token.value) : identifierName(token.identifier);
  46352. }
  46353. exports.tokenName = tokenName;
  46354. function tokenReference(token) {
  46355. if (token.identifier != null) {
  46356. return token.identifier.reference;
  46357. } else {
  46358. return token.value;
  46359. }
  46360. }
  46361. exports.tokenReference = tokenReference;
  46362. /**
  46363. * Metadata about a stylesheet
  46364. */
  46365. class CompileStylesheetMetadata {
  46366. constructor({
  46367. moduleUrl,
  46368. styles,
  46369. styleUrls
  46370. } = {}) {
  46371. this.moduleUrl = moduleUrl || null;
  46372. this.styles = _normalizeArray(styles);
  46373. this.styleUrls = _normalizeArray(styleUrls);
  46374. }
  46375. }
  46376. exports.CompileStylesheetMetadata = CompileStylesheetMetadata;
  46377. /**
  46378. * Metadata regarding compilation of a template.
  46379. */
  46380. class CompileTemplateMetadata {
  46381. constructor({
  46382. encapsulation,
  46383. template,
  46384. templateUrl,
  46385. htmlAst,
  46386. styles,
  46387. styleUrls,
  46388. externalStylesheets,
  46389. animations,
  46390. ngContentSelectors,
  46391. interpolation,
  46392. isInline,
  46393. preserveWhitespaces
  46394. }) {
  46395. this.encapsulation = encapsulation;
  46396. this.template = template;
  46397. this.templateUrl = templateUrl;
  46398. this.htmlAst = htmlAst;
  46399. this.styles = _normalizeArray(styles);
  46400. this.styleUrls = _normalizeArray(styleUrls);
  46401. this.externalStylesheets = _normalizeArray(externalStylesheets);
  46402. this.animations = animations ? flatten(animations) : [];
  46403. this.ngContentSelectors = ngContentSelectors || [];
  46404. if (interpolation && interpolation.length != 2) {
  46405. throw new Error(`'interpolation' should have a start and an end symbol.`);
  46406. }
  46407. this.interpolation = interpolation;
  46408. this.isInline = isInline;
  46409. this.preserveWhitespaces = preserveWhitespaces;
  46410. }
  46411. toSummary() {
  46412. return {
  46413. ngContentSelectors: this.ngContentSelectors,
  46414. encapsulation: this.encapsulation,
  46415. styles: this.styles,
  46416. animations: this.animations
  46417. };
  46418. }
  46419. }
  46420. exports.CompileTemplateMetadata = CompileTemplateMetadata;
  46421. /**
  46422. * Metadata regarding compilation of a directive.
  46423. */
  46424. class CompileDirectiveMetadata {
  46425. static create({
  46426. isHost,
  46427. type,
  46428. isComponent,
  46429. selector,
  46430. exportAs,
  46431. changeDetection,
  46432. inputs,
  46433. outputs,
  46434. host,
  46435. providers,
  46436. viewProviders,
  46437. queries,
  46438. guards,
  46439. viewQueries,
  46440. entryComponents,
  46441. template,
  46442. componentViewType,
  46443. rendererType,
  46444. componentFactory
  46445. }) {
  46446. const hostListeners = {};
  46447. const hostProperties = {};
  46448. const hostAttributes = {};
  46449. if (host != null) {
  46450. Object.keys(host).forEach(key => {
  46451. const value = host[key];
  46452. const matches = key.match(HOST_REG_EXP);
  46453. if (matches === null) {
  46454. hostAttributes[key] = value;
  46455. } else if (matches[1] != null) {
  46456. hostProperties[matches[1]] = value;
  46457. } else if (matches[2] != null) {
  46458. hostListeners[matches[2]] = value;
  46459. }
  46460. });
  46461. }
  46462. const inputsMap = {};
  46463. if (inputs != null) {
  46464. inputs.forEach(bindConfig => {
  46465. // canonical syntax: `dirProp: elProp`
  46466. // if there is no `:`, use dirProp = elProp
  46467. const parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  46468. inputsMap[parts[0]] = parts[1];
  46469. });
  46470. }
  46471. const outputsMap = {};
  46472. if (outputs != null) {
  46473. outputs.forEach(bindConfig => {
  46474. // canonical syntax: `dirProp: elProp`
  46475. // if there is no `:`, use dirProp = elProp
  46476. const parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  46477. outputsMap[parts[0]] = parts[1];
  46478. });
  46479. }
  46480. return new CompileDirectiveMetadata({
  46481. isHost,
  46482. type,
  46483. isComponent: !!isComponent,
  46484. selector,
  46485. exportAs,
  46486. changeDetection,
  46487. inputs: inputsMap,
  46488. outputs: outputsMap,
  46489. hostListeners,
  46490. hostProperties,
  46491. hostAttributes,
  46492. providers,
  46493. viewProviders,
  46494. queries,
  46495. guards,
  46496. viewQueries,
  46497. entryComponents,
  46498. template,
  46499. componentViewType,
  46500. rendererType,
  46501. componentFactory
  46502. });
  46503. }
  46504. constructor({
  46505. isHost,
  46506. type,
  46507. isComponent,
  46508. selector,
  46509. exportAs,
  46510. changeDetection,
  46511. inputs,
  46512. outputs,
  46513. hostListeners,
  46514. hostProperties,
  46515. hostAttributes,
  46516. providers,
  46517. viewProviders,
  46518. queries,
  46519. guards,
  46520. viewQueries,
  46521. entryComponents,
  46522. template,
  46523. componentViewType,
  46524. rendererType,
  46525. componentFactory
  46526. }) {
  46527. this.isHost = !!isHost;
  46528. this.type = type;
  46529. this.isComponent = isComponent;
  46530. this.selector = selector;
  46531. this.exportAs = exportAs;
  46532. this.changeDetection = changeDetection;
  46533. this.inputs = inputs;
  46534. this.outputs = outputs;
  46535. this.hostListeners = hostListeners;
  46536. this.hostProperties = hostProperties;
  46537. this.hostAttributes = hostAttributes;
  46538. this.providers = _normalizeArray(providers);
  46539. this.viewProviders = _normalizeArray(viewProviders);
  46540. this.queries = _normalizeArray(queries);
  46541. this.guards = guards;
  46542. this.viewQueries = _normalizeArray(viewQueries);
  46543. this.entryComponents = _normalizeArray(entryComponents);
  46544. this.template = template;
  46545. this.componentViewType = componentViewType;
  46546. this.rendererType = rendererType;
  46547. this.componentFactory = componentFactory;
  46548. }
  46549. toSummary() {
  46550. return {
  46551. summaryKind: CompileSummaryKind.Directive,
  46552. type: this.type,
  46553. isComponent: this.isComponent,
  46554. selector: this.selector,
  46555. exportAs: this.exportAs,
  46556. inputs: this.inputs,
  46557. outputs: this.outputs,
  46558. hostListeners: this.hostListeners,
  46559. hostProperties: this.hostProperties,
  46560. hostAttributes: this.hostAttributes,
  46561. providers: this.providers,
  46562. viewProviders: this.viewProviders,
  46563. queries: this.queries,
  46564. guards: this.guards,
  46565. viewQueries: this.viewQueries,
  46566. entryComponents: this.entryComponents,
  46567. changeDetection: this.changeDetection,
  46568. template: this.template && this.template.toSummary(),
  46569. componentViewType: this.componentViewType,
  46570. rendererType: this.rendererType,
  46571. componentFactory: this.componentFactory
  46572. };
  46573. }
  46574. }
  46575. exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
  46576. class CompilePipeMetadata {
  46577. constructor({
  46578. type,
  46579. name,
  46580. pure
  46581. }) {
  46582. this.type = type;
  46583. this.name = name;
  46584. this.pure = !!pure;
  46585. }
  46586. toSummary() {
  46587. return {
  46588. summaryKind: CompileSummaryKind.Pipe,
  46589. type: this.type,
  46590. name: this.name,
  46591. pure: this.pure
  46592. };
  46593. }
  46594. }
  46595. exports.CompilePipeMetadata = CompilePipeMetadata;
  46596. class CompileShallowModuleMetadata {}
  46597. exports.CompileShallowModuleMetadata = CompileShallowModuleMetadata;
  46598. /**
  46599. * Metadata regarding compilation of a module.
  46600. */
  46601. class CompileNgModuleMetadata {
  46602. constructor({
  46603. type,
  46604. providers,
  46605. declaredDirectives,
  46606. exportedDirectives,
  46607. declaredPipes,
  46608. exportedPipes,
  46609. entryComponents,
  46610. bootstrapComponents,
  46611. importedModules,
  46612. exportedModules,
  46613. schemas,
  46614. transitiveModule,
  46615. id
  46616. }) {
  46617. this.type = type || null;
  46618. this.declaredDirectives = _normalizeArray(declaredDirectives);
  46619. this.exportedDirectives = _normalizeArray(exportedDirectives);
  46620. this.declaredPipes = _normalizeArray(declaredPipes);
  46621. this.exportedPipes = _normalizeArray(exportedPipes);
  46622. this.providers = _normalizeArray(providers);
  46623. this.entryComponents = _normalizeArray(entryComponents);
  46624. this.bootstrapComponents = _normalizeArray(bootstrapComponents);
  46625. this.importedModules = _normalizeArray(importedModules);
  46626. this.exportedModules = _normalizeArray(exportedModules);
  46627. this.schemas = _normalizeArray(schemas);
  46628. this.id = id || null;
  46629. this.transitiveModule = transitiveModule || null;
  46630. }
  46631. toSummary() {
  46632. const module = this.transitiveModule;
  46633. return {
  46634. summaryKind: CompileSummaryKind.NgModule,
  46635. type: this.type,
  46636. entryComponents: module.entryComponents,
  46637. providers: module.providers,
  46638. modules: module.modules,
  46639. exportedDirectives: module.exportedDirectives,
  46640. exportedPipes: module.exportedPipes
  46641. };
  46642. }
  46643. }
  46644. exports.CompileNgModuleMetadata = CompileNgModuleMetadata;
  46645. class TransitiveCompileNgModuleMetadata {
  46646. constructor() {
  46647. this.directivesSet = new Set();
  46648. this.directives = [];
  46649. this.exportedDirectivesSet = new Set();
  46650. this.exportedDirectives = [];
  46651. this.pipesSet = new Set();
  46652. this.pipes = [];
  46653. this.exportedPipesSet = new Set();
  46654. this.exportedPipes = [];
  46655. this.modulesSet = new Set();
  46656. this.modules = [];
  46657. this.entryComponentsSet = new Set();
  46658. this.entryComponents = [];
  46659. this.providers = [];
  46660. }
  46661. addProvider(provider, module) {
  46662. this.providers.push({
  46663. provider: provider,
  46664. module: module
  46665. });
  46666. }
  46667. addDirective(id) {
  46668. if (!this.directivesSet.has(id.reference)) {
  46669. this.directivesSet.add(id.reference);
  46670. this.directives.push(id);
  46671. }
  46672. }
  46673. addExportedDirective(id) {
  46674. if (!this.exportedDirectivesSet.has(id.reference)) {
  46675. this.exportedDirectivesSet.add(id.reference);
  46676. this.exportedDirectives.push(id);
  46677. }
  46678. }
  46679. addPipe(id) {
  46680. if (!this.pipesSet.has(id.reference)) {
  46681. this.pipesSet.add(id.reference);
  46682. this.pipes.push(id);
  46683. }
  46684. }
  46685. addExportedPipe(id) {
  46686. if (!this.exportedPipesSet.has(id.reference)) {
  46687. this.exportedPipesSet.add(id.reference);
  46688. this.exportedPipes.push(id);
  46689. }
  46690. }
  46691. addModule(id) {
  46692. if (!this.modulesSet.has(id.reference)) {
  46693. this.modulesSet.add(id.reference);
  46694. this.modules.push(id);
  46695. }
  46696. }
  46697. addEntryComponent(ec) {
  46698. if (!this.entryComponentsSet.has(ec.componentType)) {
  46699. this.entryComponentsSet.add(ec.componentType);
  46700. this.entryComponents.push(ec);
  46701. }
  46702. }
  46703. }
  46704. exports.TransitiveCompileNgModuleMetadata = TransitiveCompileNgModuleMetadata;
  46705. function _normalizeArray(obj) {
  46706. return obj || [];
  46707. }
  46708. class ProviderMeta {
  46709. constructor(token, {
  46710. useClass,
  46711. useValue,
  46712. useExisting,
  46713. useFactory,
  46714. deps,
  46715. multi
  46716. }) {
  46717. this.token = token;
  46718. this.useClass = useClass || null;
  46719. this.useValue = useValue;
  46720. this.useExisting = useExisting;
  46721. this.useFactory = useFactory || null;
  46722. this.dependencies = deps || null;
  46723. this.multi = !!multi;
  46724. }
  46725. }
  46726. exports.ProviderMeta = ProviderMeta;
  46727. function flatten(list) {
  46728. return list.reduce((flat, item) => {
  46729. const flatItem = Array.isArray(item) ? flatten(item) : item;
  46730. return flat.concat(flatItem);
  46731. }, []);
  46732. }
  46733. exports.flatten = flatten;
  46734. function jitSourceUrl(url) {
  46735. // Note: We need 3 "/" so that ng shows up as a separate domain
  46736. // in the chrome dev tools.
  46737. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
  46738. }
  46739. function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
  46740. let url;
  46741. if (templateMeta.isInline) {
  46742. if (compMeta.type.reference instanceof static_symbol_1.StaticSymbol) {
  46743. // Note: a .ts file might contain multiple components with inline templates,
  46744. // so we need to give them unique urls, as these will be used for sourcemaps.
  46745. url = `${compMeta.type.reference.filePath}.${compMeta.type.reference.name}.html`;
  46746. } else {
  46747. url = `${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.html`;
  46748. }
  46749. } else {
  46750. url = templateMeta.templateUrl;
  46751. }
  46752. return compMeta.type.reference instanceof static_symbol_1.StaticSymbol ? url : jitSourceUrl(url);
  46753. }
  46754. exports.templateSourceUrl = templateSourceUrl;
  46755. function sharedStylesheetJitUrl(meta, id) {
  46756. const pathParts = meta.moduleUrl.split(/\/\\/g);
  46757. const baseName = pathParts[pathParts.length - 1];
  46758. return jitSourceUrl(`css/${id}${baseName}.ngstyle.js`);
  46759. }
  46760. exports.sharedStylesheetJitUrl = sharedStylesheetJitUrl;
  46761. function ngModuleJitUrl(moduleMeta) {
  46762. return jitSourceUrl(`${identifierName(moduleMeta.type)}/module.ngfactory.js`);
  46763. }
  46764. exports.ngModuleJitUrl = ngModuleJitUrl;
  46765. function templateJitUrl(ngModuleType, compMeta) {
  46766. return jitSourceUrl(`${identifierName(ngModuleType)}/${identifierName(compMeta.type)}.ngfactory.js`);
  46767. }
  46768. exports.templateJitUrl = templateJitUrl;
  46769. })(compile_metadata);
  46770. (function (exports) {
  46771. Object.defineProperty(exports, "__esModule", {
  46772. value: true
  46773. });
  46774. /**
  46775. * @license
  46776. * Copyright Google Inc. All Rights Reserved.
  46777. *
  46778. * Use of this source code is governed by an MIT-style license that can be
  46779. * found in the LICENSE file at https://angular.io/license
  46780. */
  46781. const chars$1 = chars;
  46782. const compile_metadata_1 = compile_metadata;
  46783. class ParseLocation {
  46784. constructor(file, offset, line, col) {
  46785. this.file = file;
  46786. this.offset = offset;
  46787. this.line = line;
  46788. this.col = col;
  46789. }
  46790. toString() {
  46791. return this.offset != null ? `${this.file.url}@${this.line}:${this.col}` : this.file.url;
  46792. }
  46793. moveBy(delta) {
  46794. const source = this.file.content;
  46795. const len = source.length;
  46796. let offset = this.offset;
  46797. let line = this.line;
  46798. let col = this.col;
  46799. while (offset > 0 && delta < 0) {
  46800. offset--;
  46801. delta++;
  46802. const ch = source.charCodeAt(offset);
  46803. if (ch == chars$1.$LF) {
  46804. line--;
  46805. const priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode(chars$1.$LF));
  46806. col = priorLine > 0 ? offset - priorLine : offset;
  46807. } else {
  46808. col--;
  46809. }
  46810. }
  46811. while (offset < len && delta > 0) {
  46812. const ch = source.charCodeAt(offset);
  46813. offset++;
  46814. delta--;
  46815. if (ch == chars$1.$LF) {
  46816. line++;
  46817. col = 0;
  46818. } else {
  46819. col++;
  46820. }
  46821. }
  46822. return new ParseLocation(this.file, offset, line, col);
  46823. } // Return the source around the location
  46824. // Up to `maxChars` or `maxLines` on each side of the location
  46825. getContext(maxChars, maxLines) {
  46826. const content = this.file.content;
  46827. let startOffset = this.offset;
  46828. if (startOffset != null) {
  46829. if (startOffset > content.length - 1) {
  46830. startOffset = content.length - 1;
  46831. }
  46832. let endOffset = startOffset;
  46833. let ctxChars = 0;
  46834. let ctxLines = 0;
  46835. while (ctxChars < maxChars && startOffset > 0) {
  46836. startOffset--;
  46837. ctxChars++;
  46838. if (content[startOffset] == '\n') {
  46839. if (++ctxLines == maxLines) {
  46840. break;
  46841. }
  46842. }
  46843. }
  46844. ctxChars = 0;
  46845. ctxLines = 0;
  46846. while (ctxChars < maxChars && endOffset < content.length - 1) {
  46847. endOffset++;
  46848. ctxChars++;
  46849. if (content[endOffset] == '\n') {
  46850. if (++ctxLines == maxLines) {
  46851. break;
  46852. }
  46853. }
  46854. }
  46855. return {
  46856. before: content.substring(startOffset, this.offset),
  46857. after: content.substring(this.offset, endOffset + 1)
  46858. };
  46859. }
  46860. return null;
  46861. }
  46862. }
  46863. exports.ParseLocation = ParseLocation;
  46864. class ParseSourceFile {
  46865. constructor(content, url) {
  46866. this.content = content;
  46867. this.url = url;
  46868. }
  46869. }
  46870. exports.ParseSourceFile = ParseSourceFile;
  46871. class ParseSourceSpan {
  46872. constructor(start, end, details = null) {
  46873. this.start = start;
  46874. this.end = end;
  46875. this.details = details;
  46876. }
  46877. toString() {
  46878. return this.start.file.content.substring(this.start.offset, this.end.offset);
  46879. }
  46880. }
  46881. exports.ParseSourceSpan = ParseSourceSpan;
  46882. exports.EMPTY_PARSE_LOCATION = new ParseLocation(new ParseSourceFile('', ''), 0, 0, 0);
  46883. exports.EMPTY_SOURCE_SPAN = new ParseSourceSpan(exports.EMPTY_PARSE_LOCATION, exports.EMPTY_PARSE_LOCATION);
  46884. var ParseErrorLevel;
  46885. (function (ParseErrorLevel) {
  46886. ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
  46887. ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR";
  46888. })(ParseErrorLevel = exports.ParseErrorLevel || (exports.ParseErrorLevel = {}));
  46889. class ParseError {
  46890. constructor(span, msg, level = ParseErrorLevel.ERROR) {
  46891. this.span = span;
  46892. this.msg = msg;
  46893. this.level = level;
  46894. }
  46895. contextualMessage() {
  46896. const ctx = this.span.start.getContext(100, 3);
  46897. return ctx ? `${this.msg} ("${ctx.before}[${ParseErrorLevel[this.level]} ->]${ctx.after}")` : this.msg;
  46898. }
  46899. toString() {
  46900. const details = this.span.details ? `, ${this.span.details}` : '';
  46901. return `${this.contextualMessage()}: ${this.span.start}${details}`;
  46902. }
  46903. }
  46904. exports.ParseError = ParseError;
  46905. function typeSourceSpan(kind, type) {
  46906. const moduleUrl = compile_metadata_1.identifierModuleUrl(type);
  46907. const sourceFileName = moduleUrl != null ? `in ${kind} ${compile_metadata_1.identifierName(type)} in ${moduleUrl}` : `in ${kind} ${compile_metadata_1.identifierName(type)}`;
  46908. const sourceFile = new ParseSourceFile('', sourceFileName);
  46909. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  46910. }
  46911. exports.typeSourceSpan = typeSourceSpan;
  46912. /**
  46913. * Generates Source Span object for a given R3 Type for JIT mode.
  46914. *
  46915. * @param kind Component or Directive.
  46916. * @param typeName name of the Component or Directive.
  46917. * @param sourceUrl reference to Component or Directive source.
  46918. * @returns instance of ParseSourceSpan that represent a given Component or Directive.
  46919. */
  46920. function r3JitTypeSourceSpan(kind, typeName, sourceUrl) {
  46921. const sourceFileName = `in ${kind} ${typeName} in ${sourceUrl}`;
  46922. const sourceFile = new ParseSourceFile('', sourceFileName);
  46923. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  46924. }
  46925. exports.r3JitTypeSourceSpan = r3JitTypeSourceSpan;
  46926. })(parse_util);
  46927. const {
  46928. ParseSourceSpan
  46929. } = parse_util;
  46930. const getLast$2 = getLast_1;
  46931. const {
  46932. htmlTrim,
  46933. getLeadingAndTrailingHtmlWhitespace,
  46934. hasHtmlWhitespace,
  46935. canHaveInterpolation,
  46936. getNodeCssStyleDisplay,
  46937. isDanglingSpaceSensitiveNode,
  46938. isIndentationSensitiveNode,
  46939. isLeadingSpaceSensitiveNode,
  46940. isTrailingSpaceSensitiveNode,
  46941. isWhitespaceSensitiveNode
  46942. } = utils$1;
  46943. const PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  46944. function preprocess$3(ast, options) {
  46945. const res = ast.map(node => node);
  46946. for (const fn of PREPROCESS_PIPELINE) {
  46947. fn(res, options);
  46948. }
  46949. return res;
  46950. }
  46951. function removeIgnorableFirstLf(ast
  46952. /*, options */
  46953. ) {
  46954. ast.walk(node => {
  46955. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length > 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  46956. const [text, ...rest] = node.children;
  46957. node.setChildren(text.value.length === 1 ? rest : [text.clone({
  46958. value: text.value.slice(1)
  46959. }), ...rest]);
  46960. }
  46961. });
  46962. }
  46963. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  46964. /*, options */
  46965. ) {
  46966. /**
  46967. * <!--[if ...]><!--><target><!--<![endif]-->
  46968. */
  46969. const isTarget = node => node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
  46970. ast.walk(node => {
  46971. if (node.children) {
  46972. const isTargetResults = node.children.map(isTarget);
  46973. if (isTargetResults.some(Boolean)) {
  46974. const newChildren = [];
  46975. for (let i = 0; i < node.children.length; i++) {
  46976. const child = node.children[i];
  46977. if (isTargetResults[i + 1]) {
  46978. // ieConditionalStartComment
  46979. continue;
  46980. }
  46981. if (isTargetResults[i]) {
  46982. const ieConditionalStartComment = child.prev;
  46983. const ieConditionalEndComment = child.firstChild;
  46984. const startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  46985. const sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  46986. newChildren.push(child.clone({
  46987. condition: ieConditionalStartComment.condition,
  46988. sourceSpan,
  46989. startSourceSpan,
  46990. children: child.children.slice(1)
  46991. }));
  46992. continue;
  46993. }
  46994. newChildren.push(child);
  46995. }
  46996. node.setChildren(newChildren);
  46997. }
  46998. }
  46999. });
  47000. }
  47001. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  47002. ast.walk(node => {
  47003. if (node.children) {
  47004. const shouldMergeResults = node.children.map(shouldMerge);
  47005. if (shouldMergeResults.some(Boolean)) {
  47006. const newChildren = [];
  47007. for (let i = 0; i < node.children.length; i++) {
  47008. const child = node.children[i];
  47009. if (child.type !== "text" && !shouldMergeResults[i]) {
  47010. newChildren.push(child);
  47011. continue;
  47012. }
  47013. const newChild = child.type === "text" ? child : child.clone({
  47014. type: "text",
  47015. value: getValue(child)
  47016. });
  47017. if (newChildren.length === 0 || getLast$2(newChildren).type !== "text") {
  47018. newChildren.push(newChild);
  47019. continue;
  47020. }
  47021. const lastChild = newChildren.pop();
  47022. newChildren.push(lastChild.clone({
  47023. value: lastChild.value + newChild.value,
  47024. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  47025. }));
  47026. }
  47027. node.setChildren(newChildren);
  47028. }
  47029. }
  47030. });
  47031. }
  47032. function mergeCdataIntoText(ast
  47033. /*, options */
  47034. ) {
  47035. return mergeNodeIntoText(ast, node => node.type === "cdata", node => `<![CDATA[${node.value}]]>`);
  47036. }
  47037. function mergeSimpleElementIntoText(ast
  47038. /*, options */
  47039. ) {
  47040. const isSimpleElement = node => node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && !hasHtmlWhitespace(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
  47041. ast.walk(node => {
  47042. if (node.children) {
  47043. const isSimpleElementResults = node.children.map(isSimpleElement);
  47044. if (isSimpleElementResults.some(Boolean)) {
  47045. const newChildren = [];
  47046. for (let i = 0; i < node.children.length; i++) {
  47047. const child = node.children[i];
  47048. if (isSimpleElementResults[i]) {
  47049. const lastChild = newChildren.pop();
  47050. const nextChild = node.children[++i];
  47051. const {
  47052. isTrailingSpaceSensitive,
  47053. hasTrailingSpaces
  47054. } = nextChild;
  47055. newChildren.push(lastChild.clone({
  47056. value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
  47057. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  47058. isTrailingSpaceSensitive,
  47059. hasTrailingSpaces
  47060. }));
  47061. } else {
  47062. newChildren.push(child);
  47063. }
  47064. }
  47065. node.setChildren(newChildren);
  47066. }
  47067. }
  47068. });
  47069. }
  47070. function extractInterpolation(ast, options) {
  47071. if (options.parser === "html") {
  47072. return;
  47073. }
  47074. const interpolationRegex = /{{(.+?)}}/s;
  47075. ast.walk(node => {
  47076. if (!canHaveInterpolation(node)) {
  47077. return;
  47078. }
  47079. const newChildren = [];
  47080. for (const child of node.children) {
  47081. if (child.type !== "text") {
  47082. newChildren.push(child);
  47083. continue;
  47084. }
  47085. let startSourceSpan = child.sourceSpan.start;
  47086. let endSourceSpan = null;
  47087. const components = child.value.split(interpolationRegex);
  47088. for (let i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  47089. const value = components[i];
  47090. if (i % 2 === 0) {
  47091. endSourceSpan = startSourceSpan.moveBy(value.length);
  47092. if (value.length > 0) {
  47093. newChildren.push({
  47094. type: "text",
  47095. value,
  47096. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  47097. });
  47098. }
  47099. continue;
  47100. }
  47101. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  47102. newChildren.push({
  47103. type: "interpolation",
  47104. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  47105. children: value.length === 0 ? [] : [{
  47106. type: "text",
  47107. value,
  47108. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  47109. }]
  47110. });
  47111. }
  47112. }
  47113. node.setChildren(newChildren);
  47114. });
  47115. }
  47116. /**
  47117. * - add `hasLeadingSpaces` field
  47118. * - add `hasTrailingSpaces` field
  47119. * - add `hasDanglingSpaces` field for parent nodes
  47120. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  47121. * - remove insensitive whitespaces
  47122. */
  47123. const WHITESPACE_NODE = {
  47124. type: "whitespace"
  47125. };
  47126. function extractWhitespaces(ast
  47127. /*, options*/
  47128. ) {
  47129. ast.walk(node => {
  47130. if (!node.children) {
  47131. return;
  47132. }
  47133. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && htmlTrim(node.children[0].value).length === 0) {
  47134. node.hasDanglingSpaces = node.children.length > 0;
  47135. node.children = [];
  47136. return;
  47137. }
  47138. const isWhitespaceSensitive = isWhitespaceSensitiveNode(node);
  47139. const isIndentationSensitive = isIndentationSensitiveNode(node);
  47140. node.setChildren(node.children // extract whitespace nodes
  47141. .flatMap(child => {
  47142. if (child.type !== "text" || isWhitespaceSensitive) {
  47143. return child;
  47144. }
  47145. const localChildren = [];
  47146. const {
  47147. leadingWhitespace,
  47148. text,
  47149. trailingWhitespace
  47150. } = getLeadingAndTrailingHtmlWhitespace(child.value);
  47151. if (leadingWhitespace) {
  47152. localChildren.push(WHITESPACE_NODE);
  47153. }
  47154. if (text) {
  47155. localChildren.push({
  47156. type: "text",
  47157. value: text,
  47158. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingWhitespace.length), child.sourceSpan.end.moveBy(-trailingWhitespace.length))
  47159. });
  47160. }
  47161. if (trailingWhitespace) {
  47162. localChildren.push(WHITESPACE_NODE);
  47163. }
  47164. return localChildren;
  47165. }) // set hasLeadingSpaces/hasTrailingSpaces
  47166. .map((child, index, children) => {
  47167. if (child === WHITESPACE_NODE) {
  47168. return;
  47169. }
  47170. return Object.assign(Object.assign({}, child), {}, {
  47171. hasLeadingSpaces: children[index - 1] === WHITESPACE_NODE,
  47172. hasTrailingSpaces: children[index + 1] === WHITESPACE_NODE
  47173. });
  47174. }) // filter whitespace nodes
  47175. .filter(Boolean));
  47176. node.isWhitespaceSensitive = isWhitespaceSensitive;
  47177. node.isIndentationSensitive = isIndentationSensitive;
  47178. });
  47179. }
  47180. function addIsSelfClosing(ast
  47181. /*, options */
  47182. ) {
  47183. ast.walk(node => Object.assign(node, {
  47184. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  47185. node.startSourceSpan === node.endSourceSpan)
  47186. }));
  47187. }
  47188. function addHasHtmComponentClosingTag(ast, options) {
  47189. ast.walk(node => node.type !== "element" ? node : Object.assign(node, {
  47190. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  47191. }));
  47192. }
  47193. function addCssDisplay(ast, options) {
  47194. ast.walk(node => Object.assign(node, {
  47195. cssDisplay: getNodeCssStyleDisplay(node, options)
  47196. }));
  47197. }
  47198. /**
  47199. * - add `isLeadingSpaceSensitive` field
  47200. * - add `isTrailingSpaceSensitive` field
  47201. * - add `isDanglingSpaceSensitive` field for parent nodes
  47202. */
  47203. function addIsSpaceSensitive(ast, options) {
  47204. ast.walk(node => {
  47205. if (!node.children) {
  47206. return;
  47207. }
  47208. if (node.children.length === 0) {
  47209. node.isDanglingSpaceSensitive = isDanglingSpaceSensitiveNode(node);
  47210. return;
  47211. }
  47212. node.setChildren(node.children.map(child => Object.assign(Object.assign({}, child), {}, {
  47213. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode(child, options),
  47214. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode(child, options)
  47215. })).map((child, index, children) => Object.assign(Object.assign({}, child), {}, {
  47216. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  47217. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  47218. })));
  47219. });
  47220. }
  47221. var printPreprocess$1 = preprocess$3;
  47222. function hasPragma$1(text) {
  47223. return /^\s*<!--\s*@(?:format|prettier)\s*-->/.test(text);
  47224. }
  47225. function insertPragma$3(text) {
  47226. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  47227. }
  47228. var pragma$1 = {
  47229. hasPragma: hasPragma$1,
  47230. insertPragma: insertPragma$3
  47231. };
  47232. function locStart$5(node) {
  47233. return node.sourceSpan.start.offset;
  47234. }
  47235. function locEnd$4(node) {
  47236. return node.sourceSpan.end.offset;
  47237. }
  47238. var loc$1 = {
  47239. locStart: locStart$5,
  47240. locEnd: locEnd$4
  47241. };
  47242. /**
  47243. * @typedef {import("../../document").Doc} Doc
  47244. */
  47245. const assert = require$$0__default$3["default"];
  47246. const {
  47247. isNonEmptyArray: isNonEmptyArray$1
  47248. } = util$8;
  47249. const {
  47250. builders: {
  47251. indent: indent$2,
  47252. join: join$5,
  47253. line: line$8,
  47254. softline: softline$5
  47255. },
  47256. utils: {
  47257. replaceTextEndOfLine: replaceTextEndOfLine$5
  47258. }
  47259. } = require$$7$3;
  47260. const {
  47261. locStart: locStart$4,
  47262. locEnd: locEnd$3
  47263. } = loc$1;
  47264. const {
  47265. isTextLikeNode: isTextLikeNode$1,
  47266. getLastDescendant,
  47267. isPreLikeNode,
  47268. hasPrettierIgnore: hasPrettierIgnore$3,
  47269. shouldPreserveContent: shouldPreserveContent$1
  47270. } = utils$1;
  47271. function printClosingTag$2(node, options) {
  47272. return [node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd$1(node, options)];
  47273. }
  47274. function printClosingTagStart(node, options) {
  47275. return node.lastChild && needsToBorrowParentClosingTagStartMarker$2(node.lastChild) ? "" : [printClosingTagPrefix(node, options), printClosingTagStartMarker$1(node, options)];
  47276. }
  47277. function printClosingTagEnd$1(node, options) {
  47278. return (node.next ? needsToBorrowPrevClosingTagEndMarker$3(node.next) : needsToBorrowLastChildClosingTagEndMarker$2(node.parent)) ? "" : [printClosingTagEndMarker$2(node, options), printClosingTagSuffix$4(node, options)];
  47279. }
  47280. function printClosingTagPrefix(node, options) {
  47281. return needsToBorrowLastChildClosingTagEndMarker$2(node) ? printClosingTagEndMarker$2(node.lastChild, options) : "";
  47282. }
  47283. function printClosingTagSuffix$4(node, options) {
  47284. return needsToBorrowParentClosingTagStartMarker$2(node) ? printClosingTagStartMarker$1(node.parent, options) : needsToBorrowNextOpeningTagStartMarker$1(node) ? printOpeningTagStartMarker$1(node.next) : "";
  47285. }
  47286. function printClosingTagStartMarker$1(node, options) {
  47287. assert(!node.isSelfClosing);
  47288. /* istanbul ignore next */
  47289. if (shouldNotPrintClosingTag(node, options)) {
  47290. return "";
  47291. }
  47292. switch (node.type) {
  47293. case "ieConditionalComment":
  47294. return "<!";
  47295. case "element":
  47296. if (node.hasHtmComponentClosingTag) {
  47297. return "<//";
  47298. }
  47299. // fall through
  47300. default:
  47301. return `</${node.rawName}`;
  47302. }
  47303. }
  47304. function printClosingTagEndMarker$2(node, options) {
  47305. if (shouldNotPrintClosingTag(node, options)) {
  47306. return "";
  47307. }
  47308. switch (node.type) {
  47309. case "ieConditionalComment":
  47310. case "ieConditionalEndComment":
  47311. return "[endif]-->";
  47312. case "ieConditionalStartComment":
  47313. return "]><!-->";
  47314. case "interpolation":
  47315. return "}}";
  47316. case "element":
  47317. if (node.isSelfClosing) {
  47318. return "/>";
  47319. }
  47320. // fall through
  47321. default:
  47322. return ">";
  47323. }
  47324. }
  47325. function shouldNotPrintClosingTag(node, options) {
  47326. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
  47327. }
  47328. function needsToBorrowPrevClosingTagEndMarker$3(node) {
  47329. /**
  47330. * <p></p
  47331. * >123
  47332. * ^
  47333. *
  47334. * <p></p
  47335. * ><a
  47336. * ^
  47337. */
  47338. return node.prev && node.prev.type !== "docType" && !isTextLikeNode$1(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  47339. }
  47340. function needsToBorrowLastChildClosingTagEndMarker$2(node) {
  47341. /**
  47342. * <p
  47343. * ><a></a
  47344. * ></p
  47345. * ^
  47346. * >
  47347. */
  47348. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode$1(getLastDescendant(node.lastChild)) && !isPreLikeNode(node);
  47349. }
  47350. function needsToBorrowParentClosingTagStartMarker$2(node) {
  47351. /**
  47352. * <p>
  47353. * 123</p
  47354. * ^^^
  47355. * >
  47356. *
  47357. * 123</b
  47358. * ></a
  47359. * ^^^
  47360. * >
  47361. */
  47362. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode$1(getLastDescendant(node));
  47363. }
  47364. function needsToBorrowNextOpeningTagStartMarker$1(node) {
  47365. /**
  47366. * 123<p
  47367. * ^^
  47368. * >
  47369. */
  47370. return node.next && !isTextLikeNode$1(node.next) && isTextLikeNode$1(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  47371. }
  47372. function getPrettierIgnoreAttributeCommentData(value) {
  47373. const match = value.trim().match(/^prettier-ignore-attribute(?:\s+(.+))?$/s);
  47374. if (!match) {
  47375. return false;
  47376. }
  47377. if (!match[1]) {
  47378. return true;
  47379. }
  47380. return match[1].split(/\s+/);
  47381. }
  47382. function needsToBorrowParentOpeningTagEndMarker$1(node) {
  47383. /**
  47384. * <p
  47385. * >123
  47386. * ^
  47387. *
  47388. * <p
  47389. * ><a
  47390. * ^
  47391. */
  47392. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  47393. }
  47394. function printAttributes(path, options, print) {
  47395. const node = path.getValue();
  47396. if (!isNonEmptyArray$1(node.attrs)) {
  47397. return node.isSelfClosing ?
  47398. /**
  47399. * <br />
  47400. * ^
  47401. */
  47402. " " : "";
  47403. }
  47404. const ignoreAttributeData = node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value);
  47405. const hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? () => ignoreAttributeData : Array.isArray(ignoreAttributeData) ? attribute => ignoreAttributeData.includes(attribute.rawName) : () => false;
  47406. const printedAttributes = path.map(attributePath => {
  47407. const attribute = attributePath.getValue();
  47408. return hasPrettierIgnoreAttribute(attribute) ? replaceTextEndOfLine$5(options.originalText.slice(locStart$4(attribute), locEnd$3(attribute))) : print();
  47409. }, "attrs");
  47410. const forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  47411. /** @type {Doc[]} */
  47412. const parts = [indent$2([forceNotToBreakAttrContent ? " " : line$8, join$5(line$8, printedAttributes)])];
  47413. if (
  47414. /**
  47415. * 123<a
  47416. * attr
  47417. * ~
  47418. * >456
  47419. */
  47420. node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) ||
  47421. /**
  47422. * <span
  47423. * >123<meta
  47424. * ~
  47425. * /></span>
  47426. */
  47427. node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker$2(node.parent) || forceNotToBreakAttrContent) {
  47428. parts.push(node.isSelfClosing ? " " : "");
  47429. } else {
  47430. parts.push(options.bracketSameLine ? node.isSelfClosing ? " " : "" : node.isSelfClosing ? line$8 : softline$5);
  47431. }
  47432. return parts;
  47433. }
  47434. function printOpeningTagEnd(node) {
  47435. return node.firstChild && needsToBorrowParentOpeningTagEndMarker$1(node.firstChild) ? "" : printOpeningTagEndMarker$1(node);
  47436. }
  47437. function printOpeningTag$2(path, options, print) {
  47438. const node = path.getValue();
  47439. return [printOpeningTagStart$1(node, options), printAttributes(path, options, print), node.isSelfClosing ? "" : printOpeningTagEnd(node)];
  47440. }
  47441. function printOpeningTagStart$1(node, options) {
  47442. return node.prev && needsToBorrowNextOpeningTagStartMarker$1(node.prev) ? "" : [printOpeningTagPrefix$4(node, options), printOpeningTagStartMarker$1(node)];
  47443. }
  47444. function printOpeningTagPrefix$4(node, options) {
  47445. return needsToBorrowParentOpeningTagEndMarker$1(node) ? printOpeningTagEndMarker$1(node.parent) : needsToBorrowPrevClosingTagEndMarker$3(node) ? printClosingTagEndMarker$2(node.prev, options) : "";
  47446. }
  47447. function printOpeningTagStartMarker$1(node) {
  47448. switch (node.type) {
  47449. case "ieConditionalComment":
  47450. case "ieConditionalStartComment":
  47451. return `<!--[if ${node.condition}`;
  47452. case "ieConditionalEndComment":
  47453. return "<!--<!";
  47454. case "interpolation":
  47455. return "{{";
  47456. case "docType":
  47457. return "<!DOCTYPE";
  47458. case "element":
  47459. if (node.condition) {
  47460. return `<!--[if ${node.condition}]><!--><${node.rawName}`;
  47461. }
  47462. // fall through
  47463. default:
  47464. return `<${node.rawName}`;
  47465. }
  47466. }
  47467. function printOpeningTagEndMarker$1(node) {
  47468. assert(!node.isSelfClosing);
  47469. switch (node.type) {
  47470. case "ieConditionalComment":
  47471. return "]>";
  47472. case "element":
  47473. if (node.condition) {
  47474. return "><!--<![endif]-->";
  47475. }
  47476. // fall through
  47477. default:
  47478. return ">";
  47479. }
  47480. }
  47481. var tag = {
  47482. printClosingTag: printClosingTag$2,
  47483. printClosingTagStart,
  47484. printClosingTagStartMarker: printClosingTagStartMarker$1,
  47485. printClosingTagEndMarker: printClosingTagEndMarker$2,
  47486. printClosingTagSuffix: printClosingTagSuffix$4,
  47487. printClosingTagEnd: printClosingTagEnd$1,
  47488. needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$2,
  47489. needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$2,
  47490. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$3,
  47491. printOpeningTag: printOpeningTag$2,
  47492. printOpeningTagStart: printOpeningTagStart$1,
  47493. printOpeningTagPrefix: printOpeningTagPrefix$4,
  47494. printOpeningTagStartMarker: printOpeningTagStartMarker$1,
  47495. printOpeningTagEndMarker: printOpeningTagEndMarker$1,
  47496. needsToBorrowNextOpeningTagStartMarker: needsToBorrowNextOpeningTagStartMarker$1,
  47497. needsToBorrowParentOpeningTagEndMarker: needsToBorrowParentOpeningTagEndMarker$1
  47498. };
  47499. var parseSrcset$1 = {exports: {}};
  47500. /**
  47501. * Srcset Parser
  47502. *
  47503. * By Alex Bell | MIT License
  47504. *
  47505. * JS Parser for the string value that appears in markup <img srcset="here">
  47506. *
  47507. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  47508. *
  47509. * Based super duper closely on the reference algorithm at:
  47510. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  47511. *
  47512. * Most comments are copied in directly from the spec
  47513. * (except for comments in parens).
  47514. */
  47515. (function (module) {
  47516. (function (root, factory) {
  47517. if (module.exports) {
  47518. // Node. Does not work with strict CommonJS, but
  47519. // only CommonJS-like environments that support module.exports,
  47520. // like Node.
  47521. module.exports = factory();
  47522. } else {
  47523. // Browser globals (root is window)
  47524. root.parseSrcset = factory();
  47525. }
  47526. })(this, function () {
  47527. // 1. Let input be the value passed to this algorithm.
  47528. return function (input, options) {
  47529. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  47530. // Manual is faster than RegEx
  47531. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  47532. // http://jsperf.com/whitespace-character/5
  47533. function isSpace(c) {
  47534. return c === "\u0020" || // space
  47535. c === "\u0009" || // horizontal tab
  47536. c === "\u000A" || // new line
  47537. c === "\u000C" || // form feed
  47538. c === "\u000D"; // carriage return
  47539. }
  47540. function collectCharacters(regEx) {
  47541. var chars,
  47542. match = regEx.exec(input.substring(pos));
  47543. if (match) {
  47544. chars = match[0];
  47545. pos += chars.length;
  47546. return chars;
  47547. }
  47548. }
  47549. var inputLength = input.length,
  47550. // (Don't use \s, to avoid matching non-breaking space)
  47551. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  47552. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  47553. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  47554. regexTrailingCommas = /[,]+$/,
  47555. regexNonNegativeInteger = /^\d+$/,
  47556. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  47557. // Must include at least one digit.
  47558. // According to spec tests any decimal point must be followed by a digit.
  47559. // No leading plus sign is allowed.)
  47560. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  47561. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  47562. url,
  47563. descriptors,
  47564. currentDescriptor,
  47565. state,
  47566. c,
  47567. // 2. Let position be a pointer into input, initially pointing at the start
  47568. // of the string.
  47569. pos = 0,
  47570. // 3. Let candidates be an initially empty source set.
  47571. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  47572. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  47573. // were collected, that is a parse error.
  47574. while (true) {
  47575. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  47576. if (pos >= inputLength) {
  47577. return candidates; // (we're done, this is the sole return path)
  47578. } // 6. Collect a sequence of characters that are not space characters,
  47579. // and let that be url.
  47580. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  47581. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  47582. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  47583. // more than one character, that is a parse error.
  47584. if (url.slice(-1) === ",") {
  47585. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  47586. parseDescriptors(); // Otherwise, follow these substeps:
  47587. } else {
  47588. tokenize();
  47589. } // (close else of step 8)
  47590. // 16. Return to the step labeled splitting loop.
  47591. } // (Close of big while loop.)
  47592. /**
  47593. * Tokenizes descriptor properties prior to parsing
  47594. * Returns undefined.
  47595. */
  47596. function tokenize() {
  47597. // 8.1. Descriptor tokeniser: Skip whitespace
  47598. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  47599. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  47600. state = "in descriptor";
  47601. while (true) {
  47602. // 8.4. Let c be the character at position.
  47603. c = input.charAt(pos); // Do the following depending on the value of state.
  47604. // For the purpose of this step, "EOF" is a special character representing
  47605. // that position is past the end of input.
  47606. // In descriptor
  47607. if (state === "in descriptor") {
  47608. // Do the following, depending on the value of c:
  47609. // Space character
  47610. // If current descriptor is not empty, append current descriptor to
  47611. // descriptors and let current descriptor be the empty string.
  47612. // Set state to after descriptor.
  47613. if (isSpace(c)) {
  47614. if (currentDescriptor) {
  47615. descriptors.push(currentDescriptor);
  47616. currentDescriptor = "";
  47617. state = "after descriptor";
  47618. } // U+002C COMMA (,)
  47619. // Advance position to the next character in input. If current descriptor
  47620. // is not empty, append current descriptor to descriptors. Jump to the step
  47621. // labeled descriptor parser.
  47622. } else if (c === ",") {
  47623. pos += 1;
  47624. if (currentDescriptor) {
  47625. descriptors.push(currentDescriptor);
  47626. }
  47627. parseDescriptors();
  47628. return; // U+0028 LEFT PARENTHESIS (()
  47629. // Append c to current descriptor. Set state to in parens.
  47630. } else if (c === "\u0028") {
  47631. currentDescriptor = currentDescriptor + c;
  47632. state = "in parens"; // EOF
  47633. // If current descriptor is not empty, append current descriptor to
  47634. // descriptors. Jump to the step labeled descriptor parser.
  47635. } else if (c === "") {
  47636. if (currentDescriptor) {
  47637. descriptors.push(currentDescriptor);
  47638. }
  47639. parseDescriptors();
  47640. return; // Anything else
  47641. // Append c to current descriptor.
  47642. } else {
  47643. currentDescriptor = currentDescriptor + c;
  47644. } // (end "in descriptor"
  47645. // In parens
  47646. } else if (state === "in parens") {
  47647. // U+0029 RIGHT PARENTHESIS ())
  47648. // Append c to current descriptor. Set state to in descriptor.
  47649. if (c === ")") {
  47650. currentDescriptor = currentDescriptor + c;
  47651. state = "in descriptor"; // EOF
  47652. // Append current descriptor to descriptors. Jump to the step labeled
  47653. // descriptor parser.
  47654. } else if (c === "") {
  47655. descriptors.push(currentDescriptor);
  47656. parseDescriptors();
  47657. return; // Anything else
  47658. // Append c to current descriptor.
  47659. } else {
  47660. currentDescriptor = currentDescriptor + c;
  47661. } // After descriptor
  47662. } else if (state === "after descriptor") {
  47663. // Do the following, depending on the value of c:
  47664. // Space character: Stay in this state.
  47665. if (isSpace(c)) ; else if (c === "") {
  47666. parseDescriptors();
  47667. return; // Anything else
  47668. // Set state to in descriptor. Set position to the previous character in input.
  47669. } else {
  47670. state = "in descriptor";
  47671. pos -= 1;
  47672. }
  47673. } // Advance position to the next character in input.
  47674. pos += 1; // Repeat this step.
  47675. } // (close while true loop)
  47676. }
  47677. /**
  47678. * Adds descriptor properties to a candidate, pushes to the candidates array
  47679. * @return undefined
  47680. */
  47681. // Declared outside of the while loop so that it's only created once.
  47682. function parseDescriptors() {
  47683. // 9. Descriptor parser: Let error be no.
  47684. var pError = false,
  47685. // 10. Let width be absent.
  47686. // 11. Let density be absent.
  47687. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  47688. w,
  47689. d,
  47690. h,
  47691. i,
  47692. candidate = {},
  47693. desc,
  47694. lastChar,
  47695. value,
  47696. intVal,
  47697. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  47698. // from the following list:
  47699. for (i = 0; i < descriptors.length; i++) {
  47700. desc = descriptors[i];
  47701. lastChar = desc[desc.length - 1];
  47702. value = desc.substring(0, desc.length - 1);
  47703. intVal = parseInt(value, 10);
  47704. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  47705. // a U+0077 LATIN SMALL LETTER W character
  47706. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  47707. // If width and density are not both absent, then let error be yes.
  47708. if (w || d) {
  47709. pError = true;
  47710. } // Apply the rules for parsing non-negative integers to the descriptor.
  47711. // If the result is zero, let error be yes.
  47712. // Otherwise, let width be the result.
  47713. if (intVal === 0) {
  47714. pError = true;
  47715. } else {
  47716. w = intVal;
  47717. } // If the descriptor consists of a valid floating-point number followed by
  47718. // a U+0078 LATIN SMALL LETTER X character
  47719. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  47720. // If width, density and future-compat-h are not all absent, then let error
  47721. // be yes.
  47722. if (w || d || h) {
  47723. pError = true;
  47724. } // Apply the rules for parsing floating-point number values to the descriptor.
  47725. // If the result is less than zero, let error be yes. Otherwise, let density
  47726. // be the result.
  47727. if (floatVal < 0) {
  47728. pError = true;
  47729. } else {
  47730. d = floatVal;
  47731. } // If the descriptor consists of a valid non-negative integer followed by
  47732. // a U+0068 LATIN SMALL LETTER H character
  47733. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  47734. // If height and density are not both absent, then let error be yes.
  47735. if (h || d) {
  47736. pError = true;
  47737. } // Apply the rules for parsing non-negative integers to the descriptor.
  47738. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  47739. // be the result.
  47740. if (intVal === 0) {
  47741. pError = true;
  47742. } else {
  47743. h = intVal;
  47744. } // Anything else, Let error be yes.
  47745. } else {
  47746. pError = true;
  47747. }
  47748. } // (close step 13 for loop)
  47749. // 15. If error is still no, then append a new image source to candidates whose
  47750. // URL is url, associated with a width width if not absent and a pixel
  47751. // density density if not absent. Otherwise, there is a parse error.
  47752. if (!pError) {
  47753. candidate.url = url;
  47754. if (w) {
  47755. candidate.w = w;
  47756. }
  47757. if (d) {
  47758. candidate.d = d;
  47759. }
  47760. if (h) {
  47761. candidate.h = h;
  47762. }
  47763. candidates.push(candidate);
  47764. } else if (logger && logger.error) {
  47765. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  47766. }
  47767. } // (close parseDescriptors fn)
  47768. };
  47769. });
  47770. })(parseSrcset$1);
  47771. const parseSrcset = parseSrcset$1.exports;
  47772. const {
  47773. builders: {
  47774. ifBreak: ifBreak$4,
  47775. join: join$4,
  47776. line: line$7
  47777. }
  47778. } = require$$7$3;
  47779. function printImgSrcset$1(value) {
  47780. const srcset = parseSrcset(value, {
  47781. logger: {
  47782. error(message) {
  47783. throw new Error(message);
  47784. }
  47785. }
  47786. });
  47787. const hasW = srcset.some(({
  47788. w
  47789. }) => w);
  47790. const hasH = srcset.some(({
  47791. h
  47792. }) => h);
  47793. const hasX = srcset.some(({
  47794. d
  47795. }) => d);
  47796. if (hasW + hasH + hasX > 1) {
  47797. throw new Error("Mixed descriptor in srcset is not supported");
  47798. }
  47799. const key = hasW ? "w" : hasH ? "h" : "d";
  47800. const unit = hasW ? "w" : hasH ? "h" : "x";
  47801. const getMax = values => Math.max(...values);
  47802. const urls = srcset.map(src => src.url);
  47803. const maxUrlLength = getMax(urls.map(url => url.length));
  47804. const descriptors = srcset.map(src => src[key]).map(descriptor => descriptor ? descriptor.toString() : "");
  47805. const descriptorLeftLengths = descriptors.map(descriptor => {
  47806. const index = descriptor.indexOf(".");
  47807. return index === -1 ? descriptor.length : index;
  47808. });
  47809. const maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  47810. return join$4([",", line$7], urls.map((url, index) => {
  47811. const parts = [url];
  47812. const descriptor = descriptors[index];
  47813. if (descriptor) {
  47814. const urlPadding = maxUrlLength - url.length + 1;
  47815. const descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  47816. const alignment = " ".repeat(urlPadding + descriptorPadding);
  47817. parts.push(ifBreak$4(alignment, " "), descriptor + unit);
  47818. }
  47819. return parts;
  47820. }));
  47821. }
  47822. function printClassNames$1(value) {
  47823. return value.trim().split(/\s+/).join(" ");
  47824. }
  47825. var syntaxAttribute = {
  47826. printImgSrcset: printImgSrcset$1,
  47827. printClassNames: printClassNames$1
  47828. };
  47829. const {
  47830. builders: {
  47831. group: group$6
  47832. }
  47833. } = require$$7$3;
  47834. /**
  47835. * v-for="... in ..."
  47836. * v-for="... of ..."
  47837. * v-for="(..., ...) in ..."
  47838. * v-for="(..., ...) of ..."
  47839. */
  47840. function printVueFor$1(value, textToDoc) {
  47841. const {
  47842. left,
  47843. operator,
  47844. right
  47845. } = parseVueFor(value);
  47846. return [group$6(textToDoc(`function _(${left}) {}`, {
  47847. parser: "babel",
  47848. __isVueForBindingLeft: true
  47849. })), " ", operator, " ", textToDoc(right, {
  47850. parser: "__js_expression"
  47851. }, {
  47852. stripTrailingHardline: true
  47853. })];
  47854. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  47855. function parseVueFor(value) {
  47856. const forAliasRE = /(.*?)\s+(in|of)\s+(.*)/s;
  47857. const forIteratorRE = /,([^,\]}]*)(?:,([^,\]}]*))?$/;
  47858. const stripParensRE = /^\(|\)$/g;
  47859. const inMatch = value.match(forAliasRE);
  47860. if (!inMatch) {
  47861. return;
  47862. }
  47863. const res = {};
  47864. res.for = inMatch[3].trim();
  47865. const alias = inMatch[1].trim().replace(stripParensRE, "");
  47866. const iteratorMatch = alias.match(forIteratorRE);
  47867. if (iteratorMatch) {
  47868. res.alias = alias.replace(forIteratorRE, "");
  47869. res.iterator1 = iteratorMatch[1].trim();
  47870. if (iteratorMatch[2]) {
  47871. res.iterator2 = iteratorMatch[2].trim();
  47872. }
  47873. } else {
  47874. res.alias = alias;
  47875. }
  47876. return {
  47877. left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
  47878. operator: inMatch[2],
  47879. right: res.for
  47880. };
  47881. }
  47882. function printVueBindings$1(value, textToDoc) {
  47883. return textToDoc(`function _(${value}) {}`, {
  47884. parser: "babel",
  47885. __isVueBindings: true
  47886. });
  47887. }
  47888. function isVueEventBindingExpression$1(eventBindingValue) {
  47889. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  47890. // arrow function or anonymous function
  47891. const fnExpRE = /^(?:[\w$]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  47892. const simplePathRE = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
  47893. const value = eventBindingValue.trim();
  47894. return fnExpRE.test(value) || simplePathRE.test(value);
  47895. }
  47896. var syntaxVue = {
  47897. isVueEventBindingExpression: isVueEventBindingExpression$1,
  47898. printVueFor: printVueFor$1,
  47899. printVueBindings: printVueBindings$1
  47900. };
  47901. const {
  47902. needsToBorrowParentClosingTagStartMarker: needsToBorrowParentClosingTagStartMarker$1,
  47903. printClosingTagStartMarker,
  47904. needsToBorrowLastChildClosingTagEndMarker: needsToBorrowLastChildClosingTagEndMarker$1,
  47905. printClosingTagEndMarker: printClosingTagEndMarker$1,
  47906. needsToBorrowParentOpeningTagEndMarker,
  47907. printOpeningTagEndMarker
  47908. } = tag;
  47909. function getNodeContent$2(node, options) {
  47910. let start = node.startSourceSpan.end.offset;
  47911. if (node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild)) {
  47912. start -= printOpeningTagEndMarker(node).length;
  47913. }
  47914. let end = node.endSourceSpan.start.offset;
  47915. if (node.lastChild && needsToBorrowParentClosingTagStartMarker$1(node.lastChild)) {
  47916. end += printClosingTagStartMarker(node, options).length;
  47917. } else if (needsToBorrowLastChildClosingTagEndMarker$1(node)) {
  47918. end -= printClosingTagEndMarker$1(node.lastChild, options).length;
  47919. }
  47920. return options.originalText.slice(start, end);
  47921. }
  47922. var getNodeContent_1 = getNodeContent$2;
  47923. const {
  47924. builders: {
  47925. breakParent: breakParent$3,
  47926. group: group$5,
  47927. hardline: hardline$6,
  47928. indent: indent$1,
  47929. line: line$6,
  47930. fill: fill$3,
  47931. softline: softline$4
  47932. },
  47933. utils: {
  47934. mapDoc,
  47935. replaceTextEndOfLine: replaceTextEndOfLine$4
  47936. }
  47937. } = require$$7$3;
  47938. const printFrontMatter = print_1;
  47939. const {
  47940. printClosingTag: printClosingTag$1,
  47941. printClosingTagSuffix: printClosingTagSuffix$3,
  47942. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$2,
  47943. printOpeningTagPrefix: printOpeningTagPrefix$3,
  47944. printOpeningTag: printOpeningTag$1
  47945. } = tag;
  47946. const {
  47947. printImgSrcset,
  47948. printClassNames
  47949. } = syntaxAttribute;
  47950. const {
  47951. printVueFor,
  47952. printVueBindings,
  47953. isVueEventBindingExpression
  47954. } = syntaxVue;
  47955. const {
  47956. isScriptLikeTag: isScriptLikeTag$1,
  47957. isVueNonHtmlBlock,
  47958. inferScriptParser,
  47959. htmlTrimPreserveIndentation,
  47960. dedentString,
  47961. unescapeQuoteEntities: unescapeQuoteEntities$1,
  47962. isVueSlotAttribute,
  47963. isVueSfcBindingsAttribute,
  47964. getTextValueParts: getTextValueParts$1
  47965. } = utils$1;
  47966. const getNodeContent$1 = getNodeContent_1;
  47967. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  47968. const isKeyMatched = patterns => new RegExp(patterns.join("|")).test(node.fullName);
  47969. const getValue = () => unescapeQuoteEntities$1(node.value);
  47970. let shouldHug = false;
  47971. const __onHtmlBindingRoot = (root, options) => {
  47972. const rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
  47973. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression" || options.parser === "__vue_expression" && (rootNode.type === "TemplateLiteral" || rootNode.type === "StringLiteral"))) {
  47974. shouldHug = true;
  47975. }
  47976. };
  47977. const printHug = doc => group$5(doc);
  47978. const printExpand = (doc, canHaveTrailingWhitespace = true) => group$5([indent$1([softline$4, doc]), canHaveTrailingWhitespace ? softline$4 : ""]);
  47979. const printMaybeHug = doc => shouldHug ? printHug(doc) : printExpand(doc);
  47980. const attributeTextToDoc = (code, opts) => originalTextToDoc(code, Object.assign({
  47981. __onHtmlBindingRoot,
  47982. __embeddedInHtml: true
  47983. }, opts), {
  47984. stripTrailingHardline: true
  47985. });
  47986. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  47987. return printExpand(printImgSrcset(getValue()));
  47988. }
  47989. if (node.fullName === "class" && !options.parentParser) {
  47990. const value = getValue();
  47991. if (!value.includes("{{")) {
  47992. return printClassNames(value);
  47993. }
  47994. }
  47995. if (node.fullName === "style" && !options.parentParser) {
  47996. const value = getValue();
  47997. if (!value.includes("{{")) {
  47998. return printExpand(attributeTextToDoc(value, {
  47999. parser: "css",
  48000. __isHTMLStyleAttribute: true
  48001. }));
  48002. }
  48003. }
  48004. if (options.parser === "vue") {
  48005. if (node.fullName === "v-for") {
  48006. return printVueFor(getValue(), attributeTextToDoc);
  48007. }
  48008. if (isVueSlotAttribute(node) || isVueSfcBindingsAttribute(node, options)) {
  48009. return printVueBindings(getValue(), attributeTextToDoc);
  48010. }
  48011. /**
  48012. * @click="jsStatement"
  48013. * @click="jsExpression"
  48014. * v-on:click="jsStatement"
  48015. * v-on:click="jsExpression"
  48016. */
  48017. const vueEventBindingPatterns = ["^@", "^v-on:"];
  48018. /**
  48019. * :class="vueExpression"
  48020. * v-bind:id="vueExpression"
  48021. */
  48022. const vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  48023. /**
  48024. * v-if="jsExpression"
  48025. */
  48026. const jsExpressionBindingPatterns = ["^v-"];
  48027. if (isKeyMatched(vueEventBindingPatterns)) {
  48028. const value = getValue();
  48029. return printMaybeHug(attributeTextToDoc(value, {
  48030. parser: isVueEventBindingExpression(value) ? "__js_expression" : "__vue_event_binding"
  48031. }));
  48032. }
  48033. if (isKeyMatched(vueExpressionBindingPatterns)) {
  48034. return printMaybeHug(attributeTextToDoc(getValue(), {
  48035. parser: "__vue_expression"
  48036. }));
  48037. }
  48038. if (isKeyMatched(jsExpressionBindingPatterns)) {
  48039. return printMaybeHug(attributeTextToDoc(getValue(), {
  48040. parser: "__js_expression"
  48041. }));
  48042. }
  48043. }
  48044. if (options.parser === "angular") {
  48045. const ngTextToDoc = (code, opts) => // angular does not allow trailing comma
  48046. attributeTextToDoc(code, Object.assign(Object.assign({}, opts), {}, {
  48047. trailingComma: "none"
  48048. }));
  48049. /**
  48050. * *directive="angularDirective"
  48051. */
  48052. const ngDirectiveBindingPatterns = ["^\\*"];
  48053. /**
  48054. * (click)="angularStatement"
  48055. * on-click="angularStatement"
  48056. */
  48057. const ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  48058. /**
  48059. * [target]="angularExpression"
  48060. * bind-target="angularExpression"
  48061. * [(target)]="angularExpression"
  48062. * bindon-target="angularExpression"
  48063. */
  48064. const ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-", // Unofficial rudimentary support for some of the most used directives of AngularJS 1.x
  48065. "^ng-(if|show|hide|class|style)$"];
  48066. /**
  48067. * i18n="longDescription"
  48068. * i18n-attr="longDescription"
  48069. */
  48070. const ngI18nPatterns = ["^i18n(-.+)?$"];
  48071. if (isKeyMatched(ngStatementBindingPatterns)) {
  48072. return printMaybeHug(ngTextToDoc(getValue(), {
  48073. parser: "__ng_action"
  48074. }));
  48075. }
  48076. if (isKeyMatched(ngExpressionBindingPatterns)) {
  48077. return printMaybeHug(ngTextToDoc(getValue(), {
  48078. parser: "__ng_binding"
  48079. }));
  48080. }
  48081. if (isKeyMatched(ngI18nPatterns)) {
  48082. const value = getValue().trim();
  48083. return printExpand(fill$3(getTextValueParts$1(node, value)), !value.includes("@@"));
  48084. }
  48085. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  48086. return printMaybeHug(ngTextToDoc(getValue(), {
  48087. parser: "__ng_directive"
  48088. }));
  48089. }
  48090. const interpolationRegex = /{{(.+?)}}/s;
  48091. const value = getValue();
  48092. if (interpolationRegex.test(value)) {
  48093. const parts = [];
  48094. for (const [index, part] of value.split(interpolationRegex).entries()) {
  48095. if (index % 2 === 0) {
  48096. parts.push(replaceTextEndOfLine$4(part));
  48097. } else {
  48098. try {
  48099. parts.push(group$5(["{{", indent$1([line$6, ngTextToDoc(part, {
  48100. parser: "__ng_interpolation",
  48101. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  48102. })]), line$6, "}}"]));
  48103. } catch {
  48104. parts.push("{{", replaceTextEndOfLine$4(part), "}}");
  48105. }
  48106. }
  48107. }
  48108. return group$5(parts);
  48109. }
  48110. }
  48111. return null;
  48112. }
  48113. function embed$3(path, print, textToDoc, options) {
  48114. const node = path.getValue();
  48115. switch (node.type) {
  48116. case "element":
  48117. {
  48118. if (isScriptLikeTag$1(node) || node.type === "interpolation") {
  48119. // Fall through to "text"
  48120. return;
  48121. }
  48122. if (!node.isSelfClosing && isVueNonHtmlBlock(node, options)) {
  48123. const parser = inferScriptParser(node, options);
  48124. if (!parser) {
  48125. return;
  48126. }
  48127. const content = getNodeContent$1(node, options);
  48128. let isEmpty = /^\s*$/.test(content);
  48129. let doc = "";
  48130. if (!isEmpty) {
  48131. doc = textToDoc(htmlTrimPreserveIndentation(content), {
  48132. parser,
  48133. __embeddedInHtml: true
  48134. }, {
  48135. stripTrailingHardline: true
  48136. });
  48137. isEmpty = doc === "";
  48138. }
  48139. return [printOpeningTagPrefix$3(node, options), group$5(printOpeningTag$1(path, options, print)), isEmpty ? "" : hardline$6, doc, isEmpty ? "" : hardline$6, printClosingTag$1(node, options), printClosingTagSuffix$3(node, options)];
  48140. }
  48141. break;
  48142. }
  48143. case "text":
  48144. {
  48145. if (isScriptLikeTag$1(node.parent)) {
  48146. const parser = inferScriptParser(node.parent);
  48147. if (parser) {
  48148. const value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  48149. const textToDocOptions = {
  48150. parser,
  48151. __embeddedInHtml: true
  48152. };
  48153. if (options.parser === "html" && parser === "babel") {
  48154. let sourceType = "script";
  48155. const {
  48156. attrMap
  48157. } = node.parent;
  48158. if (attrMap && (attrMap.type === "module" || attrMap.type === "text/babel" && attrMap["data-type"] === "module")) {
  48159. sourceType = "module";
  48160. }
  48161. textToDocOptions.__babelSourceType = sourceType;
  48162. }
  48163. return [breakParent$3, printOpeningTagPrefix$3(node, options), textToDoc(value, textToDocOptions, {
  48164. stripTrailingHardline: true
  48165. }), printClosingTagSuffix$3(node, options)];
  48166. }
  48167. } else if (node.parent.type === "interpolation") {
  48168. const textToDocOptions = {
  48169. __isInHtmlInterpolation: true,
  48170. // to avoid unexpected `}}`
  48171. __embeddedInHtml: true
  48172. };
  48173. if (options.parser === "angular") {
  48174. textToDocOptions.parser = "__ng_interpolation";
  48175. textToDocOptions.trailingComma = "none";
  48176. } else if (options.parser === "vue") {
  48177. textToDocOptions.parser = "__vue_expression";
  48178. } else {
  48179. textToDocOptions.parser = "__js_expression";
  48180. }
  48181. return [indent$1([line$6, textToDoc(node.value, textToDocOptions, {
  48182. stripTrailingHardline: true
  48183. })]), node.parent.next && needsToBorrowPrevClosingTagEndMarker$2(node.parent.next) ? " " : line$6];
  48184. }
  48185. break;
  48186. }
  48187. case "attribute":
  48188. {
  48189. if (!node.value) {
  48190. break;
  48191. } // lit-html: html`<my-element obj=${obj}></my-element>`
  48192. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  48193. return [node.rawName, "=", node.value];
  48194. } // lwc: html`<my-element data-for={value}></my-element>`
  48195. if (options.parser === "lwc") {
  48196. const interpolationRegex = /^{.*}$/s;
  48197. if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  48198. return [node.rawName, "=", node.value];
  48199. }
  48200. }
  48201. const embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, (code, opts) => // strictly prefer single quote to avoid unnecessary html entity escape
  48202. textToDoc(code, Object.assign({
  48203. __isInHtmlAttribute: true,
  48204. __embeddedInHtml: true
  48205. }, opts), {
  48206. stripTrailingHardline: true
  48207. }), options);
  48208. if (embeddedAttributeValueDoc) {
  48209. return [node.rawName, '="', group$5(mapDoc(embeddedAttributeValueDoc, doc => typeof doc === "string" ? doc.replace(/"/g, "&quot;") : doc)), '"'];
  48210. }
  48211. break;
  48212. }
  48213. case "front-matter":
  48214. return printFrontMatter(node, textToDoc);
  48215. }
  48216. }
  48217. var embed_1$1 = embed$3;
  48218. const {
  48219. builders: {
  48220. breakParent: breakParent$2,
  48221. group: group$4,
  48222. ifBreak: ifBreak$3,
  48223. line: line$5,
  48224. softline: softline$3,
  48225. hardline: hardline$5
  48226. },
  48227. utils: {
  48228. replaceTextEndOfLine: replaceTextEndOfLine$3
  48229. }
  48230. } = require$$7$3;
  48231. const {
  48232. locStart: locStart$3,
  48233. locEnd: locEnd$2
  48234. } = loc$1;
  48235. const {
  48236. forceBreakChildren,
  48237. forceNextEmptyLine,
  48238. isTextLikeNode,
  48239. hasPrettierIgnore: hasPrettierIgnore$2,
  48240. preferHardlineAsLeadingSpaces
  48241. } = utils$1;
  48242. const {
  48243. printOpeningTagPrefix: printOpeningTagPrefix$2,
  48244. needsToBorrowNextOpeningTagStartMarker,
  48245. printOpeningTagStartMarker,
  48246. needsToBorrowPrevClosingTagEndMarker: needsToBorrowPrevClosingTagEndMarker$1,
  48247. printClosingTagEndMarker,
  48248. printClosingTagSuffix: printClosingTagSuffix$2,
  48249. needsToBorrowParentClosingTagStartMarker
  48250. } = tag;
  48251. function printChild(childPath, options, print) {
  48252. const child = childPath.getValue();
  48253. if (hasPrettierIgnore$2(child)) {
  48254. return [printOpeningTagPrefix$2(child, options), ...replaceTextEndOfLine$3(options.originalText.slice(locStart$3(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), locEnd$2(child) - (child.next && needsToBorrowPrevClosingTagEndMarker$1(child.next) ? printClosingTagEndMarker(child, options).length : 0))), printClosingTagSuffix$2(child, options)];
  48255. }
  48256. return print();
  48257. }
  48258. function printBetweenLine(prevNode, nextNode) {
  48259. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : line$5 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$5 : softline$3 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (hasPrettierIgnore$2(nextNode) ||
  48260. /**
  48261. * 123<a
  48262. * ~
  48263. * ><b>
  48264. */
  48265. nextNode.firstChild ||
  48266. /**
  48267. * 123<!--
  48268. * ~
  48269. * -->
  48270. */
  48271. nextNode.isSelfClosing ||
  48272. /**
  48273. * 123<span
  48274. * ~
  48275. * attr
  48276. */
  48277. nextNode.type === "element" && nextNode.attrs.length > 0) ||
  48278. /**
  48279. * <img
  48280. * src="long"
  48281. * ~
  48282. * />123
  48283. */
  48284. prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker$1(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
  48285. /**
  48286. * Want to write us a letter? Use our<a
  48287. * ><b><a>mailing address</a></b></a
  48288. * ~
  48289. * >.
  48290. */
  48291. needsToBorrowPrevClosingTagEndMarker$1(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$5 : nextNode.hasLeadingSpaces ? line$5 : softline$3;
  48292. }
  48293. function printChildren$3(path, options, print) {
  48294. const node = path.getValue();
  48295. if (forceBreakChildren(node)) {
  48296. return [breakParent$2, ...path.map(childPath => {
  48297. const childNode = childPath.getValue();
  48298. const prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  48299. return [!prevBetweenLine ? "" : [prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$5 : ""], printChild(childPath, options, print)];
  48300. }, "children")];
  48301. }
  48302. const groupIds = node.children.map(() => Symbol(""));
  48303. return path.map((childPath, childIndex) => {
  48304. const childNode = childPath.getValue();
  48305. if (isTextLikeNode(childNode)) {
  48306. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  48307. const prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  48308. if (prevBetweenLine) {
  48309. if (forceNextEmptyLine(childNode.prev)) {
  48310. return [hardline$5, hardline$5, printChild(childPath, options, print)];
  48311. }
  48312. return [prevBetweenLine, printChild(childPath, options, print)];
  48313. }
  48314. }
  48315. return printChild(childPath, options, print);
  48316. }
  48317. const prevParts = [];
  48318. const leadingParts = [];
  48319. const trailingParts = [];
  48320. const nextParts = [];
  48321. const prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  48322. const nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  48323. if (prevBetweenLine) {
  48324. if (forceNextEmptyLine(childNode.prev)) {
  48325. prevParts.push(hardline$5, hardline$5);
  48326. } else if (prevBetweenLine === hardline$5) {
  48327. prevParts.push(hardline$5);
  48328. } else {
  48329. if (isTextLikeNode(childNode.prev)) {
  48330. leadingParts.push(prevBetweenLine);
  48331. } else {
  48332. leadingParts.push(ifBreak$3("", softline$3, {
  48333. groupId: groupIds[childIndex - 1]
  48334. }));
  48335. }
  48336. }
  48337. }
  48338. if (nextBetweenLine) {
  48339. if (forceNextEmptyLine(childNode)) {
  48340. if (isTextLikeNode(childNode.next)) {
  48341. nextParts.push(hardline$5, hardline$5);
  48342. }
  48343. } else if (nextBetweenLine === hardline$5) {
  48344. if (isTextLikeNode(childNode.next)) {
  48345. nextParts.push(hardline$5);
  48346. }
  48347. } else {
  48348. trailingParts.push(nextBetweenLine);
  48349. }
  48350. }
  48351. return [...prevParts, group$4([...leadingParts, group$4([printChild(childPath, options, print), ...trailingParts], {
  48352. id: groupIds[childIndex]
  48353. })]), ...nextParts];
  48354. }, "children");
  48355. }
  48356. var children = {
  48357. printChildren: printChildren$3
  48358. };
  48359. const {
  48360. builders: {
  48361. breakParent: breakParent$1,
  48362. dedentToRoot: dedentToRoot$1,
  48363. group: group$3,
  48364. ifBreak: ifBreak$2,
  48365. indentIfBreak,
  48366. indent,
  48367. line: line$4,
  48368. softline: softline$2
  48369. },
  48370. utils: {
  48371. replaceTextEndOfLine: replaceTextEndOfLine$2
  48372. }
  48373. } = require$$7$3;
  48374. const getNodeContent = getNodeContent_1;
  48375. const {
  48376. shouldPreserveContent,
  48377. isScriptLikeTag,
  48378. isVueCustomBlock,
  48379. countParents,
  48380. forceBreakContent
  48381. } = utils$1;
  48382. const {
  48383. printOpeningTagPrefix: printOpeningTagPrefix$1,
  48384. printOpeningTag,
  48385. printClosingTagSuffix: printClosingTagSuffix$1,
  48386. printClosingTag,
  48387. needsToBorrowPrevClosingTagEndMarker,
  48388. needsToBorrowLastChildClosingTagEndMarker
  48389. } = tag;
  48390. const {
  48391. printChildren: printChildren$2
  48392. } = children;
  48393. function printElement$1(path, options, print) {
  48394. const node = path.getValue();
  48395. if (shouldPreserveContent(node, options)) {
  48396. return [printOpeningTagPrefix$1(node, options), group$3(printOpeningTag(path, options, print)), ...replaceTextEndOfLine$2(getNodeContent(node, options)), ...printClosingTag(node, options), printClosingTagSuffix$1(node, options)];
  48397. }
  48398. /**
  48399. * do not break:
  48400. *
  48401. * <div>{{
  48402. * ~
  48403. * interpolation
  48404. * }}</div>
  48405. * ~
  48406. *
  48407. * exception: break if the opening tag breaks
  48408. *
  48409. * <div
  48410. * long
  48411. * ~
  48412. * >{{
  48413. * interpolation
  48414. * }}</div
  48415. * ~
  48416. * >
  48417. */
  48418. const shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  48419. const attrGroupId = Symbol("element-attr-group-id");
  48420. const printTag = doc => group$3([group$3(printOpeningTag(path, options, print), {
  48421. id: attrGroupId
  48422. }), doc, printClosingTag(node, options)]);
  48423. const printChildrenDoc = childrenDoc => {
  48424. if (shouldHugContent) {
  48425. return indentIfBreak(childrenDoc, {
  48426. groupId: attrGroupId
  48427. });
  48428. }
  48429. if ((isScriptLikeTag(node) || isVueCustomBlock(node, options)) && node.parent.type === "root" && options.parser === "vue" && !options.vueIndentScriptAndStyle) {
  48430. return childrenDoc;
  48431. }
  48432. return indent(childrenDoc);
  48433. };
  48434. const printLineBeforeChildren = () => {
  48435. if (shouldHugContent) {
  48436. return ifBreak$2(softline$2, "", {
  48437. groupId: attrGroupId
  48438. });
  48439. }
  48440. if (node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive) {
  48441. return line$4;
  48442. }
  48443. if (node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) {
  48444. return dedentToRoot$1(softline$2);
  48445. }
  48446. return softline$2;
  48447. };
  48448. const printLineAfterChildren = () => {
  48449. const needsToBorrow = node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent);
  48450. if (needsToBorrow) {
  48451. if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
  48452. return " ";
  48453. }
  48454. return "";
  48455. }
  48456. if (shouldHugContent) {
  48457. return ifBreak$2(softline$2, "", {
  48458. groupId: attrGroupId
  48459. });
  48460. }
  48461. if (node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive) {
  48462. return line$4;
  48463. }
  48464. if ((node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n[\\t ]{${options.tabWidth * countParents(path, node => node.parent && node.parent.type !== "root")}}$`).test(node.lastChild.value)) {
  48465. return "";
  48466. }
  48467. return softline$2;
  48468. };
  48469. if (node.children.length === 0) {
  48470. return printTag(node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$4 : "");
  48471. }
  48472. return printTag([forceBreakContent(node) ? breakParent$1 : "", printChildrenDoc([printLineBeforeChildren(), printChildren$2(path, options, print)]), printLineAfterChildren()]);
  48473. }
  48474. var element = {
  48475. printElement: printElement$1
  48476. };
  48477. /**
  48478. * @typedef {import("../document").Doc} Doc
  48479. */
  48480. const {
  48481. builders: {
  48482. fill: fill$2,
  48483. group: group$2,
  48484. hardline: hardline$4,
  48485. literalline: literalline$2
  48486. },
  48487. utils: {
  48488. cleanDoc,
  48489. getDocParts: getDocParts$2,
  48490. isConcat,
  48491. replaceTextEndOfLine: replaceTextEndOfLine$1
  48492. }
  48493. } = require$$7$3;
  48494. const clean$1 = clean_1;
  48495. const {
  48496. countChars,
  48497. unescapeQuoteEntities,
  48498. getTextValueParts
  48499. } = utils$1;
  48500. const preprocess$2 = printPreprocess$1;
  48501. const {
  48502. insertPragma: insertPragma$2
  48503. } = pragma$1;
  48504. const {
  48505. locStart: locStart$2,
  48506. locEnd: locEnd$1
  48507. } = loc$1;
  48508. const embed$2 = embed_1$1;
  48509. const {
  48510. printClosingTagSuffix,
  48511. printClosingTagEnd,
  48512. printOpeningTagPrefix,
  48513. printOpeningTagStart
  48514. } = tag;
  48515. const {
  48516. printElement
  48517. } = element;
  48518. const {
  48519. printChildren: printChildren$1
  48520. } = children;
  48521. function genericPrint$1(path, options, print) {
  48522. const node = path.getValue();
  48523. switch (node.type) {
  48524. case "front-matter":
  48525. return replaceTextEndOfLine$1(node.raw);
  48526. case "root":
  48527. if (options.__onHtmlRoot) {
  48528. options.__onHtmlRoot(node);
  48529. } // use original concat to not break stripTrailingHardline
  48530. return [group$2(printChildren$1(path, options, print)), hardline$4];
  48531. case "element":
  48532. case "ieConditionalComment":
  48533. {
  48534. return printElement(path, options, print);
  48535. }
  48536. case "ieConditionalStartComment":
  48537. case "ieConditionalEndComment":
  48538. return [printOpeningTagStart(node), printClosingTagEnd(node)];
  48539. case "interpolation":
  48540. return [printOpeningTagStart(node, options), ...path.map(print, "children"), printClosingTagEnd(node, options)];
  48541. case "text":
  48542. {
  48543. if (node.parent.type === "interpolation") {
  48544. // replace the trailing literalline with hardline for better readability
  48545. const trailingNewlineRegex = /\n[^\S\n]*?$/;
  48546. const hasTrailingNewline = trailingNewlineRegex.test(node.value);
  48547. const value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  48548. return [...replaceTextEndOfLine$1(value), hasTrailingNewline ? hardline$4 : ""];
  48549. }
  48550. const printed = cleanDoc([printOpeningTagPrefix(node, options), ...getTextValueParts(node), printClosingTagSuffix(node, options)]);
  48551. if (isConcat(printed) || printed.type === "fill") {
  48552. return fill$2(getDocParts$2(printed));
  48553. }
  48554. /* istanbul ignore next */
  48555. return printed;
  48556. }
  48557. case "docType":
  48558. return [group$2([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")]), printClosingTagEnd(node, options)];
  48559. case "comment":
  48560. {
  48561. return [printOpeningTagPrefix(node, options), ...replaceTextEndOfLine$1(options.originalText.slice(locStart$2(node), locEnd$1(node)), literalline$2), printClosingTagSuffix(node, options)];
  48562. }
  48563. case "attribute":
  48564. {
  48565. if (node.value === null) {
  48566. return node.rawName;
  48567. }
  48568. const value = unescapeQuoteEntities(node.value);
  48569. const singleQuoteCount = countChars(value, "'");
  48570. const doubleQuoteCount = countChars(value, '"');
  48571. const quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  48572. return [node.rawName, "=", quote, ...replaceTextEndOfLine$1(quote === '"' ? value.replace(/"/g, "&quot;") : value.replace(/'/g, "&apos;")), quote];
  48573. }
  48574. default:
  48575. /* istanbul ignore next */
  48576. throw new Error(`Unexpected node type ${node.type}`);
  48577. }
  48578. }
  48579. var printerHtml = {
  48580. preprocess: preprocess$2,
  48581. print: genericPrint$1,
  48582. insertPragma: insertPragma$2,
  48583. massageAstNode: clean$1,
  48584. embed: embed$2
  48585. };
  48586. const commonOptions$1 = commonOptions$6;
  48587. const CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  48588. var options$3 = {
  48589. bracketSameLine: commonOptions$1.bracketSameLine,
  48590. htmlWhitespaceSensitivity: {
  48591. since: "1.15.0",
  48592. category: CATEGORY_HTML,
  48593. type: "choice",
  48594. default: "css",
  48595. description: "How to handle whitespaces in HTML.",
  48596. choices: [{
  48597. value: "css",
  48598. description: "Respect the default value of CSS display property."
  48599. }, {
  48600. value: "strict",
  48601. description: "Whitespaces are considered sensitive."
  48602. }, {
  48603. value: "ignore",
  48604. description: "Whitespaces are considered insensitive."
  48605. }]
  48606. },
  48607. vueIndentScriptAndStyle: {
  48608. since: "1.19.0",
  48609. category: CATEGORY_HTML,
  48610. type: "boolean",
  48611. default: false,
  48612. description: "Indent script and style tags in Vue files."
  48613. }
  48614. };
  48615. var parsers$3 = {
  48616. // HTML
  48617. get html() {
  48618. return require("./parser-html.js").parsers.html;
  48619. },
  48620. // Vue
  48621. get vue() {
  48622. return require("./parser-html.js").parsers.vue;
  48623. },
  48624. // Angular
  48625. get angular() {
  48626. return require("./parser-html.js").parsers.angular;
  48627. },
  48628. // Lightning Web Components
  48629. get lwc() {
  48630. return require("./parser-html.js").parsers.lwc;
  48631. }
  48632. };
  48633. var name$2 = "HTML";
  48634. var type$2 = "markup";
  48635. var tmScope$2 = "text.html.basic";
  48636. var aceMode$2 = "html";
  48637. var codemirrorMode$1 = "htmlmixed";
  48638. var codemirrorMimeType$1 = "text/html";
  48639. var color$2 = "#e34c26";
  48640. var aliases$1 = [
  48641. "xhtml"
  48642. ];
  48643. var extensions$2 = [
  48644. ".html",
  48645. ".htm",
  48646. ".html.hl",
  48647. ".inc",
  48648. ".xht",
  48649. ".xhtml"
  48650. ];
  48651. var languageId$2 = 146;
  48652. var require$$4$1 = {
  48653. name: name$2,
  48654. type: type$2,
  48655. tmScope: tmScope$2,
  48656. aceMode: aceMode$2,
  48657. codemirrorMode: codemirrorMode$1,
  48658. codemirrorMimeType: codemirrorMimeType$1,
  48659. color: color$2,
  48660. aliases: aliases$1,
  48661. extensions: extensions$2,
  48662. languageId: languageId$2
  48663. };
  48664. var name$1 = "Vue";
  48665. var type$1 = "markup";
  48666. var color$1 = "#41b883";
  48667. var extensions$1 = [
  48668. ".vue"
  48669. ];
  48670. var tmScope$1 = "text.html.vue";
  48671. var aceMode$1 = "html";
  48672. var languageId$1 = 391;
  48673. var require$$5 = {
  48674. name: name$1,
  48675. type: type$1,
  48676. color: color$1,
  48677. extensions: extensions$1,
  48678. tmScope: tmScope$1,
  48679. aceMode: aceMode$1,
  48680. languageId: languageId$1
  48681. };
  48682. const createLanguage$1 = createLanguage$7;
  48683. const printer$1 = printerHtml;
  48684. const options$2 = options$3;
  48685. const parsers$2 = parsers$3;
  48686. const languages$2 = [createLanguage$1(require$$4$1, () => ({
  48687. name: "Angular",
  48688. since: "1.15.0",
  48689. parsers: ["angular"],
  48690. vscodeLanguageIds: ["html"],
  48691. extensions: [".component.html"],
  48692. filenames: []
  48693. })), createLanguage$1(require$$4$1, data => ({
  48694. since: "1.15.0",
  48695. parsers: ["html"],
  48696. vscodeLanguageIds: ["html"],
  48697. extensions: [...data.extensions, ".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  48698. ]
  48699. })), createLanguage$1(require$$4$1, () => ({
  48700. name: "Lightning Web Components",
  48701. since: "1.17.0",
  48702. parsers: ["lwc"],
  48703. vscodeLanguageIds: ["html"],
  48704. extensions: [],
  48705. filenames: []
  48706. })), createLanguage$1(require$$5, () => ({
  48707. since: "1.10.0",
  48708. parsers: ["vue"],
  48709. vscodeLanguageIds: ["vue"]
  48710. }))];
  48711. const printers = {
  48712. html: printer$1
  48713. };
  48714. var languageHtml = {
  48715. languages: languages$2,
  48716. printers,
  48717. options: options$2,
  48718. parsers: parsers$2
  48719. };
  48720. function isPragma$1(text) {
  48721. return /^\s*@(?:prettier|format)\s*$/.test(text);
  48722. }
  48723. function hasPragma(text) {
  48724. return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(text);
  48725. }
  48726. function insertPragma$1(text) {
  48727. return `# @format\n\n${text}`;
  48728. }
  48729. var pragma = {
  48730. isPragma: isPragma$1,
  48731. hasPragma,
  48732. insertPragma: insertPragma$1
  48733. };
  48734. function locStart$1(node) {
  48735. return node.position.start.offset;
  48736. }
  48737. function locEnd(node) {
  48738. return node.position.end.offset;
  48739. }
  48740. var loc = {
  48741. locStart: locStart$1,
  48742. locEnd
  48743. };
  48744. function embed$1(path, print, textToDoc, options) {
  48745. const node = path.getValue(); // Try to format `.prettierrc` and `.stylelintrc` as `json` first
  48746. if (node.type === "root" && options.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint)rc$/.test(options.filepath)) {
  48747. return textToDoc(options.originalText, Object.assign(Object.assign({}, options), {}, {
  48748. parser: "json"
  48749. }));
  48750. }
  48751. }
  48752. var embed_1 = embed$1;
  48753. const {
  48754. getLast: getLast$1,
  48755. isNonEmptyArray
  48756. } = util$8;
  48757. function getAncestorCount$1(path, filter) {
  48758. let counter = 0;
  48759. const pathStackLength = path.stack.length - 1;
  48760. for (let i = 0; i < pathStackLength; i++) {
  48761. const value = path.stack[i];
  48762. if (isNode$4(value) && filter(value)) {
  48763. counter++;
  48764. }
  48765. }
  48766. return counter;
  48767. }
  48768. /**
  48769. * @param {any} value
  48770. * @param {string[]=} types
  48771. */
  48772. function isNode$4(value, types) {
  48773. return value && typeof value.type === "string" && (!types || types.includes(value.type));
  48774. }
  48775. function mapNode$1(node, callback, parent) {
  48776. return callback("children" in node ? Object.assign(Object.assign({}, node), {}, {
  48777. children: node.children.map(childNode => mapNode$1(childNode, callback, node))
  48778. }) : node, parent);
  48779. }
  48780. function defineShortcut$1(x, key, getter) {
  48781. Object.defineProperty(x, key, {
  48782. get: getter,
  48783. enumerable: false
  48784. });
  48785. }
  48786. function isNextLineEmpty$1(node, text) {
  48787. let newlineCount = 0;
  48788. const textLength = text.length;
  48789. for (let i = node.position.end.offset - 1; i < textLength; i++) {
  48790. const char = text[i];
  48791. if (char === "\n") {
  48792. newlineCount++;
  48793. }
  48794. if (newlineCount === 1 && /\S/.test(char)) {
  48795. return false;
  48796. }
  48797. if (newlineCount === 2) {
  48798. return true;
  48799. }
  48800. }
  48801. return false;
  48802. }
  48803. function isLastDescendantNode$2(path) {
  48804. const node = path.getValue();
  48805. switch (node.type) {
  48806. case "tag":
  48807. case "anchor":
  48808. case "comment":
  48809. return false;
  48810. }
  48811. const pathStackLength = path.stack.length;
  48812. for (let i = 1; i < pathStackLength; i++) {
  48813. const item = path.stack[i];
  48814. const parentItem = path.stack[i - 1];
  48815. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  48816. return false;
  48817. }
  48818. }
  48819. return true;
  48820. }
  48821. function getLastDescendantNode$1(node) {
  48822. return isNonEmptyArray(node.children) ? getLastDescendantNode$1(getLast$1(node.children)) : node;
  48823. }
  48824. function isPrettierIgnore(comment) {
  48825. return comment.value.trim() === "prettier-ignore";
  48826. }
  48827. function hasPrettierIgnore$1(path) {
  48828. const node = path.getValue();
  48829. if (node.type === "documentBody") {
  48830. const document = path.getParentNode();
  48831. return hasEndComments$4(document.head) && isPrettierIgnore(getLast$1(document.head.endComments));
  48832. }
  48833. return hasLeadingComments$2(node) && isPrettierIgnore(getLast$1(node.leadingComments));
  48834. }
  48835. function isEmptyNode$2(node) {
  48836. return !isNonEmptyArray(node.children) && !hasComments(node);
  48837. }
  48838. function hasComments(node) {
  48839. return hasLeadingComments$2(node) || hasMiddleComments$2(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$4(node);
  48840. }
  48841. function hasLeadingComments$2(node) {
  48842. return node && isNonEmptyArray(node.leadingComments);
  48843. }
  48844. function hasMiddleComments$2(node) {
  48845. return node && isNonEmptyArray(node.middleComments);
  48846. }
  48847. function hasIndicatorComment$1(node) {
  48848. return node && node.indicatorComment;
  48849. }
  48850. function hasTrailingComment$2(node) {
  48851. return node && node.trailingComment;
  48852. }
  48853. function hasEndComments$4(node) {
  48854. return node && isNonEmptyArray(node.endComments);
  48855. }
  48856. /**
  48857. * " a b c d e f " -> [" a b", "c d", "e f "]
  48858. */
  48859. function splitWithSingleSpace(text) {
  48860. const parts = [];
  48861. let lastPart;
  48862. for (const part of text.split(/( +)/)) {
  48863. /* istanbul ignore else */
  48864. if (part !== " ") {
  48865. if (lastPart === " ") {
  48866. parts.push(part);
  48867. } else {
  48868. parts.push((parts.pop() || "") + part);
  48869. }
  48870. } else if (lastPart === undefined) {
  48871. parts.unshift("");
  48872. }
  48873. lastPart = part;
  48874. }
  48875. /* istanbul ignore next */
  48876. if (lastPart === " ") {
  48877. parts.push((parts.pop() || "") + " ");
  48878. }
  48879. if (parts[0] === "") {
  48880. parts.shift();
  48881. parts.unshift(" " + (parts.shift() || ""));
  48882. }
  48883. return parts;
  48884. }
  48885. function getFlowScalarLineContents$1(nodeType, content, options) {
  48886. const rawLineContents = content.split("\n").map((lineContent, index, lineContents) => index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimEnd() : lineContent.trimStart());
  48887. if (options.proseWrap === "preserve") {
  48888. return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]);
  48889. }
  48890. return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !( // trailing backslash in quoteDouble should be preserved
  48891. nodeType === "quoteDouble" && getLast$1(getLast$1(reduced)).endsWith("\\")) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords);
  48892. }
  48893. function getBlockValueLineContents$1(node, {
  48894. parentIndent,
  48895. isLastDescendant,
  48896. options
  48897. }) {
  48898. const content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
  48899. .match(/^[^\n]*?\n(.*)$/s)[1];
  48900. const leadingSpaceCount = node.indent === null ? (match => match ? match[1].length : Number.POSITIVE_INFINITY)(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  48901. const rawLineContents = content.split("\n").map(lineContent => lineContent.slice(leadingSpaceCount));
  48902. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  48903. return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]));
  48904. }
  48905. return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length > 0 && lineContentWords.length > 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), [...getLast$1(reduced), ...lineContentWords]] : [...reduced, lineContentWords], []).map(lineContentWords => lineContentWords.reduce((reduced, word) => // disallow trailing spaces
  48906. reduced.length > 0 && /\s$/.test(getLast$1(reduced)) ? [...reduced.slice(0, -1), getLast$1(reduced) + " " + word] : [...reduced, word], [])).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords));
  48907. function removeUnnecessaryTrailingNewlines(lineContents) {
  48908. if (node.chomping === "keep") {
  48909. return getLast$1(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  48910. }
  48911. let trailingNewlineCount = 0;
  48912. for (let i = lineContents.length - 1; i >= 0; i--) {
  48913. if (lineContents[i].length === 0) {
  48914. trailingNewlineCount++;
  48915. } else {
  48916. break;
  48917. }
  48918. }
  48919. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  48920. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  48921. }
  48922. }
  48923. function isInlineNode$2(node) {
  48924. /* istanbul ignore next */
  48925. if (!node) {
  48926. return true;
  48927. }
  48928. switch (node.type) {
  48929. case "plain":
  48930. case "quoteDouble":
  48931. case "quoteSingle":
  48932. case "alias":
  48933. case "flowMapping":
  48934. case "flowSequence":
  48935. return true;
  48936. default:
  48937. return false;
  48938. }
  48939. }
  48940. var utils = {
  48941. getLast: getLast$1,
  48942. getAncestorCount: getAncestorCount$1,
  48943. isNode: isNode$4,
  48944. isEmptyNode: isEmptyNode$2,
  48945. isInlineNode: isInlineNode$2,
  48946. mapNode: mapNode$1,
  48947. defineShortcut: defineShortcut$1,
  48948. isNextLineEmpty: isNextLineEmpty$1,
  48949. isLastDescendantNode: isLastDescendantNode$2,
  48950. getBlockValueLineContents: getBlockValueLineContents$1,
  48951. getFlowScalarLineContents: getFlowScalarLineContents$1,
  48952. getLastDescendantNode: getLastDescendantNode$1,
  48953. hasPrettierIgnore: hasPrettierIgnore$1,
  48954. hasLeadingComments: hasLeadingComments$2,
  48955. hasMiddleComments: hasMiddleComments$2,
  48956. hasIndicatorComment: hasIndicatorComment$1,
  48957. hasTrailingComment: hasTrailingComment$2,
  48958. hasEndComments: hasEndComments$4
  48959. };
  48960. const {
  48961. defineShortcut,
  48962. mapNode
  48963. } = utils;
  48964. function preprocess$1(ast) {
  48965. return mapNode(ast, defineShortcuts);
  48966. }
  48967. function defineShortcuts(node) {
  48968. switch (node.type) {
  48969. case "document":
  48970. defineShortcut(node, "head", () => node.children[0]);
  48971. defineShortcut(node, "body", () => node.children[1]);
  48972. break;
  48973. case "documentBody":
  48974. case "sequenceItem":
  48975. case "flowSequenceItem":
  48976. case "mappingKey":
  48977. case "mappingValue":
  48978. defineShortcut(node, "content", () => node.children[0]);
  48979. break;
  48980. case "mappingItem":
  48981. case "flowMappingItem":
  48982. defineShortcut(node, "key", () => node.children[0]);
  48983. defineShortcut(node, "value", () => node.children[1]);
  48984. break;
  48985. }
  48986. return node;
  48987. }
  48988. var printPreprocess = preprocess$1;
  48989. const {
  48990. builders: {
  48991. softline: softline$1,
  48992. align
  48993. }
  48994. } = require$$7$3;
  48995. const {
  48996. hasEndComments: hasEndComments$3,
  48997. isNextLineEmpty,
  48998. isNode: isNode$3
  48999. } = utils;
  49000. const printedEmptyLineCache = new WeakMap();
  49001. function printNextEmptyLine$2(path, originalText) {
  49002. const node = path.getValue();
  49003. const root = path.stack[0];
  49004. let isNextEmptyLinePrintedSet;
  49005. if (printedEmptyLineCache.has(root)) {
  49006. isNextEmptyLinePrintedSet = printedEmptyLineCache.get(root);
  49007. } else {
  49008. isNextEmptyLinePrintedSet = new Set();
  49009. printedEmptyLineCache.set(root, isNextEmptyLinePrintedSet);
  49010. }
  49011. if (!isNextEmptyLinePrintedSet.has(node.position.end.line)) {
  49012. isNextEmptyLinePrintedSet.add(node.position.end.line);
  49013. if (isNextLineEmpty(node, originalText) && !shouldPrintEndComments$1(path.getParentNode())) {
  49014. return softline$1;
  49015. }
  49016. }
  49017. return "";
  49018. }
  49019. function shouldPrintEndComments$1(node) {
  49020. return hasEndComments$3(node) && !isNode$3(node, ["documentHead", "documentBody", "flowMapping", "flowSequence"]);
  49021. }
  49022. function alignWithSpaces$4(width, doc) {
  49023. return align(" ".repeat(width), doc);
  49024. }
  49025. var misc = {
  49026. alignWithSpaces: alignWithSpaces$4,
  49027. shouldPrintEndComments: shouldPrintEndComments$1,
  49028. printNextEmptyLine: printNextEmptyLine$2
  49029. };
  49030. const {
  49031. builders: {
  49032. ifBreak: ifBreak$1,
  49033. line: line$3,
  49034. softline,
  49035. hardline: hardline$3,
  49036. join: join$3
  49037. }
  49038. } = require$$7$3;
  49039. const {
  49040. isEmptyNode: isEmptyNode$1,
  49041. getLast,
  49042. hasEndComments: hasEndComments$2
  49043. } = utils;
  49044. const {
  49045. printNextEmptyLine: printNextEmptyLine$1,
  49046. alignWithSpaces: alignWithSpaces$3
  49047. } = misc;
  49048. function printFlowMapping$1(path, print, options) {
  49049. const node = path.getValue();
  49050. const isMapping = node.type === "flowMapping";
  49051. const openMarker = isMapping ? "{" : "[";
  49052. const closeMarker = isMapping ? "}" : "]";
  49053. /** @type {softline | line} */
  49054. let bracketSpacing = softline;
  49055. if (isMapping && node.children.length > 0 && options.bracketSpacing) {
  49056. bracketSpacing = line$3;
  49057. }
  49058. const lastItem = getLast(node.children);
  49059. const isLastItemEmptyMappingItem = lastItem && lastItem.type === "flowMappingItem" && isEmptyNode$1(lastItem.key) && isEmptyNode$1(lastItem.value);
  49060. return [openMarker, alignWithSpaces$3(options.tabWidth, [bracketSpacing, printChildren(path, print, options), options.trailingComma === "none" ? "" : ifBreak$1(","), hasEndComments$2(node) ? [hardline$3, join$3(hardline$3, path.map(print, "endComments"))] : ""]), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker];
  49061. }
  49062. function printChildren(path, print, options) {
  49063. const node = path.getValue();
  49064. const parts = path.map((childPath, index) => [print(), index === node.children.length - 1 ? "" : [",", line$3, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine$1(childPath, options.originalText) : ""]], "children");
  49065. return parts;
  49066. }
  49067. var flowMappingSequence = {
  49068. printFlowMapping: printFlowMapping$1,
  49069. // Alias
  49070. printFlowSequence: printFlowMapping$1
  49071. };
  49072. /** @typedef {import("../../document").Doc} Doc */
  49073. const {
  49074. builders: {
  49075. conditionalGroup,
  49076. group: group$1,
  49077. hardline: hardline$2,
  49078. ifBreak,
  49079. join: join$2,
  49080. line: line$2
  49081. }
  49082. } = require$$7$3;
  49083. const {
  49084. hasLeadingComments: hasLeadingComments$1,
  49085. hasMiddleComments: hasMiddleComments$1,
  49086. hasTrailingComment: hasTrailingComment$1,
  49087. hasEndComments: hasEndComments$1,
  49088. isNode: isNode$2,
  49089. isEmptyNode,
  49090. isInlineNode: isInlineNode$1
  49091. } = utils;
  49092. const {
  49093. alignWithSpaces: alignWithSpaces$2
  49094. } = misc;
  49095. function printMappingItem$1(node, parentNode, path, print, options) {
  49096. const {
  49097. key,
  49098. value
  49099. } = node;
  49100. const isEmptyMappingKey = isEmptyNode(key);
  49101. const isEmptyMappingValue = isEmptyNode(value);
  49102. if (isEmptyMappingKey && isEmptyMappingValue) {
  49103. return ": ";
  49104. }
  49105. const printedKey = print("key");
  49106. const spaceBeforeColon = needsSpaceInFrontOfMappingValue(node) ? " " : "";
  49107. if (isEmptyMappingValue) {
  49108. if (node.type === "flowMappingItem" && parentNode.type === "flowMapping") {
  49109. return printedKey;
  49110. }
  49111. if (node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasTrailingComment$1(key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set")) {
  49112. return [printedKey, spaceBeforeColon, ":"];
  49113. }
  49114. return ["? ", alignWithSpaces$2(2, printedKey)];
  49115. }
  49116. const printedValue = print("value");
  49117. if (isEmptyMappingKey) {
  49118. return [": ", alignWithSpaces$2(2, printedValue)];
  49119. } // force explicit Key
  49120. if (hasLeadingComments$1(value) || !isInlineNode$1(key.content)) {
  49121. return ["? ", alignWithSpaces$2(2, printedKey), hardline$2, join$2("", path.map(print, "value", "leadingComments").map(comment => [comment, hardline$2])), ": ", alignWithSpaces$2(2, printedValue)];
  49122. } // force singleline
  49123. if (isSingleLineNode(key.content) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasTrailingComment$1(key.content) && !hasEndComments$1(key) && !hasLeadingComments$1(value.content) && !hasMiddleComments$1(value.content) && !hasEndComments$1(value) && isAbsolutelyPrintedAsSingleLineNode(value.content, options)) {
  49124. return [printedKey, spaceBeforeColon, ": ", printedValue];
  49125. }
  49126. const groupId = Symbol("mappingKey");
  49127. const groupedKey = group$1([ifBreak("? "), group$1(alignWithSpaces$2(2, printedKey), {
  49128. id: groupId
  49129. })]); // Construct both explicit and implicit mapping values.
  49130. const explicitMappingValue = [hardline$2, ": ", alignWithSpaces$2(2, printedValue)];
  49131. /** @type {Doc[]} */
  49132. // In the implicit case, it's convenient to treat everything from the key's colon
  49133. // as part of the mapping value
  49134. const implicitMappingValueParts = [spaceBeforeColon, ":"];
  49135. if (hasLeadingComments$1(value.content) || hasEndComments$1(value) && value.content && !isNode$2(value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(key.content) && isInlineNode$1(value.content) || isNode$2(value.content, ["mapping", "sequence"]) && value.content.tag === null && value.content.anchor === null) {
  49136. implicitMappingValueParts.push(hardline$2);
  49137. } else if (value.content) {
  49138. implicitMappingValueParts.push(line$2);
  49139. }
  49140. implicitMappingValueParts.push(printedValue);
  49141. const implicitMappingValue = alignWithSpaces$2(options.tabWidth, implicitMappingValueParts); // If a key is definitely single-line, forcibly use implicit style to avoid edge cases (very long
  49142. // keys) that would otherwise trigger explicit style as if it was multiline.
  49143. // In those cases, explicit style makes the line even longer and causes confusion.
  49144. if (isAbsolutelyPrintedAsSingleLineNode(key.content, options) && !hasLeadingComments$1(key.content) && !hasMiddleComments$1(key.content) && !hasEndComments$1(key)) {
  49145. return conditionalGroup([[printedKey, implicitMappingValue]]);
  49146. } // Use explicit mapping syntax if the key breaks, implicit otherwise
  49147. return conditionalGroup([[groupedKey, ifBreak(explicitMappingValue, implicitMappingValue, {
  49148. groupId
  49149. })]]);
  49150. }
  49151. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  49152. if (!node) {
  49153. return true;
  49154. }
  49155. switch (node.type) {
  49156. case "plain":
  49157. case "quoteSingle":
  49158. case "quoteDouble":
  49159. break;
  49160. case "alias":
  49161. return true;
  49162. default:
  49163. return false;
  49164. }
  49165. if (options.proseWrap === "preserve") {
  49166. return node.position.start.line === node.position.end.line;
  49167. }
  49168. if ( // backslash-newline
  49169. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  49170. return false;
  49171. }
  49172. switch (options.proseWrap) {
  49173. case "never":
  49174. return !node.value.includes("\n");
  49175. case "always":
  49176. return !/[\n ]/.test(node.value);
  49177. // istanbul ignore next
  49178. default:
  49179. return false;
  49180. }
  49181. }
  49182. function needsSpaceInFrontOfMappingValue(node) {
  49183. return node.key.content && node.key.content.type === "alias";
  49184. }
  49185. function isSingleLineNode(node) {
  49186. /* istanbul ignore next */
  49187. if (!node) {
  49188. return true;
  49189. }
  49190. switch (node.type) {
  49191. case "plain":
  49192. case "quoteDouble":
  49193. case "quoteSingle":
  49194. return node.position.start.line === node.position.end.line;
  49195. case "alias":
  49196. return true;
  49197. default:
  49198. return false;
  49199. }
  49200. }
  49201. var mappingItem = printMappingItem$1;
  49202. /** @typedef {import("../../document").Doc} Doc */
  49203. const {
  49204. builders: {
  49205. dedent,
  49206. dedentToRoot,
  49207. fill: fill$1,
  49208. hardline: hardline$1,
  49209. join: join$1,
  49210. line: line$1,
  49211. literalline: literalline$1,
  49212. markAsRoot
  49213. },
  49214. utils: {
  49215. getDocParts: getDocParts$1
  49216. }
  49217. } = require$$7$3;
  49218. const {
  49219. getAncestorCount,
  49220. getBlockValueLineContents,
  49221. hasIndicatorComment,
  49222. isLastDescendantNode: isLastDescendantNode$1,
  49223. isNode: isNode$1
  49224. } = utils;
  49225. const {
  49226. alignWithSpaces: alignWithSpaces$1
  49227. } = misc;
  49228. function printBlock$1(path, print, options) {
  49229. const node = path.getValue();
  49230. const parentIndent = getAncestorCount(path, ancestorNode => isNode$1(ancestorNode, ["sequence", "mapping"]));
  49231. const isLastDescendant = isLastDescendantNode$1(path);
  49232. /** @type {Doc[]} */
  49233. const parts = [node.type === "blockFolded" ? ">" : "|"];
  49234. if (node.indent !== null) {
  49235. parts.push(node.indent.toString());
  49236. }
  49237. if (node.chomping !== "clip") {
  49238. parts.push(node.chomping === "keep" ? "+" : "-");
  49239. }
  49240. if (hasIndicatorComment(node)) {
  49241. parts.push(" ", print("indicatorComment"));
  49242. }
  49243. const lineContents = getBlockValueLineContents(node, {
  49244. parentIndent,
  49245. isLastDescendant,
  49246. options
  49247. });
  49248. /** @type {Doc[]} */
  49249. const contentsParts = [];
  49250. for (const [index, lineWords] of lineContents.entries()) {
  49251. if (index === 0) {
  49252. contentsParts.push(hardline$1);
  49253. }
  49254. contentsParts.push(fill$1(getDocParts$1(join$1(line$1, lineWords))));
  49255. if (index !== lineContents.length - 1) {
  49256. contentsParts.push(lineWords.length === 0 ? hardline$1 : markAsRoot(literalline$1));
  49257. } else if (node.chomping === "keep" && isLastDescendant) {
  49258. contentsParts.push(dedentToRoot(lineWords.length === 0 ? hardline$1 : literalline$1));
  49259. }
  49260. }
  49261. if (node.indent === null) {
  49262. parts.push(dedent(alignWithSpaces$1(options.tabWidth, contentsParts)));
  49263. } else {
  49264. parts.push(dedentToRoot(alignWithSpaces$1(node.indent - 1 + parentIndent, contentsParts)));
  49265. }
  49266. return parts;
  49267. }
  49268. var block = printBlock$1;
  49269. /** @typedef {import("../document").Doc} Doc */
  49270. const {
  49271. builders: {
  49272. breakParent,
  49273. fill,
  49274. group,
  49275. hardline,
  49276. join,
  49277. line,
  49278. lineSuffix,
  49279. literalline
  49280. },
  49281. utils: {
  49282. getDocParts,
  49283. replaceTextEndOfLine
  49284. }
  49285. } = require$$7$3;
  49286. const {
  49287. isPreviousLineEmpty
  49288. } = util$8;
  49289. const {
  49290. insertPragma,
  49291. isPragma
  49292. } = pragma;
  49293. const {
  49294. locStart
  49295. } = loc;
  49296. const embed = embed_1;
  49297. const {
  49298. getFlowScalarLineContents,
  49299. getLastDescendantNode,
  49300. hasLeadingComments,
  49301. hasMiddleComments,
  49302. hasTrailingComment,
  49303. hasEndComments,
  49304. hasPrettierIgnore,
  49305. isLastDescendantNode,
  49306. isNode,
  49307. isInlineNode
  49308. } = utils;
  49309. const preprocess = printPreprocess;
  49310. const {
  49311. alignWithSpaces,
  49312. printNextEmptyLine,
  49313. shouldPrintEndComments
  49314. } = misc;
  49315. const {
  49316. printFlowMapping,
  49317. printFlowSequence
  49318. } = flowMappingSequence;
  49319. const printMappingItem = mappingItem;
  49320. const printBlock = block;
  49321. function genericPrint(path, options, print) {
  49322. const node = path.getValue();
  49323. /** @type {Doc[]} */
  49324. const parts = [];
  49325. if (node.type !== "mappingValue" && hasLeadingComments(node)) {
  49326. parts.push([join(hardline, path.map(print, "leadingComments")), hardline]);
  49327. }
  49328. const {
  49329. tag,
  49330. anchor
  49331. } = node;
  49332. if (tag) {
  49333. parts.push(print("tag"));
  49334. }
  49335. if (tag && anchor) {
  49336. parts.push(" ");
  49337. }
  49338. if (anchor) {
  49339. parts.push(print("anchor"));
  49340. }
  49341. /** @type {Doc} */
  49342. let nextEmptyLine = "";
  49343. if (isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path)) {
  49344. nextEmptyLine = printNextEmptyLine(path, options.originalText);
  49345. }
  49346. if (tag || anchor) {
  49347. if (isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node)) {
  49348. parts.push(hardline);
  49349. } else {
  49350. parts.push(" ");
  49351. }
  49352. }
  49353. if (hasMiddleComments(node)) {
  49354. parts.push([node.middleComments.length === 1 ? "" : hardline, join(hardline, path.map(print, "middleComments")), hardline]);
  49355. }
  49356. const parentNode = path.getParentNode();
  49357. if (hasPrettierIgnore(path)) {
  49358. parts.push(replaceTextEndOfLine(options.originalText.slice(node.position.start.offset, node.position.end.offset).trimEnd(), literalline));
  49359. } else {
  49360. parts.push(group(printNode(node, parentNode, path, options, print)));
  49361. }
  49362. if (hasTrailingComment(node) && !isNode(node, ["document", "documentHead"])) {
  49363. parts.push(lineSuffix([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent, print("trailingComment")]));
  49364. }
  49365. if (shouldPrintEndComments(node)) {
  49366. parts.push(alignWithSpaces(node.type === "sequenceItem" ? 2 : 0, [hardline, join(hardline, path.map(path => [isPreviousLineEmpty(options.originalText, path.getValue(), locStart) ? hardline : "", print()], "endComments"))]));
  49367. }
  49368. parts.push(nextEmptyLine);
  49369. return parts;
  49370. }
  49371. function printNode(node, parentNode, path, options, print) {
  49372. switch (node.type) {
  49373. case "root":
  49374. {
  49375. const {
  49376. children
  49377. } = node;
  49378. const parts = [];
  49379. path.each((childPath, index) => {
  49380. const document = children[index];
  49381. const nextDocument = children[index + 1];
  49382. if (index !== 0) {
  49383. parts.push(hardline);
  49384. }
  49385. parts.push(print());
  49386. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  49387. parts.push(hardline, "...");
  49388. if (hasTrailingComment(document)) {
  49389. parts.push(" ", print("trailingComment"));
  49390. }
  49391. } else if (nextDocument && !hasTrailingComment(nextDocument.head)) {
  49392. parts.push(hardline, "---");
  49393. }
  49394. }, "children");
  49395. const lastDescendantNode = getLastDescendantNode(node);
  49396. if (!isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) || lastDescendantNode.chomping !== "keep") {
  49397. parts.push(hardline);
  49398. }
  49399. return parts;
  49400. }
  49401. case "document":
  49402. {
  49403. const nextDocument = parentNode.children[path.getName() + 1];
  49404. const parts = [];
  49405. if (shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head") {
  49406. if (node.head.children.length > 0 || node.head.endComments.length > 0) {
  49407. parts.push(print("head"));
  49408. }
  49409. if (hasTrailingComment(node.head)) {
  49410. parts.push(["---", " ", print(["head", "trailingComment"])]);
  49411. } else {
  49412. parts.push("---");
  49413. }
  49414. }
  49415. if (shouldPrintDocumentBody(node)) {
  49416. parts.push(print("body"));
  49417. }
  49418. return join(hardline, parts);
  49419. }
  49420. case "documentHead":
  49421. return join(hardline, [...path.map(print, "children"), ...path.map(print, "endComments")]);
  49422. case "documentBody":
  49423. {
  49424. const {
  49425. children,
  49426. endComments
  49427. } = node;
  49428. /** @type {Doc} */
  49429. let separator = "";
  49430. if (children.length > 0 && endComments.length > 0) {
  49431. const lastDescendantNode = getLastDescendantNode(node); // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  49432. if (isNode(lastDescendantNode, ["blockFolded", "blockLiteral"])) {
  49433. // an extra newline for better readability
  49434. if (lastDescendantNode.chomping !== "keep") {
  49435. separator = [hardline, hardline];
  49436. }
  49437. } else {
  49438. separator = hardline;
  49439. }
  49440. }
  49441. return [join(hardline, path.map(print, "children")), separator, join(hardline, path.map(print, "endComments"))];
  49442. }
  49443. case "directive":
  49444. return ["%", join(" ", [node.name, ...node.parameters])];
  49445. case "comment":
  49446. return ["#", node.value];
  49447. case "alias":
  49448. return ["*", node.value];
  49449. case "tag":
  49450. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  49451. case "anchor":
  49452. return ["&", node.value];
  49453. case "plain":
  49454. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  49455. case "quoteDouble":
  49456. case "quoteSingle":
  49457. {
  49458. const singleQuote = "'";
  49459. const doubleQuote = '"';
  49460. const raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  49461. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  49462. // only quoteDouble can use escape chars
  49463. // and quoteSingle do not need to escape backslashes
  49464. const originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  49465. return [originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote];
  49466. }
  49467. if (raw.includes(doubleQuote)) {
  49468. return [singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  49469. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote];
  49470. }
  49471. if (raw.includes(singleQuote)) {
  49472. return [doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  49473. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote];
  49474. }
  49475. const quote = options.singleQuote ? singleQuote : doubleQuote;
  49476. return [quote, printFlowScalarContent(node.type, raw, options), quote];
  49477. }
  49478. case "blockFolded":
  49479. case "blockLiteral":
  49480. {
  49481. return printBlock(path, print, options);
  49482. }
  49483. case "mapping":
  49484. case "sequence":
  49485. return join(hardline, path.map(print, "children"));
  49486. case "sequenceItem":
  49487. return ["- ", alignWithSpaces(2, !node.content ? "" : print("content"))];
  49488. case "mappingKey":
  49489. case "mappingValue":
  49490. return !node.content ? "" : print("content");
  49491. case "mappingItem":
  49492. case "flowMappingItem":
  49493. {
  49494. return printMappingItem(node, parentNode, path, print, options);
  49495. }
  49496. case "flowMapping":
  49497. return printFlowMapping(path, print, options);
  49498. case "flowSequence":
  49499. return printFlowSequence(path, print, options);
  49500. case "flowSequenceItem":
  49501. return print("content");
  49502. // istanbul ignore next
  49503. default:
  49504. throw new Error(`Unexpected node type ${node.type}`);
  49505. }
  49506. }
  49507. function shouldPrintDocumentBody(document) {
  49508. return document.body.children.length > 0 || hasEndComments(document.body);
  49509. }
  49510. function shouldPrintDocumentEndMarker(document, nextDocument) {
  49511. return (
  49512. /**
  49513. *... # trailingComment
  49514. */
  49515. hasTrailingComment(document) || nextDocument && (
  49516. /**
  49517. * ...
  49518. * %DIRECTIVE
  49519. * ---
  49520. */
  49521. nextDocument.head.children.length > 0 ||
  49522. /**
  49523. * ...
  49524. * # endComment
  49525. * ---
  49526. */
  49527. hasEndComments(nextDocument.head))
  49528. );
  49529. }
  49530. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  49531. if (
  49532. /**
  49533. * ---
  49534. * preserve the first document head end marker
  49535. */
  49536. root.children[0] === document && /---(?:\s|$)/.test(options.originalText.slice(locStart(document), locStart(document) + 4)) ||
  49537. /**
  49538. * %DIRECTIVE
  49539. * ---
  49540. */
  49541. document.head.children.length > 0 ||
  49542. /**
  49543. * # end comment
  49544. * ---
  49545. */
  49546. hasEndComments(document.head) ||
  49547. /**
  49548. * --- # trailing comment
  49549. */
  49550. hasTrailingComment(document.head)) {
  49551. return "head";
  49552. }
  49553. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  49554. return false;
  49555. }
  49556. return nextDocument ? "root" : false;
  49557. }
  49558. function printFlowScalarContent(nodeType, content, options) {
  49559. const lineContents = getFlowScalarLineContents(nodeType, content, options);
  49560. return join(hardline, lineContents.map(lineContentWords => fill(getDocParts(join(line, lineContentWords)))));
  49561. }
  49562. function clean(node, newNode
  49563. /*, parent */
  49564. ) {
  49565. if (isNode(newNode)) {
  49566. delete newNode.position;
  49567. switch (newNode.type) {
  49568. case "comment":
  49569. // insert pragma
  49570. if (isPragma(newNode.value)) {
  49571. return null;
  49572. }
  49573. break;
  49574. case "quoteDouble":
  49575. case "quoteSingle":
  49576. newNode.type = "quote";
  49577. break;
  49578. }
  49579. }
  49580. }
  49581. var printerYaml = {
  49582. preprocess,
  49583. embed,
  49584. print: genericPrint,
  49585. massageAstNode: clean,
  49586. insertPragma
  49587. };
  49588. const commonOptions = commonOptions$6; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.js
  49589. var options$1 = {
  49590. bracketSpacing: commonOptions.bracketSpacing,
  49591. singleQuote: commonOptions.singleQuote,
  49592. proseWrap: commonOptions.proseWrap
  49593. };
  49594. var parsers$1 = {
  49595. get yaml() {
  49596. return require("./parser-yaml.js").parsers.yaml;
  49597. }
  49598. };
  49599. var name = "YAML";
  49600. var type = "data";
  49601. var color = "#cb171e";
  49602. var tmScope = "source.yaml";
  49603. var aliases = [
  49604. "yml"
  49605. ];
  49606. var extensions = [
  49607. ".yml",
  49608. ".mir",
  49609. ".reek",
  49610. ".rviz",
  49611. ".sublime-syntax",
  49612. ".syntax",
  49613. ".yaml",
  49614. ".yaml-tmlanguage",
  49615. ".yaml.sed",
  49616. ".yml.mysql"
  49617. ];
  49618. var filenames = [
  49619. ".clang-format",
  49620. ".clang-tidy",
  49621. ".gemrc",
  49622. "glide.lock",
  49623. "yarn.lock"
  49624. ];
  49625. var aceMode = "yaml";
  49626. var codemirrorMode = "yaml";
  49627. var codemirrorMimeType = "text/x-yaml";
  49628. var languageId = 407;
  49629. var require$$4 = {
  49630. name: name,
  49631. type: type,
  49632. color: color,
  49633. tmScope: tmScope,
  49634. aliases: aliases,
  49635. extensions: extensions,
  49636. filenames: filenames,
  49637. aceMode: aceMode,
  49638. codemirrorMode: codemirrorMode,
  49639. codemirrorMimeType: codemirrorMimeType,
  49640. languageId: languageId
  49641. };
  49642. const createLanguage = createLanguage$7;
  49643. const printer = printerYaml;
  49644. const options = options$1;
  49645. const parsers = parsers$1;
  49646. const languages$1 = [createLanguage(require$$4, data => ({
  49647. since: "1.14.0",
  49648. parsers: ["yaml"],
  49649. vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
  49650. // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629
  49651. filenames: [...data.filenames.filter(filename => filename !== "yarn.lock"), ".prettierrc", ".stylelintrc"]
  49652. }))];
  49653. var languageYaml = {
  49654. languages: languages$1,
  49655. printers: {
  49656. yaml: printer
  49657. },
  49658. options,
  49659. parsers
  49660. };
  49661. var languages = [// JS
  49662. languageJs, // CSS
  49663. languageCss, // Handlebars
  49664. languageHandlebars, // GraphQL
  49665. languageGraphql, // Markdown
  49666. languageMarkdown, // HTML
  49667. languageHtml, // YAML
  49668. languageYaml];
  49669. const fs = require$$0__default["default"];
  49670. const path = require$$0__default$2["default"];
  49671. const uniqBy = uniqBy_1;
  49672. const partition = partition_1;
  49673. const globby = globby$2.exports;
  49674. const mem = dist$1;
  49675. const internalPlugins = languages;
  49676. const thirdParty = require$$7$2;
  49677. const resolve = resolve_1;
  49678. const memoizedLoad = mem(load, {
  49679. cacheKey: JSON.stringify
  49680. });
  49681. const memoizedSearch = mem(findPluginsInNodeModules);
  49682. const clearCache = () => {
  49683. mem.clear(memoizedLoad);
  49684. mem.clear(memoizedSearch);
  49685. };
  49686. function load(plugins, pluginSearchDirs) {
  49687. if (!plugins) {
  49688. plugins = [];
  49689. }
  49690. if (!pluginSearchDirs) {
  49691. pluginSearchDirs = [];
  49692. } // unless pluginSearchDirs are provided, auto-load plugins from node_modules that are parent to Prettier
  49693. if (pluginSearchDirs.length === 0) {
  49694. const autoLoadDir = thirdParty.findParentDir(__dirname, "node_modules");
  49695. if (autoLoadDir) {
  49696. pluginSearchDirs = [autoLoadDir];
  49697. }
  49698. }
  49699. const [externalPluginNames, externalPluginInstances] = partition(plugins, plugin => typeof plugin === "string");
  49700. const externalManualLoadPluginInfos = externalPluginNames.map(pluginName => {
  49701. let requirePath;
  49702. try {
  49703. // try local files
  49704. requirePath = resolve(path.resolve(process.cwd(), pluginName));
  49705. } catch {
  49706. // try node modules
  49707. requirePath = resolve(pluginName, {
  49708. paths: [process.cwd()]
  49709. });
  49710. }
  49711. return {
  49712. name: pluginName,
  49713. requirePath
  49714. };
  49715. });
  49716. const externalAutoLoadPluginInfos = pluginSearchDirs.flatMap(pluginSearchDir => {
  49717. const resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
  49718. const nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
  49719. // isDirectory(resolvedPluginSearchDir) check might be false even though
  49720. // the node_modules actually exists.
  49721. if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
  49722. throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
  49723. }
  49724. return memoizedSearch(nodeModulesDir).map(pluginName => ({
  49725. name: pluginName,
  49726. requirePath: resolve(pluginName, {
  49727. paths: [resolvedPluginSearchDir]
  49728. })
  49729. }));
  49730. });
  49731. const externalPlugins = [...uniqBy([...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos], "requirePath").map(externalPluginInfo => Object.assign({
  49732. name: externalPluginInfo.name
  49733. }, require(externalPluginInfo.requirePath))), ...externalPluginInstances];
  49734. return [...internalPlugins, ...externalPlugins];
  49735. }
  49736. function findPluginsInNodeModules(nodeModulesDir) {
  49737. const pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
  49738. cwd: nodeModulesDir,
  49739. expandDirectories: false
  49740. });
  49741. return pluginPackageJsonPaths.map(path.dirname);
  49742. }
  49743. function isDirectory(dir) {
  49744. try {
  49745. return fs.statSync(dir).isDirectory();
  49746. } catch {
  49747. return false;
  49748. }
  49749. }
  49750. var loadPlugins = {
  49751. loadPlugins: memoizedLoad,
  49752. clearCache
  49753. };
  49754. const {
  49755. version
  49756. } = require$$0$5;
  49757. const core = core$2;
  49758. const {
  49759. getSupportInfo
  49760. } = support;
  49761. const getFileInfo = getFileInfo_1;
  49762. const sharedUtil = utilShared;
  49763. const plugins = loadPlugins;
  49764. const config = resolveConfig_1;
  49765. const doc = require$$7$3;
  49766. function _withPlugins(fn, optsArgIdx = 1 // Usually `opts` is the 2nd argument
  49767. ) {
  49768. return (...args) => {
  49769. const opts = args[optsArgIdx] || {};
  49770. args[optsArgIdx] = Object.assign(Object.assign({}, opts), {}, {
  49771. plugins: plugins.loadPlugins(opts.plugins, opts.pluginSearchDirs)
  49772. });
  49773. return fn(...args);
  49774. };
  49775. }
  49776. function withPlugins(fn, optsArgIdx) {
  49777. const resultingFn = _withPlugins(fn, optsArgIdx);
  49778. if (fn.sync) {
  49779. // @ts-expect-error
  49780. resultingFn.sync = _withPlugins(fn.sync, optsArgIdx);
  49781. }
  49782. return resultingFn;
  49783. }
  49784. const formatWithCursor = withPlugins(core.formatWithCursor);
  49785. var src = {
  49786. formatWithCursor,
  49787. format(text, opts) {
  49788. return formatWithCursor(text, opts).formatted;
  49789. },
  49790. check(text, opts) {
  49791. const {
  49792. formatted
  49793. } = formatWithCursor(text, opts);
  49794. return formatted === text;
  49795. },
  49796. doc,
  49797. resolveConfig: config.resolveConfig,
  49798. resolveConfigFile: config.resolveConfigFile,
  49799. clearConfigCache() {
  49800. config.clearCache();
  49801. plugins.clearCache();
  49802. },
  49803. /** @type {typeof getFileInfo} */
  49804. getFileInfo: withPlugins(getFileInfo),
  49805. /** @type {typeof getSupportInfo} */
  49806. getSupportInfo: withPlugins(getSupportInfo, 0),
  49807. version,
  49808. util: sharedUtil,
  49809. // Internal shared
  49810. __internal: {
  49811. errors: errors,
  49812. coreOptions: coreOptions$1,
  49813. createIgnorer: createIgnorer_1,
  49814. optionsModule: options$d,
  49815. optionsNormalizer: optionsNormalizer,
  49816. utils: {
  49817. arrayify: arrayify$1
  49818. }
  49819. },
  49820. /* istanbul ignore next */
  49821. __debug: {
  49822. parse: withPlugins(core.parse),
  49823. formatAST: withPlugins(core.formatAST),
  49824. formatDoc: withPlugins(core.formatDoc),
  49825. printToDoc: withPlugins(core.printToDoc),
  49826. printDocToString: withPlugins(core.printDocToString)
  49827. }
  49828. };
  49829. module.exports = src;